/* ============================================================
   simai.moe — silent cathedral wired with cold light
   Palette: Vellum / Cathedral Ash / Pewter Filigree
            Bruised Plum / Smoke Teal / Halogen Bloom
   ============================================================ */

:root {
    --vellum:           #E8E2D6;
    --cathedral-ash:    #1F2024;
    --pewter-filigree:  #6B6A66;
    --bruised-plum:     #5C3E55;
    --smoke-teal:       #2E5057;
    --halogen-bloom:    #E97AB6;

    --col-outer: 12.5vw;
    --col-inner: 7.5vw;

    --ease-corridor: cubic-bezier(0.22, 0.61, 0.36, 1);
    --ease-flip:     cubic-bezier(0.42, 0, 0.18, 1);
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--vellum);
    color: var(--cathedral-ash);
    cursor: none;
}

body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.7;
    letter-spacing: 0.005em;
    overscroll-behavior: none;
    position: relative;
}

/* subtle vellum noise paper grain */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background-image:
        radial-gradient(circle at 12% 18%, rgba(107,106,102,0.04) 0 1px, transparent 2px),
        radial-gradient(circle at 78% 62%, rgba(31,32,36,0.03) 0 1px, transparent 2px),
        radial-gradient(circle at 33% 88%, rgba(107,106,102,0.03) 0 1px, transparent 2px);
    background-size: 220px 220px, 180px 180px, 260px 260px;
    mix-blend-mode: multiply;
    opacity: 0.6;
}

/* ===================== Custom Cursor ===================== */
.cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 28px;
    height: 28px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 9999;
    transition:
        width 320ms var(--ease-corridor),
        height 320ms var(--ease-corridor),
        opacity 320ms ease;
    will-change: transform;
}

.cursor svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.cursor svg g {
    transition: transform 420ms var(--ease-corridor), opacity 320ms ease;
    transform-origin: 14px 14px;
}

.cursor.is-hotspot svg g {
    transform: scale(1.35) rotate(22.5deg);
}

.cursor.is-rail {
    width: 1px;
    height: 14px;
}

.cursor.is-rail svg {
    opacity: 0;
}

.cursor.is-rail::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 1px;
    height: 14px;
    background: var(--pewter-filigree);
    transform: translate(-50%, -50%);
}

/* ===================== Corridor ===================== */
.corridor {
    position: relative;
    display: flex;
    flex-direction: row;
    width: 500vw;
    height: 100vh;
    will-change: transform;
    transition: transform 900ms var(--ease-corridor);
    z-index: 2;
}

.chamber {
    position: relative;
    width: 100vw;
    height: 100vh;
    flex: 0 0 100vw;
    overflow: hidden;
    isolation: isolate;
}

/* ===================== Broken Cartouche Frames ===================== */
.cartouche-frame {
    position: absolute;
    inset: 7vh 5vw 12vh 5vw;
    pointer-events: none;
    z-index: 3;
}

.cartouche-frame svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* ===================== Sharp-angle Trespasses ===================== */
.trespass-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
}

.trespass {
    position: absolute;
    will-change: transform;
}

.trespass--parallelogram {
    width: 32vw;
    height: 14vh;
    transform: skewX(-23deg);
    opacity: 0.08;
}

.trespass--triangle {
    width: 0;
    height: 0;
    border-left: 16vw solid transparent;
    border-right: 16vw solid transparent;
    border-bottom: 38vh solid currentColor;
    opacity: 0.07;
}

.trespass--hairline {
    width: 42vw;
    height: 2px;
    transform: rotate(-23deg);
    opacity: 0.55;
}

/* ===================== Chamber Grid ===================== */
.chamber-grid {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns:
        var(--col-outer)
        repeat(10, var(--col-inner))
        var(--col-outer);
    grid-template-rows:
        12vh
        1fr
        14vh;
    height: 100vh;
    z-index: 5;
}

.chamber-mark {
    grid-column: 2 / span 6;
    grid-row: 1;
    display: flex;
    align-items: flex-end;
    gap: 16px;
    padding-bottom: 14px;
    border-bottom: 0.5px solid rgba(107,106,102,0.4);
    margin-right: 4vw;
}

.chamber-mark .roman {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--pewter-filigree);
}

.chamber-mark .mark-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--cathedral-ash);
}

.chamber-body {
    grid-row: 2;
    align-self: center;
    position: relative;
}

/* ===================== Typography ===================== */
.display {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--cathedral-ash);
    text-transform: lowercase;
}

.display--xxl { font-size: 144px; }
.display--xl  { font-size: 112px; }

.display-dot {
    color: var(--pewter-filigree);
}

.lede {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--cathedral-ash);
    max-width: 38ch;
    margin-top: 2.2vh;
    letter-spacing: 0.005em;
}

/* ===================== Epigraph (Cormorant Garamond Italic) ===================== */
.epigraph {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 500;
    font-size: 22px;
    line-height: 1.5;
    color: var(--bruised-plum);
    margin-top: 4vh;
    max-width: 36ch;
    transition: text-shadow 600ms var(--ease-corridor);
}

.chamber.is-active .epigraph {
    text-shadow: 0 0 12px rgba(233, 122, 182, 0.28);
}

/* ===================== Chamber I — Threshold ===================== */
.chamber-body--threshold {
    grid-column: 2 / span 8;
}

.chamber-corner-rosette {
    position: absolute;
    bottom: 16vh;
    right: 8vw;
    z-index: 4;
    opacity: 0.65;
    transition: transform 1200ms var(--ease-corridor);
}

.chamber.is-active .chamber-corner-rosette {
    transform: rotate(7deg);
}

.rosette-petals {
    transform-origin: 30px 30px;
    animation: rosette-breath 8s ease-in-out infinite;
}

@keyframes rosette-breath {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}

/* ===================== Chamber II — Index of Silences ===================== */
.chamber-body--cards {
    grid-column: 2 / span 10;
    display: flex;
    flex-direction: column;
    gap: 4vh;
}

.card-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2.4vw;
    perspective: 1800px;
}

.card {
    position: relative;
    height: 38vh;
    cursor: none;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transform-origin: 50% 100%;
    transition: transform 720ms var(--ease-flip);
    will-change: transform;
}

.card.is-flipped .card-inner {
    transform: rotateX(-178deg);
}

.card.is-closing .card-inner {
    transition: transform 480ms ease-in-out;
}

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    padding: 32px 28px 24px 28px;
    overflow: hidden;
}

.card-face--front {
    background: var(--vellum);
    border: 0.5px solid var(--pewter-filigree);
}

.card-face--back {
    background: #C9C3B7; /* Vellum - 12% lightness */
    transform: rotateX(180deg);
    border: 0.5px solid var(--pewter-filigree);
    color: var(--cathedral-ash);
}

.card-border {
    position: absolute;
    inset: 6px;
    border: 0.5px solid var(--pewter-filigree);
    pointer-events: none;
    transition: box-shadow 600ms ease;
}

.card.is-flipped .card-face--front .card-border,
.card.is-flipped .card-face--back .card-border {
    box-shadow:
        0 0 24px rgba(233, 122, 182, 0.35),
        inset 0 0 12px rgba(233, 122, 182, 0.18);
}

.catalogue-tab {
    position: absolute;
    top: 0;
    left: 20px;
    width: 24px;
    height: 12px;
    z-index: 2;
}

.card-content {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

.card-num {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--pewter-filigree);
    margin-bottom: auto;
}

.card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 500;
    font-size: 28px;
    line-height: 1.15;
    letter-spacing: -0.015em;
    color: var(--cathedral-ash);
    text-transform: lowercase;
    margin-bottom: 14px;
    max-width: 18ch;
}

.card-hint {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--pewter-filigree);
    opacity: 0.7;
}

.card-face--back .card-content {
    justify-content: flex-end;
}

.card-body {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 500;
    font-size: 20px;
    line-height: 1.45;
    color: var(--bruised-plum);
    max-width: 30ch;
}

/* ===================== Chamber III — The Rosette ===================== */
.chamber-body--rosette {
    grid-column: 2 / span 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4vh;
}

.rosette-stage {
    position: relative;
    width: min(60vh, 600px);
    height: min(60vh, 600px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.seraphic-rosette {
    width: 100%;
    height: 100%;
    animation: rosette-rotate 150s linear infinite; /* 0.4 rpm */
    transform-origin: center;
}

@keyframes rosette-rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.chamber-body--rosette .epigraph {
    text-align: center;
    margin-top: 0;
}

/* ===================== Chamber IV — Halogen Vespers ===================== */
.chamber--vespers {
    background:
        radial-gradient(ellipse at 50% 50%, rgba(233,122,182,0.06) 0%, transparent 55%),
        var(--vellum);
}

.chamber-body--vespers {
    grid-column: 2 / span 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3vh;
}

.vespers-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2vh;
    padding: 6vh 0;
}

.halogen-orb {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 480px;
    height: 480px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle at center, rgba(233,122,182,0.45) 0%, rgba(233,122,182,0.15) 30%, transparent 65%);
    filter: blur(40px);
    z-index: 0;
    animation: halogen-pulse 9s ease-in-out infinite;
    pointer-events: none;
}

@keyframes halogen-pulse {
    0%, 100% { opacity: 0.7; transform: translate(-50%, -50%) scale(1); }
    50%      { opacity: 1;   transform: translate(-50%, -50%) scale(1.08); }
}

.vespers-word {
    position: relative;
    z-index: 1;
    color: var(--cathedral-ash);
    text-shadow: 0 0 28px rgba(233, 122, 182, 0.45);
}

.vespers-dot {
    color: var(--halogen-bloom);
}

.vespers-line {
    position: relative;
    z-index: 1;
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--cathedral-ash);
    max-width: 40ch;
    text-align: center;
}

.epigraph--vespers {
    text-align: center;
    margin-top: 2vh;
    color: var(--bruised-plum);
}

/* ===================== Chamber V — Coda ===================== */
.chamber--coda {
    background: var(--vellum);
}

.chamber-body--coda {
    grid-column: 3 / span 8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6vh;
}

.coda-epigraph {
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-weight: 500;
    font-size: 22px;
    line-height: 1.5;
    color: var(--bruised-plum);
    text-align: center;
    max-width: 30ch;
}

.coda-flare {
    color: var(--halogen-bloom);
    text-shadow: 0 0 14px rgba(233, 122, 182, 0.85);
    animation: coda-flare-pulse 6s ease-in-out infinite;
    display: inline-block;
}

@keyframes coda-flare-pulse {
    0%, 100% { text-shadow: 0 0 14px rgba(233, 122, 182, 0.85); transform: scale(1); }
    50%      { text-shadow: 0 0 22px rgba(233, 122, 182, 1);    transform: scale(1.08); }
}

.coda-mark {
    margin-top: 2vh;
}

.coda-mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--pewter-filigree);
}

/* ===================== Filigree Rail ===================== */
.filigree-rail {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6vh;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.rail-line {
    position: absolute;
    bottom: 50%;
    left: 6vw;
    width: 88vw;
    height: 6px;
    transform: translateY(50%);
    pointer-events: none;
}

.rail-list {
    position: relative;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 88vw;
    margin: 0 auto;
}

.rail-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: none;
    padding: 8px 6px;
}

.rail-diamond {
    display: block;
    width: 6px;
    height: 6px;
    background: var(--pewter-filigree);
    transform: rotate(45deg);
    transition: background 480ms ease, transform 480ms ease, box-shadow 600ms ease;
    will-change: transform;
}

.rail-item.is-active .rail-diamond {
    background: var(--cathedral-ash);
    box-shadow: 0 0 0 2px rgba(31,32,36,0.08);
}

.rail-label {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--pewter-filigree);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 360ms ease, transform 360ms var(--ease-corridor);
    pointer-events: none;
    padding-bottom: 4px;
}

.filigree-rail:hover .rail-label {
    opacity: 0.75;
    transform: translateX(-50%) translateY(0);
}

.rail-item.is-active .rail-label {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    color: var(--cathedral-ash);
    border-bottom: 1px solid var(--halogen-bloom);
}

/* ===================== Top-right Numeric Callout ===================== */
.callout {
    position: fixed;
    top: 4vh;
    right: 5vw;
    z-index: 40;
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--pewter-filigree);
    pointer-events: none;
    mix-blend-mode: multiply;
}

.callout-current {
    color: var(--cathedral-ash);
    font-weight: 500;
    min-width: 14px;
    display: inline-block;
    transition: color 480ms ease;
}

.callout-divider {
    color: var(--pewter-filigree);
    opacity: 0.6;
}

/* ===================== Accent Color Injection per Chamber ===================== */
#chamber-1 { color: var(--pewter-filigree); }
#chamber-2 { color: var(--bruised-plum); }
#chamber-3 { color: var(--smoke-teal); }
#chamber-4 { color: var(--halogen-bloom); }
#chamber-5 { color: var(--bruised-plum); }

/* ===================== Diamond Breath (rail) ===================== */
.rail-item:nth-child(1) .rail-diamond { animation: rail-breath 4s ease-in-out infinite 0ms; }
.rail-item:nth-child(2) .rail-diamond { animation: rail-breath 4s ease-in-out infinite 800ms; }
.rail-item:nth-child(3) .rail-diamond { animation: rail-breath 4s ease-in-out infinite 1600ms; }
.rail-item:nth-child(4) .rail-diamond { animation: rail-breath 4s ease-in-out infinite 2400ms; }
.rail-item:nth-child(5) .rail-diamond { animation: rail-breath 4s ease-in-out infinite 3200ms; }

@keyframes rail-breath {
    0%, 100% { transform: rotate(45deg) scale(1); }
    50%      { transform: rotate(45deg) scale(1.06); }
}

/* ===================== Reduced motion fallback ===================== */
@media (prefers-reduced-motion: reduce) {
    .corridor { transition: transform 200ms linear; }
    .seraphic-rosette { animation: none; }
    .halogen-orb { animation: none; }
    .rosette-petals { animation: none; }
    .rail-item .rail-diamond { animation: none; }
}

/* ===================== Mobile fallback ===================== */
@media (max-width: 900px) {
    :root {
        --col-outer: 6vw;
        --col-inner: 8.8vw;
    }
    .display--xxl { font-size: 88px; }
    .display--xl  { font-size: 72px; }
    .card-row { grid-template-columns: 1fr; gap: 2vh; }
    .card { height: 26vh; }
    .rosette-stage { width: 78vw; height: 78vw; }
    .halogen-orb { width: 78vw; height: 78vw; }
}
