/* ui/Theme — design tokens, base layer, shared primitives, motion policy.
   Contract: ./Theme.spec.md
   Load this before any other block stylesheet. */

/* The faces the mockups are drawn in: self-hosted, Latin-subset woff2s (SIL
   OFL, licences beside them), so the game keeps zero runtime dependencies and
   no CDN. A screen renders in the fallback until they arrive. */
@font-face {
  font-family: "Oxanium";
  src: url("../../../assets/fonts/oxanium.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../../../assets/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
/* Other languages (meta/Locale, docs/i18n.md §5): Inter's Latin-Extended (Polish, Turkish,
   …) and Cyrillic (Russian) subsets and Oxanium's Latin-Extended, each fetched only when a page
   draws a character in its range. Declared after the Latin faces, so they are tried first for
   their own ranges. Oxanium has no Cyrillic: Russian display text falls back to Inter. */
@font-face {
  font-family: "Inter";
  src: url("../../../assets/fonts/inter-latin-ext.woff2") format("woff2");
  font-weight: 100 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: "Inter";
  src: url("../../../assets/fonts/inter-cyrillic.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Oxanium";
  src: url("../../../assets/fonts/oxanium-latin-ext.woff2") format("woff2");
  font-weight: 200 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: "JetBrains Mono";
  src: url("../../../assets/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-display: swap;
}

:root {
  /* Surfaces */
  --qc-space-0: #05040c;
  --qc-space-1: #0c0b1a;
  --qc-space-2: #17152f;
  --qc-glass: rgba(12, 11, 28, 0.66);
  --qc-line: rgba(170, 180, 255, 0.14);
  --qc-line-strong: rgba(170, 180, 255, 0.32);

  /* Text */
  --qc-text: #eceeff;
  --qc-text-dim: #a6abcf;
  --qc-text-faint: #7a7fa6;

  /* Accents and meaning */
  --qc-accent: #9282ff;
  --qc-accent-2: #5de4ff;
  --qc-danger: #ff5a5f;
  --qc-hull: #dff3ff;
  --qc-xp: #a98bff;
  /* The earned currency, Quanta: its own role so it can move without touching
     every stylesheet. Ion cyan by default. */
  --qc-quanta: var(--qc-accent-2);
  --qc-mode-tanks: #f2894b;  /* the Tanks chassis's colour (ui/ChassisToggle; docs/tanks.md). Ships' is --qc-accent. */

  /* Ship identities — one per ship id. Fourteen classes must be told apart at a
     glance, so each stays at least 3:1 against --qc-space-0, ΔE 25 from another
     identity and ΔE 15 from any paint. */
  --qc-ship-laser: #ff4f9a;
  --qc-ship-plasma: #4dffb8;
  --qc-ship-rocket: #ffa04d;
  --qc-ship-scatter: #b4f03a;
  --qc-ship-arc: #31c1ff;
  --qc-ship-graviton: #c86bff;
  --qc-ship-shuriken: #0fd8e0;
  --qc-ship-gatling: #8899b0;
  --qc-ship-tesla: #3f66ff;
  /* A hot red-orange flame: ΔE 50 from the rocket's amber, 22 from the ember paint. */
  --qc-ship-inferno: #ff3300;
  /* Brass-and-steel armour, a fortress: ΔE 39 from the rocket's amber, 38 from the gold paint. */
  --qc-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. */
  --qc-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). */
  --qc-ship-chrono: #ffcc00;
  /* The Foundry's coral (docs/ships.md §9.2): ΔE 34 from the rocket, 26 from the crimson paint. */
  --qc-ship-foundry: #ff7466;

  /* Card rarities — one per rarity id */
  --qc-rarity-common: #aab2c8;
  --qc-rarity-rare: #4da3ff;
  --qc-rarity-epic: #b86bff;
  --qc-rarity-legendary: #ffc53d;

  /* Ship paints — mastery variant hull and accent colours, one per paint key.
     Each stays at least 3:1 against --qc-space-0. */
  --qc-paint-crimson: #ff2d55;
  --qc-paint-solar: #ffe94f;
  --qc-paint-ember: #ff6a2b;
  --qc-paint-emerald: #23e87f;
  --qc-paint-ice: #a6f0ff;
  --qc-paint-chrome: #d6deeb;
  --qc-paint-void: #7b4bff;
  --qc-paint-magenta: #ff3de0;
  --qc-paint-gold: #f5c24c;
  --qc-paint-aurora: #78a6ff;
  --qc-paint-amber: #f0b94a;

  /* Shades: dark hulls, under 3:1 against --qc-space-0 on purpose. A shade is only
     ever a hull, never an accent: the rim and glow around it are what is read
     (client/Renderer, Shade hulls). */
  --qc-shade-lampblack: #2a2520;

  /* Type */
  /* Instrument lettering for the command deck: rail, buttons, panel headers,
     ship names. Uppercase, tracked, 13 px and up. */
  --qc-font-display: "Oxanium", "Chakra Petch", var(--qc-font-ui);
  --qc-font-ui: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  --qc-font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  /* Shape and motion */
  --qc-radius: 12px;
  /* The deck's two glow radii; a block tints them with its own colour. */
  --qc-glow-sm: 12px;
  --qc-glow-lg: 24px;
  --qc-radius-sm: 6px;
  --qc-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --qc-dur-fast: 120ms;
  --qc-dur: 260ms;
}

/* ---------------------------------------------------------------- base --- */

.qc-root {
  color-scheme: dark;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background-color: var(--qc-space-0);
  background-image:
    radial-gradient(ellipse 70% 55% at 78% 8%, rgba(146, 130, 255, 0.13), transparent 62%),
    radial-gradient(ellipse 55% 45% at 8% 96%, rgba(93, 228, 255, 0.07), transparent 60%);
  background-repeat: no-repeat;
  background-attachment: fixed; /* one glow per viewport, no tiling seam when content scrolls */
  color: var(--qc-text);
  font-family: var(--qc-font-ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

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

/* ----------------------------------------------------------- starfield --- */

/* Two tiled star layers drifting at different speeds give a cheap parallax.
   Each layer moves by exactly one tile so the loop is seamless. */
.qc-starfield {
  position: relative;
  isolation: isolate;
  overflow: hidden;
}

.qc-starfield::before,
.qc-starfield::after {
  content: "";
  position: fixed;
  inset: -400px;
  z-index: -1;
  pointer-events: none;
}

.qc-starfield::before {
  background-image:
    radial-gradient(1px 1px at 23px 41px, rgba(255, 255, 255, 0.85), transparent 60%),
    radial-gradient(1px 1px at 131px 97px, rgba(255, 255, 255, 0.5), transparent 60%),
    radial-gradient(1.4px 1.4px at 187px 211px, rgba(200, 210, 255, 0.75), transparent 60%),
    radial-gradient(1px 1px at 71px 173px, rgba(255, 255, 255, 0.35), transparent 60%),
    radial-gradient(1px 1px at 229px 19px, rgba(255, 255, 255, 0.45), transparent 60%);
  background-size: 260px 260px;
  opacity: 0.55;
  animation: qc-drift-near 150s linear infinite;
}

.qc-starfield::after {
  background-image:
    radial-gradient(1.8px 1.8px at 60px 300px, rgba(190, 175, 255, 0.8), transparent 60%),
    radial-gradient(1.2px 1.2px at 330px 120px, rgba(160, 235, 255, 0.7), transparent 60%),
    radial-gradient(1px 1px at 210px 380px, rgba(255, 255, 255, 0.6), transparent 60%);
  background-size: 400px 400px;
  opacity: 0.45;
  animation: qc-drift-far 260s linear infinite;
}

@keyframes qc-drift-near {
  to { transform: translate3d(-260px, -260px, 0); }
}

@keyframes qc-drift-far {
  to { transform: translate3d(-400px, 0, 0); }
}

/* ---------------------------------------------------------- primitives --- */

.qc-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;
}

.qc-eyebrow {
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--qc-text-faint);
}

.qc-kbd {
  display: inline-grid;
  place-items: center;
  min-width: 1.75em;
  height: 1.75em;
  padding: 0 0.45em;
  font: 600 12px/1 var(--qc-font-mono);
  color: var(--qc-text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--qc-line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
}

.qc-button {
  appearance: none;
  margin: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.qc-button:disabled {
  cursor: not-allowed;
}

.qc-button--primary {
  /* The command deck's primary action (docs/premium-pass.md §1.4): a dark
     glass fill edged and lit in --qc-action — the selected ship's colour where
     a block sets it, quantum violet otherwise — in the instrument face. */
  --qc-action: var(--qc-accent);
  position: relative;
  min-width: 280px;
  min-height: 48px;
  padding: 16px 36px;
  font-family: var(--qc-font-display);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  text-transform: uppercase;
  color: var(--qc-text);
  background: linear-gradient(180deg, color-mix(in srgb, var(--qc-action) 22%, var(--qc-space-2)), var(--qc-space-2));
  border: 1px solid var(--qc-action);
  border-radius: var(--qc-radius-sm);
  box-shadow:
    0 0 var(--qc-glow-sm) color-mix(in srgb, var(--qc-action) 35%, transparent),
    inset 0 0 18px color-mix(in srgb, var(--qc-action) 18%, transparent);
  transition: box-shadow var(--qc-dur-fast) var(--qc-ease-out), transform 80ms var(--qc-ease-out), border-color var(--qc-dur-fast) var(--qc-ease-out);
}

/* The corner brackets (premium-pass §1.4): four 8 px corners 8 px outside the
   button in its action colour, spreading 3 px on hover. One pseudo-element,
   eight 1 px gradient strokes. */
.qc-button--primary::before {
  --qc-bracket: color-mix(in srgb, var(--qc-action) 60%, transparent);
  content: "";
  position: absolute;
  inset: -8px;
  pointer-events: none;
  background:
    linear-gradient(var(--qc-bracket), var(--qc-bracket)) left top / 8px 1px no-repeat,
    linear-gradient(var(--qc-bracket), var(--qc-bracket)) left top / 1px 8px no-repeat,
    linear-gradient(var(--qc-bracket), var(--qc-bracket)) right top / 8px 1px no-repeat,
    linear-gradient(var(--qc-bracket), var(--qc-bracket)) right top / 1px 8px no-repeat,
    linear-gradient(var(--qc-bracket), var(--qc-bracket)) left bottom / 8px 1px no-repeat,
    linear-gradient(var(--qc-bracket), var(--qc-bracket)) left bottom / 1px 8px no-repeat,
    linear-gradient(var(--qc-bracket), var(--qc-bracket)) right bottom / 8px 1px no-repeat,
    linear-gradient(var(--qc-bracket), var(--qc-bracket)) right bottom / 1px 8px no-repeat;
  transition: inset var(--qc-dur-fast) var(--qc-ease-out);
}

.qc-button--primary:not(:disabled):hover::before {
  inset: -11px;
}

.qc-button--primary:disabled::before {
  --qc-bracket: var(--qc-line);
}

/* The scanline: one lighter bar sweeps across once on hover. */
.qc-button--primary::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--qc-text) 16%, transparent) 50%, transparent 100%) no-repeat;
  background-size: 30% 100%;
  background-position: -40% 0;
}

.qc-button--primary:not(:disabled):hover {
  box-shadow:
    0 0 var(--qc-glow-lg) color-mix(in srgb, var(--qc-action) 55%, transparent),
    inset 0 0 18px color-mix(in srgb, var(--qc-action) 22%, transparent);
}

.qc-button--primary:not(:disabled):hover::after {
  animation: qc-scanline 420ms var(--qc-ease-out) 1 both;
}

@keyframes qc-scanline {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}

.qc-button--primary:not(:disabled):active {
  transform: scale(0.97);
  border-color: var(--qc-text);
}

.qc-button--primary:disabled {
  color: var(--qc-text-faint);
  background: var(--qc-space-2);
  border-color: var(--qc-line);
  box-shadow: none;
}

.qc-button--ghost {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--qc-text-dim);
  border: 1px solid var(--qc-line-strong);
  border-radius: 999px;
  transition: color var(--qc-dur-fast), border-color var(--qc-dur-fast);
}

.qc-button--ghost:hover {
  color: var(--qc-text);
  border-color: var(--qc-text-faint);
}

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

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