/* Material system (SPEC_v3 §1). Loaded first on every page; the component sheets (tcg, codex, landing, packs) use these
   tokens and recipes.

   Texture atlas: dist/assets/materials/*.webp, built by scripts/materials.mjs — tileable neutral-grey height-shaded
   tiles (mean ≈ 128, light from the top-left), laid over a colour with a blend mode so the colour stays and the
   material adds relief. Each tile is shown at a third of its pixel size (crisp up to DPR 3).
   Inside a card (it moves every frame) no element's background mixes a raster (url) with a gradient: Chromium
   re-records such a background on every frame unless the element has its own composited layer
   (tests/motion.spec.ts pins 0 Paint while tilting / swiping). Card parts therefore lay a tile over a flat colour
   (background-color + blend) and put gradients (sheen, vignette) on a separate pseudo-element. Image values are also
   written literally rather than through var(), so a style recalc never builds a new image.
   Ornaments: dist/assets/img/*.svg from scripts/lib/{sigil,ornaments}.mjs — masks (white = metal shows) or engraving.

   Recipes (all light from the top-left):
     gold leaf       --mat-gold over a metal gradient, hard-light; engraved edge + bevel from inset shadows
     blackened steel --mat-steel over a dark gradient, hard-light at low contrast
     tooled leather  --mat-leather over a hide colour + a blind/gilt tooling lattice
     vellum          --mat-vellum over parchment, multiply-ish (soft-light) + darkened edges
     wax             --mat-wax over an oxblood radial, hard-light; irregular outline from seal.svg */
:root {
  --mat-leather-size: 192px;
  --mat-gold-size: 128px;
  --mat-steel-size: 128px;
  --mat-vellum-size: 192px;
  --mat-wax-size: 128px;
  --metal-gold: linear-gradient(135deg, #f6e3a1 0%, #b88a2c 18%, #f3d98b 34%, #8a6420 52%, #e9c874 70%, #a47a26 86%, #f6e3a1 100%);
  --metal-plate: linear-gradient(180deg, #f6e2a2, #dcb55c 48%, #b48a34 78%, #9a7428);
  --metal-steel: linear-gradient(175deg, #34323a, #1b1a20 42%, #26242b 70%, #111014);
  --wax-red: radial-gradient(circle at 36% 30%, #a3302f, #761a1e 38%, #4e0c11 72%, #2e0508);
  --oxblood: #5c1416;
  --engrave-dark: rgba(62, 38, 4, 0.7);
  --engrave-lit: rgba(255, 246, 214, 0.55);
}

/* ---------- the gilt sigil: gold leaf seen through the sigil, facet shading over it, pressed into its ground ---------- */
.gilt-sigil { position: relative; display: block; width: 100%; aspect-ratio: 1;
  filter: drop-shadow(0 -0.06em 0 rgba(0, 0, 0, 0.55)) drop-shadow(0 0.05em 0 rgba(255, 228, 170, 0.18)); }
.gilt-sigil::before, .gilt-sigil::after { content: ''; position: absolute; inset: 0; }
.gilt-sigil::before {
  background: url("../materials/gold.webp?v=1a1d0dbee7") 0 0 / 128px, linear-gradient(135deg, #f6e3a1 0%, #b88a2c 18%, #f3d98b 34%, #8a6420 52%, #e9c874 70%, #a47a26 86%, #f6e3a1 100%);
  background-blend-mode: hard-light, normal;
  -webkit-mask: url("../img/sigil-mask.svg?v=a755ada8a8") center / contain no-repeat; mask: url("../img/sigil-mask.svg?v=a755ada8a8") center / contain no-repeat;
}
.gilt-sigil::after { background: url("../img/sigil-shade.svg?v=a2bc2a3b4f") center / contain no-repeat; }

/* ---------- engraved gold plate (primary buttons) ---------- */
.mat-plate {
  position: relative; isolation: isolate;
  background: url("../materials/gold.webp?v=1a1d0dbee7") 0 0 / 128px, linear-gradient(180deg, #f6e2a2, #dcb55c 48%, #b48a34 78%, #9a7428);
  background-blend-mode: hard-light, normal;
  color: #1d1206; text-shadow: 0 1px 0 rgba(255, 240, 200, 0.55);
  box-shadow: inset 0 1px 0 rgba(255, 250, 228, 0.8), inset 0 -2px 0 rgba(96, 62, 12, 0.6), inset 0 0 0 1px rgba(110, 74, 18, 0.75),
    0 1px 0 rgba(0, 0, 0, 0.6), 0 10px 24px rgba(201, 162, 74, 0.24);
}
.mat-plate::before { /* the engraved groove a few px in, with its lit lower lip */
  content: ''; position: absolute; inset: 5px; z-index: -1; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 1px 0 var(--engrave-dark), inset 0 0 0 1px rgba(96, 62, 12, 0.35), 0 1px 0 var(--engrave-lit);
}
.mat-plate:active, .mat-plate.is-pressed {
  transform: translateY(1px);
  box-shadow: inset 0 2px 6px rgba(70, 40, 4, 0.55), inset 0 0 0 1px rgba(110, 74, 18, 0.8), 0 0 0 rgba(0, 0, 0, 0), 0 4px 12px rgba(201, 162, 74, 0.18);
  filter: brightness(0.94);
}

/* ---------- blackened-steel plate with a gold rim (secondary controls) ---------- */
.mat-steel {
  background: url("../materials/steel.webp?v=2193069f85") 0 0 / 128px, linear-gradient(175deg, #34323a, #1b1a20 42%, #26242b 70%, #111014);
  background-blend-mode: hard-light, normal;
  color: var(--gold-hi);
  box-shadow: inset 0 0 0 1px rgba(214, 178, 96, 0.62), inset 0 0 0 3px rgba(8, 7, 10, 0.75), inset 0 0 0 4px rgba(214, 178, 96, 0.2),
    inset 0 6px 10px -6px rgba(255, 255, 255, 0.14), 0 2px 0 rgba(0, 0, 0, 0.55), 0 6px 14px rgba(0, 0, 0, 0.4);
}
.mat-steel:active, .mat-steel.is-pressed {
  box-shadow: inset 0 0 0 1px rgba(214, 178, 96, 0.7), inset 0 3px 8px rgba(0, 0, 0, 0.75), 0 1px 0 rgba(0, 0, 0, 0.55);
  transform: translateY(1px);
}

/* ---------- wax ---------- */
.mat-wax {
  background: url("../materials/wax.webp?v=5d9bef09c3") 0 0 / 128px, radial-gradient(circle at 36% 30%, #a3302f, #761a1e 38%, #4e0c11 72%, #2e0508);
  background-blend-mode: hard-light, normal;
}

/* ---------- keyboard focus: a gold ring with a soft glow, on every control ---------- */
:is(.mat-plate, .mat-steel):focus-visible { outline: 2px solid var(--gold-hi); outline-offset: 3px; }
