/* ui/Theme — design tokens, base layer, shared primitives, motion policy.
   Contract: ./Theme.spec.md
   Load this before any other block stylesheet; ./skin.css after the last one. */

/* The three faces: self-hosted variable woff2s (SIL OFL, licences beside them), so the game keeps
   zero runtime dependencies and no CDN. Each comes as three subsets: Latin, Latin-Extended (Polish,
   Turkish, …) and Cyrillic (Russian), each fetched only when a page draws a character in its range
   (docs/i18n.md §5). A screen renders in the fallback until they arrive. */
@font-face {
  font-family: "Oswald";
  src: url("../../../assets/fonts/oswald-latin.woff2") format("woff2");
  font-weight: 200 700;
  font-display: swap;
}
@font-face {
  font-family: "Oswald";
  src: url("../../../assets/fonts/oswald-latin-ext.woff2") format("woff2");
  font-weight: 200 700;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Oswald";
  src: url("../../../assets/fonts/oswald-cyrillic.woff2") format("woff2");
  font-weight: 200 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Rubik";
  src: url("../../../assets/fonts/rubik-latin.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}
@font-face {
  font-family: "Rubik";
  src: url("../../../assets/fonts/rubik-latin-ext.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Rubik";
  src: url("../../../assets/fonts/rubik-cyrillic.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Martian Mono";
  src: url("../../../assets/fonts/martian-mono-latin.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}
@font-face {
  font-family: "Martian Mono";
  src: url("../../../assets/fonts/martian-mono-latin-ext.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Martian Mono";
  src: url("../../../assets/fonts/martian-mono-cyrillic.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

:root {
  /* Surfaces: the bay's floor, a plate, a raised plate. Warm, matte, near black. */
  --sp-space-0: #131211;
  --sp-space-1: #201e1b;
  --sp-space-2: #302c28;
  --sp-glass: rgba(28, 26, 23, 0.94);
  --sp-line: rgba(255, 236, 210, 0.14);
  --sp-line-strong: rgba(255, 236, 210, 0.34);
  /* The gap between two plates, and the dark lettering on a bright one. */
  --sp-seam: #050505;
  --sp-ink: #150c04;
  /* A plate's lit top edge and the lip under it, for bevels. */
  --sp-edge-light: rgba(255, 240, 220, 0.13);
  --sp-edge-dark: rgba(0, 0, 0, 0.55);
  /* The inside of a gauge or a socket. */
  --sp-well: #0b0a09;
  --sp-rivet: #8a8276;

  /* What every panel is made of. A plate: matte, lit from above. Its four rivets. Its bevel: a lit top
     edge, a dark lip, the shadow it stands on. A socket's inset. Hazard tape. A gauge's blocks of fill. */
  --sp-plate: linear-gradient(180deg, #2b2825 0%, #211f1c 55%, #1c1a18 100%);
  --sp-rivets:
    radial-gradient(circle at 9px 9px, var(--sp-rivet) 0 1.6px, var(--sp-well) 2.2px 3.2px, transparent 3.6px),
    radial-gradient(circle at calc(100% - 9px) 9px, var(--sp-rivet) 0 1.6px, var(--sp-well) 2.2px 3.2px, transparent 3.6px),
    radial-gradient(circle at 9px calc(100% - 9px), var(--sp-rivet) 0 1.6px, var(--sp-well) 2.2px 3.2px, transparent 3.6px),
    radial-gradient(circle at calc(100% - 9px) calc(100% - 9px), var(--sp-rivet) 0 1.6px, var(--sp-well) 2.2px 3.2px, transparent 3.6px);
  --sp-bevel: inset 0 1px 0 var(--sp-edge-light), inset 0 -2px 0 rgba(0, 0, 0, 0.45), 0 3px 0 var(--sp-edge-dark);
  --sp-inset: inset 0 2px 3px rgba(0, 0, 0, 0.7), 0 1px 0 var(--sp-edge-light);
  --sp-tape: repeating-linear-gradient(-45deg, var(--sp-hazard) 0 9px, var(--sp-space-0) 9px 18px);
  --sp-gauge: repeating-linear-gradient(90deg, var(--sp-hazard) 0 7px, transparent 7px 9px);

  /* Text */
  --sp-text: #f4eee4;
  --sp-text-dim: #c6bcab;
  --sp-text-faint: #9f9484;

  /* Accents and meaning. Safety orange is you and what you press; arc blue is what is selected,
     current or focused; hazard yellow is tape and what is in progress; brass is what you earned. */
  --sp-accent: #ff7a1a;
  --sp-accent-2: #62c6ff;
  --sp-select: var(--sp-accent-2);
  --sp-hazard: #ffd23f;
  --sp-danger: #ff5c70;
  --sp-hull: #f4eee4;
  --sp-xp: #ffd23f;
  /* The earned currency, Sprokets: brass, its own role so it can move without touching every stylesheet. */
  --sp-quanta: #e9c46a;
  /* A trade's two directions. Up is green, down is amber, never red: a trade is not damage. */
  --sp-up: #7bd88f;
  --sp-down: #ffb020;
  --sp-mode-tanks: #f2894b;

  /* The blueprint creator's drafting sheet (ui/BlueprintBuilder's board and viewer only): blueprint
     blue paper, chalk lines, chalk lettering. */
  --sp-sheet: #0a2140;
  --sp-sheet-raised: #0e2a50;
  --sp-sheet-line: rgba(190, 222, 255, 0.24);
  --sp-sheet-line-strong: rgba(190, 222, 255, 0.55);
  --sp-sheet-ink: #f2f8ff;
  --sp-sheet-ink-dim: #bcd3ec;

  /* Ship identities — one per ship id. Fourteen classes must be told apart at a
     glance, so each stays at least 3:1 against --sp-space-0, ΔE 25 from another
     identity and ΔE 15 from any paint. */
  --sp-ship-laser: #ff4f9a;
  --sp-ship-plasma: #4dffb8;
  --sp-ship-rocket: #ffa04d;
  --sp-ship-scatter: #b4f03a;
  --sp-ship-arc: #31c1ff;
  --sp-ship-graviton: #c86bff;
  --sp-ship-shuriken: #0fd8e0;
  --sp-ship-gatling: #8899b0;
  --sp-ship-tesla: #3f66ff;
  /* A hot red-orange flame: ΔE 50 from the rocket's amber, 22 from the ember paint. */
  --sp-ship-inferno: #ff3300;
  /* Brass-and-steel armour, a fortress: ΔE 39 from the rocket's amber, 38 from the gold paint. */
  --sp-ship-warden: #c0a878;
  /* Kelp green, the sea the hook is thrown across: ΔE 34 from the plasma's mint, 37 from the scatter's lime, 27 from the emerald paint. */
  --sp-ship-harpoon: #6fc05a;
  /* The Chrono's brass-gold (docs/ships.md §9.1): ΔE 39 from the nearest
     identity (the rocket), 19 from the nearest paint (solar). */
  --sp-ship-chrono: #ffcc00;
  /* The Foundry's coral (docs/ships.md §9.2): ΔE 34 from the rocket, 26 from the crimson paint. */
  --sp-ship-foundry: #ff7466;

  /* Card rarities — one per rarity id */
  --sp-rarity-common: #aab2c8;
  --sp-rarity-rare: #4da3ff;
  --sp-rarity-epic: #b86bff;
  --sp-rarity-legendary: #ffc53d;

  /* Ship paints — mastery variant hull and accent colours, one per paint key.
     Each stays at least 3:1 against --sp-space-0. */
  --sp-paint-crimson: #ff2d55;
  --sp-paint-solar: #ffe94f;
  --sp-paint-ember: #ff6a2b;
  --sp-paint-emerald: #23e87f;
  --sp-paint-ice: #a6f0ff;
  --sp-paint-chrome: #d6deeb;
  --sp-paint-void: #7b4bff;
  --sp-paint-magenta: #ff3de0;
  --sp-paint-gold: #f5c24c;
  --sp-paint-aurora: #78a6ff;

  /* Type */
  /* Stamped lettering for tabs, buttons, panel headers and names: condensed, uppercase, 13 px and up. */
  --sp-font-display: "Oswald", "Bahnschrift Condensed", "Arial Narrow", var(--sp-font-ui);
  --sp-font-ui: "Rubik", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --sp-font-mono: "Martian Mono", ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  /* Shape and motion */
  --sp-radius: 4px;
  --sp-radius-sm: 3px;
  /* Nothing glows: the two radii the blocks' shadows are written with are zero. */
  --sp-glow-sm: 0px;
  --sp-glow-lg: 0px;
  --sp-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --sp-dur-fast: 120ms;
  --sp-dur: 260ms;
}

/* ---------------------------------------------------------------- base --- */

.sp-root {
  color-scheme: dark;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background-color: var(--sp-space-0);
  /* The bay light: one warm pool, fixed to the viewport. */
  background-image: radial-gradient(ellipse 80% 70% at 50% 40%, rgba(255, 214, 160, 0.05), transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--sp-text);
  font-family: var(--sp-font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.sp-root *,
.sp-root *::before,
.sp-root *::after {
  box-sizing: border-box;
}

.sp-root :focus-visible {
  outline: 2px solid var(--sp-accent-2);
  outline-offset: 3px;
}

/* ---------------------------------------------------------- primitives --- */

.sp-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.sp-eyebrow {
  font-family: var(--sp-font-display);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sp-text-faint);
}

.sp-kbd {
  display: inline-grid;
  place-items: center;
  min-width: 1.75em;
  height: 1.75em;
  padding: 0 0.45em;
  font: 600 12px/1 var(--sp-font-mono);
  color: var(--sp-text);
  background: var(--sp-space-2);
  border: 1px solid var(--sp-seam);
  border-bottom-width: 3px;
  border-radius: 3px;
  box-shadow: inset 0 1px 0 var(--sp-edge-light);
}

.sp-button {
  appearance: none;
  margin: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.sp-button:disabled {
  cursor: not-allowed;
}

.sp-button--primary {
  /* The one thing to press: a plate of --sp-action (safety orange unless a block sets it) with dark
     stamped lettering, standing on a lip it sinks into when pressed. */
  --sp-action: var(--sp-accent);
  position: relative;
  min-width: 280px;
  min-height: 48px;
  padding: 16px 36px;
  font-family: var(--sp-font-display);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  text-transform: uppercase;
  color: var(--sp-ink);
  background: linear-gradient(180deg, color-mix(in srgb, var(--sp-action) 86%, white), var(--sp-action) 45%);
  border: 2px solid var(--sp-seam);
  border-radius: var(--sp-radius);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    0 5px 0 color-mix(in srgb, var(--sp-action) 55%, black),
    0 8px 0 var(--sp-edge-dark);
  transition: transform 70ms linear, box-shadow 70ms linear, filter var(--sp-dur-fast) linear;
}

/* Hazard stripes on the plate's two ends. One pseudo-element, two striped strips, 22 px wide on a
   button wider than 220 px and absent on a narrower one, where they would run under its word. */
.sp-button--primary::before {
  --sp-stripe: color-mix(in srgb, var(--sp-ink) 82%, transparent);
  --sp-stripe-width: clamp(0px, calc((100% - 220px) * 999), 22px);
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 2px;
  pointer-events: none;
  background:
    repeating-linear-gradient(-45deg, var(--sp-stripe) 0 7px, transparent 7px 14px) left / var(--sp-stripe-width) 100% no-repeat,
    repeating-linear-gradient(-45deg, var(--sp-stripe) 0 7px, transparent 7px 14px) right / var(--sp-stripe-width) 100% no-repeat;
}

.sp-button--primary:not(:disabled):hover {
  filter: brightness(1.08);
}

.sp-button--primary:not(:disabled):active {
  transform: translateY(4px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.2),
    0 1px 0 color-mix(in srgb, var(--sp-action) 55%, black),
    0 2px 0 var(--sp-edge-dark);
}

.sp-button--primary:disabled {
  color: var(--sp-text-faint);
  background: var(--sp-space-2);
  box-shadow: inset 0 1px 0 var(--sp-edge-light), 0 3px 0 var(--sp-edge-dark);
}

.sp-button--primary:disabled::before {
  opacity: 0.2;
}

.sp-button--ghost {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-family: var(--sp-font-display);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sp-text);
  background: var(--sp-space-2);
  border: 1px solid var(--sp-seam);
  border-radius: var(--sp-radius-sm);
  box-shadow: inset 0 1px 0 var(--sp-edge-light), 0 3px 0 var(--sp-edge-dark);
  transition: background-color var(--sp-dur-fast), transform 70ms linear;
}

.sp-button--ghost:hover {
  background: color-mix(in srgb, var(--sp-text) 10%, var(--sp-space-2));
}

.sp-button--ghost:active {
  transform: translateY(2px);
}

/* -------------------------------------------------------------- motion --- */

@media (prefers-reduced-motion: reduce) {
  .sp-root,
  .sp-root::before,
  .sp-root::after,
  .sp-root *,
  .sp-root *::before,
  .sp-root *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
  }
}
