/*
 * CRITTERS lane: the avatar disc and ring (CR-07), frames (CR-20 to CR-23) and the honours ribbon (CR-30).
 * The critter replaces the initial inside the existing .av circle without changing its size, the presence dot or the
 * rank leaf badge. Identity reads first as colour (the disc tint and the ring), then as the animal.
 * Colour comes only from theme tokens (art_tokens.css and the desk's --p-1, --p-2, --p-3). No inline styles:
 * everything here is a stylesheet, so it holds under the desk's style-src 'self' policy.
 */

/* ---------- CR-07 the disc and the ring ---------- */
.av.crit { --art-person: var(--p-1); background: color-mix(in srgb, var(--art-person) 16%, var(--solid)); color: transparent; }
.av.crit[data-p="1"] { --art-person: var(--p-1); }
.av.crit[data-p="2"] { --art-person: var(--p-2); }
.av.crit[data-p="3"] { --art-person: var(--p-3); }
.av.crit > .crit-art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 50%; overflow: hidden; }
.av.crit::after { content: ""; position: absolute; inset: 0; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--art-person); pointer-events: none; z-index: 1; }
.av.crit > .dot, .av.crit > .leafb { z-index: 3; }
.av.crit > .crit-frm { position: absolute; left: -12.5%; top: -12.5%; width: 125%; height: 125%; overflow: visible; pointer-events: none; z-index: 2; }
.av.crit > .crit-art use, .av.crit > .crit-frm use { transform-box: view-box; transform-origin: 50% 50%; }
/* the bilby's ear tips: the one part of any critter allowed past the ring (fix round 2); above the ring and frame */
.av.crit > .crit-over { position: absolute; left: -12.5%; top: -12.5%; width: 125%; height: 125%; overflow: visible; pointer-events: none; z-index: 2; }
.av.crit > .crit-over use { transform-box: view-box; transform-origin: 50% 50%; }
@media (forced-colors: active) { .av.crit > .crit-over { display: none; } }
/* on the overlapping crew strip a framed avatar takes a small gap instead of the -8 px overlap, so frames never collide */
.crew .av.crit.crit-framed, .crew .av.crit.crit-framed + .av { margin-left: 7px; }
.crew .av.crit.crit-framed:first-child { margin-left: 0; }
/* frames and ribbons render at 32 px and up only */
.av.crit.av-sm > .crit-frm { display: none; }
@supports not (color: color-mix(in srgb, red 16%, white)) { .av.crit { background: var(--solid); } }

/* ---------- CR-30 honours ribbon colours (never the status, welfare or remembrance colours) ---------- */
.crit-frm [data-honour="wordsmith"] { --ribbon: var(--fauna-wren-blue-deep); }
.crit-frm [data-honour="eagle_eye"] { --ribbon: var(--flora-wattle-deep); }
.crit-frm [data-honour="bundler"] { --ribbon: var(--flora-bark); }
.crit-frm [data-honour="all_rounder"] { --ribbon: var(--flora-gum); }
.crit-frm [data-honour="teacher"] { --ribbon: var(--flora-wild-violet); }
.crit-frm [data-honour="good_mate"] { --ribbon: var(--fauna-lori-orange); }
.crit-frm [data-honour="trailblazer"] { --ribbon: var(--fauna-kooka-blue); }
.crit-frm [data-honour="field_naturalist"] { --ribbon: var(--fauna-lori-green); }
.crit-frm [data-honour="warm_word"] { --ribbon: var(--fauna-galah-pink); }
.crit-frm [data-honour="fixer"] { --ribbon: var(--metal-silver); }

/* ---------- CR-23 frame colourways: token mixes only, so every colourway follows the theme ---------- */
.crit-frm [data-cw="rose_gold"] { --frm-metal: url(#art-cr-23-rose_gold); --frm-lo: color-mix(in oklab, var(--fauna-galah-pink) 55%, var(--metal-bronze-lo)); }
.crit-frm [data-cw="old_bronze"] { --frm-metal: url(#art-cr-23-old_bronze); --frm-lo: var(--metal-bronze-lo); }
.crit-frm [data-cw="smoky_silver"] { --frm-ring: url(#art-cr-23-smoky_silver); --frm-night: color-mix(in oklab, var(--fauna-eye) 80%, var(--metal-silver-lo)); }
.crit-frm [data-cw="midnight_silver"] { --frm-ring: url(#art-cr-23-midnight_silver); --frm-star: var(--flora-blossom); }
.crit-frm [data-cw="verdigris"] { --frm-leaf-a: color-mix(in oklab, var(--fauna-kooka-blue) 55%, var(--flora-gum-juvenile)); --frm-leaf-b: color-mix(in oklab, var(--flora-gum-juvenile) 70%, var(--fauna-lori-green)); --frm-leaf-k: color-mix(in oklab, var(--fauna-wren-blue-deep) 45%, var(--flora-gum-key)); }
.crit-frm [data-cw="autumn_gum"] { --frm-leaf-a: color-mix(in oklab, var(--flora-banksia) 80%, var(--flora-gum)); --frm-leaf-b: color-mix(in oklab, var(--flora-wattle) 75%, var(--flora-gum)); --frm-leaf-k: var(--flora-banksia-key); }

/* ---------- High contrast: the ring edge only for frames; the person slots are the HC values already ---------- */
.crit-frm .frm-hc { display: none; }
:root[data-theme="high_contrast"] .crit-frm .frm-art { display: none; }
:root[data-theme="high_contrast"] .crit-frm .frm-hc { display: inline; }
:root[data-theme="high_contrast"] .av.crit { background: var(--solid); }

/* ---------- forced colours: the avatar stays (it carries identity) as Canvas and CanvasText; frames are decoration ---------- */
@media (forced-colors: active) {
  .av.crit { forced-color-adjust: none; background: Canvas; }
  .av.crit::after { box-shadow: inset 0 0 0 2px CanvasText; }
  .av.crit > .crit-frm { display: none; }
}

/* ---------- CR-08 the critter picker (composition on still glass tiles) ---------- */
.crit-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0; padding: 0; }
@media (max-width: 520px) { .crit-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.crit-card { position: relative; display: grid; justify-items: center; gap: 10px; padding: 18px 12px 14px; min-height: 44px; border-radius: var(--r-card, 20px);
  background: var(--glass-1); border: 1px solid var(--glass-edge); box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 1px var(--glass-rim), var(--shadow-1);
  color: var(--ink); font: inherit; cursor: pointer; contain: layout paint; }
.crit-card::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--glass-hover); opacity: 0; transition: opacity var(--t-small, 180ms) var(--ease-out, ease); pointer-events: none; }
.crit-card:hover::before { opacity: 1; }
.crit-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.crit-card[aria-checked="true"] { outline: 3px solid var(--focus); outline-offset: 2px; }
.crit-card .av.crit { width: 96px; height: 96px; position: relative; display: inline-grid; border-radius: 50%; }
.crit-card .crit-name { font-size: .9375rem; font-weight: 600; line-height: 1.4; }
.crit-card .crit-check { position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--focus); color: var(--solid); opacity: 0; }
.crit-card[aria-checked="true"] .crit-check { opacity: 1; }
.crit-card .crit-check svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="high_contrast"] .crit-card { background: var(--solid); border: 2px solid var(--ink); box-shadow: none; }
@media (forced-colors: active) { .crit-card[aria-checked="true"] { outline: 3px solid Highlight; } .crit-card .crit-check { forced-color-adjust: none; background: Highlight; color: HighlightText; } }

/* ---------- CR-31 Fred made portrait ---------- */
.crit-portrait { display: block; width: 100%; height: auto; max-width: 256px; }

/* ---------- critter local tones (fix rounds 1 and 2) ---------- */
/* the bilby's soft blue grey: its fur token eased towards the kookaburra wing blue, so it follows every theme */
/* the wombat's paler, projecting muzzle: its fur eased towards the quokka's pale fur (fix round 2) */
/* the galah's bare eye ring: its rose eased towards the bilby's ear pink, so the ring reads as bare skin, and its bone
   coloured bill (fix round 2) */
/* the bilby's pale cheek and throat and the deeper blue grey behind the ear (fix round 2) */
:root { --crit-bilby-fur: color-mix(in oklab, var(--fauna-bilby) 78%, var(--fauna-kooka-blue));
  --crit-bilby-deep: color-mix(in oklab, var(--crit-bilby-fur) 80%, var(--fauna-bilby-key));
  --crit-wombat-muzzle: color-mix(in oklab, var(--fauna-wombat) 92%, var(--fauna-quokka-light));
  --crit-wombat-nose: color-mix(in oklab, var(--fauna-wombat-deep) 60%, var(--fauna-eye));
  --crit-wombat-nostril: color-mix(in oklab, var(--crit-wombat-nose) 45%, var(--fauna-eye));
  --crit-quill-tip: var(--fauna-eye);
  --crit-galah-ring: color-mix(in oklab, var(--fauna-galah-pink) 45%, var(--fauna-bilby-ear));
  --crit-galah-bill: color-mix(in oklab, var(--flora-bark-pale) 80%, var(--fauna-kooka-cream));
  --crit-galah-key: color-mix(in oklab, var(--fauna-galah-key) 55%, var(--fauna-galah-pink)); }
/* the Tall Timber scarf (fix round 4): knitted as color-mix(in oklab, person colour 70%, the critter's deep fur tone) in
   Light; the Dark person colours are bright by design, so in Dark the knit takes the deep tone a step further and stays
   a calm accent, never the loudest thing in the avatar. High contrast and forced colours knit in the plain person colour. */
:root[data-theme="dark"], :root[data-theme="night_shift"] { --crit-knit-p: 55%; }
:root[data-theme="high_contrast"] { --crit-knit-p: 100%; --crit-hc-glint: var(--solid, #FFFFFF); --crit-bilby-fur: var(--fauna-bilby); --crit-bilby-deep: var(--fauna-bilby); --crit-wombat-muzzle: var(--fauna-wombat); --crit-wombat-nose: var(--fauna-eye); --crit-wombat-nostril: var(--fauna-eye); --crit-quill-tip: transparent; --crit-galah-ring: var(--fauna-galah-pink); --crit-galah-key: var(--fauna-galah-key); }
@supports not (color: color-mix(in oklab, red 50%, white)) { :root { --crit-bilby-fur: var(--fauna-bilby); --crit-bilby-deep: var(--fauna-bilby); --crit-wombat-muzzle: var(--fauna-wombat); --crit-wombat-nose: var(--fauna-eye); --crit-wombat-nostril: var(--fauna-eye); --crit-galah-ring: var(--fauna-bilby-ear); --crit-galah-key: var(--fauna-galah-key); } }
@media (forced-colors: active) { :root { --crit-knit-p: 100%; --crit-hc-glint: Canvas; --crit-bilby-fur: var(--fauna-bilby); --crit-bilby-deep: var(--fauna-bilby); --crit-wombat-muzzle: var(--fauna-wombat); --crit-wombat-nose: var(--fauna-eye); --crit-wombat-nostril: var(--fauna-eye); --crit-quill-tip: transparent; --crit-galah-ring: var(--fauna-galah-pink); --crit-galah-key: var(--fauna-galah-key); } }

/* ---------- the rank leaf badge on a critter avatar: a glass chip about 28 percent of the avatar ---------- */
.av.crit > .leafb, .av.crit[data-size] > .leafb { width: 28%; height: 28%; min-width: 12px; min-height: 12px; left: 0; bottom: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--glass-2); -webkit-backdrop-filter: blur(12px) saturate(160%); backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid var(--glass-edge); box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 1px var(--glass-rim), 0 1px 3px rgba(16,24,16,.14); color: var(--brand-text); }
.av.crit > .leafb svg, .av.crit[data-size] > .leafb svg { width: 62%; height: 62%; }
.av.crit.av-sm > .leafb { left: -3px; bottom: -3px; }
:root[data-theme="high_contrast"] .av.crit > .leafb { background: var(--solid); border: 1px solid var(--ink); box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
@media (forced-colors: active) { .av.crit > .leafb { forced-color-adjust: auto; background: Canvas; border: 1px solid CanvasText; } }

/* ---------- FLORA's HC edge classes (the season spray pressed behind a Fred made portrait uses them) ---------- */
.fl-e { stroke: var(--art-hc-edge, none); stroke-width: var(--art-hc-edge-w, 0); stroke-linejoin: round; }
.fl-h { fill: none; stroke: var(--art-hc-edge, none); stroke-width: calc(var(--art-hc-edge-w, 0) * .6); stroke-linecap: round; stroke-linejoin: round; }
