/*
 * Design tokens from design-reference/README.md. Values are copied verbatim —
 * only their location changes (CLAUDE.md §2).
 *
 * --accent is the single channel for the per-student brand colour. Never write
 * a brand hex anywhere else; set --accent on :root or a container instead.
 *
 * Self-hosted @font-face declarations (Space Grotesk, JetBrains Mono,
 * Press Start 2P) arrive with the Avatar Creator in M3.
 */

:root {
    --accent: #0f766e;
    --accent-ink: #ffffff;

    --text-1: #16171a;
    --text-2: #6b6f77;
    --text-3: #83878f;
    --text-4: #9a9ea6;

    --surface: #fffffe;
    --surface-pixel: #fffdf6;
    --page: #f5f6f4;
    --border: rgba(20, 30, 18, 0.12);
    --track: #e6e8e4;
    --xp: #f0b429;
    --danger: #e8552f;
    /* A teacher's posts (§15.9). Not a brand colour: it has to stand out
       against every student's --accent and every module's --module. */
    --staff: #7c3aed;

    --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --font-pixel: "Press Start 2P", "Courier New", monospace;

    --radius-card: 18px;
    --radius-control: 12px;
    --shadow-card: 0 14px 34px -18px rgba(12, 32, 20, 0.55);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--text-1);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.page--auth,
.page--bare {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    align-items: center;
    justify-content: center;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
}

.shell {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 20px;
}

.shell--narrow {
    max-width: 420px;
    padding: 0;
}

/* --- Top bar --- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar__brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.02em;
    color: var(--text-1);
    text-decoration: none;
}

.topbar__actions {
    margin: 0;
}

.topbar__nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: auto;
    flex-wrap: wrap;
}

.topbar__link {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: var(--radius-control);
    color: var(--text-2);
    font-size: 14px;
    text-decoration: none;
}

.topbar__link:hover {
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--accent);
}

.topbar__link[aria-current="page"] {
    color: var(--accent);
    font-weight: 600;
}

@media (max-width: 520px) {
    .topbar {
        gap: 8px;
        padding: 10px 14px;
    }

    .topbar__link {
        padding: 8px 8px;
        font-size: 13.5px;
    }
}

/* --- Brand lockup --- */

.brand {
    text-align: center;
    margin-bottom: 20px;
}

.brand__mark {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 26px;
    letter-spacing: -0.025em;
    color: var(--accent);
}

.brand__tagline {
    display: block;
    margin-top: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

/* --- Card / panel --- */

.card,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    padding: 26px 24px;
}

.panel--centered {
    text-align: center;
}

.card__title,
.panel__title {
    margin: 0 0 8px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 25px;
    line-height: 1.18;
    letter-spacing: -0.025em;
}

.card__intro,
.panel__body {
    margin: 0 0 20px;
    max-width: 38ch;
    color: var(--text-2);
    font-size: 14px;
}

.panel--centered .panel__body {
    margin-inline: auto;
}

.panel__meta,
.panel__status {
    margin: 0 0 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.card__footnote {
    margin: 20px 0 0;
    font-size: 13px;
    color: var(--text-3);
}

.notice {
    margin: 0 0 16px;
    padding: 10px 12px;
    border-radius: var(--radius-control);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--accent);
    font-size: 13px;
}

.link {
    color: var(--accent);
}

/* --- Forms --- */

.field {
    display: block;
    margin-bottom: 16px;
}

.field__label {
    display: block;
    margin-bottom: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-2);
}

.field__input {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: var(--surface);
    color: var(--text-1);
    font-family: inherit;
    /* 16px keeps iOS Safari from zooming the viewport on focus. */
    font-size: 16px;
    line-height: 1.4;
}

.field__input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.field__error {
    display: block;
    margin-top: 6px;
    color: var(--danger);
    font-size: 13px;
}

/* --- Buttons --- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* 44px minimum touch target (CLAUDE.md §3). */
    min-height: 44px;
    padding: 11px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
}

.button--primary {
    background: var(--accent);
    color: var(--accent-ink);
}

.button--ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--text-2);
}

.button--block {
    width: 100%;
}

.button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- Form hints, consent block and summary lists (M2) --- */

.field__hint {
    display: block;
    margin-top: 6px;
    color: var(--text-3);
    font-size: 12.5px;
    line-height: 1.45;
}

.field__toggle {
    margin-top: 8px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
    /* Inline text control — keep the 44px target without a 44px-tall box. */
    min-height: 24px;
}

.consent {
    margin: 4px 0 20px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.consent__check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.consent__check input {
    /* Comfortable on a thumb without breaking the row rhythm. */
    width: 22px;
    height: 22px;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--accent);
}

.consent__body {
    margin: 10px 0 0;
    color: var(--text-2);
    font-size: 12.5px;
    line-height: 1.55;
}

.notice--warning {
    background: color-mix(in srgb, var(--xp) 18%, transparent);
    color: #6b4b04;
}

.summary {
    margin: 0;
    display: grid;
    gap: 12px;
}

.summary__row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.summary__key {
    margin: 0;
    min-width: 140px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.summary__value {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

/* --- Avatar thumbnail --- */
/* Renders avatar_config.px (20x24, row-major) anywhere a small avatar is shown:
   the map HUD, the leaderboard, comment authors. Set --thumb-bg to the stored
   bg colour and --px to scale it. */

.avatar-thumb {
    --px: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-radius: 14px;
    background: var(--thumb-bg, #a5e0d8);
    line-height: normal;
}

.avatar-thumb__grid {
    display: grid;
    grid-template-columns: repeat(20, var(--px));
    grid-auto-rows: var(--px);
}

.avatar-thumb__grid i {
    display: block;
}

/* A teacher has no pixel avatar (§15.9). */
.avatar-thumb--staff {
    background: color-mix(in oklab, var(--staff) 16%, #fffffe);
}

.avatar-thumb__emoji {
    font-size: 19px;
    line-height: 1;
}

/* --- Leaderboard (CLAUDE.md §10.4) --- */

.board {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.board__head {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.board__title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 28px;
    letter-spacing: -0.025em;
}

.board__intro {
    margin: 0;
    font-size: 13.5px;
    color: var(--text-3);
}

.board__tabs {
    display: flex;
    gap: 8px;
}

.board__tab {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text-2);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.board__tab[aria-current="page"] {
    border-color: var(--accent);
    background: color-mix(in oklab, var(--accent) 10%, #fffffe);
    color: var(--accent);
}

.board__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.board__row {
    display: grid;
    /* Rang, avatar, alias, tal. HQ-status står ikke på listen (rettelse
       2026-10-01): det er point, der rangeres efter. */
    grid-template-columns: 34px 44px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px 10px 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
}

.board__row[data-me="true"] {
    border-color: var(--accent);
    background: color-mix(in oklab, var(--accent) 7%, #fffffe);
}

.board__rank {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-3);
    text-align: right;
}

.board__avatar {
    --px: 1.8px;
    padding: 4px;
    border-radius: 9px;
    width: 44px;
    height: 44px;
}

.board__alias {
    display: flex;
    align-items: baseline;
    gap: 7px;
    min-width: 0;
    font-size: 15px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.board__you {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}


/* Forklaringen under fanerne. Kun streak-fanen har en: hverdagsreglen er
   ikke til at gætte sig til. */
.board__tab-intro {
    margin: -6px 0 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--text-3);
}

/* I streak-fanen er rekorden tallet, rækken handler om. */
.board__points--streak {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
}

.board__points {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.board__own-label,
.board__empty,
.board__back {
    margin: 0;
    font-size: 13px;
    color: var(--text-3);
}

.board__own-label {
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 6px;
}

@media (max-width: 560px) {
    .board__row {
        grid-template-columns: 26px 36px minmax(0, 1fr) auto;
        gap: 9px;
        padding: 9px 12px 9px 8px;
    }

    .board__avatar {
        --px: 1.5px;
        width: 36px;
        height: 36px;
        padding: 3px;
    }
}

.board__initial {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    color: rgba(20, 30, 18, 0.45);
}

/* Skip link: hidden until it takes focus, then the first thing on the page. */
.skip-link {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: 0 0 10px 10px;
    background: var(--surface);
    color: var(--text-1);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(20, 22, 26, 0.16);
    transition: top 0.15s ease;
}

.skip-link:focus {
    /* :focus, not :focus-visible — the link is only ever reached by keyboard. */
    top: 0;
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

main:focus {
    outline: none;
}

/* Et alias er et link til profilen (§5.1) overalt, uden at ligne et link før
   man peger på det. */
.alias-link {
    color: inherit;
    text-decoration: none;
}

.alias-link:hover,
.alias-link:focus-visible {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Kontoret (§8.5-§8.7) tegnes af tegnemotoren i bufferens egne pixels og
   skaleres op til rammens bredde med skarpe kanter. Rammen har bufferens
   format (aspect-ratio sat af paintScene), så canvas fylder den præcist. */
.office-canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}


/* --- Login: kortet som baggrund (layouts/auth.php) ---------------------
   Øen fra kortet ligger bag kortet med formularen, sløret og under et mørkt
   lag, så formularen står klart. Den tones ind, når den er tegnet. */
.auth-backdrop {
    position: fixed;
    inset: -24px;
    z-index: 0;
    overflow: hidden;
    background: #58a6d8;
    filter: blur(3px) saturate(1.05);
    opacity: 0;
    transition: opacity .6s ease;
}

.has-backdrop--ready .auth-backdrop { opacity: 1; }

.auth-backdrop__map {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* På en smal skærm viser midten mest hav; lidt mod venstre og ned er øen. */
    object-position: 38% 60%;
    image-rendering: pixelated;
}

.has-backdrop::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 1;
    background:
        radial-gradient(ellipse at center, rgba(16, 24, 32, .35) 0%, rgba(16, 24, 32, .62) 100%);
    pointer-events: none;
}

.has-backdrop .shell {
    position: relative;
    z-index: 2;
}

.has-backdrop .brand__mark { color: #fffffe; text-shadow: 0 2px 12px rgba(0, 0, 0, .35); }

.brand__logo { display: inline-block; }

.brand__logo img {
    display: block;
    width: auto;
    height: 56px;
    margin: 0 auto;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, .3));
}

@media (max-width: 520px) {
    .brand__logo img { height: 48px; }
}
.has-backdrop .brand__tagline { color: rgba(255, 255, 254, .82); }

.has-backdrop .card {
    box-shadow: 0 24px 60px rgba(10, 16, 24, .35);
}

@media (prefers-reduced-motion: reduce) {
    .auth-backdrop { transition: none; }
}

/* "Funded by the European Union" under kortet med formularen (layouts/auth). */
.funded-by {
    display: flex;
    justify-content: center;
    margin-top: 28px;
}

.funded-by img {
    display: block;
    width: auto;
    height: 32px;
    opacity: .92;
}

@media (max-width: 520px) {
    .funded-by { margin-top: 22px; }
    .funded-by img { height: 27px; }
}


/* GATE-symbolet i stedet for ordet "GATE" (partials/brand-symbol.php). */
.brand-symbol { display: inline-flex; flex: none; }
.brand-symbol img { display: block; width: auto; }
.topbar__brand { display: inline-flex; align-items: center; }
.topbar__symbol img { height: 32px; }
