/* Candy Keno: numbered-board candy-disc finish.
   Loaded AFTER board-skins.css. Paints only #numberGrid tile appearance for
   the Candy theme (also when no data-theme is set, the legacy Candy default).
   Geometry (size, grid, font-size, touch targets, font-family) is left to
   style.css / fx.css / game-layout.css; nothing here changes box size.

   Colour flows through --ct-* custom properties:
     - defaults below are Candy-default-only values;
     - board-skins.css remaps them from the existing --bs-* / --skin-* formulas
       for the six district skins, so skins keep their exact palettes.

   State precedence (later wins; written in this order on purpose):
     base < hover (plain tiles only) < selected < drawn miss < match (hit)
     Miss is .is-drawn:not(.is-match), so match never competes with it; match
     is written after selected so a hit pick shows gold.
   Non-colour cues: selected = solid inner ring, hit = double ring,
   miss = dashed ring. Focus is a separate 2px outline. */

/* ---------- Default Candy palette (non-skinned only) ---------- */
body:is([data-theme="candy"], :not([data-theme])) #numberGrid {
  --ct-face-hi: #fffaf3;
  --ct-face: #fdeef3;
  --ct-face-lo: #efe4f8;
  --ct-rim: #f0e6f5;
  --ct-inner-rim: rgba(255, 255, 255, .85);
  --ct-depth: #d9c2e9;
  --ct-shadow: rgba(99, 48, 129, .14);
  --ct-ink: #633081;
  --ct-focus: #2a0f3d;

  --ct-sel-hi: #c3336d;
  --ct-sel: #ad215a;
  --ct-sel-rim: #fff3f8;
  --ct-sel-depth: #81164b;
  --ct-sel-ink: #fffaf3;

  --ct-hit-hi: var(--yellow-light);
  --ct-hit: var(--yellow-main);
  --ct-hit-rim: var(--yellow-light);
  --ct-hit-depth: var(--yellow-dark);
  --ct-hit-ink: #69400a;
  --ct-hit-halo: color-mix(in srgb, var(--yellow-main) 60%, transparent);
}

/* ---------- Base disc ---------- */
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button {
  position: relative;
  isolation: isolate; /* z-index:-1 decorations sit above the face, below the numeral */
  border-radius: 50%;
  border: 2px solid var(--ct-rim);
  background: radial-gradient(circle at 50% 30%, var(--ct-face-hi) 0%, var(--ct-face) 55%, var(--ct-face-lo) 100%);
  color: var(--ct-ink);
  text-shadow: 0 1px 0 color-mix(in srgb, var(--ct-face-hi) 70%, transparent);
  box-shadow:
    inset 0 0 0 2px var(--ct-inner-rim),
    inset 0 -3px 5px color-mix(in srgb, var(--ct-depth) 45%, transparent),
    0 4px 0 var(--ct-depth),
    0 5px 8px var(--ct-shadow);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
/* Small gloss cap, kept in the top band clear of the numeral. */
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 8%;
  left: 30%;
  width: 40%;
  height: 15%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.8), rgba(255,255,255,0));
  pointer-events: none;
}
/* State ring (non-colour cue): transparent by default. */
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 3px;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
}

/* ---------- Hover (subtle, plain tiles only) ---------- */
@media (hover: hover) {
  body:is([data-theme="candy"], :not([data-theme])) #numberGrid button:not(:disabled):not(.is-selected):not(.is-drawn):not(.is-match):hover {
    filter: brightness(1.03) saturate(1.08);
    box-shadow:
      inset 0 0 0 2px var(--ct-inner-rim),
      inset 0 -3px 5px color-mix(in srgb, var(--ct-depth) 55%, transparent),
      0 4px 0 var(--ct-depth),
      0 6px 10px var(--ct-shadow);
  }
}

/* ---------- Selected: berry disc, solid cream ring ---------- */
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-selected {
  border-color: var(--ct-sel-rim);
  background: radial-gradient(circle at 50% 30%, var(--ct-sel-hi) 0%, var(--ct-sel) 70%);
  color: var(--ct-sel-ink);
  text-shadow: 0 1px 1px color-mix(in srgb, var(--ct-sel-depth) 70%, transparent);
  box-shadow:
    inset 0 -3px 5px color-mix(in srgb, var(--ct-sel-depth) 50%, transparent),
    0 4px 0 var(--ct-sel-depth),
    0 5px 9px color-mix(in srgb, var(--ct-sel-depth) 35%, transparent);
  transform: scale(1.05);
}
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-selected::after {
  border: 2px solid color-mix(in srgb, var(--ct-sel-rim) 80%, transparent);
}

/* ---------- Drawn miss: intentionally grey, dashed ring ---------- */
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-drawn:not(.is-match) {
  border-color: #94a3b8;
  background: radial-gradient(circle at 50% 30%, #e2e8f0 0%, #cbd5e1 65%);
  color: #475569;
  text-shadow: none;
  box-shadow: inset 0 -2px 4px rgba(71, 85, 105, .2), 0 4px 0 #94a3b8;
  filter: none;
}
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-drawn:not(.is-match)::before { opacity: .45; }
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-drawn:not(.is-match)::after {
  border: 2px dashed rgba(71, 85, 105, .4);
}

/* ---------- Match (hit): warm gold, double ring. After selected => wins. ---------- */
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-match {
  border-color: var(--ct-hit-rim);
  background: radial-gradient(circle at 50% 30%, var(--ct-hit-hi) 0%, var(--ct-hit) 70%);
  color: var(--ct-hit-ink);
  text-shadow: 0 1px 0 color-mix(in srgb, var(--ct-hit-hi) 70%, transparent);
  box-shadow:
    inset 0 -3px 5px color-mix(in srgb, var(--ct-hit-depth) 45%, transparent),
    0 4px 0 var(--ct-hit-depth),
    0 0 8px var(--ct-hit-halo);
  filter: none;
}
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-match::after {
  inset: 2px;
  border: 4px double color-mix(in srgb, var(--ct-hit-depth) 75%, transparent);
}

/* ---------- Locked board: picks and hits keep full colour ---------- */
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button:disabled { opacity: 1; filter: none; }

/* ---------- Focus: tight 2px outline, raised above neighbours ---------- */
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button:focus-visible {
  z-index: 1;
  outline: 2px solid var(--ct-focus);
  outline-offset: 1px;
}

/* ---------- Press. Global button:active is translateY(4px) !important,
   so transforms here are !important too. Depth shrinks as the disc drops,
   footprint unchanged. Order: plain < selected < hit < hit+selected. ---------- */
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button:not(:disabled):active {
  transform: translateY(3px) !important;
  box-shadow:
    inset 0 0 0 2px var(--ct-inner-rim),
    inset 0 2px 4px color-mix(in srgb, var(--ct-depth) 50%, transparent),
    0 1px 0 var(--ct-depth);
}
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-selected:not(:disabled):active {
  transform: scale(1.05) translateY(3px) !important;
  box-shadow: inset 0 2px 4px color-mix(in srgb, var(--ct-sel-depth) 50%, transparent), 0 1px 0 var(--ct-sel-depth);
}
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-match:not(:disabled):active {
  box-shadow: inset 0 2px 4px color-mix(in srgb, var(--ct-hit-depth) 50%, transparent), 0 1px 0 var(--ct-hit-depth);
}
/* Disabled tiles never sink (selected keeps its scale). */
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button:disabled:active { transform: none !important; }
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-selected:disabled:active { transform: scale(1.05) !important; }

/* ---------- FX shimmer: keep numerals readable (CSS only) ---------- */
body:is([data-theme="candy"], :not([data-theme])) #numberGrid button .fx-shimmer-clip { mix-blend-mode: soft-light; }

/* ---------- Reduced motion: shadow-only press, no translation ----------
   Same selectors as the press block, written later, so they win. */
@media (prefers-reduced-motion: reduce) {
  /* Beat the shared 0.01ms !important fallback with a genuinely static tile. */
  body:is([data-theme="candy"], :not([data-theme])) #numberGrid button { transition: none !important; }
  body:is([data-theme="candy"], :not([data-theme])) #numberGrid button:not(:disabled):active { transform: none !important; }
  body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-selected:not(:disabled):active { transform: scale(1.05) !important; }
}
body.fx-reduced-motion:is([data-theme="candy"], :not([data-theme])) #numberGrid button { transition: none !important; }
body.fx-reduced-motion:is([data-theme="candy"], :not([data-theme])) #numberGrid button:not(:disabled):active { transform: none !important; }
body.fx-reduced-motion:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-selected:not(:disabled):active { transform: scale(1.05) !important; }

/* ---------- Forced colours ----------
   :not(#ct-none) adds ID weight so these beat every state/press/hover rule
   above. Hit is written after selected so a hit pick reads as a hit. */
@media (forced-colors: active) {
  html body:is([data-theme="candy"], :not([data-theme])) #numberGrid button:not(#ct-none) {
    forced-color-adjust: none;
    background: ButtonFace;
    color: ButtonText;
    border: 2px solid ButtonText;
    box-shadow: none;
    text-shadow: none;
    filter: none;
  }
  html body:is([data-theme="candy"], :not([data-theme])) #numberGrid button:not(#ct-none)::before { display: none; }
  html body:is([data-theme="candy"], :not([data-theme])) #numberGrid button:not(#ct-none)::after { border-color: transparent; }

  html body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-selected:not(#ct-none) {
    background: Highlight;
    color: HighlightText;
    border-color: HighlightText;
  }
  html body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-selected:not(#ct-none)::after {
    border: 2px solid HighlightText;
  }

  html body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-drawn:not(.is-match):not(#ct-none) {
    background: Canvas;
    color: GrayText;
    border-color: GrayText;
  }
  html body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-drawn:not(.is-match):not(#ct-none)::after {
    border: 2px dashed GrayText;
  }

  html body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-match:not(#ct-none) {
    background: Highlight;
    color: HighlightText;
    border-color: HighlightText;
  }
  html body:is([data-theme="candy"], :not([data-theme])) #numberGrid button.is-match:not(#ct-none)::after {
    inset: 2px;
    border: 4px double HighlightText;
  }

  html body:is([data-theme="candy"], :not([data-theme])) #numberGrid button:not(#ct-none):focus-visible {
    outline: 2px solid CanvasText;
    outline-offset: 1px;
  }
}
