/* =========================================================
   ADLC game "Ship It" — builds on style.css, adlc.css, adlc-phase.css
   Gremlins are always --fail red; their kind is a glyph, not a colour.
   ========================================================= */

.hidden { display: none !important; }
.muted { color: var(--text-muted); }

.ic {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--role, currentColor);
}

.k-ambiguity { --glyph: "?"; }
.k-logic     { --glyph: "L"; }
.k-security  { --glyph: "S"; }
.k-blast     { --glyph: "B"; }
.k-scale     { --glyph: "↑"; }

/* ---------- Hero + cast ---------- */

.game-hero { padding-bottom: 20px; }
.game-hero .back-link { margin-bottom: 18px; }
.game-hero p.lede { margin-bottom: 22px; }

.cast {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cast li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 8px;
  border: 1px solid color-mix(in srgb, var(--role) 30%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--role) 7%, var(--bg-elevated));
  font-size: 12.5px;
  color: var(--text-muted);
  transition: opacity 0.3s ease;
}

.cast li .ic { width: 24px; height: 24px; }
.cast strong { color: var(--text); margin-right: 5px; font-weight: 600; }
.cast li.off { opacity: 0.45; }

/* ---------- Game frame ---------- */

.game-section { padding: 8px 0 48px; }

.game {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* HUD */
.hud {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  min-width: 0;
}

.hud-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hud-val {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.hud-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  min-height: 1.3em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.focus-pips {
  display: flex;
  gap: 5px;
  height: 28px;
  align-items: center;
}

.focus-pips i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--human);
  transition: background 0.2s ease;
}

.focus-pips i.on { background: var(--human); }

.trust-bar {
  --v: 1;
  height: 6px;
  margin-top: 5px;
  border-radius: 99px;
  background: var(--code-bg);
  overflow: hidden;
}

.trust-bar i {
  display: block;
  height: 100%;
  width: calc(var(--v) * 100%);
  background: var(--gate);
  transition: width 0.4s ease, background 0.4s ease;
}

.trust-bar.low i { background: var(--fail); }

/* ---------- Pipeline ---------- */

.pipe-wrap {
  position: relative;
  margin-bottom: 16px;
}

.pipe {
  --lane-h: 40px;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  overflow: hidden;
}

.stage {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px 0;
  border-left: 1px dashed var(--border);
  min-width: 0;
  transition: background 0.25s ease;
}

.stage:first-child { border-left: none; }
.stage.busy { background: var(--accent-soft); }

.stage-name {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}

.stage-name:hover { color: var(--accent-strong); }

.stage-who {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 44px;
  align-content: flex-start;
}

.stage-who > span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px 2px 3px;
  border-radius: 999px;
  color: var(--text);
  background: color-mix(in srgb, var(--role, var(--text-muted)) 10%, transparent);
  transition: opacity 0.3s ease, filter 0.3s ease;
}

.stage-who .ic { width: 15px; height: 15px; }
.stage-who > span.off { opacity: 0.35; filter: grayscale(1); text-decoration: line-through; }
.pawns { display: inline-flex; }
.earned { margin: 0 0 10px; font-size: 13px; color: var(--text-muted); }
.pawns .ic { color: var(--text-muted); margin-right: -4px; }

/* Caught gremlins pile up at the stage that caught them. */
.tray {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-height: 22px;
}

.caught {
  position: relative;
  display: inline-flex;
  width: 22px;
  height: 22px;
  color: var(--fail);
  opacity: 0;
  transform: scale(0.3);
  transition: opacity 0.25s ease, transform 0.3s cubic-bezier(.3, 1.6, .5, 1);
}

.caught .ic { width: 22px; height: 22px; color: var(--fail); }
.caught.on { opacity: 0.6; transform: scale(1); }

.caught::after {
  content: var(--glyph);
  position: absolute;
  right: -3px;
  bottom: -3px;
  font: 700 9px/13px var(--font-mono);
  min-width: 13px;
  text-align: center;
  border-radius: 7px;
  color: var(--bg-elevated);
  background: var(--fail);
}

/* A teal tick says "a layer stopped this one". */
.caught:not(.escaped)::before {
  content: "✓";
  position: absolute;
  left: -3px;
  top: -4px;
  font: 700 10px/13px var(--font-sans);
  width: 13px;
  text-align: center;
  border-radius: 50%;
  color: var(--bg-elevated);
  background: var(--gate);
}

.caught.escaped.on {
  opacity: 1;
  animation: escaped 0.9s ease-in-out 3;
}

@keyframes escaped {
  50% { transform: scale(1.25); filter: drop-shadow(0 0 6px var(--fail)); }
}

.lanes {
  display: block;
  height: calc(3 * var(--lane-h) + 8px);
}

/* Feature tokens travel over the lanes; --p is the stage position 0..6. */
.track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1px;
  height: calc(3 * 40px + 8px);
  pointer-events: none;
}

.token {
  --p: 0;
  --lane: 0;
  position: absolute;
  left: calc(var(--p) * 100% / 7 + 5px);
  top: calc(var(--lane) * 40px + 4px);
  width: calc(100% / 7 - 10px);
  height: 34px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  font-size: 11.5px;
  overflow: hidden;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.token.bonus { border-color: color-mix(in srgb, var(--pm) 55%, var(--border)); }
.token.done { border-color: var(--gate); background: color-mix(in srgb, var(--gate) 10%, var(--bg-elevated)); }
.token.done.bad { border-color: var(--fail); background: color-mix(in srgb, var(--fail) 10%, var(--bg-elevated)); }

.token-id {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--accent-strong);
}

.token-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}

.dots { display: flex; gap: 2px; }

.dot {
  display: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--fail);
}

.dot.on { display: block; }

.dot::after {
  content: var(--glyph);
  display: block;
  font: 700 8.5px/13px var(--font-mono);
  text-align: center;
  color: var(--bg-elevated);
}

/* ---------- Main grid ---------- */

.game-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 1000px) {
  .game-grid { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
}

.game-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.game-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Scarlett */
.scarlett {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.avatar-lg {
  width: 40px;
  height: 40px;
  padding: 4px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--pm) 13%, var(--bg));
}

.scarlett-bubble {
  position: relative;
  flex: 1;
  margin: 0;
  padding: 10px 14px;
  border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
  background: color-mix(in srgb, var(--pm) 9%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--pm) 30%, var(--border));
  font-size: 14px;
  line-height: 1.5;
  min-height: 44px;
}

.tips-btn {
  flex: none;
  font: 500 12px var(--font-sans);
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
}

.tips-btn:hover { color: var(--text); border-color: var(--text-muted); }

.scarlett-btns {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Gremlin glyph badge, used in hints, actions and the intro. */
.gl {
  display: inline-block;
  width: 15px;
  height: 15px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--fail);
  vertical-align: -3px;
}

.gl::after {
  content: var(--glyph);
  display: block;
  font: 700 9.5px/15px var(--font-mono);
  text-align: center;
  color: var(--bg-elevated);
}

.act small .gl { width: 13px; height: 13px; vertical-align: -2px; margin-right: 3px; }
.act small .gl::after { font-size: 8.5px; line-height: 13px; }
.hints li[class^="k-"] { color: var(--text); background: color-mix(in srgb, var(--fail) 9%, var(--code-bg)); padding-left: 3px; }

/* How to play */
.intro { border-color: color-mix(in srgb, var(--pm) 40%, var(--border)); outline: none; }
.intro .panel-body { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.intro .goal { margin: 0; font-size: 15px; }
.intro .goal .ic { width: 15px; height: 15px; vertical-align: -2px; }

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}

.steps li { display: flex; gap: 10px; }
.steps strong { color: var(--text); }
.steps .ic { width: 14px; height: 14px; vertical-align: -2px; }

.steps .n {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 600 13px var(--font-display);
  color: var(--pm);
  background: color-mix(in srgb, var(--pm) 13%, transparent);
}

.kinds { display: block; margin-top: 4px; color: var(--text); font-size: 13px; }
.kinds { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.kind { white-space: nowrap; }

.pips-mini { display: inline-flex; gap: 3px; vertical-align: -1px; }
.pips-mini i { width: 10px; height: 10px; border-radius: 50%; background: var(--human); }

.game.intro-open .deck,
.game.intro-open .run-btn,
.game.intro-open .after { display: none; }

/* Coach mark: the one thing to press next in the guided first sprint. */
.coach {
  outline: 3px solid var(--pm);
  outline-offset: 3px;
  animation: coach 1.4s ease-in-out infinite;
}

@keyframes coach {
  50% { outline-color: color-mix(in srgb, var(--pm) 35%, transparent); }
}

/* Feature cards */
.deck {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.fcard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.fcard.bonus { border-top-color: var(--pm); }

.fcard-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.fcard-head h3 {
  flex: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.25;
}

.fcard-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-strong);
}

.fcard.bonus .fcard-id { color: var(--pm); }

.fcard-value {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.fcard-value .ic { width: 15px; height: 15px; color: var(--text-muted); }

.fcard-src {
  margin: -4px 0 0;
  font-size: 12px;
  color: var(--pm);
}

.hints {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.hints li {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--code-bg);
  color: var(--text-muted);
}

.acts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.act,
.upg {
  display: flex;
  align-items: center;
  gap: 7px;
  text-align: left;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.act { --role: var(--human); }
.act[data-act="canary"] { --role: var(--agent); }
.act:hover:not(:disabled),
.upg:hover:not(:disabled) { border-color: var(--role, var(--accent)); }

.act[aria-pressed="true"] {
  border-color: var(--role);
  background: color-mix(in srgb, var(--role) 14%, var(--bg-elevated));
  box-shadow: inset 0 0 0 1px var(--role);
}

.act:disabled,
.upg:disabled { cursor: not-allowed; opacity: 0.45; }
.act[aria-pressed="true"]:disabled { opacity: 0.8; }

.act-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.act-text strong { font-size: 12.5px; font-weight: 600; }
.act-text small { font-size: 11px; color: var(--text-muted); }

.run-btn { align-self: flex-start; }

/* Between sprints */
.after {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.after .panel { width: 100%; }

.shop {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.upg .ic { width: 22px; height: 22px; }
.upg[data-id="sast"],
.upg[data-id="mutation"] { --role: var(--gate); }
.upg[data-id="critic"],
.upg[data-id="testsFirst"] { --role: var(--agent); }
.upg[data-id="theo"] { --role: var(--human); }
.upg .act-text { flex: 1; }

.cost {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--accent-strong);
}

.upg.owned:disabled { opacity: 0.7; border-color: var(--gate); }
.upg.owned .cost { color: var(--gate); }

/* End of season */
.end h2 {
  margin: 4px 0 8px;
  font-family: var(--font-display);
  font-size: 24px;
}

.end h3 { margin: 18px 0 8px; font-size: 14px; }
.end p { margin: 6px 0; }

.end-score {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.end-score .big {
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 700;
  color: var(--accent-strong);
  line-height: 1;
}

.table-scroll { overflow-x: auto; }

.report {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.report th,
.report td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: center;
  white-space: nowrap;
}

.report thead th { font-size: 11.5px; font-weight: 600; color: var(--text-muted); }
.report thead a { color: inherit; }
.report tbody th { text-align: left; font-weight: 500; }
.report tbody th .ic { width: 15px; height: 15px; color: var(--fail); vertical-align: -3px; }
.report td { color: var(--text-muted); }
.report td.has { color: var(--text); font-weight: 600; background: color-mix(in srgb, var(--gate) 10%, transparent); }
.report td.esc.has { color: var(--fail); background: color-mix(in srgb, var(--fail) 11%, transparent); }
.report .esc { color: var(--fail); }
.report thead .s { display: none; }

.lesson {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  font-size: 14px;
}

.end .cta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* Field guide */
.guide {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text-muted);
}

.guide li { display: flex; gap: 8px; }

.guide .ic {
  width: 22px;
  height: 22px;
  color: var(--fail);
}

.guide strong { display: block; color: var(--text); font-weight: 600; }
.guide strong::after { content: "  " var(--glyph); font-family: var(--font-mono); color: var(--fail); }

.guide-foot {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.log-body {
  max-height: 340px;
  overflow-y: auto;
}

/* Takeaways */
.game-notes { padding: 24px 0 100px; }

.game-notes h2 {
  font-family: var(--font-display);
  font-size: 24px;
  margin: 0 0 20px;
}

.game-notes .stage-card h3 { margin: 0 0 8px; font-size: 16px; }
.game-notes .stage-card p { margin: 0; font-size: 14px; color: var(--text-muted); }

.game-notes .cta-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

/* ---------- Narrow screens: pipeline runs top to bottom ---------- */

@media (max-width: 760px) {
  .hud { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hud-item:last-child { grid-column: span 2; }
}

@media (max-width: 640px) {
  .game { padding: 10px; border-radius: var(--radius-md); }
  .hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hud-item:first-child { grid-column: span 2; flex-direction: row; align-items: baseline; gap: 10px; }

  /* Rows take their natural height; the script sets --y from the measured row centres. */
  .pipe {
    grid-template-columns: 1fr;
    padding-right: 124px;
  }

  .stage {
    border-left: none;
    border-top: 1px dashed var(--border);
    padding: 8px 10px;
    min-height: 60px;
    gap: 4px;
  }

  .stage:first-child { border-top: none; }
  .stage-who { min-height: 0; }
  .tray { min-height: 0; }
  .lanes { display: none; }

  .track {
    left: auto;
    right: 1px;
    top: 1px;
    bottom: 1px;
    width: 122px;
    height: auto;
    border-left: 1px dashed var(--border);
  }

  .token {
    --y: 0px;
    left: calc(var(--lane) * 39px + 4px);
    top: var(--y);
    width: 36px;
    height: 48px;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 2px;
  }

  .token-name { display: none; }
  .dots { flex-wrap: wrap; justify-content: center; }
  .dot { width: 11px; height: 11px; }
  .dot::after { font-size: 7.5px; line-height: 11px; }

  .acts { grid-template-columns: 1fr; }
  .scarlett { flex-wrap: wrap; }
  .scarlett-bubble { flex-basis: calc(100% - 50px); }
  .scarlett-btns { flex-direction: row; margin-left: 50px; }
  .report th,
  .report td { padding: 6px 4px; font-size: 12px; }
  .report thead th { font-size: 11px; }
  .report tbody th { white-space: normal; min-width: 72px; }
  .report thead .l { display: none; }
  .report thead .s { display: inline; }
}

@media (prefers-reduced-motion: reduce) {
  .caught,
  .trust-bar i,
  .stage { transition: none; }
  .caught.escaped.on { animation: none; }
  .coach { animation: none; }
}
