/* The screen's own copy of DejaVu Sans Mono, the same 6 KB subset dos-defrag
   and bios-flash bundle (printable ASCII, U+00A0, the em dash, U+2500-259F).
   Copied rather than linked, because a prank screen owns its assets. Every
   glyph on this screen has to come from inside that subset: the progress bar
   is U+2588/U+2591, not U+25A0. */
@font-face {
    font-family: "HK DejaVu Sans Mono";
    src: url("dejavu-sans-mono.1794772050.woff2") format("woff2");
    font-weight: normal;
    font-style: normal;
    font-display: block;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000000;
    cursor: default;
}


/* ---- The suite ---------------------------------------------------------- */

#hk-screen {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1;

    display: flex;
    flex-direction: column;
    gap: 1em;
    padding: 1.1em 1.6em;

    font-family: "HK DejaVu Sans Mono", "DejaVu Sans Mono", "Liberation Mono", Consolas, "Courier New", monospace;
    font-size: clamp(10px, min(1.1vw, 1.9vh), 20px);
    line-height: 1.35;
    color: #33FF66;
    text-shadow: 0 0 0.35em rgba(51, 255, 102, 0.55);

    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;

    transition: opacity 0.4s ease;
}

#hk-top,
#hk-foot {
    flex: none;
    display: flex;
    justify-content: space-between;
    gap: 2em;
    white-space: pre;
    overflow: hidden;
}

#hk-top {
    padding-bottom: 0.45em;
    border-bottom: 1px solid #1A7F36;
}

#hk-foot {
    padding-top: 0.45em;
    border-top: 1px solid #1A7F36;
    color: #1FA347;
}

#hk-foot [data-reveal] {
    cursor: pointer;
    color: #33FF66;
}

#hk-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    gap: 1.6em;
}

.hk-pane {
    position: relative;
    min-height: 0;
    min-width: 0;
    border: 1px solid #1A7F36;
    padding: 1.1em 1em 0.6em;
    box-shadow: inset 0 0 1.5em rgba(51, 255, 102, 0.06);
}

.hk-pane-title {
    position: absolute;
    left: 0.8em;
    top: -0.72em;
    padding: 0 0.5em;
    background: #000000;
    color: #9FFFBF;
    white-space: pre;
}

#hk-term {
    flex: 62 1 0;
    display: flex;
    flex-direction: column;
}

#hk-side {
    flex: 38 1 0;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 1.6em;
}

#hk-target {
    flex: none;
}

#hk-target .hk-row {
    white-space: pre;
    overflow: hidden;
}

#hk-hex {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

/* Newest line at the bottom, oldest pushed out of the top. The script trims
   what has gone, so nothing ever scrolls and the page never grows. */
.hk-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

#hk-term-body > div {
    flex: none;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

#hk-hex-body > div {
    flex: none;
    white-space: pre;
}

.hk-dim {
    color: #1FA347;
    text-shadow: none;
}

.hk-hi {
    color: #CCFFDD;
}

.hk-ok {
    color: #7CFF9E;
}

.hk-warn {
    color: #FFC233;
    text-shadow: 0 0 0.35em rgba(255, 194, 51, 0.5);
}

.hk-prompt {
    color: #CCFFDD;
}

.hk-current {
    color: #CCFFDD;
}

.hk-blink {
    animation: hk-blink 1s steps(1) infinite;
}

@keyframes hk-blink {
    50% { opacity: 0; }
}


/* ---- Upright: target on top, terminal under it, no hex pane ------------ */

@media (orientation: portrait) {
    #hk-screen {
        font-size: clamp(10px, 3vw, 20px);
        padding: 0.9em 0.9em;
        gap: 0.9em;
    }

    #hk-top,
    #hk-foot {
        gap: 1em;
    }

    .hk-wide {
        display: none;
    }

    #hk-main {
        flex-direction: column;
        gap: 1.4em;
    }

    #hk-side {
        order: -1;
        flex: none;
    }

    #hk-hex {
        display: none;
    }

    #hk-term {
        flex: 1 1 auto;
    }
}


/* ---- The reveal --------------------------------------------------------- */

#hk-reveal {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 3;

    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.9);

    font-family: "HK DejaVu Sans Mono", "DejaVu Sans Mono", "Liberation Mono", Consolas, "Courier New", monospace;
    color: #33FF66;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

body.hk-revealed #hk-reveal {
    display: flex;
}

body.hk-revealed #hk-screen {
    opacity: 0.2;
}

#hk-granted {
    font-size: clamp(24px, min(7vw, 12vh), 110px);
    line-height: 1.2;
    letter-spacing: 0.12em;
    white-space: pre;
    color: #CCFFDD;
    padding: 0.3em 0.5em 0.3em 0.62em;
    border: 0.07em solid #33FF66;
    background: rgba(0, 20, 6, 0.85);
    text-shadow: 0 0 0.12em #33FF66, 0 0 0.4em rgba(51, 255, 102, 0.8);
    box-shadow: 0 0 0.3em rgba(51, 255, 102, 0.45), inset 0 0 0.3em rgba(51, 255, 102, 0.3);
    animation: hk-glow 2.4s ease-in-out infinite;
}

@keyframes hk-glow {
    50% {
        box-shadow: 0 0 0.5em rgba(51, 255, 102, 0.7), inset 0 0 0.4em rgba(51, 255, 102, 0.45);
    }
}

#hk-outro {
    margin-top: 1.6em;
    width: 100%;
    max-width: 44em;
    min-height: 7.2em;
    font-size: clamp(13px, min(1.7vw, 2.8vh), 28px);
    line-height: 1.45;
    white-space: pre-wrap;
    text-shadow: 0 0 0.35em rgba(51, 255, 102, 0.55);
}

@media (orientation: portrait) {
    #hk-outro {
        font-size: clamp(13px, 3.6vw, 28px);
    }
}

#hk-cursor {
    animation: hk-blink 1s steps(1) infinite;
}

/* One flash on the way into the reveal, and only one. */
body.hk-flash::before {
    content: "";
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    background: #CCFFDD;
    opacity: 0.55;
    pointer-events: none;
}


/* ---- CRT dressing: scanlines and a vignette, over everything ----------- */

body::after {
    content: "";
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    pointer-events: none;
    background:
        repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.28) 3px),
        radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.55) 100%);
}


/* ---- Hint --------------------------------------------------------------- */

#hk-hint {
    position: fixed;
    left: 50%;
    top: 34px;
    transform: translateX(-50%);
    z-index: 6;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: clamp(15px, 4vw, 20px);
    line-height: 1.5;
    text-align: center;
    color: #FFFFFF;
    background: rgba(0, 0, 0, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 14px;
    padding: 18px 28px 22px;
    box-sizing: border-box;
    width: max-content;
    max-width: min(92vw, 30em);
    overflow: hidden;

    transition: opacity 0.6s ease;
}

#hk-hint kbd {
    font-family: inherit;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 4px;
    padding: 1px 6px;
    white-space: nowrap;
}

/* Countdown to the hint going away: drains over HINT_TIMEOUT_MS, which the
   JS hands over as --hint-ms. */
#hk-hint::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    box-sizing: content-box;
    height: 5px;
    background: #FFFFFF;
    border-top: 1px solid #000000;
    border-bottom: 1px solid #000000;
    transform-origin: left center;
    animation: hk-hint-countdown var(--hint-ms, 8s) linear forwards;
}

@keyframes hk-hint-countdown {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

#hk-hint.hk-hint-gone {
    opacity: 0;
    pointer-events: none;
}
