/* Injection-site picker (redesign) — polished flat medical illustration.
   Owns ALL picker styling; the old inline rules were removed from app.html. */

.site-field { container-type: inline-size; }

/* Header row: route (TRT can be IM or SubQ) + a small legend. */
.site-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.route-note { font-size: .875rem; font-weight: 700; color: var(--text); }
.route-note[hidden], .route-seg[hidden] { display: none; }
.route-seg { display: inline-flex; padding: 4px; border-radius: 999px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); max-width: 100%; }
.route-seg button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px;
  background: transparent; font: inherit; font-size: .875rem; font-weight: 700; color: var(--text-muted); cursor: pointer; white-space: nowrap;
  transition: background-color .2s var(--ease-out), color .2s var(--ease-out);
}
.route-seg button small { font-size: .6875rem; font-weight: 800; padding: 2px 6px; border-radius: 999px; background: oklch(0.5 0.05 266 / .12); }
.route-seg button[aria-checked="true"] { background: var(--ink); color: #fff; }
.route-seg button[aria-checked="true"] small { background: oklch(1 0 0 / .22); }
.route-seg button:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
@container (max-width: 459px) {
  .route-seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .route-seg button { justify-content: center; flex-wrap: wrap; white-space: normal; text-align: center; padding: 6px 8px; line-height: 1.2; row-gap: 2px; }
}
.site-key { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .8125rem; font-weight: 600; color: var(--text); }
.site-key span { display: inline-flex; align-items: center; gap: 6px; }
.site-key i { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.site-key span + span { margin-left: 10px; }
.site-key .k-on { background: oklch(0.6 0.2 266); border: 2px solid var(--cobalt-deep); }
.site-key .k-last { background: var(--last); border: 2px solid var(--last-deep); }

/* Layout: figures on top, roomy site chips underneath; side by side only when there's real room. */
.sitemap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
@container (min-width: 820px) {
  .sitemap { grid-template-columns: minmax(360px, 420px) minmax(0, 1fr); gap: 28px; }
  .sitemap .site-groups { grid-template-columns: minmax(0, 1fr); }
}

/* Stage */
.body-stage {
  position: relative; border-radius: var(--r-lg); padding: 16px 16px 14px; overflow: clip;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--line);
}

.body-tools { display: none; justify-content: center; align-items: center; gap: 8px; margin-bottom: 10px; }

/* Front/Back toggle — hidden while both figures are shown side by side. */
.mini-seg { display: none; padding: 3px; border-radius: 999px; background: oklch(1 0 0 / .8); box-shadow: inset 0 0 0 1px var(--line); }
.mini-seg button { min-height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; font: inherit; font-size: .8125rem; font-weight: 700; color: var(--text-muted); cursor: pointer; transition: background-color .2s, color .2s; }
.mini-seg button[aria-pressed="true"] { background: var(--cobalt); color: #fff; }
.mini-seg button:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 1px; }

/* Two figures, side by side. */
.body-view { position: relative; }
.body-flip { display: flex; gap: clamp(12px, 5cqi, 40px); align-items: flex-start; justify-content: center; }
.face { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; opacity: 1; }
.face-cap {
  font-size: .8125rem; font-weight: 800; letter-spacing: .01em; color: var(--cobalt-deep);
  background: oklch(1 0 0 / .82); padding: 3px 14px; border-radius: 999px; box-shadow: 0 1px 2px oklch(0.2 0.1 266 / .12);
}

.fig { position: relative; width: 100%; max-width: 210px; aspect-ratio: 250 / 588; margin: 0 auto; }
.fig-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none;
  filter: drop-shadow(0 8px 14px oklch(0.3 0.08 266 / .14)); }
.fig::before { content: ""; position: absolute; left: 50%; bottom: -1.5%; width: 62%; height: 3%; translate: -50% 0; border-radius: 50%;
  background: radial-gradient(closest-side, oklch(0.35 0.1 266 / .22), transparent); }
/* R / L orientation markers (correct per face). */
.fig-lr { position: absolute; inset: 14% -4% auto; display: flex; justify-content: space-between; pointer-events: none; }
.fig-lr i { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: #fff; font: 800 11px/1 var(--font); font-style: normal;
  color: var(--cobalt-deep); box-shadow: 0 1px 3px oklch(0.2 0.1 266 / .18); }

/* Injection zones: soft translucent highlighted AREAS sized to each body region. */
.spot {
  position: absolute; left: var(--x); top: var(--y); translate: -50% -50%;
  width: var(--w, 14%); height: var(--h, 12%); min-width: 22px; min-height: 22px;
  padding: 0; border: 2px dotted oklch(0.4 0.16 266 / .6); border-radius: 48% / 46%;
  background: #fff; cursor: pointer;
  display: grid; place-items: center; -webkit-tap-highlight-color: transparent;
  transition: background-color .2s, border-color .2s, box-shadow .2s, transform .25s var(--ease-out);
}
.spot:hover { background: oklch(0.92 0.06 266); border-color: var(--cobalt); }
.spot:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; }
.spot[hidden] { display: none; }

/* Last shot → solid green area + a small "Last" tag inside it. */
.site-field { --last: oklch(0.72 0.17 150); --last-deep: oklch(0.48 0.14 150); }
.spot.last { background: var(--last); border: 2px solid var(--last-deep); }
.spot.last::after {
  content: "Last"; font-size: .58rem; font-weight: 800; line-height: 1; letter-spacing: .02em;
  color: #fff; background: var(--last-deep); padding: 2px 5px; border-radius: 999px; pointer-events: none;
}

/* Selected → cobalt fill and outline, gentle pulse (green is reserved for the last shot). */
.spot.on { background: oklch(0.6 0.2 266); border: 2.4px solid var(--cobalt-deep); box-shadow: 0 4px 14px oklch(0.35 0.2 266 / .32); }
.spot.on::after {
  content: ""; position: absolute; inset: -3px; border-radius: inherit; border: 2px solid var(--cobalt);
  animation: sitePulse 1.8s var(--ease-out) infinite; pointer-events: none;
}
@keyframes sitePulse { from { transform: scale(.85); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }

/* Accessible label on hover / focus. */
.spot .tip {
  position: absolute; left: 50%; bottom: calc(100% + 6px); translate: -50% 4px; white-space: nowrap;
  font-size: .72rem; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: var(--ink); color: #fff;
  opacity: 0; pointer-events: none; transition: opacity .15s, translate .2s var(--ease-out); z-index: 3;
}
.spot:hover .tip, .spot:focus-visible .tip { opacity: 1; translate: -50% 0; }

.site-cap { margin: 12px 0 0; text-align: center; font-size: .875rem; font-weight: 700; color: var(--cobalt-deep); min-height: 1.3em; }

/* Site chips */
.site-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px 24px; align-content: start; }
.site-group h4 { margin: 0 0 10px; font-size: .875rem; font-weight: 800; color: var(--text); letter-spacing: -0.005em; }
.site-field .sites { display: flex; flex-wrap: wrap; gap: 8px; }
.site-field .sites label span { min-height: 44px; padding: 0 16px; gap: 8px; }
.site-field .sites label span em { font-style: normal; font-size: .6875rem; font-weight: 800; color: #fff; background: var(--last-deep); padding: 2px 7px; border-radius: 999px; }
.site-field .sites label.was span { background: oklch(0.95 0.05 150); border-color: var(--last-deep); color: oklch(0.36 0.1 150); }
.site-field .sites input:checked + span { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }
.site-field .sites input:checked + span em { background: #fff; color: var(--last-deep); }
.rotate-note { grid-column: 1 / -1; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--surface-2); font-size: .875rem; line-height: 1.55; color: var(--text); }
.rotate-note > svg { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--ok); }
.rotate-note > div { display: grid; gap: 4px; max-width: 62ch; text-wrap: pretty; }
.rotate-note p { margin: 0; }
.rotate-note b { color: var(--last-deep); }

/* Very narrow: fall back to a single figure with a Front/Back crossfade. */
@container (max-width: 359px) {
  .mini-seg { display: inline-flex; }
  .body-tools { display: flex; }
  .body-flip { display: grid; grid-template-columns: minmax(0, 1fr); }
  .face { grid-area: 1 / 1; width: 100%; transition: opacity .35s var(--ease-out); }
  .face .fig { max-width: 220px; }
  .body-stage[data-view="front"] .face-back,
  .body-stage[data-view="back"] .face-front { opacity: 0; pointer-events: none; }
}

@media (prefers-reduced-motion: reduce) {
  .spot.on::after { animation: none; }
  .face { transition: none; }
}

.site-guides { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin: 12px 0; padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(99,102,241,.35); background: linear-gradient(135deg, rgba(99,102,241,.14), rgba(20,184,166,.12)); }
.site-guides .sg-ico { width: 28px; height: 28px; flex: none; object-fit: contain; }
.site-guides .sg-txt { flex: 1 1 160px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.site-guides .sg-txt strong { font-size: 14px; }
.site-guides .sg-txt span { opacity: .75; }
.site-guides .sg-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.site-guides .sg-btns a { padding: 7px 12px; border-radius: 999px; background: #4f46e5; color: #fff; font-size: 13px; font-weight: 600; text-decoration: none; }
.site-guides .sg-btns a:hover, .site-guides .sg-btns a:focus-visible { filter: brightness(1.12); }
