/* Ayumu Task — monochrome laboratory console
   The page is two screens: an operator console (chrome, rules, readouts)
   wrapped around a subject display (pure black, white marks, nothing else). */

:root {
    --void: #000000;
    --phosphor: #ffffff;
    --console: #e8e8e8;
    --dim: #8a8a8a;
    --rule: #3c3c3c;

    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
    --pad: clamp(14px, 3.6vw, 28px);
    --scan: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .045) 0 1px, transparent 1px 3px);
}

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

html,
body {
    margin: 0;
    height: 100%;
}

body {
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--void);
    color: var(--console);
    font: 400 16px/1.5 var(--mono);
    font-variant-numeric: tabular-nums;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

:focus-visible {
    outline: 2px solid var(--phosphor);
    outline-offset: 3px;
}

/* ---------------------------------------------------------------- console */

.console {
    position: relative;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 10px var(--pad);
    border-bottom: 1px solid var(--rule);
    text-shadow: 0 0 7px rgba(255, 255, 255, .22);
}

.console::after,
.readout::after,
.status::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--scan);
    pointer-events: none;
}

.mark {
    margin: 0;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .24em;
    text-transform: uppercase;
}

.mark span {
    color: var(--dim);
    font-weight: 400;
}

.mark span::before {
    content: " · ";
}

.tools {
    display: flex;
    gap: 1px;
    flex: none;
}

.tool {
    border: 0;
    padding: 5px 9px;
    background: var(--void);
    box-shadow: inset 0 0 0 1px var(--rule);
    color: var(--dim);
    font: 400 .6rem/1 var(--mono);
    letter-spacing: .16em;
    text-transform: uppercase;
    cursor: pointer;
}

.tool b {
    color: var(--console);
    font-weight: 400;
}

.tool:hover {
    color: var(--console);
}

.tool:active {
    background: var(--phosphor);
    color: var(--void);
}

/* ------------------------------------------------------------------ stage */

.stage {
    display: grid;
    min-height: 0;
}

.screen {
    grid-area: 1 / 1;
    display: none;
    flex-direction: column;
    min-height: 0;
}

.screen.is-active {
    display: flex;
}

#screenTitle,
#screenResults {
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* auto on all sides centres the sheet when there is room and lets it scroll when there is not */
.sheet {
    width: min(46rem, 100%);
    margin: auto;
    padding: clamp(20px, 4vh, 40px) var(--pad) calc(var(--pad) + 24px);
}

/* -------------------------------------------------------- title: the hero */

.preview {
    margin: 0 0 clamp(22px, 4.5vh, 38px);
    border: 1px solid var(--rule);
}

.preview-field {
    position: relative;
    height: clamp(124px, 23vh, 200px);
    background: var(--void);
    overflow: hidden;
}

.preview figcaption {
    padding: 6px 10px;
    border-top: 1px solid var(--rule);
    color: var(--dim);
    font-size: .58rem;
    letter-spacing: .2em;
    text-transform: uppercase;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--dim);
    font-size: .6rem;
    letter-spacing: .24em;
    text-transform: uppercase;
}

.display {
    margin: 0 0 .55em;
    font-size: clamp(1.85rem, 7.4vw, 3rem);
    font-weight: 700;
    line-height: 1.03;
    letter-spacing: -.025em;
    text-transform: uppercase;
    color: var(--phosphor);
    text-shadow: 0 0 18px rgba(255, 255, 255, .18);
}

.lede {
    margin: 0 0 clamp(22px, 4vh, 34px);
    max-width: 34em;
    font-size: clamp(.82rem, 2.9vw, .94rem);
    line-height: 1.65;
    color: var(--console);
}

.setup {
    margin: 0 0 18px;
}

.setup.is-off {
    opacity: .35;
    pointer-events: none;
}

.label {
    margin: 0 0 7px;
    color: var(--dim);
    font-size: .58rem;
    letter-spacing: .22em;
    text-transform: uppercase;
}

.seg {
    display: flex;
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
}

.seg-btn {
    flex: 1 1 0;
    display: grid;
    gap: 3px;
    align-content: center;
    justify-items: center;
    min-height: 56px;
    padding: 8px 6px;
    border: 0;
    background: var(--void);
    color: var(--dim);
    font: 700 .72rem/1.2 var(--mono);
    letter-spacing: .12em;
    text-transform: uppercase;
    cursor: pointer;
}

.seg-btn small {
    font-size: .55rem;
    font-weight: 400;
    letter-spacing: .1em;
    opacity: .75;
}

.seg-btn.is-on {
    background: var(--phosphor);
    color: var(--void);
}

.cta {
    display: block;
    width: 100%;
    min-height: 58px;
    margin: clamp(20px, 4vh, 32px) 0 14px;
    border: 0;
    background: var(--phosphor);
    color: var(--void);
    font: 700 .82rem/1 var(--mono);
    letter-spacing: .26em;
    text-transform: uppercase;
    cursor: pointer;
}

.cta:active {
    background: var(--console);
}

.cta--ghost {
    background: var(--void);
    color: var(--console);
    box-shadow: inset 0 0 0 1px var(--rule);
}

.cta--ghost:active {
    background: var(--phosphor);
    color: var(--void);
}

.actions {
    display: grid;
    gap: 10px;
}

.actions .cta {
    margin: 0;
}

.actions .cta:first-child {
    margin-top: clamp(20px, 4vh, 32px);
}

.meta {
    margin: 0 0 6px;
    font-size: .64rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--console);
}

.note {
    margin: 14px 0 0;
    padding-top: 14px;
    border-top: 1px solid var(--rule);
    font-size: .66rem;
    line-height: 1.7;
    color: var(--dim);
}

.note em {
    font-style: italic;
}

/* ------------------------------------------------------------ play screen */

.readout {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    padding: 8px var(--pad);
    border-bottom: 1px solid var(--rule);
    font-size: .6rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    text-shadow: 0 0 7px rgba(255, 255, 255, .2);
}

.rd b {
    color: var(--dim);
    font-weight: 400;
}

.rd i {
    margin-left: .6em;
    font-style: normal;
    color: var(--phosphor);
}

.rd--score {
    margin-left: auto;
}

.pips {
    letter-spacing: .1em;
}

.field {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: var(--void);
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    cursor: crosshair;
}

.field.is-flash {
    background: var(--phosphor);
}

.status {
    position: relative;
    margin: 0;
    padding: 11px var(--pad);
    border-top: 1px solid var(--rule);
    font-size: .62rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--console);
    text-shadow: 0 0 7px rgba(255, 255, 255, .2);
}

/* -------------------------------------------------------------- the marks */

.cell {
    position: absolute;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--phosphor);
    font-family: var(--mono);
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 90ms linear;
}

.cell.is-masked {
    background: var(--phosphor);
    color: transparent;
}

.cell.is-cleared {
    opacity: 0;
    pointer-events: none;
}

.cell.is-revealed {
    background: transparent;
    color: var(--dim);
}

.cell.is-expected {
    color: var(--phosphor);
    box-shadow: inset 0 0 0 2px var(--phosphor);
}

.cell--start {
    background: var(--phosphor);
    color: var(--void);
    font-size: .58rem;
    letter-spacing: .14em;
    text-transform: uppercase;
}

/* --------------------------------------------------------- results: a log */

.log-wrap {
    overflow-x: auto;
    border: 1px solid var(--rule);
    margin-bottom: 18px;
}

.log {
    width: 100%;
    border-collapse: collapse;
    font-size: .64rem;
    letter-spacing: .1em;
    text-transform: uppercase;
    white-space: nowrap;
}

.log th,
.log td {
    padding: 7px 12px;
    text-align: right;
    border-bottom: 1px solid var(--rule);
}

.log th:first-child,
.log td:first-child {
    text-align: left;
}

.log th {
    color: var(--dim);
    font-weight: 400;
}

.log tbody tr:last-child td {
    border-bottom: 0;
}

.log .is-fail {
    color: var(--dim);
}

.log .is-fail td:nth-child(3) {
    color: var(--phosphor);
}

.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
    gap: 1px;
    margin: 0 0 18px;
    background: var(--rule);
    border: 1px solid var(--rule);
}

.summary div {
    padding: 12px;
    background: var(--void);
}

.summary dt {
    color: var(--dim);
    font-size: .56rem;
    letter-spacing: .18em;
    text-transform: uppercase;
}

.summary dd {
    margin: 6px 0 0;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--phosphor);
}

/* ------------------------------------------------------------------- boot */

.boot {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: var(--pad);
    background: var(--void);
}

.boot.is-done {
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease;
}

.boot-log {
    display: grid;
    gap: .6em;
    justify-items: start;
    font-size: clamp(.6rem, 2.7vw, .78rem);
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--console);
    text-shadow: 0 0 8px rgba(255, 255, 255, .25);
}

.boot-log span {
    opacity: 0;
}

.boot-log span.is-in {
    opacity: 1;
}

.caret {
    display: inline-block;
    width: .55em;
    height: 1em;
    margin-left: .3em;
    vertical-align: -.12em;
    background: var(--phosphor);
    animation: blink 1s steps(1) infinite;
}

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

/* On a phone the console bar has room for the mark or the subtitle, not both. */
@media (max-width: 30rem) {
    .mark span {
        display: none;
    }

    .tool {
        padding: 5px 7px;
        letter-spacing: .1em;
    }

    .readout {
        gap: 4px 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
