/* =====================================================================
   Wasteland mode: hidden easter egg. Toggled by the footer © button.
   Everything is scoped under html.wasteland / html.ws-* so the normal
   site is untouched until the switch is pressed.
   ===================================================================== */

/* the hidden switch: indistinguishable from the © glyph */
.ws-trigger {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    cursor: text;
    line-height: inherit;
}
.ws-trigger:focus { outline: none; }
.ws-trigger:focus-visible { outline: 1px dotted currentColor; outline-offset: 2px; }

/* ---------- phase 1: the system starts failing ---------- */
html.ws-glitching .content,
html.ws-glitching body > footer {
    animation: ws-shake 0.09s steps(2) infinite, ws-hue 0.45s steps(3) infinite;
    text-shadow: -3px 0 rgba(255, 0, 70, 0.75), 3px 0 rgba(0, 255, 220, 0.75);
}
html.ws-glitching img { animation: ws-img-tear 0.18s steps(2) infinite; }

@keyframes ws-shake {
    0%   { transform: translate(0, 0); }
    25%  { transform: translate(-6px, 2px) skewX(-2deg); }
    50%  { transform: translate(5px, -3px); }
    75%  { transform: translate(-3px, 4px) skewX(3deg); }
    100% { transform: translate(4px, 0); }
}
@keyframes ws-hue {
    0%   { filter: none; }
    33%  { filter: invert(1) hue-rotate(180deg) contrast(1.4); }
    66%  { filter: hue-rotate(90deg) saturate(4); }
    100% { filter: none; }
}
@keyframes ws-img-tear {
    0%   { clip-path: inset(0 0 60% 0); transform: translateX(-12px); }
    50%  { clip-path: inset(40% 0 10% 0); transform: translateX(10px); }
    100% { clip-path: inset(0); transform: none; }
}

/* CRT shutdown / power-on overlay (animated from JS) */
.ws-tv { position: fixed; inset: 0; z-index: 3000; pointer-events: none; }
.ws-tv-top, .ws-tv-bot { position: absolute; left: 0; right: 0; height: 0; background: #000; }
.ws-tv-top { top: 0; }
.ws-tv-bot { bottom: 0; }
.ws-tv-line {
    position: absolute; left: 0; right: 0; top: 50%;
    height: 3px; margin-top: -1px;
    background: #fff;
    box-shadow: 0 0 24px 8px rgba(255, 240, 210, 0.9), 0 0 80px 20px rgba(255, 140, 0, 0.5);
    transform: scaleX(0);
}

/* ---------- the wasteland itself ---------- */
html.wasteland {
    --ws-bg: #0a0907;
    --ws-ink: #e2d8bf;
    --ws-dim: #b3a78b;
    --ws-amber: #ffae1a;
    --ws-rust: #a2461b;
    --ws-tox: #a6ff3d;
    background: var(--ws-bg);
    color-scheme: dark;
    scroll-behavior: auto;
}
html.wasteland body {
    background: var(--ws-bg);
    color: var(--ws-ink);
}
html.wasteland ::selection { background: var(--ws-tox); color: #000; }

/* drifting smog behind the content */
html.wasteland body::before {
    content: "";
    position: fixed;
    inset: -20%;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(ellipse 60% 40% at 20% 110%, rgba(255, 90, 0, 0.28), transparent 70%),
        radial-gradient(ellipse 50% 35% at 85% 100%, rgba(190, 40, 0, 0.22), transparent 70%),
        radial-gradient(ellipse 70% 50% at 50% -10%, rgba(120, 140, 40, 0.10), transparent 70%),
        radial-gradient(ellipse 40% 30% at 70% 40%, rgba(80, 70, 50, 0.18), transparent 70%);
    animation: ws-smog 26s ease-in-out infinite alternate;
}
@keyframes ws-smog {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(-4%, 2%) scale(1.08); }
    100% { transform: translate(3%, -2%) scale(1.02); }
}

/* text and links */
html.wasteland a,
html.wasteland a:hover,
html.wasteland .project-link { color: var(--ws-amber); }
html.wasteland a:hover {
    background: rgba(255, 174, 26, 0.14);
    color: var(--ws-tox);
    text-shadow: 0 0 8px rgba(166, 255, 61, 0.6);
}
html.wasteland .menu-item,
html.wasteland .section-nav a,
html.wasteland .arrow,
html.wasteland .additional,
html.wasteland blockquote,
html.wasteland .project-stat-cap { color: var(--ws-dim); }
html.wasteland button.additional:hover { background: rgba(255, 174, 26, 0.14); color: var(--ws-tox); }
html.wasteland a.additional::after { filter: invert(0.7) sepia(1) saturate(3) hue-rotate(-10deg); }

html.wasteland .logo {
    color: #f3e6c4;
    letter-spacing: 0.06em;
    text-shadow: -2px 0 rgba(255, 30, 60, 0.7), 2px 0 rgba(0, 230, 255, 0.55), 0 0 18px rgba(255, 120, 0, 0.45);
    animation: ws-flicker 5.5s infinite;
}
html.wasteland h2 {
    color: var(--ws-amber);
    letter-spacing: 0.08em;
    text-shadow: 0 0 10px rgba(255, 140, 0, 0.45);
}
html.wasteland h2::before { content: "\26A0\FE0E  "; color: var(--ws-rust); }
html.wasteland h3 { color: var(--ws-amber); }

@keyframes ws-flicker {
    0%, 18%, 22%, 62%, 64%, 66%, 100% { opacity: 1; }
    20%, 63%, 65% { opacity: 0.35; }
}

/* hazard-stripe rules */
html.wasteland hr {
    height: 6px;
    border: 0;
    background: repeating-linear-gradient(-45deg, #e0a000 0 10px, #111 10px 20px);
    opacity: 0.75;
    clip-path: polygon(0 0, 38% 0, 40% 100%, 41% 0, 100% 0, 100% 100%, 63% 100%, 61% 0, 60% 100%, 0 100%);
}

/* portrait: irradiated monitor */
html.wasteland .image img {
    border-color: var(--ws-rust) !important;
    filter: contrast(1.08) saturate(1.1);
    animation: ws-portrait 7s infinite;
    box-shadow: 0 0 40px rgba(255, 90, 0, 0.25);
}
@keyframes ws-portrait {
    0%, 91%, 100% { clip-path: inset(0); transform: none; }
    92% { clip-path: inset(10% 0 55% 0); transform: translateX(-10px); }
    93% { clip-path: inset(60% 0 8% 0); transform: translateX(14px); }
    94% { clip-path: inset(0); transform: translateX(-3px) skewX(4deg); opacity: 0.55; }
    95% { clip-path: inset(0); transform: none; }
}

/* project cards: salvaged, bent, taped up */
html.wasteland .project-card {
    position: relative;
    background: linear-gradient(160deg, rgba(30, 26, 20, 0.92), rgba(16, 14, 11, 0.92));
    border: 1px solid rgba(162, 70, 27, 0.55);
    padding-top: calc(1.5rem + 8px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    clip-path: polygon(0 0, 92% 0, 100% 7%, 100% 100%, 6% 100%, 0 94%);
}
html.wasteland .project-card::before {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 0; height: 8px;
    background: repeating-linear-gradient(-45deg, #e0a000 0 8px, #111 8px 16px);
}
html.wasteland .project-card:nth-child(odd)  { transform: rotate(-0.6deg); }
html.wasteland .project-card:nth-child(even) { transform: rotate(0.5deg); }
html.wasteland .project-name,
html.wasteland .project-mark,
html.wasteland .project-stat-num { color: var(--ws-amber); }
html.wasteland .project-stat-num { text-shadow: 0 0 14px rgba(255, 140, 0, 0.5); }
html.wasteland .project-tagline { color: var(--ws-tox); }

/* paper overviews go dark too */
html.wasteland .paper-overview,
html.wasteland .paper-overview:target { background-color: var(--ws-bg) !important; }
html.wasteland .overview-inner { color: var(--ws-ink); }
html.wasteland .paper-overview svg,
html.wasteland .paper-overview img { filter: invert(0.88) hue-rotate(180deg) sepia(0.5); }
html.wasteland .paper-overview [class^="ov-"],
html.wasteland .paper-overview [class*=" ov-"] { border-color: rgba(162, 70, 27, 0.5); }

/* ---------- glitch bursts while in the wasteland ---------- */
html.wasteland.ws-burst .content,
html.wasteland.ws-burst body > footer {
    text-shadow: -4px 0 rgba(255, 0, 70, 0.8), 4px 0 rgba(0, 255, 220, 0.7);
}
html.ws-distort .content,
html.ws-distort body > footer { filter: url(#ws-distort); }

/* ---------- HUD overlays ---------- */
.ws-crt {
    position: fixed; inset: 0; z-index: 1490; pointer-events: none;
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 1px, transparent 1px 3px),
        radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, 0.55) 100%);
    animation: ws-crt-flicker 0.12s steps(2) infinite;
}
@keyframes ws-crt-flicker { 0% { opacity: 0.9; } 100% { opacity: 1; } }

.ws-grain {
    position: fixed; inset: -100px; z-index: 1491; pointer-events: none;
    opacity: 0.09;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    animation: ws-grain 0.5s steps(5) infinite;
}
@keyframes ws-grain {
    0%   { transform: translate(0, 0); }
    20%  { transform: translate(-40px, 30px); }
    40%  { transform: translate(30px, -50px); }
    60%  { transform: translate(-60px, -20px); }
    80%  { transform: translate(50px, 40px); }
    100% { transform: translate(0, 0); }
}

.ws-canvas { position: fixed; inset: 0; z-index: 1480; pointer-events: none; }

.ws-flash {
    position: fixed; inset: 0; z-index: 1495; pointer-events: none;
    background: rgba(255, 245, 225, 0.0);
}

.ws-ticker {
    position: fixed; left: 0; right: 0; top: 0; z-index: 1500;
    overflow: hidden; white-space: nowrap;
    font: 12px/26px "Concourse C4", ui-monospace, monospace;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #111;
    background: repeating-linear-gradient(-45deg, #e0a000 0 14px, #c88e00 14px 28px);
    border-bottom: 2px solid #111;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
}
.ws-ticker-track { display: inline-block; padding-left: 100%; animation: ws-marquee 38s linear infinite; }
.ws-ticker-track b { background: #111; color: #e0a000; padding: 2px 8px; margin: 0 10px; font-weight: normal; }
@keyframes ws-marquee { to { transform: translateX(-100%); } }

.ws-geiger {
    position: fixed; right: 18px; bottom: 18px; z-index: 1500;
    min-width: 190px;
    padding: 10px 14px 12px;
    font: 11px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
    letter-spacing: 0.08em;
    color: var(--ws-tox);
    background: rgba(8, 10, 6, 0.86);
    border: 1px solid rgba(166, 255, 61, 0.35);
    box-shadow: 0 0 22px rgba(166, 255, 61, 0.15), inset 0 0 20px rgba(166, 255, 61, 0.06);
    text-shadow: 0 0 6px rgba(166, 255, 61, 0.7);
}
.ws-geiger-val { font-size: 24px; line-height: 1.1; letter-spacing: 0.02em; }
.ws-geiger-bar { height: 4px; margin: 6px 0 8px; background: rgba(166, 255, 61, 0.15); }
.ws-geiger-bar i { display: block; height: 100%; width: 40%; background: var(--ws-tox); box-shadow: 0 0 8px var(--ws-tox); transition: width 0.12s linear; }
.ws-geiger button {
    font: inherit; letter-spacing: inherit;
    color: var(--ws-amber);
    background: none;
    border: 1px solid rgba(255, 174, 26, 0.5);
    padding: 3px 8px;
    cursor: pointer;
    text-shadow: none;
}
.ws-geiger button:hover { background: var(--ws-amber); color: #000; }
.ws-geiger .ws-blink { animation: ws-flicker 1.4s infinite; color: #ff4d2e; text-shadow: 0 0 6px #ff4d2e; }

@media (max-width: 600px) {
    .ws-geiger { right: 8px; bottom: 8px; min-width: 0; padding: 5px 8px; opacity: 0.92; }
    .ws-geiger > div:first-child, .ws-geiger-bar { display: none; }
    .ws-geiger-val { font-size: 13px; margin-bottom: 4px; }
    .ws-geiger button { font-size: 10px; padding: 2px 6px; }
    .ws-ticker { font-size: 10px; line-height: 22px; }
}

/* the content sits under the ticker without being hidden by it */
html.wasteland .content { padding-top: calc(3em + 26px); }

/* reduced motion: keep the look, drop the movement */
@media (prefers-reduced-motion: reduce) {
    html.wasteland body::before,
    html.wasteland .logo,
    html.wasteland .image img,
    .ws-crt, .ws-grain, .ws-ticker-track { animation: none !important; }
    .ws-ticker-track { padding-left: 1rem; }
}

/* ---------- intensity layer ---------- */
/* burning horizon along the bottom edge */
.ws-crt::before {
    content: "";
    position: absolute; left: -10%; right: -10%; bottom: 0; height: 38vh;
    background:
        radial-gradient(ellipse 30% 60% at 15% 100%, rgba(255, 110, 0, 0.55), transparent 70%),
        radial-gradient(ellipse 25% 55% at 48% 100%, rgba(255, 60, 0, 0.45), transparent 70%),
        radial-gradient(ellipse 35% 65% at 82% 100%, rgba(255, 130, 20, 0.5), transparent 70%);
    mix-blend-mode: screen;
    filter: blur(6px);
    animation: ws-fire 2.6s ease-in-out infinite alternate;
}
.ws-crt::after {   /* scorched, burning edges */
    content: "";
    position: absolute; inset: 0;
    box-shadow: inset 0 0 120px 30px rgba(120, 30, 0, 0.55), inset 0 0 40px 6px rgba(0, 0, 0, 0.9);
    animation: ws-fire 1.7s ease-in-out infinite alternate-reverse;
}
@keyframes ws-fire {
    0%   { opacity: 0.55; transform: scaleY(0.92); }
    35%  { opacity: 0.9;  transform: scaleY(1.05); }
    60%  { opacity: 0.7;  transform: scaleY(0.98); }
    100% { opacity: 1;    transform: scaleY(1.1); }
}

/* cracked glass (drawn on a canvas by wasteland.js) */
.ws-cracks { position: fixed; inset: 0; z-index: 1492; pointer-events: none; transition: opacity 0.4s ease; }

/* body text: faint heat glow; links jitter on hover */
html.wasteland .content { text-shadow: 0 0 1px rgba(255, 170, 80, 0.25); }
html.wasteland .content a:hover { animation: ws-jitter 0.18s steps(2) infinite; }
@keyframes ws-jitter {
    0%   { text-shadow: -2px 0 #ff1e46, 2px 0 #00e6ff; }
    100% { text-shadow: 2px 0 #ff1e46, -2px 0 #00e6ff; }
}
html.wasteland h2 { animation: ws-flicker 7s infinite; }
html.wasteland h2:nth-of-type(2n) { animation-delay: -3s; }

/* list numerals become stencil warning tags */
html.wasteland ol li::before { color: var(--ws-rust); text-shadow: 0 0 8px rgba(255, 80, 0, 0.6); }

@media (prefers-reduced-motion: reduce) {
    .ws-crt::before, .ws-crt::after, html.wasteland h2, html.wasteland .content a:hover { animation: none !important; }
}

/* ---------- readability: paper overviews, data pages, buttons ---------- */
html.wasteland .overview-inner,
html.wasteland .ov-hook,
html.wasteland .ov-q-text,
html.wasteland .ov-card p,
html.wasteland .ov-takeaway p { color: var(--ws-ink); }
html.wasteland .ov-q-text { color: #f1e8d2; }
html.wasteland .ov-authors,
html.wasteland .ov-measure,
html.wasteland .ov-stat-cap,
html.wasteland .ov-cap,
html.wasteland .overview-back,
html.wasteland .ov-footer-home,
html.wasteland .aipi-fig-sub,
html.wasteland .aipi-small-c,
html.wasteland .aipi-empty { color: var(--ws-dim); }
html.wasteland .ov-title,
html.wasteland .ov-h2,
html.wasteland .ov-figure-title,
html.wasteland .ov-card-h,
html.wasteland .ov-stat-num,
html.wasteland .aipi-chapter-t,
html.wasteland .aipi-fig-title,
html.wasteland .aipi-decomp-cap { color: var(--ws-amber); }
html.wasteland .ov-eyebrow,
html.wasteland .ov-q-label,
html.wasteland .aipi-chapter-k { color: #ff7a3d; }
html.wasteland .overview-back:hover,
html.wasteland .ov-footer-home:hover { color: var(--ws-tox); }
html.wasteland .ov-measure a,
html.wasteland .ov-takeaway p a,
html.wasteland .ov-block p a,
html.wasteland .aipi-prose .ov-card p a { color: var(--ws-amber); }
html.wasteland .ov-hero,
html.wasteland .aipi-chapter { border-color: rgba(255, 174, 26, 0.55); }
html.wasteland .ov-card,
html.wasteland .aipi-empty {
    background: rgba(28, 24, 18, 0.92);
    border-color: rgba(162, 70, 27, 0.5);
}
/* solid buttons: amber on black instead of navy */
html.wasteland .ov-ssrn,
html.wasteland .ov-footer-ssrn,
html.wasteland .overview-trigger,
html.wasteland .aipi-chip,
html.wasteland .aipi-play {
    background: #15120d;
    color: var(--ws-amber);
    border: 1px solid rgba(255, 174, 26, 0.6);
}
html.wasteland .ov-ssrn:hover,
html.wasteland .ov-footer-ssrn:hover,
html.wasteland .overview-trigger:hover,
html.wasteland .aipi-chip[aria-pressed="true"] {
    background: var(--ws-amber);
    border-color: var(--ws-amber);
    color: #0a0907;
    text-shadow: none;
}
html.wasteland .aipi-tip { background: #15120d; border: 1px solid var(--ws-amber); color: var(--ws-ink); }

/* a dark halo keeps text legible over embers, ash and cracks */
html.wasteland .content p,
html.wasteland .content li,
html.wasteland .overview-inner p,
html.wasteland .overview-inner li {
    text-shadow: 0 0 2px #000, 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* cracks recede while reading a paper overview */
body.overview-open .ws-cracks { opacity: 0.18; }

/* announcement card (e.g. ARES symposium): salvaged-metal like the project cards */
html.wasteland .event-card {
    background: linear-gradient(160deg, rgba(30, 26, 20, 0.94), rgba(16, 14, 11, 0.94));
    border-color: rgba(162, 70, 27, 0.6);
    border-left-color: #ff5a1f;
    color: var(--ws-ink);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 174, 26, 0.08);
}
html.wasteland .event-desc { color: var(--ws-ink); }
html.wasteland .event-logo { filter: sepia(0.6) saturate(1.3) brightness(0.9); }

/* while reading a paper, pull the overlays back so the text leads */
html.wasteland .ws-crt { transition: opacity 0.4s ease; }
html.wasteland body.overview-open .ws-crt { opacity: 0.45; animation: none; }
