@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600&family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400;1,500&family=IM+Fell+English:ital@0;1&display=swap');

:root {
    --bg:           #0a0806;
    --bg-deep:      #050403;
    --bg-vellum:    #0f0c08;
    --ink:          #e7dcc4;
    --ink-bright:   #f4ebd2;
    --ink-muted:    #8c7d63;
    --ink-dim:      #5a4d3a;
    --ember:        #b8442a;
    --ember-soft:   rgba(184, 68, 42, 0.55);
    --gold:         #c9a05c;
    --gold-soft:    rgba(201, 160, 92, 0.4);
    --rule:         #2a221a;
    --shadow:       rgba(0, 0, 0, 0.6);
}

*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    font-size: 19px;
    scrollbar-gutter: stable both-edges;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

@media (min-width: 720px)  { html { font-size: 22px; } }
@media (min-width: 1100px) { html { font-size: 26px; } }
@media (min-width: 1500px) { html { font-size: 30px; } }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background:
        radial-gradient(ellipse at 50% 0%, rgba(184, 68, 42, 0.06) 0%, transparent 55%),
        radial-gradient(ellipse at 50% 100%, rgba(201, 160, 92, 0.04) 0%, transparent 55%),
        var(--bg);
    color: var(--ink);
    font-family: 'Cormorant Garamond', 'Times New Roman', serif;
    font-size: 1rem;
    line-height: 1.8;
    font-weight: 400;
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Film grain — barely there, but the page feels alive */
body::before {
    content: '';
    position: fixed;
    inset: -50%;
    pointer-events: none;
    opacity: 0.18;
    z-index: 1;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.91  0 0 0 0 0.86  0 0 0 0 0.77  0 0 0 0.5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    mix-blend-mode: overlay;
    animation: drift 24s steps(6) infinite;
}

/* Deep vignette — pulls focus to the column */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    background: radial-gradient(ellipse at center, transparent 25%, rgba(0,0,0,0.55) 95%);
}

@keyframes drift {
    0%   { transform: translate( 0,  0); }
    20%  { transform: translate(-2%, 1%); }
    40%  { transform: translate( 1%,-1%); }
    60%  { transform: translate(-1%, 2%); }
    80%  { transform: translate( 2%, 0); }
    100% { transform: translate( 0,  0); }
}

::selection {
    background: var(--ember);
    color: var(--bg);
}

a {
    color: var(--gold);
    text-decoration: none;
}

/* ============================================
   READER
   ============================================ */

.main {
    position: relative;
    z-index: 5;
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 2rem 8rem;
}

.scribe-mark {
    position: fixed;
    top: 1.6rem;
    right: 2rem;
    z-index: 20;
    font-family: 'Cinzel', serif;
    font-size: 0.68rem;
    letter-spacing: 0.5em;
    color: var(--ink-muted);
    text-indent: 0.5em;
    padding: 0.85rem 1.4rem 0.85rem 1.7rem;
    border: 1px solid var(--rule);
    background: rgba(10, 8, 6, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: color 0.6s ease, border-color 0.6s ease, letter-spacing 0.6s ease;
}

.scribe-mark:hover {
    color: var(--gold);
    border-color: var(--gold-soft);
    letter-spacing: 0.6em;
}

/* ============================================
   COVER
   ============================================ */

.cover {
    text-align: center;
    padding: 1.5rem 0 5rem;
    margin-bottom: 4rem;
    border-bottom: 1px solid var(--rule);
    animation: rise 1.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.sigil {
    display: inline-block;
    width: 36px;
    height: 48px;
    color: var(--gold);
    opacity: 0.85;
}

.cover-sigil {
    width: 48px;
    height: 64px;
    margin-bottom: 1.5rem;
    animation: breathe 7s ease-in-out infinite;
    filter: drop-shadow(0 0 14px rgba(201, 160, 92, 0.18));
}

.cover h1 {
    margin: 0 0 1.2rem;
    display: flex;
    justify-content: center;
    perspective: 1000px;
}

.cover h1 .title {
    font-family: 'Cinzel', serif;
    font-weight: 500;
    letter-spacing: 0.42em;
    margin-right: -0.42em;
    color: var(--ink-bright);
    will-change: filter, transform, letter-spacing, background-position;
    animation: title-carve 2.6s cubic-bezier(0.2, 0.7, 0.2, 1) 0.15s both;
}

/* Gold shimmer — only in browsers that support background-clip: text */
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
    .cover h1 .title {
        background-image: linear-gradient(
            100deg,
            var(--ink-bright) 0%,
            var(--ink-bright) 38%,
            #f0d49a 48%,
            #e8c177 52%,
            #f0d49a 56%,
            var(--ink-bright) 64%,
            var(--ink-bright) 100%
        );
        background-size: 260% 100%;
        background-position: 100% 50%;
        background-repeat: no-repeat;
        -webkit-background-clip: text;
        background-clip: text;
        -webkit-text-fill-color: transparent;
        color: transparent;
        animation:
            title-carve   2.6s cubic-bezier(0.2, 0.7, 0.2, 1) 0.15s both,
            title-shimmer 14s ease-in-out 3s infinite alternate;
    }
}

@keyframes title-carve {
    0% {
        opacity: 0;
        letter-spacing: 0.05em;
        filter: blur(14px) drop-shadow(0 0 50px rgba(201, 160, 92, 0.55));
        transform: scale(0.94) translateZ(0);
    }
    50% {
        opacity: 1;
        filter: blur(3px) drop-shadow(0 0 32px rgba(201, 160, 92, 0.3));
    }
    100% {
        opacity: 1;
        letter-spacing: 0.42em;
        filter: blur(0) drop-shadow(0 0 22px rgba(201, 160, 92, 0.14));
        transform: scale(1) translateZ(0);
    }
}

@keyframes title-shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position:   0% 50%; }
}

.cover .revision {
    will-change: opacity, transform, letter-spacing;
    animation:
        revision-write 1.8s cubic-bezier(0.2, 0.7, 0.2, 1) 1.5s both,
        revision-glow  9s ease-in-out 4s infinite;
}

@keyframes revision-write {
    0% {
        opacity: 0;
        transform: translateY(6px);
        letter-spacing: 0.9em;
    }
    100% {
        opacity: 1;
        transform: translateY(0);
        letter-spacing: 0.35em;
    }
}

@keyframes revision-glow {
    0%, 100% { color: var(--ink-muted);            text-shadow: none; }
    50%      { color: rgba(201, 160, 92, 0.72);    text-shadow: 0 0 20px rgba(201, 160, 92, 0.18); }
}

.cover-rule {
    will-change: opacity;
    animation: rule-fade 1.4s ease-out 2.6s both;
}

@keyframes rule-fade {
    from { opacity: 0; transform: scaleX(0.6); }
    to   { opacity: 1; transform: scaleX(1);   }
}

.cover .revision {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 300;
    font-size: 1rem;
    letter-spacing: 0.35em;
    color: var(--ink-muted);
    text-indent: 0.35em;
    margin: 0 0 2.5rem;
}

.cover-rule {
    margin: 2rem auto 3rem;
    color: var(--gold-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.cover-rule::before,
.cover-rule::after {
    content: '';
    height: 1px;
    width: 64px;
    background: linear-gradient(to right, transparent, var(--gold-soft), transparent);
}

.cover-rule .pipe {
    color: var(--gold);
    opacity: 0.6;
    font-weight: 300;
    font-size: 1.2rem;
    line-height: 1;
}

.cover .epigraph {
    max-width: 660px;
    margin: 0 auto;
    font-style: italic;
    font-weight: 300;
    color: var(--ink-muted);
    font-size: 1.1rem;
    line-height: 1.85;
}

/* ============================================
   CHAPTERS
   ============================================ */

.chapter {
    margin: 7rem 0;
    scroll-margin-top: 3rem;
    animation: rise 1.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

html {
    scroll-behavior: smooth;
}

/* Staggered fade-in */
.chapter:nth-of-type(1) { animation-delay: 0.05s; }
.chapter:nth-of-type(2) { animation-delay: 0.15s; }
.chapter:nth-of-type(3) { animation-delay: 0.25s; }
.chapter:nth-of-type(4) { animation-delay: 0.35s; }
.chapter:nth-of-type(5) { animation-delay: 0.45s; }
.chapter:nth-of-type(6) { animation-delay: 0.55s; }
.chapter:nth-of-type(7) { animation-delay: 0.65s; }
.chapter:nth-of-type(8) { animation-delay: 0.75s; }
.chapter:nth-of-type(9) { animation-delay: 0.85s; }
.chapter:nth-of-type(n+10) { animation-delay: 0.95s; }

.chapter-header {
    text-align: center;
    margin-bottom: 3.5rem;
}

.chapter-book {
    font-family: 'Cinzel', serif;
    font-weight: 400;
    font-size: 0.72rem;
    letter-spacing: 0.58em;
    text-indent: 0.58em;
    color: var(--ink-muted);
    margin-bottom: 0.6rem;
}

.chapter-number {
    position: relative;
    display: inline-block;
    font-family: 'Cinzel', serif;
    font-weight: 400;
    font-size: clamp(3.4rem, 8vw, 4.8rem);
    line-height: 1;
    margin: 0.3rem 0 0.8rem;
    color: var(--ember);
    letter-spacing: 0.04em;
    padding-left: 0.04em;
    z-index: 1;
}

.chapter-number .halo {
    position: absolute;
    inset: -2.5rem;
    z-index: -1;
    background: radial-gradient(
        circle at center,
        rgba(184, 68, 42, 0.18) 0%,
        rgba(184, 68, 42, 0.06) 35%,
        transparent 70%
    );
    pointer-events: none;
    animation: ember 5.5s ease-in-out infinite;
}

.chapter-anchor {
    color: inherit;
    text-decoration: none;
    position: relative;
    transition: color 0.35s ease, text-shadow 0.35s ease;
}

.chapter-anchor::after {
    content: '§';
    position: absolute;
    top: 0.18em;
    left: calc(100% + 0.35em);
    font-size: 0.32em;
    color: var(--gold, #c9a05c);
    opacity: 0;
    transition: opacity 0.35s ease, transform 0.35s ease;
    transform: translateX(-0.25em);
    pointer-events: none;
    letter-spacing: 0;
}

.chapter-anchor:hover,
.chapter-anchor:focus-visible {
    color: var(--gold, #c9a05c);
    text-shadow: 0 0 18px rgba(201, 160, 92, 0.35);
    outline: none;
}

.chapter-anchor:hover::after,
.chapter-anchor:focus-visible::after {
    opacity: 0.85;
    transform: translateX(0);
}

.chapter:target .chapter-number {
    animation: chapter-target-pulse 1.6s ease-out 1;
}

@keyframes chapter-target-pulse {
    0%   { text-shadow: 0 0 0 rgba(201, 160, 92, 0); }
    35%  { text-shadow: 0 0 28px rgba(201, 160, 92, 0.55); }
    100% { text-shadow: 0 0 0 rgba(201, 160, 92, 0); }
}

.chapter-rule {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    margin-top: 0.8rem;
}

.chapter-rule::before,
.chapter-rule::after {
    content: '';
    height: 1px;
    width: 78px;
    background: linear-gradient(to right, transparent, var(--ink-dim), transparent);
}

.chapter-rule .pipe {
    color: var(--gold);
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.25rem;
    line-height: 1;
    opacity: 0.65;
    font-weight: 300;
}

.chapter-body {
    font-size: 1.22rem;
    color: var(--ink);
    text-align: left;
    line-height: 1.85;
    font-weight: 400;
}

.verse {
    margin: 0 0 2rem;
}

/* AMEND / STRIKE — sub-header, hover-revealed */
.chapter-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.9rem;
    margin-top: 1.4rem;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.chapter:hover .chapter-actions,
.chapter:focus-within .chapter-actions { opacity: 1; }

.chapter-actions-sep {
    color: var(--ink-dim);
    font-size: 0.65rem;
    line-height: 1;
}

.chapter-edit,
.chapter-strike {
    display: inline-block;
    font-family: 'Cinzel', serif;
    font-weight: 500;
    font-size: 0.6rem;
    letter-spacing: 0.45em;
    padding: 0 0 0 0.45em;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--ink-dim);
    transition: color 0.5s ease, letter-spacing 0.5s ease;
}

.chapter-edit:hover {
    color: var(--gold);
    letter-spacing: 0.55em;
}

.chapter-strike:hover {
    color: var(--ember);
    letter-spacing: 0.55em;
}

.chapter-strike-form { display: inline; margin: 0; padding: 0; }

/* Static export — final colophon */
.colophon {
    text-align: center;
    margin-top: 8rem;
    padding-top: 4rem;
}

.colophon .cover-rule {
    margin: 0 auto 2.5rem;
}

.colophon p {
    font-style: italic;
    color: var(--ink-muted);
    font-size: 1rem;
    line-height: 1.7;
    margin: 0;
}

.colophon em {
    color: var(--ink-dim);
    font-size: 0.9rem;
}

/* Toast after destructive action */
.toast {
    position: fixed;
    top: 1.6rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    letter-spacing: 0.4em;
    color: var(--gold);
    background: rgba(10, 8, 6, 0.85);
    border: 1px solid var(--gold-soft);
    padding: 0.8rem 1.4rem 0.8rem calc(1.4rem + 0.4em);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: toast-fade 4s ease-in forwards;
}

@keyframes toast-fade {
    0%   { opacity: 0; transform: translate(-50%, -10px); }
    10%  { opacity: 1; transform: translate(-50%, 0); }
    80%  { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -10px); }
}

.verse:last-child {
    margin-bottom: 0;
}

/* The voice of the unseen — all-caps lines */
.voice {
    display: inline;
    font-family: 'Cinzel', serif;
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--ink-bright);
    font-size: 0.92em;
    text-shadow: 0 0 18px rgba(244, 235, 210, 0.12);
}

/* ============================================
   FOOTER / CTA
   ============================================ */

.footer-scribe {
    text-align: center;
    margin-top: 9rem;
    padding-top: 5rem;
    border-top: 1px solid var(--rule);
    animation: rise 2s ease-out both;
    animation-delay: 1.05s;
}

.footer-scribe p {
    font-style: italic;
    color: var(--ink-muted);
    margin: 0 0 2.5rem;
    font-size: 1.05rem;
}

.scribe-cta {
    display: inline-block;
    font-family: 'Cinzel', serif;
    font-weight: 500;
    font-size: 0.82rem;
    letter-spacing: 0.45em;
    color: var(--ember);
    text-indent: 0.45em;
    padding: 1.1rem 2.4rem;
    border: 1px solid var(--ember-soft);
    transition:
        background 0.7s ease,
        color 0.7s ease,
        letter-spacing 0.7s ease,
        box-shadow 0.7s ease;
}

.scribe-cta:hover {
    background: var(--ember);
    color: var(--bg);
    letter-spacing: 0.55em;
    box-shadow: 0 0 40px rgba(184, 68, 42, 0.25);
}

/* ============================================
   SCRIBE PAGE
   ============================================ */

.scribe-page {
    position: relative;
    z-index: 5;
    max-width: 620px;
    margin: 0 auto;
    padding: 4rem 2rem 8rem;
    animation: rise 1.6s ease-out both;
}

.scribe-page .back {
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    letter-spacing: 0.42em;
    color: var(--ink-muted);
    text-indent: 0.42em;
    display: inline-block;
    margin-bottom: 4rem;
    transition: color 0.5s ease;
}

.scribe-page .back:hover {
    color: var(--gold);
}

.scribe-sigil-wrap {
    text-align: center;
    margin-bottom: 1.5rem;
}

.scribe-page h2 {
    display: flex;
    justify-content: center;
    color: var(--ink-bright);
    margin: 0 0 1rem;
}

.scribe-page h2 .title {
    font-family: 'Cinzel', serif;
    font-weight: 500;
    font-size: clamp(1.6rem, 3.6vw, 2.1rem);
    letter-spacing: 0.4em;
    margin-right: -0.4em;
}

.scribe-page .subtitle {
    text-align: center;
    color: var(--ink-muted);
    font-size: 1.05rem;
    line-height: 1.75;
    margin: 0 auto 4rem;
    max-width: 420px;
}

.alert {
    padding: 1.4rem 1.6rem;
    border-left: 2px solid var(--ember);
    color: var(--ember);
    font-style: italic;
    margin: 0 0 2.5rem;
    background: rgba(184, 68, 42, 0.05);
    font-size: 1.05rem;
    line-height: 1.6;
}

.alert.success {
    border-color: var(--gold);
    color: var(--gold);
    background: rgba(201, 160, 92, 0.05);
}

.inline-link {
    color: inherit;
    border-bottom: 1px solid currentColor;
    padding-bottom: 1px;
}

.field {
    margin: 0 0 2.5rem;
}

.field label {
    display: block;
    font-family: 'Cinzel', serif;
    font-size: 0.68rem;
    letter-spacing: 0.42em;
    text-indent: 0.42em;
    color: var(--ink-muted);
    margin-bottom: 0.8rem;
}

.field input,
.field textarea {
    width: 100%;
    background: transparent;
    border: 1px solid var(--rule);
    color: var(--ink);
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.15rem;
    line-height: 1.7;
    padding: 1rem 1.2rem;
    outline: none;
    transition: border-color 0.5s ease, background 0.5s ease;
    border-radius: 0;
    -webkit-appearance: none;
}

.field textarea {
    min-height: 320px;
    resize: vertical;
    font-size: 1.18rem;
    line-height: 1.85;
}

.field input:focus,
.field textarea:focus {
    border-color: var(--gold-soft);
    background: rgba(201, 160, 92, 0.025);
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--ink-dim);
    font-style: italic;
}

.field .hint {
    font-size: 0.85rem;
    color: var(--ink-dim);
    font-style: italic;
    margin-top: 0.6rem;
    line-height: 1.5;
}

.row {
    display: flex;
    gap: 1.2rem;
}

.field-grow { flex: 2; }
.field-small { flex: 1; min-width: 140px; }

.submit-row {
    text-align: center;
    margin-top: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
}

.submit {
    background: transparent;
    border: 1px solid var(--ember-soft);
    color: var(--ember);
    font-family: 'Cinzel', serif;
    font-weight: 500;
    font-size: 0.82rem;
    letter-spacing: 0.5em;
    padding-left: calc(3rem + 0.5em);
    padding-right: 3rem;
    padding-top: 1.2rem;
    padding-bottom: 1.2rem;
    cursor: pointer;
    transition:
        background 0.7s ease,
        color 0.7s ease,
        letter-spacing 0.7s ease,
        box-shadow 0.7s ease;
}

.submit:hover {
    background: var(--ember);
    color: var(--bg);
    letter-spacing: 0.6em;
    box-shadow: 0 0 40px rgba(184, 68, 42, 0.25);
}

.submit:focus {
    outline: none;
    box-shadow: 0 0 0 1px var(--gold-soft);
}

/* Strike — destructive */
.strike-form {
    margin-top: 4rem;
    padding-top: 3rem;
    border-top: 1px solid var(--rule);
    text-align: center;
    width: 100%;
}

.strike-form p {
    color: var(--ink-dim);
    font-style: italic;
    font-size: 0.95rem;
    margin: 0 0 1.5rem;
}

.strike-button {
    background: transparent;
    border: 1px solid var(--rule);
    color: var(--ink-dim);
    font-family: 'Cinzel', serif;
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 0.5em;
    padding: 0.9rem 2rem 0.9rem calc(2rem + 0.5em);
    cursor: pointer;
    transition: all 0.6s ease;
}

.strike-button:hover {
    border-color: var(--ember);
    color: var(--ember);
    letter-spacing: 0.6em;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes breathe {
    0%, 100% {
        opacity: 0.65;
        transform: scale(1);
        filter: drop-shadow(0 0 12px rgba(201, 160, 92, 0.12));
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
        filter: drop-shadow(0 0 24px rgba(201, 160, 92, 0.28));
    }
}

@keyframes ember {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50%      { opacity: 1.0; transform: scale(1.08); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001s !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001s !important;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 640px) {
    .main { padding: 1.5rem 1.3rem 6rem; }
    .scribe-page { padding: 2.5rem 1.3rem 6rem; }
    .scribe-mark {
        top: 1rem;
        right: 1rem;
        padding: 0.6rem 1rem 0.6rem 1.25rem;
        font-size: 0.6rem;
        letter-spacing: 0.35em;
        text-indent: 0.35em;
    }
    .cover { padding: 1rem 0 4rem; margin-bottom: 2rem; }
    .cover h1 .title { letter-spacing: 0.3em; margin-right: -0.3em; }
    .chapter { margin: 5rem 0; }
    .chapter-header { margin-bottom: 2.5rem; }
    .chapter-rule::before,
    .chapter-rule::after { width: 50px; }
    .row { flex-direction: column; gap: 0; }
    .footer-scribe { margin-top: 6rem; padding-top: 4rem; }
    .chapter-edit { opacity: 0.5; }
}

