/* ==================================================================
   θ ACCESS TERMINAL — arcade / CRT skin
   Pure skin: no rule here changes DOM structure or script behaviour.
   Functional geometry from the sizing pass is preserved verbatim; each
   such declaration carries a KEEP marker so it is obvious what must
   not be re-tuned.
   ================================================================== */

:root {
    --bg:        #0a0a0f;
    --bg-deep:   #06060a;
    --cyan:      #00e5ff;
    --mag:       #ff2bd6;
    --grn:       #00ff66;
    --amb:       #ffb000;
    --red:       #ff3355;
    --orange:    #ff8a3d;
    --silver:    #c0c8d2;
    --bronze:    #b87333;

    --ink:       #d6dde6;   /* body text            ~13.8:1 on --bg */
    --ink-dim:   #9aa4b2;   /* secondary text       ~7.4:1  on --bg */
    --ink-faint: #6f7a8a;   /* labels / chrome only */

    --key-face:  #14161d;
    --panel:     linear-gradient(180deg, #14161d 0%, #0d0f15 100%);
    --crt:       #02120a;

    --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
            "DejaVu Sans Mono", monospace;
}

/* ============ PAGE ============ */

body {
    font-family: var(--mono);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px 12px 60px;
    background-color: var(--bg);
    color: var(--ink);
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
}

/* radial vignette — sits behind everything */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(ellipse 120% 80% at 50% 0%, rgba(255, 43, 214, 0.10), transparent 60%),
        radial-gradient(ellipse 100% 70% at 50% 100%, rgba(0, 229, 255, 0.08), transparent 65%),
        radial-gradient(ellipse 140% 100% at 50% 50%, transparent 35%, rgba(0, 0, 0, 0.75) 100%);
}

/* CRT scanlines — fixed overlay, never intercepts pointer events */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.05) 0px,
        rgba(255, 255, 255, 0.05) 2px,
        transparent 2px,
        transparent 4px
    );
    animation: scan-drift 9s linear infinite;
}

@keyframes scan-drift { from { background-position: 0 0; } to { background-position: 0 4px; } }

/* ============ MASTHEAD ============ */

.masthead-wrap {
    width: 100%;
    max-width: 750px;
    margin: 0 0 20px;
    text-align: center;
}

.masthead {
    display: block;
    width: 100%;
    max-width: 750px;
    height: auto;
    margin: 0 auto;
    filter: drop-shadow(0 0 18px rgba(255, 43, 214, 0.25));
}

/* ============ RIDDLE / PROSE ============ */

.riddle {
    width: 100%;
    max-width: 750px;
    text-align: left;
    margin-bottom: 18px;
    line-height: 1.5;
    box-sizing: border-box;
    color: var(--ink);
}

.riddle p { color: var(--ink); }
.riddle small { color: var(--ink-dim); }
.riddle strong { color: var(--amb); }

.terminal {
    background: #000305;
    border: 1px solid rgba(0, 255, 102, 0.45);
    border-radius: 6px;
    padding: 14px 16px;
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
    overflow-x: auto;
    margin-bottom: 18px;
    color: var(--grn);
    text-shadow: 0 0 6px rgba(0, 255, 102, 0.45);
    box-shadow: 0 0 18px rgba(0, 255, 102, 0.12), inset 0 0 40px rgba(0, 255, 102, 0.05);
}

.eq {
    font-size: 17px;
    line-height: 1.8;
    color: var(--cyan);
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.35);
}

code {
    background: rgba(0, 229, 255, 0.07);
    border: 1px solid rgba(0, 229, 255, 0.22);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--mono);
    color: var(--cyan);
}

.dim { color: var(--ink-dim); }
.bad { color: var(--red); text-shadow: 0 0 6px rgba(255, 51, 85, 0.5); }

/* ============ CALCULATORS ============ */

.calculator-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;                      /* KEEP */
    justify-content: center;
    width: 100%;
    max-width: 780px;                     /* KEEP */
}

.calculator {
    width: 230px;                         /* KEEP */
    padding: 10px;
    border: 1px solid var(--cyan);
    border-radius: 10px;
    background: var(--panel);
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
    box-shadow:
        0 0 0 1px rgba(0, 229, 255, 0.18),
        0 0 16px rgba(0, 229, 255, 0.22),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.calculator:hover {
    box-shadow:
        0 0 0 1px rgba(0, 229, 255, 0.3),
        0 0 26px rgba(0, 229, 255, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.calculator.verified {
    border-color: var(--grn);
    box-shadow:
        0 0 0 1px rgba(0, 255, 102, 0.3),
        0 0 26px rgba(0, 255, 102, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* mini-marquee */
.calc-header {
    background: #05060a;
    color: var(--mag);
    font-family: var(--mono);
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-align: center;
    padding: 8px 4px;
    border: 1px solid rgba(255, 43, 214, 0.5);
    border-radius: 6px;
    margin-bottom: 10px;
    width: 100%;
    box-sizing: border-box;
    text-shadow: 0 0 6px rgba(255, 43, 214, 0.8), 0 0 14px rgba(255, 43, 214, 0.4);
    box-shadow: inset 0 0 18px rgba(255, 43, 214, 0.1);
    transition: color 0.3s ease, border-color 0.3s ease, text-shadow 0.3s ease;
}

.calculator.verified .calc-header {
    color: var(--grn);
    border-color: rgba(0, 255, 102, 0.55);
    text-shadow: 0 0 6px rgba(0, 255, 102, 0.8), 0 0 14px rgba(0, 255, 102, 0.4);
    box-shadow: inset 0 0 18px rgba(0, 255, 102, 0.1);
}

.display {
    width: 100%;
    height: 40px;                         /* KEEP */
    font-size: 18px;                      /* KEEP */
    margin-bottom: 5px;
    text-align: right;
    padding: 5px 8px;
    background-color: var(--crt);
    border: 1px solid rgba(0, 255, 102, 0.35);
    border-radius: 5px;
    color: var(--grn);
    font-family: var(--mono);
    text-shadow: 0 0 8px rgba(0, 255, 102, 0.6);
    box-sizing: border-box;
    box-shadow: inset 0 0 14px rgba(0, 255, 102, 0.12);
    animation: crt-pulse 2.4s ease-in-out infinite;
}

@keyframes crt-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.75; } }

.history {
    width: 100%;
    height: 58px;                         /* KEEP */
    font-size: 13px;                      /* KEEP */
    line-height: 16px;                    /* KEEP */
    margin-bottom: 10px;
    padding: 5px 8px;
    background-color: #010905;
    border: 1px solid rgba(0, 255, 102, 0.18);
    border-radius: 5px;
    color: rgba(0, 255, 102, 0.75);
    overflow-y: auto;
    box-sizing: border-box;
    resize: none;
    font-family: var(--mono);
    scrollbar-width: thin;
    scrollbar-color: #1c3a2a #010905;
}

.history::-webkit-scrollbar { width: 8px; }
.history::-webkit-scrollbar-track { background: #010905; }
.history::-webkit-scrollbar-thumb { background: #1c3a2a; border-radius: 4px; }

.buttons {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));   /* KEEP */
    gap: 4px;                                           /* KEEP */
    padding: 5px;
    box-sizing: border-box;
    width: 100%;
}

button {
    padding: 7px 2px;                     /* KEEP */
    font-size: 14px;                      /* KEEP */
    min-width: 0;                         /* KEEP */
    white-space: nowrap;                  /* KEEP */
    overflow: hidden;                     /* KEEP */
    cursor: pointer;
    border: 1px solid #2a2f3a;
    border-radius: 5px;
    background-color: var(--key-face);
    color: var(--ink);
    font-family: var(--mono);
    font-weight: bold;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease,
                color 0.2s ease, transform 0.1s ease;
}

button:hover { border-color: #4a5262; }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

/* keypad colour classes */
.k-num, .k-op, .k-fn, .k-ac, .k-eq { background-color: var(--key-face); }

.k-num { border-color: rgba(0, 229, 255, 0.45); color: var(--cyan); }
.k-op  { border-color: rgba(255, 43, 214, 0.45); color: var(--mag); }
.k-fn  { border-color: rgba(255, 176, 0, 0.45); color: var(--amb); }
.k-ac  { border-color: rgba(255, 51, 85, 0.55); color: var(--red); }
.k-eq  { border-color: rgba(0, 255, 102, 0.5); color: var(--grn); }

.k-num:hover:not(:disabled) { border-color: var(--cyan); box-shadow: 0 0 10px rgba(0, 229, 255, 0.35); }
.k-op:hover:not(:disabled)  { border-color: var(--mag);  box-shadow: 0 0 10px rgba(255, 43, 214, 0.35); }
.k-fn:hover:not(:disabled)  { border-color: var(--amb);  box-shadow: 0 0 10px rgba(255, 176, 0, 0.35); }
.k-ac:hover:not(:disabled)  { border-color: var(--red);  box-shadow: 0 0 10px rgba(255, 51, 85, 0.4); }
.k-eq:hover:not(:disabled)  { border-color: var(--grn);  box-shadow: 0 0 10px rgba(0, 255, 102, 0.4); }

.copy-buttons {
    display: flex;
    justify-content: space-between;
    gap: 4px;
    margin-top: 10px;
    width: 100%;
    box-sizing: border-box;
}

.copy-buttons button {
    font-size: 12px;                      /* KEEP */
    flex: 1;
    border-color: rgba(192, 200, 210, 0.3);
    color: var(--silver);
    font-weight: normal;
    /* "Copy to Calc 2" is 101px in the mono stack against 96px of usable
       width, so it would clip under the KEEP'd overflow:hidden. The system
       sans stack measures 83px — same stack the pre-skin build used. */
    font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    letter-spacing: normal;
}
.copy-buttons button:hover:not(:disabled) {
    border-color: var(--silver);
    box-shadow: 0 0 10px rgba(192, 200, 210, 0.25);
}

/* ============ GATE ============ */

.gate {
    width: 100%;
    max-width: 750px;
    margin-top: 28px;
    border: 1px solid rgba(0, 229, 255, 0.5);
    border-radius: 10px;
    background: var(--panel);
    padding: 0 0 18px;
    box-sizing: border-box;
    box-shadow:
        0 0 0 1px rgba(0, 229, 255, 0.14),
        0 0 24px rgba(0, 229, 255, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.gate.unlocked {
    border-color: var(--grn);
    box-shadow:
        0 0 0 1px rgba(0, 255, 102, 0.3),
        0 0 34px rgba(0, 255, 102, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.gate-header {
    background: #05060a;
    color: var(--cyan);
    font-family: var(--mono);
    font-weight: bold;
    letter-spacing: 6px;
    font-size: 13px;
    padding: 10px 16px;
    border-radius: 9px 9px 0 0;
    border-bottom: 1px solid rgba(0, 229, 255, 0.35);
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.8), 0 0 18px rgba(0, 229, 255, 0.35);
    transition: color 0.4s ease, border-color 0.4s ease, text-shadow 0.4s ease;
}

.gate.unlocked .gate-header {
    color: var(--grn);
    border-bottom-color: rgba(0, 255, 102, 0.45);
    text-shadow: 0 0 8px rgba(0, 255, 102, 0.8), 0 0 18px rgba(0, 255, 102, 0.35);
}

.account {
    margin: 16px;
    padding: 14px 16px;
    background: #05070c;
    border: 1px solid rgba(0, 229, 255, 0.18);
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 14px;
    position: relative;
    box-shadow: inset 0 0 26px rgba(0, 229, 255, 0.05);
}

.account-row { display: flex; gap: 14px; margin-bottom: 8px; align-items: baseline; }
.account-label { color: var(--ink-faint); width: 58px; flex-shrink: 0; font-size: 12px; }
.account-value { color: var(--ink); letter-spacing: 1px; word-break: break-all; }

.badge {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 1px;
    font-family: var(--mono);
    border: 1px solid transparent;
}
.badge.locked  { background: rgba(255, 51, 85, 0.12);  border-color: rgba(255, 51, 85, 0.5);  color: var(--red); }
.badge.partial { background: rgba(255, 176, 0, 0.12);  border-color: rgba(255, 176, 0, 0.5);  color: var(--amb); }
.badge.open    { background: rgba(0, 255, 102, 0.12);  border-color: rgba(0, 255, 102, 0.5);  color: var(--grn);
                 text-shadow: 0 0 8px rgba(0, 255, 102, 0.6); }

.gate-note {
    margin: 0 16px 18px;
    font-size: 12px;
    color: var(--ink-dim);
    line-height: 1.5;
}

.gate-label {
    display: block;
    margin: 0 16px 6px;
    font-size: 12px;
    color: var(--ink-dim);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.gate-input-row { display: flex; gap: 8px; margin: 0 16px; }

.gate-input {
    flex: 1;
    min-width: 0;                         /* KEEP */
    padding: 10px 12px;
    font-size: 16px;
    background: var(--crt);
    border: 1px solid rgba(0, 255, 102, 0.35);
    border-radius: 5px;
    color: var(--grn);
    font-family: var(--mono);
    box-sizing: border-box;
    text-shadow: 0 0 6px rgba(0, 255, 102, 0.45);
    box-shadow: inset 0 0 14px rgba(0, 255, 102, 0.1);
}

.gate-input::placeholder { color: rgba(0, 255, 102, 0.4); }

.gate-input:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: inset 0 0 14px rgba(0, 255, 102, 0.1), 0 0 12px rgba(0, 229, 255, 0.4);
}

#theta-submit {
    background: linear-gradient(180deg, #2a0a24 0%, #180614 100%);
    border: 1px solid var(--mag);
    color: var(--mag);
    font-weight: bold;
    padding: 10px 20px;
    letter-spacing: 3px;
    flex-shrink: 0;
    border-radius: 6px;
    text-shadow: 0 0 8px rgba(255, 43, 214, 0.7);
    box-shadow: 0 0 14px rgba(255, 43, 214, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
#theta-submit:hover:not(:disabled) {
    color: #ffd6f6;
    box-shadow: 0 0 24px rgba(255, 43, 214, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.gate-status {
    margin: 12px 16px 0;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--ink-dim);
    min-height: 18px;
    word-break: break-word;
}
/* class -> colour semantics preserved from the previous skin */
.gate-status.warm    { color: var(--amb);    text-shadow: 0 0 8px rgba(255, 176, 0, 0.4); }
.gate-status.close   { color: var(--orange); text-shadow: 0 0 8px rgba(255, 138, 61, 0.4); }
.gate-status.good    { color: var(--grn);    text-shadow: 0 0 8px rgba(0, 255, 102, 0.5); }
.gate-status.bad     { color: var(--red);    text-shadow: 0 0 8px rgba(255, 51, 85, 0.45); }
.gate-status.working { color: var(--cyan);   text-shadow: 0 0 8px rgba(0, 229, 255, 0.45); }

.reveal {
    margin: 0 16px;
    line-height: 1.65;
}
.reveal.open {
    margin-top: 20px;
    padding: 18px 20px;
    background: #010905;
    border: 1px solid var(--grn);
    border-radius: 6px;
    color: var(--ink);
    box-shadow: 0 0 22px rgba(0, 255, 102, 0.2), inset 0 0 50px rgba(0, 255, 102, 0.05);
}
.reveal h2 {
    margin-top: 0;
    color: var(--grn);
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(0, 255, 102, 0.55);
}
.reveal h3 {
    color: var(--amb);
    margin-bottom: 6px;
    font-size: 15px;
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(255, 176, 0, 0.4);
}
.reveal a { color: var(--cyan); }
.reveal code { color: var(--cyan); }
.reveal .muted { color: var(--ink-dim); font-size: 13px; }

/* ============ SOLVER PROOF ============ */

.solver-gen { margin: 16px 0 18px; }
.solver-gen .gate-label { margin: 0 0 6px; }
.solver-gen .gate-input { width: 100%; margin-bottom: 10px; }

#solver-generate {
    background: linear-gradient(180deg, #2a1c00 0%, #180f00 100%);
    border: 1px solid var(--amb);
    color: var(--amb);
    font-weight: bold;
    padding: 9px 18px;
    letter-spacing: 3px;
    border-radius: 6px;
    text-shadow: 0 0 8px rgba(255, 176, 0, 0.7);
    box-shadow: 0 0 14px rgba(255, 176, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
#solver-generate:hover:not(:disabled) {
    color: #ffe0a3;
    box-shadow: 0 0 24px rgba(255, 176, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.solver-row {
    background: #000305;
    border: 1px solid rgba(0, 255, 102, 0.4);
    border-radius: 6px;
    padding: 14px 16px;
    margin: 12px 0 0;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.6;
    color: var(--grn);
    text-shadow: 0 0 6px rgba(0, 255, 102, 0.35);
    white-space: pre-wrap;                /* KEEP */
    word-break: break-all;                /* KEEP */
    box-shadow: inset 0 0 30px rgba(0, 255, 102, 0.06);
}

#solver-note { margin-top: 10px; line-height: 1.5; }

/* ============ FOOTER ============ */

footer {
    max-width: 750px;
    margin-top: 30px;
    font-size: 12px;
    text-align: center;
    line-height: 1.6;
    color: var(--ink-dim);
}
footer a { color: rgba(0, 229, 255, 0.75); text-decoration: none; border-bottom: 1px solid rgba(0, 229, 255, 0.3); }
footer a:hover { color: var(--cyan); border-bottom-color: var(--cyan); }

/* ============ FOCUS / A11Y ============ */

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 560px) {
    .calculator { width: 100%; max-width: 320px; }   /* KEEP */
    .terminal { font-size: 11px; }
}

/* ============ REDUCED MOTION ============ */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    body::after { animation: none; }
    .display { animation: none; opacity: 1; }
    /* stops the masthead's SMIL blink: !important author declarations
       outrank the animation origin the SMIL value lands in */
    .mast-blink { opacity: 1 !important; }
}
