/* ============================================================
   MOTH — style.css
   The DOM/UI layer only (the canvas draws the world). Warm-amber
   accents on cold moon-silver ink over a blue-black night; system
   fonts; letter-spaced pill buttons; ≥56px tap targets; safe-area
   insets everywhere. Follows ART §5.
   ============================================================ */

:root {
  --night:      #0A0E17;
  --night-edge: #060910;
  --ink:        #D7E0EC;
  --ink-dim:    #67738A;
  --line:       rgba(158,178,204,0.28);
  --scrim:      rgba(6,9,16,0.78);
  --amber:      #FFC46B;
  --amber-ink:  #FFE9C9;
  --gold:       #FFD98A;
  --danger:     #FF6B4A;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --sans: -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--night-edge);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ===================== OVERLAYS ===================== */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2rem; text-align: center;
  padding: calc(24px + var(--safe-t)) calc(24px + var(--safe-r)) calc(24px + var(--safe-b)) calc(24px + var(--safe-l));
  transition: opacity .4s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }

/* ===================== TITLE ===================== */
.title-block { display: flex; flex-direction: column; align-items: center; gap: 1rem; margin-top: 8vh; }
.wordmark {
  font-size: 44px; font-weight: 275;
  letter-spacing: .5em; text-indent: .5em;   /* re-center the letter-spacing */
  color: var(--ink);
}
.tagline {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: 14px; letter-spacing: .06em; color: var(--ink-dim);
}

/* ===================== BUTTONS (pills, ART §5.6) ===================== */
.btn {
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--ink);
  background: rgba(13,18,30,0.62);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 1.05em 2.4em; min-height: 56px; min-width: 56px;
  cursor: pointer; transition: transform .12s ease, background .12s ease;
}
.btn:active { transform: scale(0.97); background: rgba(201,214,232,0.14); }
.btn:focus-visible { outline: 1px solid var(--amber); outline-offset: 2px; }
.btn-primary { border-color: rgba(255,196,107,0.45); color: var(--amber-ink); background: rgba(255,196,107,0.08); }
.btn-corner {
  position: fixed; left: calc(20px + var(--safe-l)); bottom: calc(20px + var(--safe-b));
  padding: .9em 1.8em;
}

/* ===================== ICON BUTTONS ===================== */
.iconbtn {
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 999px;
  background: rgba(10,14,22,0.55); border: 1px solid var(--line);
  color: var(--ink); cursor: pointer; transition: transform .12s ease, background .12s ease;
}
.iconbtn:active { transform: scale(0.94); background: rgba(201,214,232,0.14); }
.mutebtn { position: fixed; z-index: 30; top: calc(14px + var(--safe-t)); right: calc(14px + var(--safe-r)); }
.mutebtn .slash { opacity: 0; transition: opacity .15s ease; }
.mutebtn.muted .wave { opacity: 0; }
.mutebtn.muted .slash { opacity: 1; }

/* ===================== HUD ===================== */
#hud { position: fixed; inset: 0; z-index: 15; pointer-events: none; transition: opacity .3s ease; }
#hud.hidden { opacity: 0; pointer-events: none; }
#hud .iconbtn, #hud .pouch { pointer-events: auto; }

.pouch {
  position: fixed; z-index: 15;
  top: calc(14px + var(--safe-t)); left: calc(16px + var(--safe-l));
  display: flex; align-items: center; gap: 6px;
  background: rgba(10,14,22,0.55); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; min-height: 44px;
}
.pouch.shake { animation: pshake .12s ease 3; }
@keyframes pshake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.pouch.shake .pglyph, .pouch.shake .pnum { color: var(--danger); }
.pglyph { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
.pglyph.full { background: var(--amber); box-shadow: 0 0 4px rgba(255,196,107,0.7); }
.pglyph.spent { background: transparent; border: 1px solid var(--line); }
.pnum { margin-left: 6px; font-size: 15px; font-weight: 600; letter-spacing: .18em; color: var(--ink); }

.restartbtn { position: fixed; z-index: 15; top: calc(14px + var(--safe-t)); right: calc(78px + var(--safe-r)); }

.level-name {
  position: fixed; z-index: 15; left: 0; right: 0; bottom: calc(22px + var(--safe-b));
  text-align: center; font-family: var(--serif); font-style: italic;
  font-size: 12px; color: var(--ink-dim); opacity: 0;
}
.level-name.fade { animation: nameFade 2.9s ease forwards; }
@keyframes nameFade { 0% { opacity: 0; } 12% { opacity: 1; } 78% { opacity: 1; } 100% { opacity: 0; } }

/* ===================== LEVEL SELECT ===================== */
#selectNodes { position: fixed; inset: 0; z-index: 21; }
.nodebtn {
  position: absolute; width: 56px; height: 56px; border-radius: 999px;
  background: transparent; border: 0; cursor: pointer; padding: 0;
}
.nodebtn.locked { cursor: default; }
.select-footer {
  position: fixed; z-index: 22; left: 0; right: 0; bottom: calc(84px + var(--safe-b));
  text-align: center; pointer-events: none;
}
.sel-name { font-family: var(--serif); font-style: italic; font-size: 16px; color: var(--ink); }
.sel-par { margin-top: 4px; font-size: 11px; letter-spacing: .18em; color: var(--ink-dim); }

/* ===================== WIN ===================== */
#win { background: var(--scrim); animation: fadein .26s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.win-col { display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }
.win-name { font-family: var(--serif); font-style: italic; font-size: 18px; color: var(--ink); }
.win-stars { width: 180px; height: 60px; }
.win-score { font-size: 11px; letter-spacing: .18em; color: var(--ink-dim); }
.win-btns { display: flex; flex-direction: column; gap: 12px; align-items: stretch; width: min(72vw, 280px); }
.win-btns .btn { width: 100%; }

/* section-header letter-spacing law kept available for future headers */
.section-header { letter-spacing: .28em; text-transform: uppercase; }

/* contextual whisper hints (levels 1-3 only) — the game's silent teacher */
.hint {
  position: fixed; left: 0; right: 0;
  bottom: calc(46px + env(safe-area-inset-bottom, 0px));
  text-align: center; pointer-events: none;
  font: italic 17px Georgia, 'Times New Roman', serif;
  letter-spacing: 0.06em;
  color: rgba(226, 232, 246, 0.82);
  text-shadow: 0 0 14px rgba(120, 140, 200, 0.45);
  opacity: 0; transition: opacity 0.6s ease;
}
.hint.on { opacity: 1; }
