/**
 * Core layer
 * Design language: "Printed Game Cabinet" — a museum-catalogue print
 * aesthetic: warm ivory stock, deep pine ink, marigold letterpress accent,
 * Bodoni Moda display serif paired with Archivo grotesque.
 *
 * Hallmark · macrostructure: Cabinet Plate · tone: editorial-print
 * anchor hue: marigold ~78° · theme: custom (light / roman-serif / warm)
 *
 * This file owns: design tokens, reset, typography primitives, page shell,
 * shared utilities. It does NOT own component skins (components.css) or
 * page composition (layout.css).
 */

/* ------------------------------------------------------------------
   1 · Design tokens
   ------------------------------------------------------------------ */
:root {
    /* Paper stock — warm ivory, never cool grey */
    --mc-paper: #FBF2DF;
    --mc-paper-deep: #F4E7CE;
    --mc-paper-panel: #FFFBF1;
    --mc-paper-shade: #EFDFC2;

    /* Ink — deep pine green reads warmer than black on ivory */
    --mc-ink: #16241D;
    --mc-ink-pine: #12362A;
    --mc-ink-soft: #3A4E44;
    --mc-ink-muted: #5A6A5F;
    /* ink-faint is only ever used for small caps labels, so it must clear
       4.5:1 on paper rather than read as a faint tint. */
    --mc-ink-faint: #5F6A61;

    /* Signature ink — marigold letterpress */
    --mc-marigold: #E8A317;
    /* Deep marigold is the small-caps accent: dark enough for AA on paper,
       still visibly warmer than ink. */
    --mc-marigold-deep: #8F5D03;
    /* Hover tone for marigold fills; one step brighter than the base. */
    --mc-marigold-hover: #F0B234;
    /* Ink used on marigold surfaces, where pine would be too low-contrast. */
    --mc-ink-on-marigold: #2A1B00;
    /* Deepest pine, for pressed/hover states on ink-coloured controls. */
    --mc-ink-pine-deep: #0C2A20;
    --mc-marigold-pale: #FBE3AC;
    --mc-marigold-wash: rgba(232, 163, 23, 0.14);

    /* Second accent — brick red, used sparingly for "play" affordances */
    --mc-brick: #B23A2B;
    --mc-brick-deep: #932B1E;
    --mc-brick-wash: rgba(178, 58, 43, 0.1);

    /* Support tints */
    --mc-sage: #C9D6C2;
    --mc-sage-soft: #E6EDE0;

    /* Rules — print hairlines, not UI borders */
    --mc-rule: rgba(18, 54, 42, 0.22);
    --mc-rule-soft: rgba(18, 54, 42, 0.12);
    --mc-rule-ink: var(--mc-ink-pine);

    /* Type */
    --mc-font-display: "Bodoni Moda", "Times New Roman", Georgia, serif;
    --mc-font-body: "Archivo", "Helvetica Neue", Arial, sans-serif;

    /* Type scale — fluid, print-page proportions */
    --mc-text-plate: clamp(2.6rem, 8.4vw, 5.5rem);
    --mc-text-display: clamp(2rem, 5.2vw, 3.1rem);
    --mc-text-h2: clamp(1.5rem, 3.4vw, 2.15rem);
    --mc-text-h3: clamp(1.12rem, 2.2vw, 1.35rem);
    --mc-text-lead: clamp(1.02rem, 1.9vw, 1.2rem);
    --mc-text-body: 1rem;
    --mc-text-sm: 0.875rem;
    --mc-text-xs: 0.75rem;
    --mc-text-micro: 0.6875rem;

    /* 4pt spacing scale with semantic names */
    --mc-space-3xs: 0.25rem;
    --mc-space-2xs: 0.5rem;
    --mc-space-xs: 0.75rem;
    --mc-space-sm: 1rem;
    --mc-space-md: 1.5rem;
    --mc-space-lg: 2.25rem;
    --mc-space-xl: 3.5rem;
    --mc-space-2xl: 5rem;
    --mc-space-3xl: 7rem;

    /* Geometry — the cabinet is rectilinear; corners are near-square */
    --mc-radius-xs: 2px;
    --mc-radius-sm: 3px;
    --mc-radius-md: 5px;
    --mc-radius-pill: 999px;

    /* Depth — printed shadow offsets, no blur halos */
    --mc-shadow-plate: 6px 6px 0 rgba(18, 54, 42, 0.15);
    --mc-shadow-card: 4px 4px 0 rgba(18, 54, 42, 0.12);
    --mc-shadow-lift: 8px 8px 0 rgba(18, 54, 42, 0.18);

    /* Motion */
    --mc-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --mc-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --mc-dur-fast: 140ms;
    --mc-dur: 220ms;
    --mc-dur-slow: 420ms;

    /* Layout */
    --mc-max: 1280px;
    --mc-gutter: 1.25rem;
    /* Nameplate height. The masthead is no longer sticky, so this only sets the
       plate's own min-height; nothing positions relative to it any more. */
    --mc-header-h: 54px;

    color-scheme: light;
}

@media (min-width: 768px) {
    :root {
        --mc-gutter: 2rem;
        --mc-header-h: 58px;
    }
}

@media (min-width: 1200px) {
    :root {
        --mc-gutter: 2.75rem;
    }
}

/* ------------------------------------------------------------------
   2 · Reset
   ------------------------------------------------------------------ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    overflow-x: clip;
    /* The masthead scrolls away with the page, so anchors only need a small
       breathing gap — not the full header height they previously cleared. */
    scroll-padding-top: 1.25rem;
    -webkit-text-size-adjust: 100%;
}

body {
    min-width: 320px;
    min-height: 100vh;
    overflow-x: clip;
    background-color: var(--mc-paper);
    /* Faint horizontal rule repeat reads like laid paper, not a gradient */
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0 31px,
        rgba(18, 54, 42, 0.035) 31px 32px
    );
    color: var(--mc-ink);
    font-family: var(--mc-font-body);
    font-size: var(--mc-text-body);
    line-height: 1.62;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

img,
svg,
video {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

ul,
ol {
    list-style: none;
}

:where(a, button, input, select, textarea, summary):focus-visible {
    /* Two-tone ring: the outer brick ring reads on paper, the inner paper ring
       guarantees contrast on the pine colophon, the play stage and the
       marigold buttons (where brick alone measured 2.23-2.74:1). */
    outline: 2px solid var(--mc-brick);
    outline-offset: 3px;
    box-shadow: 0 0 0 3px var(--mc-paper);
    border-radius: var(--mc-radius-xs);
}

::selection {
    background: var(--mc-marigold-pale);
    color: var(--mc-ink-pine);
}

[hidden] {
    display: none !important;
}

/* ------------------------------------------------------------------
   3 · Page shell
   ------------------------------------------------------------------ */
.mc-wrap {
    width: min(100% - (var(--mc-gutter) * 2), var(--mc-max));
    margin-inline: auto;
}

.mc-wrap--narrow {
    width: min(100% - (var(--mc-gutter) * 2), 860px);
    margin-inline: auto;
}

.mc-main {
    display: block;
}

/* Skip link — translated out of view rather than offset negatively, so it
   never adds scrollable width to the document. */
.mc-skip {
    position: absolute;
    top: 0;
    left: 0.75rem;
    z-index: 200;
    padding: 0.7rem 1.1rem;
    background: var(--mc-ink-pine);
    color: var(--mc-paper);
    font-size: var(--mc-text-sm);
    font-weight: 600;
    border-radius: 0 0 var(--mc-radius-xs) var(--mc-radius-xs);
    transform: translateY(-120%);
    transition: transform var(--mc-dur) var(--mc-ease-out);
}

.mc-skip:focus {
    transform: translateY(0);
}

/* ------------------------------------------------------------------
   4 · Typography primitives
   ------------------------------------------------------------------ */
.mc-display {
    font-family: var(--mc-font-display);
    font-weight: 500;
    font-optical-sizing: auto;
    letter-spacing: -0.015em;
    line-height: 1.06;
    overflow-wrap: anywhere;
    min-width: 0;
}

.mc-display em {
    font-style: italic;
    color: var(--mc-ink-pine);
}

/* Letterpress label — small caps grotesque with wide tracking */
.mc-label {
    font-family: var(--mc-font-body);
    font-size: var(--mc-text-micro);
    font-weight: 600;
    letter-spacing: 0.19em;
    text-transform: uppercase;
    color: var(--mc-ink-muted);
    line-height: 1.4;
}

.mc-label--marigold {
    color: var(--mc-marigold-deep);
}

.mc-label--paper {
    color: rgba(251, 242, 223, 0.72);
}

.mc-lede {
    font-size: var(--mc-text-lead);
    line-height: 1.55;
    color: var(--mc-ink-soft);
    max-width: 46ch;
}

.mc-prose {
    font-size: 1.02rem;
    line-height: 1.72;
    color: var(--mc-ink-soft);
}

.mc-prose > * + * {
    margin-top: 1em;
}

.mc-prose h2 {
    font-family: var(--mc-font-display);
    font-size: var(--mc-text-h2);
    font-weight: 500;
    line-height: 1.14;
    letter-spacing: -0.012em;
    color: var(--mc-ink);
    margin-top: 2.1em;
    padding-top: 0.55em;
    border-top: 1px solid var(--mc-rule);
}

.mc-prose h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.mc-prose h3 {
    font-family: var(--mc-font-body);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.005em;
    color: var(--mc-ink);
    margin-top: 1.9em;
}

.mc-prose ul,
.mc-prose ol {
    padding-left: 0;
    display: grid;
    gap: 0.55rem;
}

.mc-prose ul > li {
    position: relative;
    padding-left: 1.35rem;
}

.mc-prose ul > li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.72em;
    width: 7px;
    height: 7px;
    background: var(--mc-marigold);
    transform: rotate(45deg);
}

.mc-prose ol {
    counter-reset: mc-li;
}

.mc-prose ol > li {
    position: relative;
    padding-left: 1.9rem;
    counter-increment: mc-li;
}

.mc-prose ol > li::before {
    content: counter(mc-li) ".";
    position: absolute;
    left: 0;
    top: 0;
    font-family: var(--mc-font-display);
    font-size: 0.95em;
    color: var(--mc-marigold-deep);
    font-weight: 600;
}

.mc-prose a {
    color: var(--mc-ink-pine);
    text-decoration: underline;
    text-decoration-color: var(--mc-marigold);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    /* Long partner URLs must wrap inside the prose column, not widen it. */
    overflow-wrap: anywhere;
    transition: color var(--mc-dur-fast) var(--mc-ease-out),
        text-decoration-color var(--mc-dur-fast) var(--mc-ease-out);
}

.mc-prose a:hover {
    color: var(--mc-brick);
    text-decoration-color: var(--mc-brick);
}

.mc-prose code {
    font-family: ui-monospace, "SFMono-Regular", "Consolas", monospace;
    font-size: 0.86em;
    padding: 0.12em 0.4em;
    background: var(--mc-marigold-wash);
    border-radius: var(--mc-radius-xs);
}

.mc-prose strong {
    color: var(--mc-ink);
    font-weight: 700;
}

/* ------------------------------------------------------------------
   5 · Spacing helpers
   ------------------------------------------------------------------
   These exist so repeated one-off margins are declared once instead of being
   sprinkled as inline style attributes across templates.
   ------------------------------------------------------------------ */
.mc-mt-sm {
    margin-top: var(--mc-space-sm);
}

.mc-mt-lg {
    margin-top: var(--mc-space-lg);
}

/* ------------------------------------------------------------------
   6 · Accessibility helpers
   ------------------------------------------------------------------ */

/* Touch-target floor: every interactive control is at least 44px tall.
   Inline links inside running prose keep their natural height — enlarging
   them would break the text rhythm — so this only applies to chrome. */
:is(.mc-nav__link, .mc-index__row, .mc-chip, .mc-btn, .mc-link,
    .mc-drawer-rail__link, .mc-legal__toc a, .mc-colophon__list a,
    .mc-colophon__cats a, .mc-indexbtn, .mc-index__close,
    .mc-colophon__bottom a, .mc-drawer__thumb, .mc-drawer__more,
    .mc-relcard__link) {
    min-height: 44px;
    min-width: 44px;
}
.mc-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Scroll reveal — opacity + translate only, never layout properties.
   Progressive enhancement: the hidden start state only applies once JS has
   confirmed it can observe elements (it sets .mc-js on <html>). If a script
   fails to load, every reveal block stays fully visible instead of blank. */
.mc-js .mc-reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity var(--mc-dur-slow) var(--mc-ease-out),
        transform var(--mc-dur-slow) var(--mc-ease-out);
    will-change: opacity, transform;
}

.mc-js .mc-reveal.is-in {
    opacity: 1;
    transform: none;
    will-change: auto;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .mc-js .mc-reveal,
    .mc-reveal {
        opacity: 1;
        transform: none;
    }
}
