/*
 * Copyright (c) 2026, the web3270 contributors.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the names of the web3270 contributors nor the names of their
 *       contributors may be used to endorse or promote products derived from
 *       this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE WEB3270 CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE WEB3270 CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

/* The CfP kiosk: an IBM 3472 (InfoWindow) style display terminal in a
 * System/370 machine room, with a 9-track tape drive and the operator
 * console's LOAD button. All artwork is original CSS/SVG. Loaded after
 * web3270.css, which supplies the screen colours and the key behaviour. */

:root {
    --putty: #d9d3c1;
    --putty-hi: #ebe6d6;
    --putty-lo: #b3ac98;
    --warm: #8d8672;
    --warm-dk: #4a463b;
    --ink: #26231c;
    --ibm-blue: #1f4e99;
    --ibm-blue-dk: #163a73;
    --lamp-red: #d93b2b;
    --lamp-yel: #e8b923;
    --lamp-grn: #2e9d4a;
    --glow: #7dff9a;
    --keycap: #c8c1ad;
    --keycap-hi: #e2dccb;
    --keycap-lo: #8d8672;
    --legend: #26231c;
    --chrome-bg: var(--putty);
    --chrome-fg: var(--ink);
    --chrome-dim: #5a5648;
    --mono: "IBM 3270", "IBM Plex Mono", "DejaVu Sans Mono", Menlo, Consolas, "Liberation Mono", monospace;
    color-scheme: light;
}

html { background: #8f8a7b; }

/* A raised floor: square perforated-looking tiles, darker towards the edges. */
body {
    background:
        radial-gradient(90% 70% at 50% 35%, rgba(255, 250, 235, 0.35), transparent 70%),
        linear-gradient(rgba(60, 55, 44, 0.45) 0 2px, transparent 2px) 0 0 / 64px 64px,
        linear-gradient(90deg, rgba(60, 55, 44, 0.45) 0 2px, transparent 2px) 0 0 / 64px 64px,
        linear-gradient(180deg, #a49e8c, #8a8473);
    background-color: #8f8a7b;
    color: var(--ink);
    padding: 0 12px 28px;
    line-height: 1.45;
}

a { color: #12408a; }
a:hover { color: #000; }
a:focus-visible { outline: 3px solid var(--ibm-blue); outline-offset: 2px; }

/* ---- The room: tape drive | terminal | console ---- */

.room {
    width: 100%;
    max-width: 1260px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}
.desk {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    order: 1;
}
.tape { order: 3; }
.console { order: 2; }

@media (min-width: 1100px) {
    .room { grid-template-columns: 190px minmax(0, 860px) 190px; justify-content: center; gap: 22px; }
    .tape { order: 0; padding-top: 150px; }
    .console { order: 2; margin-top: 150px; }
}

/* ---- Header ---- */

.masthead {
    margin-top: 18px;
    padding: 12px 18px 10px;
    text-align: center;
    background: linear-gradient(180deg, var(--putty-hi), var(--putty));
    border: 1px solid var(--warm);
    border-top: 6px solid var(--ibm-blue);
    border-radius: 4px;
    box-shadow: 0 6px 14px rgba(40, 35, 25, 0.35);
}
.masthead h1 {
    margin: 0 0 6px;
    font-size: clamp(1.4rem, 5vw, 2.1rem);
    letter-spacing: 0.02em;
    color: var(--ibm-blue-dk);
}
.lede { margin: 0 auto 6px; max-width: 48em; font-size: 1rem; color: var(--ink); }
.alt { margin: 0; font-size: 0.95rem; color: var(--warm-dk); }

/* ---- The 3472: boxy putty housing, flat bezel, recessed screen ---- */

.monitor {
    position: relative;
    background: linear-gradient(180deg, var(--putty-hi), var(--putty) 10%, var(--putty-lo));
    border: 1px solid var(--warm);
    border-radius: 6px 6px 4px 4px;
    padding: 0 22px 14px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.7) inset,
        0 18px 30px rgba(40, 35, 25, 0.45);
}
.vents {
    height: 22px;
    margin: 0 -22px 14px;
    border-bottom: 1px solid var(--warm);
    background:
        repeating-linear-gradient(90deg, transparent 0 8px, rgba(60, 55, 44, 0.5) 8px 10px) 50% 50% / 60% 8px no-repeat,
        linear-gradient(180deg, var(--putty-hi), var(--putty));
}
.foot {
    position: absolute; left: 12%; right: 12%; bottom: -12px; height: 12px;
    background: linear-gradient(180deg, var(--warm), var(--warm-dk));
    border-radius: 0 0 8px 8px;
    z-index: -1;
}

.bezel {
    background: linear-gradient(180deg, #bdb6a2, #cdc7b4);
    border: 1px solid var(--warm);
    border-radius: 3px;
    padding: 16px 16px 6px;
    box-shadow: 0 2px 6px rgba(60, 55, 44, 0.5) inset, 0 1px 0 rgba(255, 255, 255, 0.6);
}

#term-wrap {
    max-width: none;
    border-radius: 10px / 8px;
    background: #000;
    overflow: hidden;
    box-shadow:
        0 0 0 3px #17150f,
        0 0 0 5px #8d8672,
        0 3px 10px 5px rgba(0, 0, 0, 0.6) inset;
}

/* Scanlines, a faint flicker and a glare on the glass. */
#term-wrap::before,
#term-wrap::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 2;
    border-radius: inherit;
}
#term-wrap::before {
    background: repeating-linear-gradient(180deg, rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, 0.18) 2px 3px);
    animation: flicker 6s steps(1, end) infinite;
}
#term-wrap::after {
    background:
        radial-gradient(130% 90% at 20% 0%, rgba(255, 255, 255, 0.06), transparent 45%),
        radial-gradient(120% 120% at 50% 50%, transparent 65%, rgba(0, 0, 0, 0.45) 100%);
}
@keyframes flicker {
    0%, 92%, 96%, 100% { opacity: 1; }
    94% { opacity: 0.85; }
    98% { opacity: 0.92; }
}

#term {
    padding: 14px 18px 6px;
    border-radius: 0;
    text-shadow: 0 0 3px currentColor;
    background: #000;
    line-height: 1.2;
}
#term.focused .cursor { text-shadow: none; }

#oia {
    padding: 3px 18px 10px;
    border-radius: 0;
    text-shadow: 0 0 3px currentColor;
    line-height: 1.2;
}
#oia-msg { color: #ff6b5e; }

#overlay {
    z-index: 3;
    border-radius: inherit;
    background: rgba(0, 12, 4, 0.82);
    color: var(--glow);
    font-family: var(--mono);
    text-shadow: 0 0 3px currentColor;
}
#overlay p { color: var(--c-green); font-size: clamp(0.95rem, 2.6vw, 1.25rem); max-width: 32em; }
body[data-state="queued"] #overlay-reconnect,
body[data-state="signon"] #overlay-reconnect { display: none; }

/* The control strip under the glass: power lamp, brightness, model plate. */
.chin {
    max-width: none;
    padding: 10px 4px 8px;
    gap: 12px;
}
#conn {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
#conn.state-up, #conn.state-down { color: var(--ink); }
#conn::before {
    content: "";
    flex: none;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--lamp-yel);
    box-shadow: 0 0 6px var(--lamp-yel), 0 0 0 2px #6b665a;
}
#conn.state-up::before {
    background: var(--lamp-grn);
    box-shadow: 0 0 7px #4fd36e, 0 0 0 2px #6b665a;
}
.knob {
    flex: none; width: 22px; height: 22px; border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #5a564a, #26231c);
    box-shadow: 0 0 0 3px var(--putty-lo), 0 0 0 4px var(--warm);
    position: relative;
}
.knob::after { content: ""; position: absolute; left: 10px; top: 2px; width: 2px; height: 8px; background: #ebe6d6; }
.modelplate {
    flex: none;
    margin-left: auto;
    padding: 1px 10px;
    font-family: var(--mono);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #fff;
    background: var(--ibm-blue);
    border: 1px solid var(--ibm-blue-dk);
}
#title {
    flex: none;
    max-width: 30%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--warm-dk);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
#reconnect { min-height: 30px; padding: 2px 10px; font-size: 0.85rem; }

#state-note {
    margin: 0;
    padding: 0 8px 8px;
    min-height: 1.2em;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6b3a00;
}
#state-note:empty { display: none; }

/* ---- The keyboard: a separate, low-profile unit below the terminal ---- */

#keys {
    max-width: none;
    margin: 10px 18px 0;
    padding: 10px 12px;
    gap: 10px;
    background: linear-gradient(180deg, var(--putty-hi), var(--putty-lo));
    border: 1px solid var(--warm);
    border-radius: 3px 3px 10px 10px;
    position: relative;
    transform: perspective(500px) rotateX(8deg);
    transform-origin: top;
    box-shadow: 0 8px 12px rgba(40, 35, 25, 0.4);
}
.pfgrid { gap: 8px; }
/* Hinted key rows of the separate keyboard unit (decoration). */
#keys::before {
    content: ""; position: absolute; left: 12px; right: 170px; top: 10px; bottom: 10px;
    pointer-events: none; opacity: 0.8;
    background:
        repeating-linear-gradient(90deg, var(--keycap) 0 22px, transparent 22px 26px) 0 0 / 100% 14px repeat-y;
    -webkit-mask: repeating-linear-gradient(180deg, #000 0 14px, transparent 14px 20px);
    mask: repeating-linear-gradient(180deg, #000 0 14px, transparent 14px 20px);
    filter: drop-shadow(0 1px 0 var(--keycap-lo));
}
@media (max-width: 700px) { #keys::before { display: none; } }
.actions { justify-content: flex-end; gap: 8px; }
.actions button { flex: 0 1 140px; }

#keys button, button {
    font-family: var(--mono);
}
#keys button {
    min-height: 44px;
    color: var(--legend);
    font-size: 0.85rem;
    font-weight: 700;
    background: linear-gradient(180deg, var(--keycap-hi), var(--keycap));
    border: 1px solid var(--warm);
    border-bottom-width: 4px;
    border-bottom-color: var(--keycap-lo);
    border-radius: 5px 5px 3px 3px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.6) inset;
    transition: none;
}
#keys button:hover { filter: brightness(1.06); }
#keys button:active { transform: translateY(2px); border-bottom-width: 2px; }
#keys button:focus-visible { outline: 3px solid var(--ibm-blue); outline-offset: 2px; }
#keys button.enter { background: linear-gradient(180deg, #4d7bc4, var(--ibm-blue)); color: #fff; border-bottom-color: var(--ibm-blue-dk); }
#keys button.clear { background: linear-gradient(180deg, #e0b9b2, #c9958c); }

#kbd-label { color: var(--ink); }
#kbd { background: #14171c; color: var(--glow); border-color: var(--warm); }

/* ---- Tape drive and card/tape reader (decoration) ---- */

.tape { display: flex; flex-direction: row; justify-content: center; align-items: flex-end; gap: 14px; }
.tape svg { display: block; width: 150px; max-width: 100%; height: auto; filter: drop-shadow(0 10px 8px rgba(40, 35, 25, 0.45)); }
.tape .reader { width: 130px; }
@media (min-width: 1100px) {
    .tape { flex-direction: column; align-items: center; }
    .tape svg { width: 100%; }
    .tape .reader { width: 85%; margin-top: 18px; }
}
@media (max-width: 700px) {
    .tape .reader { display: none; }
    .tape svg { width: 96px; }
}
.reel { transform-box: fill-box; transform-origin: center; animation: spin 1.1s linear infinite; animation-play-state: paused; }
.reel.r2 { animation-duration: 1.7s; animation-direction: reverse; }
body.ipl .reel { animation-play-state: running; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Operator console: LOAD UNIT dials and the LOAD pushbutton ---- */

.console {
    padding: 10px 12px 14px;
    background: linear-gradient(180deg, var(--putty-hi), var(--putty-lo));
    border: 1px solid var(--warm);
    border-top: 22px solid var(--ibm-blue);
    border-radius: 3px;
    box-shadow: 0 10px 16px rgba(40, 35, 25, 0.4);
    position: relative;
    max-width: 320px;
    width: 100%;
    justify-self: center;
}
.plate-title {
    position: absolute; top: -20px; left: 0; right: 0; text-align: center;
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; color: #fff;
}
.lamps { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.lamp { display: flex; flex-direction: column; align-items: center; gap: 4px;
    font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; color: var(--ink); }
.lamp i { width: 16px; height: 16px; border-radius: 50%; background: #6b665a; box-shadow: 0 0 0 2px var(--warm-dk) inset; }
body[data-state="ready"] .l-system i, body[data-state="signing-on"] .l-system i, body[data-state="signon"] .l-system i { background: var(--lamp-grn); box-shadow: 0 0 8px #4fd36e; }
body[data-state="ready"]:not(.ipl) .l-wait i { background: var(--lamp-yel); box-shadow: 0 0 8px var(--lamp-yel); }
body[data-state="ended"] .l-manual i, body[data-state="closed"] .l-manual i { background: var(--lamp-red); box-shadow: 0 0 8px var(--lamp-red); }
.unit { text-align: center; margin-bottom: 12px; }
.unit-label { display: block; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.12em; margin-bottom: 6px; }
.dials { display: flex; justify-content: center; gap: 10px; }
.dial {
    width: 38px; height: 38px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--mono); font-size: 1.1rem; font-weight: 700; color: #fff;
    background:
        radial-gradient(circle, #2a2822 0 55%, transparent 56%),
        repeating-conic-gradient(#f2eee0 0 6deg, #26231c 6deg 36deg);
    box-shadow: 0 0 0 3px var(--warm), 0 2px 4px rgba(0, 0, 0, 0.5);
}
.load {
    display: block; width: 100%; min-height: 48px;
    font-size: 1.05rem; font-weight: 700; letter-spacing: 0.18em; color: #fff;
    background: linear-gradient(180deg, #3d6bb3, var(--ibm-blue));
    border: 1px solid var(--ibm-blue-dk); border-bottom-width: 5px; border-radius: 3px;
    cursor: pointer;
}
.load:hover:not(:disabled) { filter: brightness(1.12); }
.load:active:not(:disabled) { transform: translateY(3px); border-bottom-width: 2px; }
.load:focus-visible { outline: 3px solid var(--lamp-yel); outline-offset: 2px; }
.load:disabled { opacity: 1; background: #6f7c93; border-color: #4f5a6d; cursor: not-allowed; }
body.ipl .load { background: linear-gradient(180deg, #e0a33c, var(--lamp-yel)); color: #26231c; }

kbd {
    font-family: var(--mono);
    font-size: 0.9em;
    padding: 1px 6px;
    color: var(--legend);
    background: var(--keycap);
    border: 1px solid var(--warm);
    border-bottom-width: 3px;
    border-radius: 4px;
}

/* ---- Small screens ---- */

@media (max-width: 700px) {
    body { padding: 0 6px 20px; }
    .masthead { margin-top: 8px; padding: 8px 10px; }
    .lede { font-size: 0.92rem; }
    .monitor { padding: 0 8px 10px; }
    .vents { margin: 0 -8px 8px; height: 14px; }
    .bezel { padding: 8px 8px 2px; }
    #term-wrap { border-radius: 6px; }
    #term { padding: 8px 6px 4px; }
    #oia { padding: 2px 6px 6px; }
    .chin { padding: 8px 2px 4px; flex-wrap: wrap; gap: 8px; }
    #title { display: none; }
    #keys { margin: 8px 4px 0; padding: 8px 6px; transform: none; }
    .pfgrid { grid-template-columns: repeat(6, 1fr); gap: 6px; }
    .actions button { flex: 1 1 0; }
    .room { gap: 12px; }
    .console { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
    #term-wrap::before { animation: none; }
    .g-blink { animation: none; }
    .reel { animation: none; }
}

@media (forced-colors: active) {
    #term-wrap::before, #term-wrap::after { display: none; }
    #conn::before { background: Highlight; box-shadow: none; }
}

/* Warm-up / goodbye screen over the glass. */
#boot {
    position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column;
    align-items: flex-start; justify-content: center; gap: 1rem; padding: 6%;
    background: #000; color: var(--c-green);
    font-family: var(--mono);
    text-shadow: 0 0 3px currentColor;
}
#boot[hidden] { display: none; }
#boot.vm { justify-content: flex-start; align-items: stretch; gap: 0; padding: 14px 18px 6px; cursor: pointer; }
#boot.vm pre { white-space: pre; line-height: 1.2; font-size: 14px; }
#boot.vm pre::after { content: none; }
#boot pre { margin: 0; font: inherit; font-size: clamp(0.7rem, 2.2vw, 1rem); white-space: pre-wrap; }
#boot pre::after { content: "\2588"; animation: blink 1s steps(2) infinite; }
#boot button { font: inherit; }
@keyframes blink { 50% { opacity: 0; } }
.slowtag {
    position: absolute; right: 10px; bottom: 8px; padding: 2px 8px; z-index: 5;
    font-size: clamp(9px, 2.4vw, 14px); color: var(--c-yellow); background: #000;
    border: 1px solid var(--c-yellow); letter-spacing: 0.05em;
}
.slowtag[hidden] { display: none; }
#pf, .actions .clear { display: none; }
@media (prefers-reduced-motion: reduce) { #boot pre::after { animation: none; } }
