/* TBD teaser: Axiom Corp. cathode terminal on aged parchment glass.
   Visual reference: mockup card "ad2" (A x D aged). */

:root {
    --bezel: #2b2015;
    --bezel-edge: #120d08;
    --glass-hi: #b89a5a;
    --glass-mid: #9c7f45;
    --glass-lo: #4a3618;
    --ink: #1e1408;
    --rubric: #9c2f1c;
    --parch: #d8c08a;
    --rule: rgba(42, 28, 14, .5);
}

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

html, body { margin: 0; }

body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 18px;
    padding: 32px 16px;
    background: #0c0906;
    font-family: "Jacquarda Bastarda 9", serif;
    overflow-x: hidden;
}

/* Studio credit sits outside the tube, in the Sunset High pixel font, deliberately
   breaking the fiction so the Axiom piety reads as a joke we're in on. */
@font-face {
    font-family: pixellari;
    src: url(../Pixellari.ttf);
}

.studio {
    font-family: pixellari, sans-serif;
    font-size: 14px;
    color: #a8997a;
    text-align: center;
}

.studio a { color: inherit; }

/* ---------- CRT tube ---------- */

.crt {
    position: relative;
    width: min(92vw, 1100px, calc((100vh - 110px) * 4 / 3));
    aspect-ratio: 4 / 3;
    border-radius: 22px / 18px;
    overflow: hidden;
    background: radial-gradient(ellipse at center, var(--glass-hi) 0%, var(--glass-mid) 50%, var(--glass-lo) 100%);
    box-shadow:
        0 0 0 10px var(--bezel),
        0 0 0 12px var(--bezel-edge),
        inset 0 0 60px rgba(30, 18, 4, .8),
        0 0 40px rgba(200, 160, 80, .15);
    color: var(--ink);
    text-shadow: 0 0 1px rgba(42, 28, 14, .6);
    animation: flicker 4s infinite steps(60);
}

.crt::before { /* scanlines */
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    background: repeating-linear-gradient(to bottom, rgba(60, 40, 10, .16) 0 1px, transparent 1px 3px);
}

.crt::after { /* stains + vignette */
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 4;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(110, 70, 20, .35), transparent 40%),
        radial-gradient(ellipse at 85% 15%, rgba(110, 70, 20, .25), transparent 35%),
        radial-gradient(ellipse at center, transparent 50%, rgba(50, 30, 8, .7) 100%);
    mix-blend-mode: multiply;
}

.noise {
    position: absolute;
    inset: 0;
    z-index: 2;
    opacity: .3;
    pointer-events: none;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: .96; }
    51% { opacity: 1; }
    80% { opacity: .98; }
}

/* Warm-up: a bright line widens across the dark tube, then opens to full glass. */
.warmup {
    display: none;
    position: absolute;
    z-index: 5;
    pointer-events: none;
    background: #f6e7b8;
    box-shadow: 0 0 24px 8px rgba(255, 240, 200, .8), 0 0 0 200vmax #0d0905;
}

.crt.warming .warmup {
    display: block;
    animation: warm-up .5s ease-out forwards;
}

@keyframes warm-up {
    0%   { top: calc(50% - 1px); bottom: calc(50% - 1px); left: 50%; right: 50%; opacity: 1; }
    35%  { top: calc(50% - 1px); bottom: calc(50% - 1px); left: 0; right: 0; opacity: 1; }
    75%  { top: 0; bottom: 0; left: 0; right: 0; opacity: .9; }
    100% { top: 0; bottom: 0; left: 0; right: 0; opacity: 0; }
}

/* Sits under the grain, scanlines and vignette, so the Angel reads as part of
   the picture on the glass rather than a sticker on top of it. */
#angel-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

/* ---------- Screen content ---------- */

.screen {
    position: absolute;
    inset: 0;
    z-index: 1;
    padding: clamp(18px, 3.2%, 40px) clamp(22px, 4%, 52px);
    overflow-y: auto;
    overflow-x: hidden; /* a centred .redacted-note must never scroll the tube sideways */
    font-size: clamp(18px, 2.1vw, 27px);
    line-height: 1.25;
}

.boot {
    white-space: pre-wrap;
}

.boot:empty { display: none; }

.hdr {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-size: .7em;
    letter-spacing: .08em;
    opacity: .85;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 6px;
    margin-bottom: .6em;
}

.title {
    margin: 0;
    font-family: "Jacquard 24", serif;
    font-weight: normal;
    font-size: clamp(40px, 6.4vw, 76px);
    line-height: 1;
}

/* Working title, kept illegible by glitch.js: offset ink and rubric slices jitter over the scrambled text. */
.glitch {
    position: relative;
    display: inline-block;
    white-space: pre;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.glitch::before {
    animation: glitch-top 0.9s steps(2) infinite;
    clip-path: inset(0 0 55% 0);
    text-shadow: -3px 0 var(--ink);
}

.glitch::after {
    color: var(--rubric);
    animation: glitch-bottom 0.7s steps(2) infinite;
    clip-path: inset(55% 0 0 0);
    text-shadow: 3px 0 var(--ink);
}

@keyframes glitch-top {
    0%   { transform: translate(-4px, -2px); clip-path: inset(0 0 60% 0); }
    25%  { transform: translate(5px, 1px);   clip-path: inset(10% 0 45% 0); }
    50%  { transform: translate(-2px, 0);    clip-path: inset(0 0 75% 0); }
    75%  { transform: translate(3px, -1px);  clip-path: inset(30% 0 40% 0); }
    100% { transform: translate(-4px, -2px); clip-path: inset(0 0 60% 0); }
}

@keyframes glitch-bottom {
    0%   { transform: translate(4px, 2px);   clip-path: inset(60% 0 0 0); }
    25%  { transform: translate(-5px, 0);    clip-path: inset(45% 0 15% 0); }
    50%  { transform: translate(2px, 1px);   clip-path: inset(70% 0 0 0); }
    75%  { transform: translate(-3px, 2px);  clip-path: inset(50% 0 20% 0); }
    100% { transform: translate(4px, 2px);   clip-path: inset(60% 0 0 0); }
}

.tagline { margin: .3em 0 .6em; }

/* Keyboard hint along the foot of the screen. */
.keys {
    margin: 1.2em 0 0;
    font-size: .75em;
    letter-spacing: .06em;
    opacity: .7;
}

p { margin: 0 0 .6em; }

/* Menu: Fallout-style "> Item" lines; selected or hovered item is inverted. */
.menu {
    list-style: none;
    margin: .4em 0 .9em;
    padding: 0;
}

.menu li {
    padding: 1px 6px;
    cursor: pointer;
}

.menu li::before { content: "> "; }

.menu li a {
    color: inherit;
    text-decoration: none;
}

.menu li.selected,
.menu li:hover,
.menu li:focus-visible,
.menu li:focus-within {
    background: var(--ink);
    color: var(--parch);
    text-shadow: none;
    outline: none;
}

/* Rubric drop capital */
.drop {
    float: left;
    font-family: "Jacquard 24", serif;
    font-size: 2.75em;
    line-height: .8;
    margin: 4px 8px 0 0;
    color: var(--rubric);
    text-shadow: none;
}

.pitch::after { content: ""; display: block; clear: both; }

/* Email form */
.fealty-form label {
    display: block;
    font-size: .8em;
    letter-spacing: .06em;
    opacity: .85;
}

.field {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 4px;
}

.field input {
    flex: 1;
    min-width: 0;
    font: inherit;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--ink);
    padding: 2px 4px;
    border-radius: 0;
}

.field input:focus {
    outline: none;
    background: rgba(30, 20, 8, .08);
}

.field button {
    font: inherit;
    color: var(--parch);
    background: var(--ink);
    border: 0;
    padding: 2px 12px;
    cursor: pointer;
    border-radius: 0;
}

.field button::before { content: "> "; }

.field button:hover,
.field button:focus-visible {
    color: var(--ink);
    background: transparent;
    outline: 1px solid var(--ink);
}

.field button:disabled {
    opacity: .5;
    cursor: wait;
}

.toast {
    min-height: 2.5em;
    margin-top: .8em;
}

/* Redaction bar with Law S48 note */
.redacted {
    position: relative;
    display: inline-block;
    padding: 0 .25em;
    background: var(--ink);
    color: transparent;
    text-shadow: none;
    cursor: help;
    user-select: none;
}

.redacted-note {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    width: min(30ch, 70vw);
    padding: 8px 10px;
    background: var(--parch);
    color: var(--ink);
    border: 1px solid var(--ink);
    box-shadow: 3px 3px 0 rgba(30, 20, 8, .5);
    font-size: .75em;
    line-height: 1.3;
    text-shadow: none;
    user-select: text;
    z-index: 7;
}

.redacted:hover .redacted-note,
.redacted:focus-within .redacted-note,
.redacted.open .redacted-note {
    display: block;
}

.redacted:focus { outline: 1px dashed var(--ink); outline-offset: 2px; }

/* Ink-in: each letter blots in from blur to sharp. */
.ink-char {
    opacity: 0;
    filter: blur(2px);
    animation: ink .35s forwards;
}

@keyframes ink {
    to { opacity: 1; filter: blur(0); }
}

/* ---------- Phones: single column, auto height ---------- */

@media (max-width: 640px) {
    /* Anchor the Law S48 popup to the toast, not the CENSORED bar, so it never clips. */
    .toast { position: relative; }
    .redacted { position: static; }
    .redacted-note {
        bottom: auto;
        top: 100%;
        left: 0;
        right: 0;
        width: auto;
        margin-top: 6px;
        transform: none;
    }

    body {
        align-items: flex-start;
        padding: 24px 16px;
    }

    .crt {
        width: 100%;
        aspect-ratio: auto;
        min-height: calc(100svh - 48px);
    }

    .screen {
        position: relative;
        inset: auto;
        overflow: visible;
        padding: 18px 16px 24px;
    }

    .field { flex-wrap: wrap; }
    .field input { flex-basis: 70%; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .crt { animation: none; }
    .crt.warming .warmup { display: none; animation: none; }
    .ink-char { animation: none; opacity: 1; filter: none; }
    .glitch::before, .glitch::after { animation: none; }
}

/* ---------- The Angel (an ophan): the only colour on the glass ---------- */

.ophan {
    position: absolute;
    width: 0;
    height: 0;
}

/* Groups carry the iridescence and glow, so the filter runs once per group,
   not once per cursor. */
.ophan-group {
    position: absolute;
    left: 0;
    top: 0;
    animation: ophan-iris 3.2s linear infinite;
}

.ophan-wings { animation-delay: -1.6s; }

/* Classic arrow cursor, cut from a rainbow; --h staggers the hues. */
.ophan-cursor {
    position: absolute;
    left: 0;
    top: 0;
    will-change: transform, opacity;
    width: calc(var(--cursor) * .64);
    height: var(--cursor);
    transform-origin: 0 0;
    clip-path: polygon(0 0, 0 88.9%, 34.8% 67.8%, 59.1% 100%, 80% 94.4%, 56.5% 62.2%, 100% 62.2%);
    background: linear-gradient(165deg,
        hsl(calc(var(--h) * 1deg) 100% 74%),
        hsl(calc(var(--h) * 1deg + 70deg) 100% 66%));
}

/* Iridescence: the hues wheel round; a white rim and coloured glow pulse with them. */
@keyframes ophan-iris {
    0%   { filter: hue-rotate(0deg) drop-shadow(0 0 1px #fff) drop-shadow(0 0 5px rgba(255, 170, 240, .75)); }
    50%  { filter: hue-rotate(180deg) drop-shadow(0 0 1px #fff) drop-shadow(0 0 7px rgba(150, 225, 255, .8)); }
    100% { filter: hue-rotate(360deg) drop-shadow(0 0 1px #fff) drop-shadow(0 0 5px rgba(255, 170, 240, .75)); }
}

@media (prefers-reduced-motion: reduce) {
    #angel-layer { display: none; }
}
