/* =====================================================================
   iisugi.com — a nocturnal aurora observatory
   Jewel tones on cosmic black, grain-as-medium, slow circulating light.
   ===================================================================== */

:root {
    --cosmic-vellum: #0A0815;
    --indigo-drift: #171128;
    --garnet-aurora: #5B1F4D;
    --tourmaline-cyan: #1A6E7E;
    --topaz-ember: #C28B2C;
    --amethyst-veil: #7A4FBF;
    --beryl-greenlight: #2E8B57;
    --linen-glow: #EFE6D2;
    --lichen-dim: #C6BCA6;

    --display-font: 'Abril Fatface', 'Cormorant Garamond', Georgia, serif;
    --editorial-font: 'Cormorant Garamond', Georgia, serif;
    --mono-font: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    background: var(--cosmic-vellum);
    color: var(--linen-glow);
    font-family: var(--editorial-font);
    font-weight: 300;
    font-style: italic;
    line-height: 1.78;
    overflow-x: hidden;
    width: 100%;
    scroll-behavior: auto;
}

body {
    position: relative;
    min-height: 100vh;
}

/* ================================ Grain layer ================================ */
.grain-layer {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 90;
    mix-blend-mode: overlay;
    opacity: 1;
}

/* ================================ Tick rail ================================ */
.tick-rail {
    position: fixed;
    top: 50%;
    right: 36px;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 28px;
    pointer-events: auto;
}

.tick {
    position: relative;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.tick-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--lichen-dim);
    opacity: 0.38;
    animation: breathe 6.4s ease-in-out infinite;
    transition: box-shadow 480ms cubic-bezier(0.22, 0.61, 0.36, 1),
                background 480ms cubic-bezier(0.22, 0.61, 0.36, 1),
                width 480ms cubic-bezier(0.22, 0.61, 0.36, 1),
                height 480ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.tick:nth-child(2) .tick-dot { animation-delay: -1.0s; }
.tick:nth-child(3) .tick-dot { animation-delay: -2.1s; }
.tick:nth-child(4) .tick-dot { animation-delay: -3.2s; }
.tick:nth-child(5) .tick-dot { animation-delay: -4.3s; }
.tick:nth-child(6) .tick-dot { animation-delay: -5.4s; }

.tick.is-active .tick-dot {
    background: var(--topaz-ember);
    width: 8px;
    height: 8px;
    opacity: 0.92;
    box-shadow: 0 0 12px 4px rgba(194, 139, 44, 0.55),
                0 0 22px 8px rgba(194, 139, 44, 0.22);
    animation: none;
}

.tick-label {
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--mono-font);
    font-size: 12.5px;
    font-style: normal;
    letter-spacing: 0.04em;
    color: var(--lichen-dim);
    opacity: 0;
    transition: opacity 240ms cubic-bezier(0.22, 0.61, 0.36, 1);
    white-space: nowrap;
    pointer-events: none;
}

.tick:hover .tick-label {
    opacity: 0.62;
}

@keyframes breathe {
    0%, 100% { opacity: 0.40; }
    50%      { opacity: 0.95; }
}

/* ================================ Canvas ================================ */
.canvas {
    position: relative;
    width: 100%;
    z-index: 1;
}

.chamber {
    position: relative;
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
    isolation: isolate;
}

.chamber-1 { background: var(--cosmic-vellum); }
.chamber-2 { background: var(--indigo-drift); }
.chamber-3 { background: var(--cosmic-vellum); }
.chamber-4 { background: var(--indigo-drift); }
.chamber-5 { background: var(--cosmic-vellum); }
.chamber-6 { background: var(--cosmic-vellum); }

/* Inner shadow vignette */
.chamber::after {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 220px 30px rgba(23, 17, 40, 0.55);
    pointer-events: none;
    z-index: 6;
}

/* ================================ Bokeh fields ================================ */
.bokeh-field {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.bokeh-node {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    will-change: transform, opacity;
    filter: blur(6px);
}

.bokeh-node.bright {
    animation: bokeh-pulse 7s ease-in-out infinite;
}

@keyframes bokeh-pulse {
    0%, 100% { opacity: var(--bokeh-opacity, 0.42); }
    50%      { opacity: calc(var(--bokeh-opacity, 0.42) + 0.20); }
}

/* ================================ Horizon ================================ */
.horizon {
    position: absolute;
    left: -2%;
    right: -2%;
    height: 0.75px;
    background: var(--horizon-color, var(--linen-glow));
    box-shadow: 0 0 2.4px 0.4px var(--horizon-color, var(--linen-glow)),
                0 0 8px 1px var(--horizon-color, var(--linen-glow));
    z-index: 5;
    opacity: 0.72;
    transform: translateZ(0);
}

.chamber-1 .horizon { --horizon-color: #5B1F4D; }
.chamber-2 .horizon { --horizon-color: #1A6E7E; }
.chamber-3 .horizon { --horizon-color: #2E8B57; }
.chamber-4 .horizon { --horizon-color: #5B1F4D; }
.chamber-5 .horizon { --horizon-color: #C28B2C; }
.chamber-6 .horizon { --horizon-color: #1A6E7E; }

/* ================================ Chapter sigils ================================ */
.chapter-sigil {
    position: absolute;
    top: 48px;
    left: 56px;
    width: 56px;
    height: 56px;
    z-index: 7;
    opacity: 0.36;
}

/* ================================ Constellations ================================ */
.constellation {
    position: absolute;
    z-index: 4;
    pointer-events: none;
    opacity: 0.7;
}

.chamber-3 .constellation[data-constellation='3a'] {
    top: 18%;
    left: 6%;
    width: 160px;
    height: auto;
}

.chamber-3 .constellation[data-constellation='3b'] {
    top: 70%;
    left: 11%;
    width: 110px;
    height: auto;
}

.chamber-5 .constellation[data-constellation='5a'] {
    top: 76%;
    left: 12%;
    width: 180px;
    height: auto;
}

/* ================================ Aurora curtains ================================ */
.aurora-curtain {
    position: absolute;
    top: 0;
    left: -20%;
    width: 140%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    filter: blur(11px) saturate(1.18);
    will-change: transform;
}

/* ================================ Chamber border traveler ================================ */
.chamber-border {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 8;
    pointer-events: none;
}

.chamber-border .border-trace {
    fill: none;
    stroke-width: 0.18;
    stroke-dasharray: 6 94;
    stroke-dashoffset: 0;
    opacity: 0.55;
    animation: border-travel 14s linear infinite;
}

.poem-card .card-border {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.poem-card .card-border .border-trace {
    fill: none;
    stroke-width: 0.5;
    stroke-dasharray: 6 94;
    stroke-dashoffset: 0;
    opacity: 0.55;
    animation: border-travel 14s linear infinite;
}

@keyframes border-travel {
    from { stroke-dashoffset: 0; }
    to   { stroke-dashoffset: -100; }
}

/* Stagger card border phases */
.poem-card:nth-child(1) .border-trace { animation-delay: 0s; }
.poem-card:nth-child(2) .border-trace { animation-delay: -3.5s; }
.poem-card:nth-child(3) .border-trace { animation-delay: -7s; }
.poem-card:nth-child(4) .border-trace { animation-delay: -10.5s; }

/* ================================ Chamber content ================================ */
.chamber-content {
    position: absolute;
    z-index: 7;
    color: var(--linen-glow);
}

.numeral-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.numeral {
    font-family: var(--display-font);
    font-style: normal;
    font-weight: 400;
    font-size: clamp(4.6rem, 9vw, 8.4rem);
    line-height: 0.98;
    letter-spacing: -0.012em;
    color: var(--garnet-aurora);
    text-shadow: 0 0 24px rgba(91, 31, 77, 0.18);
}

.numeral-topaz {
    color: var(--topaz-ember);
    text-shadow: 0 0 24px rgba(194, 139, 44, 0.20);
}

.numeral-tourmaline {
    color: var(--tourmaline-cyan);
    text-shadow: 0 0 24px rgba(26, 110, 126, 0.22);
}

.hero-word {
    font-family: var(--display-font);
    font-style: normal;
    font-weight: 400;
    font-size: clamp(2.6rem, 5.4vw, 4.6rem);
    line-height: 0.98;
    letter-spacing: -0.012em;
    color: var(--garnet-aurora);
    text-shadow: 0 0 18px rgba(91, 31, 77, 0.16);
}

.hero-beryl {
    color: var(--beryl-greenlight);
    text-shadow: 0 0 18px rgba(46, 139, 87, 0.18);
}

.hero-tourmaline {
    color: var(--tourmaline-cyan);
    text-shadow: 0 0 18px rgba(26, 110, 126, 0.22);
}

/* Specific layouts */
.content-block-1 {
    top: 20%;
    left: 38%;
    width: 36%;
}
.content-block-1 .ground-text {
    margin-top: 32%;
    max-width: 36ch;
}

.content-block-2 {
    top: 14%;
    left: 62%;
    width: 32%;
}
.content-block-2 .ground-text {
    margin-top: 38%;
    max-width: 38ch;
    position: relative;
}

.content-block-3 {
    top: 18%;
    left: 28%;
    width: 38%;
}
.content-block-3 .ground-text {
    margin-top: 28%;
    max-width: 44ch;
}

.content-block-4 {
    top: 8%;
    left: 50%;
    transform: translateX(-50%);
    width: min(86%, 1080px);
    text-align: center;
}
.content-block-4 .numeral-block {
    align-items: center;
    margin-bottom: clamp(6vh, 10vh, 14vh);
}
.content-block-4 .numeral-center {
    text-align: center;
}

.content-block-5 {
    top: 28%;
    left: 18%;
    width: 60%;
}
.content-block-5 .numeral-large .numeral {
    font-size: clamp(7rem, 14vw, 14rem);
}
.content-block-5 .ground-text-5 {
    position: absolute;
    top: 44vh;
    left: calc(60% - 18%);
    max-width: 32ch;
}

.content-block-6 {
    inset: 0;
}
.numeral-upper-left {
    position: absolute;
    top: 12%;
    left: 8%;
}
.colophon {
    position: absolute;
    right: 6%;
    bottom: 14%;
    width: 44%;
    text-align: justify;
}

.colophon-text {
    font-family: var(--editorial-font);
    font-style: italic;
    font-weight: 300;
    font-size: 17px;
    line-height: 1.78;
    color: var(--linen-glow);
    text-align: justify;
    hyphens: auto;
    margin-bottom: 28px;
}

.signature {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: var(--mono-font);
    font-style: normal;
    font-size: 12.5px;
    letter-spacing: 0.04em;
    line-height: 1.6;
    color: var(--lichen-dim);
    opacity: 0.78;
}

.sig-line {
    display: block;
}

/* ================================ Body text ================================ */
.entry {
    font-family: var(--editorial-font);
    font-style: italic;
    font-weight: 300;
    font-size: 18px;
    line-height: 1.78;
    color: var(--linen-glow);
    margin-bottom: 14px;
    max-width: 44ch;
}

.entry-em {
    font-family: var(--editorial-font);
    font-style: italic;
    font-weight: 300;
    font-size: 18px;
    color: var(--linen-glow);
    text-align: left;
    margin: 6px 0;
    opacity: 0.7;
}

.timestamp {
    display: inline-block;
    margin-top: 16px;
    font-family: var(--mono-font);
    font-style: normal;
    font-size: 12.5px;
    letter-spacing: 0.04em;
    color: var(--lichen-dim);
    opacity: 0.62;
    line-height: 1.6;
}

/* ================================ Poem cards ================================ */
.poem-row {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: stretch;
    gap: 28px;
    margin-top: 0;
}

.poem-card {
    position: relative;
    width: 220px;
    flex-shrink: 0;
    padding: 24px;
    background: rgba(10, 8, 21, 0.42);
    border: 1px solid rgba(46, 139, 87, 0.20);
    text-align: left;
    min-height: 180px;
}

.card-label {
    display: block;
    font-family: var(--mono-font);
    font-style: normal;
    font-size: 11.5px;
    letter-spacing: 0.04em;
    color: var(--lichen-dim);
    opacity: 0.62;
    margin-bottom: 14px;
}

.couplet {
    font-family: var(--editorial-font);
    font-style: italic;
    font-weight: 300;
    font-size: 16px;
    line-height: 1.62;
    color: var(--linen-glow);
}

/* ================================ Closing line (chamber 6) ================================ */
.closing-line {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--beryl-greenlight);
    box-shadow: 0 0 4px 0.5px rgba(46, 139, 87, 0.55);
    opacity: 0.68;
    z-index: 9;
}

/* ================================ Responsive trim ================================ */
@media (max-width: 900px) {
    .content-block-1, .content-block-2, .content-block-3, .content-block-5 {
        left: 8% !important;
        width: 84% !important;
    }
    .content-block-5 .ground-text-5 {
        left: 0;
        top: 38vh;
    }
    .colophon {
        width: 80%;
        right: 8%;
        bottom: 8%;
    }
    .poem-row {
        flex-wrap: wrap;
        gap: 18px;
    }
    .poem-card {
        width: calc(50% - 12px);
        min-height: 140px;
    }
    .tick-rail {
        right: 18px;
        gap: 22px;
    }
    .chapter-sigil {
        top: 24px;
        left: 24px;
        width: 42px;
        height: 42px;
    }
}
