/* The screen's own copy of DejaVu Sans Mono, the same 6 KB subset dos-defrag
   bundles (printable ASCII, U+00A0, the em dash, U+2500-259F). Copied rather
   than linked, because a prank screen owns its assets. Android's own monospace
   is a different width, which would throw every column out. font-display:
   block, so text never flashes up in a fallback face; the JS refits once the
   font has arrived. Any character outside the subset renders from a fallback
   font at the wrong width, so the legend swatches are U+2588, not U+25A0. */
@font-face {
    font-family: "BF DejaVu Sans Mono";
    src: url("dejavu-sans-mono.1794768948.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: #0000AA;

    cursor: default;
}

body.bf-revealed {
    cursor: none;
}


/* One text screen, sized off a single font-size the JS fits to the viewport:
   80 columns in landscape, 42 upright (--tc): the widest upright line is
   the "Programming Flash Memory - 0005E000 FAIL" of the reveal, 40 columns plus
   the one-column indent. No media queries. */
#bf-screen {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 1;

    display: flex;
    align-items: center;
    justify-content: center;

    font-family: "BF DejaVu Sans Mono", "DejaVu Sans Mono", "Liberation Mono", Consolas, "Lucida Console", "Courier New", monospace;
    font-size: 16px;
    line-height: 1.2;
    color: #AAAAAA;

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

#bf-board {
    width: calc(var(--tc, 80) * 1ch);
}

.bf-ln {
    white-space: pre;
    overflow: hidden;
}

.bf-c {
    text-align: center;
}

.bf-body {
    padding: 0 5ch;
}

.bf-portrait .bf-body {
    padding: 0 1ch;
}

.bf-n {
    display: none;
}

.bf-portrait .bf-w {
    display: none;
}

.bf-portrait div.bf-n {
    display: block;
}

/* A line break that only exists upright, where the warning would otherwise
   wrap one word onto a line of its own. */
br.bf-nbr {
    display: none;
}

.bf-portrait br.bf-nbr {
    display: inline;
}

.bf-hi {
    color: #FFFFFF;
}

.bf-y {
    color: #FFFF55;
}

.bf-red {
    color: #FF5555;
}

.bf-body p {
    margin: 0;
}


/* The block map: one cell per 4 KB block, inside a single-line frame. Sized in
   ch and em so it scales with the text and needs no measuring of its own. */
#bf-blocks {
    display: grid;
    grid-template-columns: repeat(var(--bc, 32), 1.4ch);
    grid-auto-rows: 0.8em;
    gap: 0.4em 0.6ch;

    width: -webkit-fit-content;
    width: fit-content;
    margin: 0.6em auto;
    padding: 0.5em 1.2ch;

    border: var(--b, 2px) solid #AAAAAA;
}

/* Not yet reached: an empty outline, so the size of the job is visible. */
#bf-blocks i {
    display: block;
    border: var(--bb, 1px) solid #5555FF;
}

#bf-blocks i.bf-ok {
    background: #FFFFFF;
    border-color: #FFFFFF;
}

#bf-blocks i.bf-skip {
    background: #00AAAA;
    border-color: #00AAAA;
}

#bf-blocks i.bf-fail {
    background: #FF5555;
    border-color: #FF5555;
}

/* The block being written blinks yellow: the one thing that visibly moves
   once the address counter slows to a crawl. */
#bf-blocks i.bf-cur {
    background: #FFFF55;
    border-color: #FFFF55;
    animation: bf-write 0.8s steps(1, end) infinite;
}

/* Blinks the fill only; the outline stays, so the cell never vanishes. */
@keyframes bf-write {
    50% {
        background: transparent;
        border-color: #5555FF;
    }
}

.bf-sw-ok {
    color: #FFFFFF;
}

.bf-sw-skip {
    color: #00AAAA;
}

.bf-sw-fail {
    color: #FF5555;
}

#bf-ok.bf-fail-tag {
    color: #FF5555;
}

/* The two key labels are the only things a single click or tap answers. */
#bf-keys span {
    cursor: default;
}


/* Reveal: the warning gives way to the error, then the punchline is added
   under it. */
#bf-error,
#bf-outro {
    display: none;
}

body.bf-failed #bf-msg {
    display: none;
}

body.bf-failed #bf-error {
    display: block;
}

body.bf-revealed #bf-outro {
    display: block;
    margin-top: 1.2em;
    color: #FFFFFF;
}

#bf-outro p {
    margin: 0 0 1.2em;
}

#bf-outro p:last-child {
    margin-bottom: 0;
}

#bf-cursor {
    animation: bf-blink 1s steps(1, end) infinite;
}

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


/* Over the top of the screen, where it covers only the product banner. */
#bf-hint {
    position: fixed;
    left: 50%;
    top: 34px;
    transform: translateX(-50%);
    z-index: 4;

    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.72);
    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;
}

#bf-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. */
#bf-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: bf-hint-countdown var(--hint-ms, 8s) linear forwards;
}

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

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