/* ============================================================
   iGEM Bonn — shared game shell
   The chrome every game reuses: topbar + brand + HUD, icon buttons,
   overlays and panels, setup choice groups, the score grid and
   win badge, the review list, the reference sheet, and the toast.

   Link it after theme.css and before the game's own stylesheet:
     <link rel="stylesheet" href="../../css/theme.css">
     <link rel="stylesheet" href="../../css/game-shell.css">
     <link rel="stylesheet" href="mygame.css">

   Note: no url() assets here — see the note in theme.css.
   ============================================================ */

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------ topbar */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px clamp(12px, 1.6vw, 18px);
  background: linear-gradient(180deg, rgb(255 255 255 / 0.05), rgb(255 255 255 / 0.02));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.brand:hover .brand__text strong { color: var(--accent); }

.brand__text { display: grid; line-height: 1.15; min-width: 0; }
.brand__text strong { font-size: 0.98rem; letter-spacing: -0.01em; }
.brand__text small { font-size: 0.74rem; color: var(--ink-3); }

.hud {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 4px;
  background: rgb(0 0 0 / 0.32);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

.hud__item {
  display: grid;
  justify-items: center;
  gap: 1px;
  min-width: 66px;
  padding: 4px 10px;
  border-radius: 8px;
}
.hud__val {
  font-size: 1.02rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.hud__key {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--ink-3);
}
.hud__item--score .hud__val { color: var(--gold); }

.hud__val.is-bumped { animation: bump 420ms var(--ease); }
@keyframes bump {
  0% { transform: scale(1); }
  35% { transform: scale(1.28); color: var(--accent); }
  100% { transform: scale(1); }
}

.topbar__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* ------------------------------------------------------------ icon buttons */

.iconbtn {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgb(255 255 255 / 0.04);
  color: var(--ink-2);
  cursor: pointer;
  transition: color 160ms, background 160ms, border-color 160ms;
}
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn:hover { color: var(--ink); background: rgb(255 255 255 / 0.09); }
.iconbtn[aria-pressed="false"] { color: var(--ink-3); }
.iconbtn[aria-pressed="false"] .wave { opacity: 0.18; }

/* ------------------------------------------------------------ overlays */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(4 7 12 / 0.82);
  backdrop-filter: blur(16px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 300ms var(--ease), visibility 300ms;
}
.overlay.is-open { opacity: 1; visibility: visible; }

.panel {
  position: relative;
  width: min(660px, 100%);
  max-height: min(88dvh, 900px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(24px, 3.4vw, 40px);
  text-align: center;
  background: linear-gradient(170deg, var(--surface-2), var(--surface) 55%, var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 40px 90px -30px rgb(0 0 0 / 0.9);
  transform: translateY(16px) scale(0.985);
  transition: transform 380ms var(--ease);
}
.overlay.is-open .panel { transform: none; }

.panel__glow {
  position: absolute;
  inset: -1px -1px auto;
  height: 180px;
  border-radius: inherit;
  background: radial-gradient(60% 100% at 50% 0%, hsl(210 95% 45% / 0.22), transparent 70%);
  pointer-events: none;
}

.panel__logo {
  display: block;
  width: clamp(84px, 14vw, 116px);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  margin: 0 auto 16px;
  padding: 9px;
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 16px 34px -14px hsl(210 90% 25% / 0.7), 0 0 0 1px hsl(43 90% 60% / 0.35);
  animation: rise 500ms var(--ease) backwards;
}
.panel__logo--sm { width: 68px; padding: 7px; border-radius: 16px; margin-bottom: 12px; }

.panel__kicker {
  margin: -4px 0 16px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--gold);
}

.panel__title {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 3.6vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.035em;
}
.panel__title em {
  font-style: normal;
  background: linear-gradient(100deg, var(--accent) 20%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.panel__lede {
  margin: 0 auto 24px;
  max-width: 46ch;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.panel__actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ------------------------------------------------------------ setup choices */

.setup { display: grid; gap: 20px; margin-bottom: 26px; text-align: left; }

.setup__group { border: none; margin: 0; padding: 0; }
.setup__group legend {
  padding: 0 0 9px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-3);
}

.choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.choices--wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.choice {
  display: grid;
  gap: 3px;
  padding: 11px 13px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(255 255 255 / 0.03);
  cursor: pointer;
  transition: border-color 170ms, background 170ms, transform 170ms var(--ease);
}
.choice:hover { border-color: hsl(210 70% 55% / 0.6); background: rgb(255 255 255 / 0.06); }
.choice b { font-size: 0.95rem; font-weight: 650; letter-spacing: -0.01em; }
.choice span { font-size: 0.7rem; line-height: 1.35; color: var(--ink-3); }

.choice.is-selected {
  border-color: var(--accent);
  background: linear-gradient(150deg, hsl(210 80% 45% / 0.2), hsl(43 90% 55% / 0.1));
  box-shadow: 0 0 0 1px hsl(210 80% 55% / 0.4), 0 10px 26px -14px hsl(210 90% 45% / 0.9);
}
.choice.is-selected b { color: var(--accent); }
.choice.is-selected span { color: var(--ink-2); }

/* ------------------------------------------------------------ win screen */

.win__badge {
  display: inline-block;
  margin-bottom: 14px;
  padding: 7px 18px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  border-radius: 999px;
  color: #06170f;
  background: linear-gradient(120deg, var(--gold), #ffe6ad);
  box-shadow: 0 12px 30px -14px hsl(40 100% 62% / 0.9);
}

.scoregrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}
.scoregrid__cell {
  display: grid;
  gap: 3px;
  padding: 14px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgb(0 0 0 / 0.28);
}
.scoregrid__cell b {
  font-size: 1.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.scoregrid__cell span {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--ink-3);
}

.win__best { margin: 0 0 20px; font-size: 0.82rem; color: var(--gold); min-height: 1.2em; }

.recap { margin-top: 22px; text-align: left; }
.recap summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-3);
  padding: 8px 0;
  list-style: none;
}
.recap summary::-webkit-details-marker { display: none; }
.recap summary::before { content: "▸"; display: inline-block; width: 1.1em; }
.recap[open] summary::before { content: "▾"; }
.recap summary:hover { color: var(--accent); }

.recap__list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.recap__list li {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 0.79rem;
  border-radius: 9px;
  border-left: 3px solid hsl(var(--hue, 200) 70% 55%);
  background: rgb(0 0 0 / 0.26);
}
.recap__list b { font-weight: 600; }
.recap__list i { font-style: normal; color: hsl(var(--hue, 200) 60% 72%); }
.recap__arrow { color: var(--ink-3); }

/* ------------------------------------------------------------ codex */

.overlay--sheet .panel { width: min(880px, 100%); text-align: left; }

.codex__head { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.codex__head .panel__title { margin-bottom: 6px; }
.overlay--sheet .panel__lede { margin-left: 0; }

.iconbtn--close { flex: none; }

.codex { display: grid; gap: 22px; }

.codex__group h3 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: hsl(var(--hue, 200) 65% 72%);
}
.codex__group h3::before {
  content: "";
  width: 9px; height: 9px;
  border-radius: 3px;
  background: hsl(var(--hue, 200) 70% 55%);
  box-shadow: 0 0 12px hsl(var(--hue, 200) 80% 55% / 0.8);
}
.codex__group h3::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, hsl(var(--hue, 200) 50% 45% / 0.4), transparent);
}

.codex__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: 14px;
  padding: 11px 14px;
  border-radius: 11px;
  background: rgb(0 0 0 / 0.25);
  border: 1px solid var(--line-soft);
  margin-bottom: 6px;
}
.codex__row dt { font-weight: 650; font-size: 0.88rem; }
.codex__row dd { margin: 0; font-size: 0.85rem; color: hsl(var(--hue, 200) 55% 80%); }
.codex__note { grid-column: 1 / -1; font-size: 0.78rem; line-height: 1.55; color: var(--ink-3); }

/* ------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 60;
  transform: translate(-50%, 14px);
  padding: 11px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 999px;
  color: var(--ink);
  background: rgb(16 24 37 / 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 260ms, transform 260ms var(--ease);
  pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast--streak { border-color: hsl(40 90% 60% / 0.5); color: var(--gold); }

/* ------------------------------------------------------------ responsive */

@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; row-gap: 10px; }
  .hud { order: 3; grid-column: 1 / -1; justify-content: space-between; }
  .hud__item { flex: 1; min-width: 0; }
  .brand__text small { display: none; }
  .brand__text strong { font-size: 0.88rem; }
  .brand__mark { width: 32px; height: 32px; border-radius: 9px; }
  .brand__mark svg { width: 19px; height: 19px; }
  .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choices--wide { grid-template-columns: minmax(0, 1fr); }
  .scoregrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .codex__row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .recap__list li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .recap__arrow { display: none; }
}


@media (prefers-reduced-motion: reduce) {
  .hud__val.is-bumped,
  .panel__logo { animation: none; }
  .overlay, .panel, .toast { transition: none; }
}
