/* ============================================================
   menu.css — Ant Terrarium start screen + level select
   Standalone module (menu.html). Phone-first, 360×640 fully usable.
   Palette: soil browns #2a1d12/#4a3421, amber #d8b878/#e8c890,
   glass highlights rgba(255,255,255,.06–.12), hairline amber borders.
   No external fonts/CDNs — system-ui only. Vanilla only.
   ============================================================ */

:root {
  --soil-deep: #2a1d12;
  --soil-mid:  #4a3421;
  --amber:     #d8b878;
  --amber-2:   #e8c890;
  --amber-dim: #a8895a;
  --hairline:  rgba(216, 184, 120, 0.25);
  --glass-hi:  rgba(255, 255, 255, 0.06);
  --glass-hi2: rgba(255, 255, 255, 0.12);
  --ink:       #f0e2c8;
  --ink-dim:   #c9b189;
  --card-bg:   linear-gradient(165deg, rgba(74,52,33,0.92), rgba(42,29,18,0.94));
  --radius:    14px;
  --radius-sm: 10px;
  --shadow:    0 24px 60px rgba(0,0,0,0.55), 0 4px 14px rgba(0,0,0,0.4);
  --target:    44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #17100a; /* behind canvas — same family as bg sky */
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* the whole menu fits one viewport; steps scroll internally */
}

/* ---------- living background canvas ---------- */
#farm-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* ---------- scene + card (perspective tilt) ---------- */
.scene {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vw, 32px);
  perspective: 1200px;
}

.card {
  width: min(680px, 100%);
  max-height: calc(100dvh - 20px);
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform-style: preserve-3d;
  will-change: transform;
}

/* glass top highlight — the "terrarium pane" sheen */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(115deg,
    rgba(255,255,255,0.10) 0%, rgba(255,255,255,0.03) 22%,
    rgba(255,255,255,0) 40%, rgba(255,255,255,0.05) 78%,
    rgba(255,255,255,0.10) 100%);
  pointer-events: none;
  z-index: 3;
}

/* ---------- steps ---------- */
.step {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
.step.active { display: flex; }

.step-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: clamp(14px, 3.5vw, 28px);
  scrollbar-width: thin;
  scrollbar-color: var(--amber-dim) transparent;
}

.step h1, .step h2 {
  margin: 0 0 6px;
  color: var(--amber-2);
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.step h1 { font-size: clamp(30px, 8vw, 44px); }
.step h2 { font-size: clamp(20px, 5vw, 26px); }
.step h1:focus, .step h2:focus { outline: none; }
.step .lede {
  margin: 0 0 16px;
  color: var(--amber);
  opacity: 0.9;
  font-size: clamp(14px, 3.8vw, 16px);
}

.kicker {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--amber-dim);
  margin-bottom: 6px;
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(232,200,144,0.16), rgba(232,200,144,0.06));
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  min-height: var(--target);
  min-width: var(--target);
  padding: 10px 20px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.08s ease, border-color 0.15s ease;
}
.btn:hover { background: linear-gradient(180deg, rgba(232,200,144,0.26), rgba(232,200,144,0.10)); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: linear-gradient(180deg, #e8c890, #c9a35f);
  border-color: rgba(255,235,200,0.5);
  color: #241708;
  text-shadow: 0 1px 0 rgba(255,255,255,0.25);
}
.btn.primary:hover { filter: brightness(1.06); }

.btn.ghost { background: transparent; }

/* visible focus for keyboard users */
.btn:focus-visible,
.chip:focus-visible,
.dot:focus-visible {
  outline: 2px solid var(--amber-2);
  outline-offset: 2px;
}

/* ---------- title step ---------- */
.title-wrap {
  min-height: 46vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
}
.title-wrap h1 { text-shadow: 0 3px 18px rgba(0,0,0,0.6); }
.tagline {
  margin: 0 0 22px;
  color: var(--amber);
  font-size: clamp(14px, 4vw, 17px);
  opacity: 0.95;
}
.title-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(320px, 100%);
}
.title-actions .btn { width: 100%; }
.version-tag {
  margin-top: 18px;
  font-size: 11px;
  color: var(--amber-dim);
  letter-spacing: 0.12em;
}

/* ---------- step 2: colony roles ---------- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 4px 0 16px;
}
.chip {
  appearance: none;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--target);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--glass-hi);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.chip:hover { background: var(--glass-hi2); }
.chip[aria-expanded="true"] {
  background: linear-gradient(180deg, rgba(232,200,144,0.30), rgba(232,200,144,0.12));
  border-color: var(--amber);
}
.chip svg { flex: 0 0 auto; }

.role-detail {
  display: none;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: rgba(20, 13, 7, 0.55);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.role-detail.open { display: block; animation: rise 0.18s ease; }
.role-detail h3 { margin: 0 0 6px; color: var(--amber-2); font-size: 16px; }
.role-detail p { margin: 0; font-size: 14px; line-height: 1.5; color: #e6d5b8; }

.lifecycle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 14px 10px;
  border: 1px dashed var(--hairline);
  border-radius: var(--radius-sm);
  background: rgba(20, 13, 7, 0.35);
}
.lifecycle .stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--amber);
  min-width: 56px;
}
.lifecycle .arrow { color: var(--amber-dim); font-size: 18px; }

/* ---------- step 3: mechanics mini-cards ---------- */
.mini-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.mini-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
}
.mini-card svg, .mini-card .glyph {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  color: var(--amber);
}
.mini-card h3 { margin: 0 0 3px; font-size: 14.5px; color: var(--amber-2); }
.mini-card p { margin: 0; font-size: 13px; line-height: 1.45; color: #ddcbab; }

/* ---------- step 4: how to play ---------- */
.howto {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.howto-col {
  padding: 12px 14px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: rgba(20, 13, 7, 0.45);
}
.howto-col h3 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber-dim);
}
.howto-col ul { margin: 0; padding: 0; list-style: none; }
.howto-col li {
  font-size: 13.5px;
  line-height: 1.5;
  padding: 3px 0;
  color: #e6d5b8;
}
.howto-col b { color: var(--amber-2); font-weight: 600; }
kbd {
  display: inline-block;
  padding: 1px 7px;
  margin: 0 1px;
  border: 1px solid var(--hairline);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(232,200,144,0.10);
  color: var(--amber-2);
  font: 600 12px/1.6 ui-monospace, Menlo, Consolas, monospace;
}
.toolbar-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.toolbar-strip span {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  font-size: 17px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--glass-hi);
}

/* ---------- step 5: level select ---------- */
.levels {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.level-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
}
.level-preview {
  display: block;
  width: 100%;
  height: auto;
  background: #140d07;
  border-bottom: 1px solid var(--hairline);
}
.level-info { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.level-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.level-info h3 { margin: 0; font-size: 16px; color: var(--amber-2); }
.pips { display: inline-flex; gap: 4px; align-items: center; }
.pips i {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 1px solid var(--amber-dim);
  background: transparent;
}
.pips i.on { background: var(--amber); border-color: var(--amber); }
.pips .pip-label {
  font-size: 11px;
  color: var(--amber-dim);
  margin-left: 6px;
  letter-spacing: 0.08em;
}
.level-brief { margin: 0; font-size: 13px; line-height: 1.45; color: #ddcbab; flex: 1; }
.level-params {
  font-size: 11.5px;
  color: var(--amber-dim);
  font-family: ui-monospace, Menlo, Consolas, monospace;
  overflow-wrap: anywhere;
}
.level-card .btn { margin: 0 14px 14px; }

.levels-note {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--amber-dim);
}

/* ---------- footer nav + dots ---------- */
.nav {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--hairline);
  background: rgba(15, 10, 5, 0.55);
}
.nav .spacer { flex: 1; }

.dots {
  display: flex;
  gap: 2px;
}
.dot {
  appearance: none;
  border: 0;
  background: transparent;
  width: var(--target);
  height: var(--target);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
}
.dot i {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid var(--amber-dim);
  background: transparent;
  transition: background 0.15s ease, transform 0.15s ease;
}
.dot[aria-current="true"] i {
  background: var(--amber);
  border-color: var(--amber-2);
  transform: scale(1.25);
}

/* ============================================================
   Desktop ≥900px: two-column layouts, wider card
   ============================================================ */
@media (min-width: 900px) {
  .card { width: min(880px, 100%); }
  .mini-grid { grid-template-columns: 1fr 1fr; }
  .howto { grid-template-columns: 1fr 1fr; }
  .levels { grid-template-columns: 1fr 1fr; }
  .title-actions { flex-direction: row; width: auto; }
  .title-actions .btn { width: auto; min-width: 200px; }
}

/* small phones: keep nav buttons from overflowing */
@media (max-width: 359px) {
  .btn { padding: 10px 12px; }
}

/* phone nav: icon-only Back + narrower dot hit areas so the row fits 360px */
@media (max-width: 480px) {
  .back-label { display: none; }
  #btn-back { padding: 10px 12px; }
  .dot { width: 34px; }
}

/* ============================================================
   Reduced motion: kill animations/transitions (JS pauses canvas)
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

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

/* ===== Site build: LOOK-INSIDE screenshots pager ("turn through the game") ===== */
.shot-pager { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.shot-nav { width: 46px; height: 56px; border-radius: 10px; border: 1px solid rgba(216,184,120,.25);
  background: rgba(58,42,28,.7); color: #e8c890; font-size: 22px; cursor: pointer; flex: 0 0 auto; }
.shot-nav:hover { background: rgba(74,56,38,.9); }
.shot-frame { flex: 1 1 auto; margin: 0; min-width: 0; text-align: center; }
.shot-frame img { max-width: 100%; max-height: 46vh; border-radius: 10px; border: 1px solid rgba(216,184,120,.25);
  box-shadow: 0 12px 40px rgba(0,0,0,.45); object-fit: contain; background: #1a120c; }
.shot-frame figcaption { color: #b09a78; font-size: 12.5px; margin-top: 8px; line-height: 1.4; }
.shot-dots { display: flex; gap: 7px; justify-content: center; margin-top: 10px; }
.shot-dot { width: 9px; height: 9px; border-radius: 50%; border: 0; background: rgba(216,184,120,.25); cursor: pointer; padding: 0; }
.shot-dot.on { background: #e8c890; }
@media (max-width: 480px) { .shot-nav { width: 38px; height: 64px; } .shot-frame img { max-height: 40vh; } }
