/* =========================================================
   RITUAL — base layer for index.html.
   Loads first; css/desk.css restyles the page on top of it.
   Owns: atmosphere layers, nav, and the shared widgets
   (lightbox, overlays, card, music player, toast).
   Colour + type tokens live in css/desk.css. The wordmark lives in css/logo.css.
   ========================================================= */

:root {
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
    --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

    --dur-fast: 160ms;
    --dur-base: 260ms;
    --dur-slow: 480ms;
}

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

html {
    scrollbar-width: none;
}
html::-webkit-scrollbar {
    display: none;
}

body {
    background: var(--bg);
    color: var(--paper-dim);
    font-family: var(--serif);
    min-height: 100vh;
    overflow-x: hidden;
    cursor: crosshair;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Content protection: no text selection, no dragging (js/protection.js backs this up, minus ?dev=1) */
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}
body.overlay-open { overflow: hidden; }
:focus-visible { outline: 2px solid var(--red-bright); outline-offset: 3px; border-radius: 1px; }
img { max-width: 100%; display: block; -webkit-user-drag: none; }
button { font: inherit; }
::selection { background: var(--red-deep); color: var(--paper); }

@keyframes blink { 0%,100%{opacity:1;} 50%{opacity:0;} }

/* ===== background / atmosphere layers ===== */
#three-canvas {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    opacity: 0.55; transition: opacity 0.8s ease;
}
@media (prefers-reduced-motion: reduce) { #three-canvas { display: none !important; } }
@media (max-width: 860px) { #three-canvas { opacity: 0.3; } }

.grain {
    position: fixed; inset: -100px; z-index: 2; pointer-events: none; opacity: 0.05; mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.vignette {
    position: fixed; inset: 0; pointer-events: none; z-index: 1;
    background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,0.72) 100%);
    animation: vignetteBreathe 9s ease-in-out infinite;
}
@keyframes vignetteBreathe { 0%,100%{opacity:.76;} 50%{opacity:.92;} }
@media (prefers-reduced-motion: reduce) { .vignette { animation: none; opacity: .8; } }

#scroll-progress {
    position: fixed; top: 0; left: 0; height: 2px; background: var(--red-bright);
    z-index: 10000; width: 100%; transform-origin: left; transform: scaleX(0);
    will-change: transform;
    box-shadow: 0 0 18px var(--red-glow-strong); pointer-events: none;
}

/* ===== preloader ===== */
#preloader { position: fixed; inset: 0; z-index: 10050; pointer-events: none; }
.preloader-panel { position: absolute; left: 0; right: 0; height: 51%; background: var(--bg); z-index: 1; }
.preloader-panel-top { top: 0; }
.preloader-panel-bottom { bottom: 0; }
.preloader-inner {
    position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 1.15rem;
}
.preloader-label { font-family: var(--mono); font-size: .62rem; letter-spacing: .34em; text-transform: uppercase; color: var(--ink); }
.preloader-barwrap { width: 210px; height: 1px; background: var(--line-bright); overflow: hidden; }
.preloader-bar { width: 0%; height: 100%; background: var(--red-bright); box-shadow: 0 0 10px var(--red-glow-strong); }
.preloader-pct { font-family: var(--mono); font-size: .6rem; letter-spacing: .15em; color: var(--paper); min-width: 3ch; text-align: center; }
@media (prefers-reduced-motion: reduce) { #preloader { display: none !important; } }

#cursor-glow {
    position: fixed; pointer-events: none; z-index: 9997; top: 0; left: 0;
    width: 90px; height: 90px; border-radius: 50%;
    background: radial-gradient(circle, rgba(216,31,47,.2) 0%, rgba(216,31,47,.05) 50%, transparent 70%);
    will-change: transform;
    transition: width .35s var(--ease-out), height .35s var(--ease-out), opacity .35s var(--ease-out);
    mix-blend-mode: screen;
}
#cursor-glow.hover {
    width: 150px; height: 150px; opacity: 1;
    background: radial-gradient(circle, rgba(255,51,70,.3) 0%, rgba(216,31,47,.09) 50%, transparent 70%);
}
@media (max-width: 860px), (hover: none) { #cursor-glow { display: none; } }
@media (prefers-reduced-motion: reduce) { #cursor-glow { display: none !important; } }

.ripple-container { position: fixed; inset: 0; pointer-events: none; z-index: 9996; overflow: hidden; }
.ripple {
    position: absolute; border-radius: 50%; border: 1px solid rgba(216,31,47,.35);
    animation: rippleAnim .8s var(--ease-out) forwards; pointer-events: none;
}
@keyframes rippleAnim { 0%{transform:scale(0);opacity:.7;} 100%{transform:scale(4.2);opacity:0;} }
@media (prefers-reduced-motion: reduce) { .ripple { display: none !important; } }

/* ===== nav ===== */
.nav-bar {
    position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h); z-index: 5000;
    background: rgba(10,9,8,0.78); backdrop-filter: blur(20px) saturate(1.2); -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-bottom: 1px solid var(--line);
    transition: background .4s var(--ease-out), border-color .4s var(--ease-out), box-shadow .4s var(--ease-out);
}
.nav-bar.scrolled {
    background: rgba(10,9,8,0.94); border-bottom-color: var(--line-bright);
    box-shadow: 0 4px 40px rgba(0,0,0,.55);
}
.nav-inner {
    max-width: 1440px; height: 100%; margin: 0 auto; padding: 0 2.2rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
}

.nav-links { display: flex; align-items: center; gap: .3rem; list-style: none; position: relative; }
.nav-links li { position: relative; }
.nav-links a {
    font-family: var(--mono); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase;
    color: var(--ink); text-decoration: none; position: relative; padding: .55rem .85rem; display: block;
    transition: color var(--dur-fast) ease; border-radius: 3px;
}
.nav-links a:hover { color: var(--paper); }
.nav-links a.active { color: var(--paper); }
#nav-indicator {
    position: absolute; bottom: -1px; height: 2px; background: var(--red-bright); border-radius: 2px;
    box-shadow: 0 0 10px var(--red-glow-strong); width: 0; left: 0; pointer-events: none;
}

.nav-status {
    display: flex; align-items: center; gap: .5rem; font-family: var(--mono); font-size: .6rem;
    color: var(--ink); letter-spacing: .1em;
}
.status-dot {
    width: 6px; height: 6px; border-radius: 50%; background: var(--red-bright);
    box-shadow: 0 0 10px var(--red-glow-strong); animation: pulseDot 2.2s ease-in-out infinite; display: block;
}
@keyframes pulseDot { 0%,100%{opacity:1;box-shadow:0 0 10px var(--red-glow-strong);} 50%{opacity:.3;box-shadow:0 0 3px var(--red-glow);} }
.mobile-nav-toggle {
    display: none; background: none; border: 1px solid var(--line-bright); color: var(--paper);
    font-size: 1rem; cursor: pointer; padding: .4rem .65rem; border-radius: 3px; transition: border-color var(--dur-fast), color var(--dur-fast);
}
.mobile-nav-toggle:hover { border-color: var(--red-bright); color: var(--red-bright); }

@media (max-width: 860px) {
    .nav-inner { padding: 0 1.2rem; }
    .nav-links { display: none; }
    .nav-status { display: none; }
    .mobile-nav-toggle { display: block; }
    .nav-bar { height: var(--nav-h-m); }
}

.mobile-menu {
    position: fixed; inset: 0; z-index: 4900; background: rgba(10,9,8,0.98);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.8rem;
    opacity: 0; pointer-events: none; transition: opacity var(--dur-slow) var(--ease-out);
}
.mobile-menu.active { opacity: 1; pointer-events: all; }
.mobile-menu a {
    font-family: var(--display); font-size: 2.2rem; color: var(--paper); text-decoration: none;
    letter-spacing: .06em; text-transform: uppercase; transition: color var(--dur-base) ease;
}
.mobile-menu a:hover { color: var(--red-bright); }
.mobile-menu-close {
    position: absolute; top: 1.4rem; right: 1.4rem; background: none; border: 1px solid var(--line-bright);
    color: var(--paper); font-size: 1.2rem; cursor: pointer; padding: .5rem .7rem; border-radius: 3px;
}

main { position: relative; z-index: 2; }

/* ===== dossier / hello ===== */
#dossier {
    display: grid; grid-template-columns: 1.05fr .95fr; gap: 0;
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
    position: relative;
}
.meo-mark {
    position: absolute; left: 128px; top: 50%; transform: translateY(-50%);
    width: 100px; z-index: 50; pointer-events: none;
}
.meo-mark img { width: 100%; filter: drop-shadow(0 6px 12px rgba(0,0,0,.55)); }
@media (max-width: 860px) { .meo-mark { width: 90px; left: 100px; } }
.polaroid {
    background: var(--paper); padding: .9rem .9rem 3.2rem; max-width: 380px; width: 100%;
    transform: rotate(-2.2deg); position: relative; box-shadow: 0 25px 60px rgba(0,0,0,.6);
    transition: transform .5s var(--ease-out), box-shadow .5s var(--ease-out);
    cursor: zoom-in;
}
.polaroid:hover { transform: rotate(0deg) scale(1.02); box-shadow: 0 30px 70px rgba(0,0,0,.7); }
.polaroid-frame { overflow: hidden; background: var(--bg2); }
.polaroid-frame img {
    width: 100%; height: 100%; object-fit: cover; object-position: top; aspect-ratio: 4/5;
    filter: grayscale(85%) brightness(.5); transition: filter .5s ease, transform .6s var(--ease-out);
}
.polaroid:hover .polaroid-frame img { filter: grayscale(25%) brightness(.85); transform: scale(1.04); }
.polaroid-frame .px-night { display: none; }
.polaroid-caption {
    position: absolute; left: .9rem; right: .9rem; bottom: 1.1rem; font-family: var(--mono);
    font-size: .55rem; letter-spacing: .06em; color: var(--bg2); text-align: center;
}
.tape { position: absolute; width: 64px; height: 22px; background: rgba(216,31,47,.72); opacity: .85; box-shadow: 0 3px 8px rgba(0,0,0,.35); }
.tape-l { top: -10px; left: -14px; transform: rotate(-38deg); }
.tape-r { top: -10px; right: -14px; transform: rotate(38deg); }
.hint-tag {
    position: absolute; top: 1rem; right: 1rem; font-family: var(--mono); font-size: .5rem;
    letter-spacing: .12em; color: var(--paper); background: rgba(0,0,0,.75); padding: .3rem .6rem;
    border: 1px solid var(--line-bright); opacity: 0; transition: opacity var(--dur-base); text-transform: uppercase;
}
.polaroid:hover .hint-tag { opacity: 1; }
@media (max-width: 860px) {
    #dossier { grid-template-columns: 1fr; }
}

/* ===== prints ===== */
.frame-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-bottom: 1.6rem;
}
.frame-filter {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-family: var(--mono);
    font-size: .58rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--bg2);
    border: 1px solid var(--line);
    padding: .62rem 1rem;
    border-radius: 3px;
    cursor: pointer;
    transition: color var(--dur-base), border-color var(--dur-base), background var(--dur-base);
}
.frame-filter em {
    font-style: normal;
    font-size: .5rem;
    color: var(--ink-dim);
    transition: color var(--dur-base);
}
.frame-filter:hover { color: var(--paper); border-color: var(--line-bright); }
.frame-filter.active {
    color: var(--bg);
    background: var(--red-bright);
    border-color: var(--red-bright);
}
.frame-filter.active em { color: rgba(10, 9, 8, .6); }

.frame-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 190px;
    grid-auto-flow: dense;
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
}
.frame-cell {
    position: relative;
    margin: 0;
    overflow: hidden;
    background: var(--bg2);
    cursor: zoom-in;
    user-select: none;
}

.frame-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(85%) brightness(.48);
    transform: scale(1.01);
    transition: transform .7s var(--ease-out), filter .5s ease;
}
.frame-cell:hover img {
    transform: scale(1.07);
    filter: grayscale(5%) brightness(.94);
}

.frame-cell.is-hidden { display: none; }
.frame-cell.filter-in { animation: frameIn .5s var(--ease-out) both; }
@keyframes frameIn {
    0%   { opacity: 0; transform: translateY(18px) scale(.96); }
    100% { opacity: 1; transform: none; }
}

@media (max-width: 1100px) {
    .frame-grid { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 168px; }
}
@media (max-width: 860px) {
    .frame-grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 150px; }
}
@media (max-width: 560px) {
    .frame-grid { grid-template-columns: 1fr; grid-auto-rows: 200px; }
}
@media (prefers-reduced-motion: reduce) {
    .frame-cell img { transition: none; }
    .frame-cell.filter-in { animation: none; }
}

/* ===== on repeat ===== */
.signal-eq { display: flex; align-items: flex-end; justify-content: center; gap: 5px; height: 26px; margin: 0 auto 2.6rem; }
.signal-eq span {
    width: 4px; height: 100%; background: var(--red); border-radius: 1px; transform-origin: bottom;
    animation: eqBounce 1.1s ease-in-out infinite;
}
.signal-eq span:nth-child(1) { animation-duration: 1.3s; animation-delay: 0s; }
.signal-eq span:nth-child(2) { animation-duration: .9s; animation-delay: .1s; }
.signal-eq span:nth-child(3) { animation-duration: 1.5s; animation-delay: .2s; }
.signal-eq span:nth-child(4) { animation-duration: 1s; animation-delay: .05s; }
.signal-eq span:nth-child(5) { animation-duration: 1.2s; animation-delay: .15s; }
@keyframes eqBounce { 0%,100%{transform:scaleY(.25);} 50%{transform:scaleY(1);} }
@media (prefers-reduced-motion: reduce) { .signal-eq span { animation: none; transform: scaleY(.6); } }
.whisper-container { max-width: 680px; margin: 0 auto; min-height: 12rem; display: flex; align-items: center; justify-content: center; }
.whisper-text {
    font-family: var(--serif); font-size: clamp(1.3rem, 3vw, 2.1rem); font-style: italic; line-height: 1.7;
    color: var(--paper); transition: opacity .5s var(--ease-out), transform .5s var(--ease-out); opacity: 1; transform: translateY(0);
}
.whisper-text.fading { opacity: 0; transform: translateY(12px); }
.whisper-leds { display: flex; gap: .55rem; justify-content: center; margin-top: 2.4rem; }
.whisper-dot {
    width: 16px; height: 5px; background: var(--line-bright); cursor: pointer; transition: all var(--dur-base) var(--ease-out); border-radius: 3px;
}
.whisper-dot.active { background: var(--red-bright); box-shadow: 0 0 12px var(--red-glow-strong); width: 30px; }
.whisper-dot:hover { background: var(--red); }

/* ===== writing ===== */
.notes-tabs {
    display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .3rem; margin-bottom: 2.6rem;
}
.notes-tab {
    font-family: var(--mono); font-size: .6rem; letter-spacing: .1em; text-transform: uppercase;
    color: var(--ink); background: var(--bg2); border: 1px solid var(--line); padding: .7rem 1.15rem;
    cursor: pointer; white-space: nowrap; transition: all var(--dur-base) ease; flex: none; border-radius: 3px;
}
.notes-tab:hover { color: var(--paper); border-color: var(--line-bright); }
.notes-tab.active { color: var(--bg); background: var(--red-bright); border-color: var(--red-bright); }
.notes-panel {
    border-left: 2px solid var(--red); padding: .3rem 0 .3rem 2.1rem; display: flex; flex-direction: column;
    gap: 1.3rem; transition: opacity .3s ease; max-width: 720px;
}
.notes-panel.swapping { opacity: .1; }
.notes-tag { font-family: var(--mono); font-size: .55rem; color: var(--red-bright); letter-spacing: .22em; text-transform: uppercase; }
.notes-title { font-family: var(--display); font-size: clamp(1.8rem, 3.4vw, 2.8rem); letter-spacing: .01em; text-transform: uppercase; color: var(--paper); line-height: 1.05; }
.notes-body {
    font-size: .98rem; line-height: 1.95; color: var(--ink); max-height: 5.8em; overflow: hidden;
    position: relative; transition: max-height .55s var(--ease-drawer); white-space: pre-line;
}
.notes-body.expanded { max-height: 50em; }
.notes-body::after {
    content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2.5em;
    background: linear-gradient(to bottom, transparent, var(--bg)); transition: opacity var(--dur-slow);
}
.notes-body.expanded::after { opacity: 0; }
.read-more-btn {
    font-family: var(--mono); font-size: .55rem; color: var(--red-bright); letter-spacing: .18em;
    text-transform: uppercase; background: none; border: none; cursor: pointer; padding: 0;
    display: inline-flex; align-items: center; gap: .5rem; transition: gap var(--dur-base), color var(--dur-base); width: fit-content;
}
.read-more-btn:hover { gap: .9rem; color: var(--paper); }

/* ===== footer ===== */
footer { border-top: 1px solid var(--line); }
.footer-left { display: flex; gap: 2rem; align-items: center; flex-wrap: wrap; }
.footer-links { display: flex; gap: 1.5rem; list-style: none; flex-wrap: wrap; }
.footer-links a {
    font-family: var(--mono); font-size: .55rem; color: var(--ink); text-decoration: none; letter-spacing: .06em;
    transition: color var(--dur-fast);
}
.footer-links a::before { content: '['; color: var(--line-bright); margin-right: .15rem; }
.footer-links a::after { content: ']'; color: var(--line-bright); margin-left: .15rem; }
.footer-links a:hover { color: var(--red-bright); }
.footer-right { font-family: var(--mono); font-size: .52rem; color: var(--ink); letter-spacing: .08em; white-space: nowrap; }
@media (max-width: 860px) {
    .footer-left { flex-direction: column; align-items: flex-start; gap: .8rem; }
}

#back-to-top {
    position: fixed; bottom: 2rem; right: 2rem; z-index: 5000; width: 44px; height: 44px;
    border: 1px solid var(--line-bright); background: rgba(10,9,8,.86); backdrop-filter: blur(10px);
    color: var(--paper); font-size: 1rem; cursor: pointer; transition: border-color var(--dur-base), color var(--dur-base), box-shadow var(--dur-base); opacity: 0;
    transform: translateY(16px) scale(.94); pointer-events: none; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; will-change: transform, opacity;
}
#back-to-top.visible { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out); }
#back-to-top:hover { border-color: var(--red-bright); color: var(--red-bright); box-shadow: 0 0 30px var(--red-glow); }

/* ===== lightbox ===== */
.lightbox {
    position: fixed; inset: 0; z-index: 8000; display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity .35s var(--ease-out);
}
.lightbox.active { opacity: 1; pointer-events: all; }
.lightbox-backdrop { position: absolute; inset: 0; background: rgba(6,5,5,.97); backdrop-filter: blur(16px); cursor: zoom-out; }
.lightbox-frame {
    position: relative; z-index: 1; max-width: 90vw; max-height: 88vh; display: flex; flex-direction: column;
    align-items: center; gap: 1rem; transform: scale(.94); transition: transform .35s var(--ease-out); padding: 1.4rem;
}
.lightbox.active .lightbox-frame { transform: scale(1); }
.lightbox-frame::before, .lightbox-frame::after,
.lightbox-corner-a, .lightbox-corner-b {
    content: ''; position: absolute; width: 22px; height: 22px; border: 2px solid var(--red-bright); opacity: .8;
}
.lightbox-frame::before { top: 0; left: 0; border-right: none; border-bottom: none; }
.lightbox-frame::after { top: 0; right: 0; border-left: none; border-bottom: none; }
.lightbox-corner-a { bottom: 0; left: 0; border-right: none; border-top: none; }
.lightbox-corner-b { bottom: 0; right: 0; border-left: none; border-top: none; }
.lightbox-img { max-width: 88vw; max-height: 78vh; object-fit: contain; background: var(--bg); min-height: 100px; min-width: 100px; }
.lightbox-caption { font-family: var(--mono); font-size: .55rem; color: var(--ink); letter-spacing: .16em; text-transform: uppercase; text-align: center; }
.lightbox-close {
    position: absolute; top: 1.4rem; right: 1.75rem; z-index: 5; background: none; border: none; color: var(--paper);
    font-family: var(--mono); font-size: .55rem; letter-spacing: .2em; cursor: pointer; text-transform: uppercase;
    transition: color var(--dur-fast); display: flex; align-items: center; gap: .5rem; opacity: .6;
}
.lightbox-close:hover { color: var(--red-bright); opacity: 1; }
@media (max-width: 860px) {
    .lightbox-close { top: 1rem; right: 1rem; }
}
.lightbox-nav {
    position: absolute; top: 50%; transform: translateY(-50%); background: rgba(10,9,8,.72);
    border: 1px solid var(--line-bright); color: var(--paper); font-family: var(--mono); font-size: .85rem;
    width: 2.7rem; height: 2.7rem; display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: all var(--dur-fast); z-index: 2; opacity: .5; border-radius: 50%;
}
.lightbox-nav:hover { border-color: var(--red-bright); color: var(--red-bright); opacity: 1; }
.lightbox-prev { left: -3rem; } .lightbox-next { right: -3rem; }
@media (max-width: 860px) {
    .lightbox-prev { left: .1rem; } .lightbox-next { right: .1rem; }
    .lightbox-nav { width: 2.2rem; height: 2.2rem; font-size: .7rem; }
}

/* ===== overlays shared ===== */
.poem-overlay, .glitch-overlay, .card-overlay {
    position: fixed; inset: 0; z-index: 8200; display: flex; align-items: center; justify-content: center;
    background: rgba(6,5,5,.96); backdrop-filter: blur(14px); opacity: 0; pointer-events: none; transition: opacity .35s var(--ease-out);
}
.poem-overlay.active, .glitch-overlay.active, .card-overlay.active { opacity: 1; pointer-events: all; }
.poem-card, .glitch-card {
    background: var(--bg2); border: 1px solid var(--line); padding: 2.8rem 3rem; max-width: 500px; width: 90%;
    position: relative; box-shadow: 0 0 80px rgba(0,0,0,.9); transform: translateY(10px) scale(.98); transition: transform .35s var(--ease-out);
}
.poem-overlay.active .poem-card, .glitch-overlay.active .glitch-card { transform: translateY(0) scale(1); }
.overlay-close {
    position: absolute; top: .8rem; right: 1rem; background: none; border: none; color: var(--ink);
    font-size: 1rem; cursor: pointer; transition: color var(--dur-fast); z-index: 5;
}
.overlay-close:hover { color: var(--red-bright); }
.poem-label {
    font-family: var(--mono); font-size: .55rem; letter-spacing: .3em; color: var(--red-bright);
    text-transform: uppercase; margin-bottom: 1.7rem; display: flex; align-items: center; gap: .8rem;
}
.poem-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.poem-title { font-family: var(--display); font-size: 2rem; letter-spacing: .02em; text-transform: uppercase; color: var(--paper); margin-bottom: 1.5rem; }
.poem-card { border-left: 3px solid var(--red); }
.poem-text { font-family: var(--serif); font-size: 1rem; line-height: 2.05; color: var(--ink); font-style: italic; white-space: pre-line; }

.glitch-card { max-width: 700px; overflow: hidden; }
.glitch-scan-lines {
    position: absolute; inset: 0; pointer-events: none; z-index: 2;
    background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(216,31,47,.012) 3px, rgba(216,31,47,.012) 6px);
    animation: scanFlicker 8s infinite linear;
}
@keyframes scanFlicker { 0%,99.5%,100%{opacity:1;} 99.6%,99.9%{opacity:.15;} }
.glitch-ritual-wrapper { position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 0; }
/* the wordmark, big: same face as css/logo.css (italic 600, mixed case) */
.glitch-ritual {
    font-family: var(--display); font-style: italic; font-weight: 600; font-size: clamp(3.5rem, 11vw, 9rem);
    color: var(--paper); letter-spacing: .01em; line-height: 1; position: relative; display: inline-block;
}
.glitch-red { color: var(--red-bright); position: relative; z-index: 1; }
.glitch-ritual::before, .glitch-ritual::after {
    content: attr(data-text); position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    font: inherit; letter-spacing: inherit; opacity: 0; pointer-events: none;
}
.glitch-ritual::before { color: #ff0000; clip-path: inset(12% 0 55% 0); animation: gSliceA 2.5s infinite steps(1); }
.glitch-ritual::after { color: #ffffff; clip-path: inset(52% 0 18% 0); animation: gSliceB 3.1s infinite steps(1); }
@keyframes gSliceA { 0%,92%,100%{opacity:0;transform:translate(0,0);} 93%{opacity:.5;transform:translate(-5px,1px);} 94%{opacity:.65;transform:translate(4px,-2px);} 95%{opacity:0;transform:translate(0,0);} }
@keyframes gSliceB { 0%,88%,100%{opacity:0;transform:translate(0,0);} 89%{opacity:.4;transform:translate(4px,-1px);} 90%{opacity:.6;transform:translate(-3px,2px);} 91%{opacity:0;transform:translate(0,0);} }
.glitch-ritual.intense::before { animation: gIntA .25s steps(2) !important; opacity: .75 !important; clip-path: inset(5% 0 70% 0) !important; transform: translate(-8px,3px) !important; }
.glitch-ritual.intense::after { animation: gIntB .25s steps(2) !important; opacity: .7 !important; clip-path: inset(60% 0 8% 0) !important; transform: translate(6px,-3px) !important; }
@keyframes gIntA { 0%{transform:translate(-8px,3px);clip-path:inset(5% 0 70% 0);} 50%{transform:translate(10px,-5px);clip-path:inset(30% 0 40% 0);} 100%{transform:translate(-4px,7px);clip-path:inset(55% 0 15% 0);} }
@keyframes gIntB { 0%{transform:translate(6px,-3px);clip-path:inset(60% 0 8% 0);} 50%{transform:translate(-9px,4px);clip-path:inset(15% 0 55% 0);} 100%{transform:translate(5px,-6px);clip-path:inset(45% 0 25% 0);} }
@media (max-width: 860px) {
    .glitch-card { padding: 2rem 1.2rem; }
    .glitch-ritual { font-size: clamp(2.5rem, 16vw, 4.5rem); }
    .poem-card { padding: 2rem 1.4rem; max-width: 95%; }
}
.ritual-glitch {
    animation: ritualGlitch 0.12s steps(2, end) infinite;
}
@keyframes ritualGlitch {
    0%   { transform: translate(0); text-shadow: none; }
    20%  { transform: translate(-3px, 2px); text-shadow: 3px 0 #f00, -3px 0 #0ff; }
    40%  { transform: translate(3px, -2px); text-shadow: -3px 0 #f00, 3px 0 #0ff; }
    60%  { transform: translate(-2px, -1px); }
    80%  { transform: translate(2px, 1px); text-shadow: 2px 0 #f00, -2px 0 #0ff; }
    100% { transform: translate(0); text-shadow: none; }
}
/* Ritual sequence: total freeze. Nothing on the page can be clicked,
   hovered, focused, or opened from the moment "ritual" is typed until
   the page is blacked out. Scrolling is also killed. */
body.ritual-active,
body.ritual-active * {
    pointer-events: none !important;
    user-select: none;
}
body.ritual-active {
    overflow: hidden !important;
    overscroll-behavior: none;
}
html:has(body.ritual-active) {
    overflow: hidden !important;
    overscroll-behavior: none;
}

/* ===== card overlay ===== */
.card-overlay .card-scene { width: 360px; height: 244px; position: relative; perspective: 1100px; }
.card-overlay .card-flip {
    width: 100%; height: 100%; position: relative; transform-style: preserve-3d;
    transition: transform 0.7s var(--ease-in-out); cursor: pointer;
}
.card-overlay .card-scene.flipped .card-flip,
.card-overlay .card-scene.hover-flipped .card-flip { transform: rotateY(180deg); }
.card-overlay .card-face {
    position: absolute; width: 100%; height: 100%; backface-visibility: hidden; border: 1px solid var(--line-bright);
    display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden;
    background: var(--bg2); border-radius: 18px; padding: 22px 26px;
}
.card-overlay .card-front { justify-content: center; align-items: center; text-align: center; padding: 22px 30px; }
/* the wordmark on the card: same face as css/logo.css */
.card-overlay .card-front .card-front-text { font-family: var(--display); font-style: italic; font-weight: 600; font-size: clamp(58px, 14vw, 78px); letter-spacing: .01em; line-height: 1; color: var(--paper); }
.card-overlay .card-front .card-front-text .accent { color: var(--red-bright); }
.card-overlay .card-back { transform: rotateY(180deg); justify-content: flex-start; padding: 22px 26px; }
.card-overlay .card-back .face-row { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.card-overlay .card-back .serial { font-size: 10px; letter-spacing: .14em; color: var(--ink); text-transform: uppercase; }
.card-overlay .card-back .back-body { padding-top: 4px; width: 100%; }
.card-overlay .card-back .back-name { font-family: var(--display); font-style: italic; font-weight: 600; font-size: 26px; letter-spacing: .02em; line-height: 1; color: var(--paper); }
.card-overlay .card-back .back-name .accent { color: var(--red-bright); }
.card-overlay .card-back .back-title { margin-top: 4px; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); }
.card-overlay .card-back .hr { height: 1px; background: linear-gradient(90deg, transparent, var(--line), transparent); margin: 8px 0; flex-shrink: 0; width: 100%; }
.card-overlay .card-back .detail-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; width: 100%; }
.card-overlay .card-back .detail { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--paper); border-radius: 6px; padding: 3px 4px; margin: -3px -4px; }
.card-overlay .card-back .detail-icon { color: var(--red-bright); font-size: 11px; width: 14px; flex-shrink: 0; text-align: center; }
.card-overlay .card-back .detail-text { flex: 1; }
.card-overlay .card-back .detail.copyable { cursor: pointer; transition: background var(--dur-base); }
.card-overlay .card-back .detail.copyable:hover, .card-overlay .card-back .detail.copyable:focus-visible { background: rgba(236, 230, 216, .06); outline: none; }
.card-overlay .card-back .detail-action {
    font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); border: 1px solid var(--line);
    border-radius: 20px; padding: 2px 7px; opacity: 0; transform: translateX(-2px);
    transition: opacity var(--dur-base), transform var(--dur-base), color var(--dur-base), border-color var(--dur-base);
}
.card-overlay .card-back .detail.copyable:hover .detail-action, .card-overlay .card-back .detail.copyable:focus-visible .detail-action { opacity: 1; transform: translateX(0); }
.card-overlay .card-back .back-footer { margin-top: auto; display: flex; align-items: center; gap: 14px; width: 100%; }
.card-overlay .card-back .barcode {
    height: 26px; flex: 1; opacity: .8;
    background: repeating-linear-gradient(90deg, var(--paper) 0 2px, transparent 2px 4px, var(--paper) 4px 5px, transparent 5px 9px,
        var(--paper) 9px 12px, transparent 12px 13px, var(--paper) 13px 14px, transparent 14px 19px,
        var(--paper) 19px 21px, transparent 21px 24px, var(--paper) 24px 25px, transparent 25px 30px);
}
.card-overlay .card-back .footer-text { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink); flex-shrink: 0; white-space: nowrap; }
.card-overlay .card-back .sheen, .card-overlay .card-front .sheen {
    position: absolute; inset: 0; pointer-events: none; border-radius: inherit;
    background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 38%), rgba(255, 255, 255, .14), rgba(255, 255, 255, .03) 34%, transparent 62%);
    mix-blend-mode: overlay;
}
.card-overlay .card-front .foil-strip {
    position: absolute; right: -10px; top: -14px; bottom: -14px; width: 64px; pointer-events: none; opacity: .45;
    background: repeating-linear-gradient(124deg, transparent 0 9px, rgba(216, 31, 47, .25) 9px 11px, transparent 11px 20px, rgba(236, 230, 216, .08) 20px 22px);
    background-size: 140% 140%; animation: foilShift 9s linear infinite;
}
@keyframes foilShift { 0% { background-position: 0% 0%; } 100% { background-position: 0% 100%; } }
@media (max-width: 860px) {
    .card-overlay .card-scene { width: 285px; height: 218px; }
    .card-overlay .card-front .card-front-text { font-size: 2.6rem; }
    .card-overlay .card-back .back-name { font-size: 1.15rem; }
    .card-overlay .card-face { padding: 18px 22px; }
}

/* ===== music player ===== */
.music-player-overlay {
    position: fixed; z-index: 8100; width: 275px; background: rgba(10,9,8,.96); border: 1px solid var(--line-bright);
    box-shadow: 0 0 60px rgba(0,0,0,.9); display: flex; flex-direction: column; opacity: 0; pointer-events: none;
    transition: opacity .3s var(--ease-out); user-select: none; backdrop-filter: blur(16px); border-radius: 8px; overflow: hidden;
}
.music-player-overlay.active { opacity: 1; pointer-events: all; }
.player-header { display: flex; justify-content: space-between; align-items: center; padding: .65rem .85rem; border-bottom: 1px solid var(--line); cursor: grab; background: var(--bg3); gap: .6rem; }
.player-header:active { cursor: grabbing; }
.player-eq { display: flex; align-items: flex-end; gap: 2px; height: 12px; }
.player-eq span { width: 3px; height: 100%; background: var(--red-bright); border-radius: 1px; transform: scaleY(.2); transform-origin: bottom; transition: transform .2s; }
.music-player-overlay.playing .player-eq span { animation: eqBounce 1s ease-in-out infinite; }
.music-player-overlay.playing .player-eq span:nth-child(1) { animation-duration: 1.1s; }
.music-player-overlay.playing .player-eq span:nth-child(2) { animation-duration: .8s; }
.music-player-overlay.playing .player-eq span:nth-child(3) { animation-duration: 1.3s; }
.player-title-label { font-family: var(--mono); font-size: .55rem; letter-spacing: .22em; color: var(--ink); text-transform: uppercase; flex: 1; }
.player-close-btn { background: none; border: none; color: var(--ink); font-size: .85rem; cursor: pointer; transition: color var(--dur-fast); line-height: 1; padding: .2rem; }
.player-close-btn:hover { color: var(--red-bright); }
.player-track-info { padding: .75rem .95rem .4rem; display: flex; flex-direction: column; gap: .1rem; }
.player-track-title { font-family: var(--serif); font-size: 1rem; font-style: italic; color: var(--paper); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-track-artist { font-family: var(--mono); font-size: .5rem; color: var(--ink); letter-spacing: .1em; text-transform: uppercase; }
.player-progress-container { padding: .4rem .95rem .2rem; display: flex; flex-direction: column; gap: .15rem; }
.player-progress { width: 100%; appearance: none; background: var(--line-bright); height: 3px; border-radius: 2px; outline: none; cursor: pointer; }
.player-progress::-webkit-slider-thumb { appearance: none; width: 11px; height: 11px; border-radius: 50%; background: var(--red-bright); cursor: pointer; border: 1px solid var(--bg); box-shadow: 0 0 14px var(--red-glow-strong); }
.player-time { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .45rem; color: var(--ink-dim); letter-spacing: .1em; }
.player-controls { display: flex; align-items: center; justify-content: center; gap: .9rem; padding: .55rem .95rem; border-top: 1px solid var(--line); position: relative; }
.player-btn { background: none; border: none; color: var(--paper); font-size: .9rem; cursor: pointer; transition: color var(--dur-fast), transform var(--dur-fast) var(--ease-out); display: flex; align-items: center; justify-content: center; width: 1.8rem; height: 1.8rem; opacity: .5; }
.player-btn:hover { color: var(--red-bright); opacity: 1; }
.player-btn:active { transform: scale(.88); }
.play-btn { font-size: 1.2rem; }
.volume-slider-popup { display: none; position: absolute; bottom: 110%; left: 50%; transform: translateX(-50%); background: var(--bg3); border: 1px solid var(--line); padding: .45rem; border-radius: 4px; z-index: 10; }
.volume-slider-popup.active { display: block; }
.player-volume { appearance: none; background: var(--line-bright); height: 3px; width: 75px; border-radius: 2px; outline: none; cursor: pointer; }
.player-volume::-webkit-slider-thumb { appearance: none; width: 11px; height: 11px; border-radius: 50%; background: var(--red-bright); cursor: pointer; border: 1px solid var(--bg); }
@media (max-width: 860px) { .music-player-overlay { width: 85vw; max-width: 275px; } }

/* ===== spark burst ===== */
.mark-burst-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.mark-pop {
    position: absolute; font-size: 1.2rem; color: var(--red-bright); text-shadow: 0 0 18px var(--red-glow-strong);
    transform: translate(-50%, -50%); animation: markPop 1s var(--ease-out) forwards; pointer-events: none;
}
@keyframes markPop {
    0% { opacity: 0; transform: translate(-50%,-50%) scale(.3) rotate(0deg); }
    15% { opacity: 1; transform: translate(-50%,-60%) scale(1.1) rotate(-8deg); }
    100% { opacity: 0; transform: translate(-50%,-160%) scale(.85) rotate(10deg); }
}

/* ===== toast ===== */
#toast-stack { position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%); z-index: 9500; display: flex; flex-direction: column; align-items: center; gap: .5rem; pointer-events: none; }
.toast {
    font-family: var(--mono); font-size: .55rem; letter-spacing: .1em; color: var(--paper);
    background: rgba(10,9,8,.94); border: 1px solid var(--line-bright); border-left: 2px solid var(--red-bright);
    padding: .65rem 1.05rem; opacity: 0; transform: translateY(10px); transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
    white-space: nowrap; pointer-events: none; backdrop-filter: blur(8px); border-radius: 3px;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ===== self-destruct ("ritual" easter egg) ===== */
.wipe-scan {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    height: 3px;
    z-index: 10020;
    pointer-events: none;
    opacity: 0;
    background: var(--red-bright);
    box-shadow: 0 0 24px var(--red-glow-strong), 0 0 70px var(--red-glow);
}
.wipe-scan.active {
    opacity: 1;
    animation: wipeSweep 5s linear forwards;
}
@keyframes wipeSweep {
    0%   { transform: translateY(-10vh); }
    100% { transform: translateY(110vh); }
}
