/* MK Play design system: tokens, base elements, site chrome and the controls every game shares. */

@font-face {
    font-family: "Bricolage Grotesque";
    src: url("../fonts/bricolage-grotesque.woff2") format("woff2");
    font-weight: 200 800;
    font-stretch: 75% 100%;
    font-display: swap;
}

@font-face {
    font-family: "Geist";
    src: url("../fonts/geist.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    /* Colour. Gold is the only "material": the coin, the current result, the winner.
       Violet and sky exist only as stage light behind the action. */
    --ink: #080B14;
    --ink-soft: #0C1120;
    --slate: #111827;
    --slate-2: #1B2335;
    --slate-3: #28334D;
    --line: rgb(148 163 184 / .14);
    --line-strong: rgb(148 163 184 / .3);
    --paper: #F8FAFC;
    --mist: #94A3B8;
    --gold: #FBBF24;
    --gold-bright: #FDE68A;
    --gold-deep: #92540A;
    --on-gold: #1A1204;
    --violet: #8B5CF6;
    --sky: #38BDF8;
    --ok: #34D399;
    --danger: #F87171;

    --font-display: "Bricolage Grotesque", "Arial Narrow", system-ui, sans-serif;
    --font-ui: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: .75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;
    --space-9: 6rem;

    --radius-s: .5rem;
    --radius-m: .875rem;
    --radius-l: 1.5rem;
    --radius-xl: 2.25rem;
    --radius-pill: 999px;

    --shadow-panel: 0 1.5rem 4rem rgb(0 0 0 / .5);
    --glow-gold: 0 0 .6em rgb(251 191 36 / .32);

    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
    --dur-fast: 120ms;
    --dur: 240ms;
    --dur-slow: 520ms;

    --nav-h: 4.5rem;
    --footer-h: 3.25rem;
    --gutter: clamp(1rem, 4vw, 4.5rem);
}

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

/* The root size grows with the screen, so the whole interface scales up on a television
   instead of sitting small in the middle of it. */
html {
    font-size: clamp(16px, 0.42vw + 0.42vh + 4px, 36px);
    background: var(--ink);
    color-scheme: dark;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    overflow-x: hidden;
    font-family: var(--font-ui);
    font-size: 1rem;
    line-height: 1.5;
    color: var(--paper);
    background: var(--ink);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1,
h2,
h3 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.05;
    text-wrap: balance;
}

h1:focus {
    outline: none;
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: .1875rem solid var(--sky);
    outline-offset: .1875rem;
    border-radius: var(--radius-s);
}

::selection {
    background: var(--gold);
    color: var(--on-gold);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: fixed;
    left: var(--space-4);
    top: var(--space-4);
    z-index: 100;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-m);
    background: var(--gold);
    color: var(--on-gold);
    font-weight: 600;
    text-decoration: none;
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: none;
}

/* ---------- App shell ---------- */

.app {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    isolation: isolate;
}

.app > main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

main:focus {
    outline: none;
}

/* Two slow beams of stage light behind everything. Gradients only: no blur filters to repaint. */
.stage-lights {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background: var(--ink);
}

.beam {
    position: absolute;
    width: 90vmax;
    height: 90vmax;
    border-radius: 50%;
    will-change: transform;
}

.beam-violet {
    left: -38vmax;
    top: -48vmax;
    background: radial-gradient(closest-side, rgb(139 92 246 / .34), rgb(139 92 246 / .1) 45%, transparent 70%);
    animation: beam-drift-a 28s ease-in-out infinite alternate;
}

.beam-sky {
    right: -42vmax;
    bottom: -56vmax;
    background: radial-gradient(closest-side, rgb(56 189 248 / .24), rgb(56 189 248 / .07) 45%, transparent 70%);
    animation: beam-drift-b 34s ease-in-out infinite alternate;
}

@keyframes beam-drift-a {
    to {
        transform: translate3d(14vmax, 8vmax, 0) scale(1.12);
    }
}

@keyframes beam-drift-b {
    to {
        transform: translate3d(-12vmax, -9vmax, 0) scale(1.08);
    }
}

/* ---------- Navigation ---------- */

.nav {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: var(--space-5);
    height: var(--nav-h);
    padding: 0 var(--gutter);
}

.brand {
    display: inline-flex;
    border-radius: var(--radius-s);
    text-decoration: none;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: .625rem;
}

.logo-mark {
    width: 2rem;
    height: 2rem;
    flex: none;
}

.logo-word {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: -.01em;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-left: auto;
}

.nav-links a {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    padding: 0 var(--space-4);
    border-radius: var(--radius-pill);
    color: var(--mist);
    font-weight: 500;
    text-decoration: none;
    transition: color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}

.nav-links a:hover {
    color: var(--paper);
    background: rgb(148 163 184 / .08);
}

/* The current page is marked by weight and a gold bar, not by colour alone. */
.nav-links a.active {
    color: var(--paper);
    font-weight: 650;
}

.nav-links a.active::after {
    content: "";
    position: absolute;
    left: var(--space-4);
    right: var(--space-4);
    bottom: .3rem;
    height: .1875rem;
    border-radius: var(--radius-pill);
    background: var(--gold);
}

.nav-tools {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.nav .nav-toggle {
    display: none;
}

@media (max-width: 760px) {
    .nav .nav-toggle {
        display: inline-flex;
    }

    .nav-tools {
        margin-left: auto;
    }

    .nav-links {
        position: absolute;
        left: var(--space-3);
        right: var(--space-3);
        top: calc(var(--nav-h) - .25rem);
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-1);
        margin: 0;
        padding: var(--space-3);
        border-radius: var(--radius-l);
        background: var(--slate);
        box-shadow: var(--shadow-panel), inset 0 0 0 1px var(--line);
    }

    .nav.is-open .nav-links {
        display: flex;
        animation: menu-in var(--dur) var(--ease-out);
    }

    .nav-links a {
        min-height: 3.25rem;
        padding: 0 var(--space-5);
        border-radius: var(--radius-m);
        font-size: 1.125rem;
    }

    .nav-links a.active::after {
        left: .5rem;
        right: auto;
        top: 1rem;
        bottom: 1rem;
        width: .1875rem;
        height: auto;
    }
}

@keyframes menu-in {
    from {
        opacity: 0;
        transform: translateY(-.5rem);
    }
}

/* ---------- Footer ---------- */

.site-footer {
    display: grid;
    place-items: center;
    min-height: var(--footer-h);
    padding: 0 var(--gutter);
    color: var(--mist);
    font-size: .875rem;
    text-align: center;
}

.site-footer a {
    color: var(--paper);
    text-underline-offset: .2em;
}

.site-footer a:hover {
    color: var(--gold);
}

/* ---------- Buttons: console keys with a little physical depth ---------- */

.btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 3rem;
    padding: 0 1.25rem;
    border: 0;
    border-radius: var(--radius-m);
    background: var(--slate-2);
    color: var(--paper);
    font-family: var(--font-ui);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .09), inset 0 0 0 1px var(--line), 0 .2rem 0 rgb(0 0 0 / .55);
    transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out),
        background var(--dur) var(--ease-out), opacity var(--dur) var(--ease-out);
}

.btn:hover {
    background: var(--slate-3);
}

.btn:active {
    transform: translateY(.15rem);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .09), inset 0 0 0 1px var(--line), 0 .05rem 0 rgb(0 0 0 / .55);
}

.btn[disabled] {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    min-height: 3.75rem;
    padding: 0 2.25rem;
    background: var(--gold);
    color: var(--on-gold);
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: .035em;
    text-transform: uppercase;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .6), inset 0 -.2rem 0 rgb(146 84 10 / .32), 0 .3rem 0 var(--gold-deep),
        0 1rem 2.5rem rgb(251 191 36 / .2);
}

.btn-primary:hover {
    background: #FFCD45;
}

.btn-primary:active {
    transform: translateY(.22rem);
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .6), inset 0 -.1rem 0 rgb(146 84 10 / .32), 0 .08rem 0 var(--gold-deep),
        0 .5rem 1.5rem rgb(251 191 36 / .16);
}

.btn-quiet {
    background: transparent;
    box-shadow: inset 0 0 0 1px var(--line-strong);
}

.btn-quiet:hover {
    background: rgb(148 163 184 / .1);
}

.btn-quiet:active {
    box-shadow: inset 0 0 0 1px var(--line-strong);
}

.btn-danger {
    background: #C2303B;
    color: #fff;
    box-shadow: inset 0 1px 0 rgb(255 255 255 / .25), 0 .2rem 0 #7A1820;
}

.btn-danger:hover {
    background: #D53C48;
}

.icon-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding: 0 .65rem;
    border: 0;
    border-radius: var(--radius-pill);
    background: transparent;
    color: var(--mist);
    font-size: .9375rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}

.icon-btn:hover {
    color: var(--paper);
    background: rgb(148 163 184 / .12);
}

.icon-btn[disabled] {
    opacity: .35;
    cursor: not-allowed;
}

.icon-btn.is-on {
    color: var(--gold);
}

.icon {
    width: 1.375rem;
    height: 1.375rem;
    flex: none;
}

.icon-btn-label {
    display: none;
}

@media (min-width: 900px) {
    .icon-btn.has-label .icon-btn-label {
        display: inline;
    }

    .icon-btn.has-label {
        padding: 0 .9rem;
    }
}

/* ---------- Dialogs ---------- */

dialog.modal {
    width: min(34rem, calc(100vw - 2rem));
    max-height: calc(100dvh - 2rem);
    padding: var(--space-6);
    border: 0;
    border-radius: var(--radius-l);
    background: var(--slate);
    color: var(--paper);
    box-shadow: var(--shadow-panel), inset 0 0 0 1px var(--line-strong);
}

dialog.modal[open] {
    animation: modal-in var(--dur-slow) var(--ease-out);
}

dialog.modal::backdrop {
    background: rgb(4 6 12 / .74);
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(1rem) scale(.97);
    }
}

.modal-title {
    font-size: 1.75rem;
}

.modal-text {
    margin-top: var(--space-3);
    color: var(--mist);
    font-size: 1.0625rem;
}

.modal-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

/* ---------- Start-up and failure states ---------- */

.boot {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: var(--space-5);
    min-height: 100dvh;
}

.boot-mark {
    width: 4.5rem;
    height: 4.5rem;
    animation: boot-pulse 1.6s var(--ease-out) infinite alternate;
}

.boot-bar {
    width: 11rem;
    height: .25rem;
    border-radius: var(--radius-pill);
    background: var(--slate-2);
    overflow: hidden;
}

.boot-bar span {
    display: block;
    width: var(--blazor-load-percentage, 8%);
    height: 100%;
    border-radius: inherit;
    background: var(--gold);
    transition: width var(--dur) linear;
}

.boot-text {
    color: var(--mist);
    font-size: .9375rem;
}

@keyframes boot-pulse {
    from {
        transform: scale(.94);
        opacity: .75;
    }
}

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 50%;
    bottom: var(--space-5);
    z-index: 200;
    transform: translateX(-50%);
    width: min(36rem, calc(100vw - 2rem));
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-m);
    background: #3A1418;
    color: #FFE4E6;
    box-shadow: var(--shadow-panel), inset 0 0 0 1px rgb(248 113 113 / .5);
}

#blazor-error-ui .reload {
    margin-left: var(--space-3);
    font-weight: 600;
}

#blazor-error-ui .dismiss {
    float: right;
    border: 0;
    background: none;
    text-decoration: underline;
    cursor: pointer;
}

.noscript {
    padding: var(--space-7) var(--gutter);
    text-align: center;
}

.not-found {
    display: grid;
    place-content: center;
    justify-items: center;
    gap: var(--space-5);
    flex: 1;
    padding: var(--space-8) var(--gutter);
    text-align: center;
}

.not-found h1 {
    font-size: clamp(2.5rem, 7vw, 5rem);
}

.not-found p {
    color: var(--mist);
    font-size: 1.125rem;
}

/* ---------- Presentation mode: the chrome leaves, the game stays ---------- */

.app.is-presenting .nav,
.app.is-presenting .site-footer {
    display: none;
}

/* ---------- Reduced motion ---------- */

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

    .beam {
        animation: none;
    }
}
