/* ============================================================
   Word Hive — game-specific styles. Design tokens + .btn / .brand /
   .hud come from common.css; everything below is Word Hive's own.

   Word Hive is the Hive half of Word Foundry, extracted into its own
   single-mode PWA. Forge-only styles (tile rack, timer, run overlay) are
   intentionally absent.
   ============================================================ */

/* `hidden` should win over any `display:flex` declarations below so toggled
   elements never leak onto the screen. Restores the UA [hidden] behaviour. */
[hidden] { display: none !important; }

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 0 14px 28px;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  /* common.css locks html/body to the viewport (overflow:hidden). The Hive
     layout can run taller than a phone screen, so make main the scroll
     container — it takes the space left under the header and scrolls
     internally rather than clipping the controls off-screen. */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
body.install-visible main { padding-bottom: 88px; }

/* Difficulty stays pinned to the top of the scroll area so it's always
   reachable — switching tiers no longer requires scrolling back up past the
   board and controls. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 6;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 0 10px;
  background: rgba(26, 31, 58, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.flag-mark { display: flex; align-items: center; flex-shrink: 0; }
.flag-mark svg {
  width: 28px; height: 18px; border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ── Difficulty bar ───────────────────────────────────────── */

/* Difficulty uses the shared .segmented control (common.css); buttons keep
   their .diff-btn class purely as a JS hook. Three tiers fit the track. */

/* ── Scorebar ─────────────────────────────────────────────── */

.scorebar {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border: 1.5px solid rgba(201, 169, 97, 0.3);
  border-radius: 12px;
  background: var(--slot-bg);
}
.score-main { display: flex; align-items: baseline; gap: 8px; }
.score-label {
  font-family: var(--sans);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
.score-value {
  font-family: var(--serif);
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--gold);
  line-height: 1;
}
.score-aux { font-family: var(--sans); font-size: 0.8rem; color: rgba(245, 237, 224, 0.65); }

.score-rank { display: flex; flex-direction: column; gap: 4px; min-width: 130px; flex: 1; }
.rank-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--gold-bright);
  text-align: right;
}
.rank-progress {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: rgba(201, 169, 97, 0.18);
  overflow: hidden;
}
.rank-fill {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-bright));
  transition: width 0.4s ease;
}

/* ── Entry + feedback ─────────────────────────────────────── */

.entry {
  min-height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 2rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--card);
}
.entry .caret {
  width: 2px; height: 1.6rem;
  background: var(--gold);
  animation: blink 1s step-end infinite;
}
.entry.empty::after {
  content: 'Tap or type letters';
  font-family: var(--sans);
  font-size: 0.9rem;
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--gold-dim);
}
.entry .ec-center { color: var(--gold-bright); }
@keyframes blink { 50% { opacity: 0; } }

.feedback {
  font-family: var(--sans);
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  color: rgba(245, 237, 224, 0.7);
  min-height: 1.3rem;
  text-align: center;
}
.feedback.error { color: #e8a0a0; }
.feedback.good  { color: #9fd6a0; }
.feedback.pangram { color: var(--gold-bright); font-weight: 700; }

/* ── Hive — hex flower ────────────────────────────────────── */

.hive-board {
  --hex: clamp(58px, 19vw, 92px);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.hive-row { display: flex; justify-content: center; }
.hive-row + .hive-row { margin-top: calc(var(--hex) * -0.18); }
.hex {
  width: var(--hex);
  height: calc(var(--hex) * 1.02);
  margin: 3px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  position: relative;
}
.hex .hex-face {
  position: absolute;
  inset: 0;
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  background: var(--card);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-weight: 600;
  font-size: calc(var(--hex) * 0.42);
  text-transform: uppercase;
  transition: transform 0.08s ease, filter 0.12s ease;
}
.hex:active .hex-face { transform: scale(0.92); }
/* Focus ring goes on the button, not .hex-face: the face has a clip-path
   (hexagon) which would clip a box-shadow ring to nothing. An outline on the
   un-clipped button stays visible for keyboard players. */
.hex:focus-visible { outline: 2.5px solid var(--gold-bright); outline-offset: 1px; border-radius: 6px; }
.hex:focus-visible .hex-face { filter: brightness(1.08); }

/* Centre cell (the required letter) — a solid contrasting fill so it stands
   out from the cream petals. (The American-flag requirement is met by the
   header flag-mark.) */
.hex.center .hex-face {
  background: var(--gold);
  color: var(--bg-1);
}

/* ── Controls ─────────────────────────────────────────────── */

.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }
/* Meet the >=44px touch-target minimum (common.css .btn padding alone is ~39px). */
.controls .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.btn-primary { background: var(--gold); color: var(--bg-1); border-color: var(--gold-bright); font-weight: 700; }
.btn-primary:hover, .btn-primary:focus-visible { background: var(--gold-bright); }
.btn:disabled { opacity: 0.4; cursor: default; pointer-events: none; }

/* ── Found-words panel ────────────────────────────────────── */

.found-panel {
  width: 100%;
  border: 1.5px solid rgba(201, 169, 97, 0.22);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--slot-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.found-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: rgba(245, 237, 224, 0.75);
}
.pangram-tally { color: var(--gold-bright); font-weight: 700; }

.remaining-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.len-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--sans);
  font-size: 0.72rem;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(201, 169, 97, 0.12);
  color: rgba(245, 237, 224, 0.8);
}
.len-chip b { color: var(--gold-bright); font-variant-numeric: tabular-nums; }
.len-chip.done { background: rgba(159, 214, 160, 0.18); color: #bfe6bf; }

.found-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.found-list li {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 5px;
  background: rgba(245, 237, 224, 0.06);
  color: var(--card);
}
.found-list li.pangram { background: var(--gold); color: var(--bg-1); font-weight: 700; }

/* ── End-of-board reveal overlay (family-consistent) ──────── */

.win-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 25, 55, 0.88);
  display: flex;
  /* Scroll rather than clip on short/landscape viewports so the action
     button stays reachable (mirrors Word Forge's run overlay). */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 16px;
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
  z-index: 100;
}
.win-overlay.visible { opacity: 1; visibility: visible; pointer-events: all; transition: opacity 0.3s ease, visibility 0s; }
.win-panel {
  background:
    radial-gradient(ellipse at top, rgba(86, 64, 138, 0.42) 0%, transparent 70%),
    var(--panel);
  border: 1px solid var(--gold);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  padding: 38px 28px 28px;
  text-align: center;
  max-width: 360px; width: 90%; margin: auto;
  display: flex; flex-direction: column; gap: 10px;
  position: relative; overflow: hidden;
}
/* American-flag motif — a slim stars-and-stripes accent across the top */
.win-panel::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--red) 0 34%, #f5ede0 34% 66%, #3c3b6e 66% 100%);
}
.win-dismiss {
  position: absolute; top: 6px; right: 6px;
  background: none; border: none; color: rgba(245, 237, 224, 0.5);
  font-size: 1.1rem; cursor: pointer; width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.win-dismiss:hover, .win-dismiss:focus-visible { color: var(--card); outline: none; }
.win-title { font-family: var(--serif); font-size: 1.9rem; font-style: italic; font-weight: 500; color: var(--gold-bright); margin: 0; }
.reveal-detail { font-family: var(--sans); font-size: 0.84rem; color: rgba(245, 237, 224, 0.75); }
.reveal-list {
  justify-content: center;
  max-height: 46vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 2px 0 0;
}
.win-panel .btn { margin-top: 10px; align-self: center; padding: 12px 30px; font-size: 0.95rem; }

/* ── Install banner (family-consistent) ───────────────────── */

/* The install banner is now the shared #pwa-banner (common.css), injected by
   ../pwa-install.js; the old .install-banner toast styles were removed. (BL-022) */

/* ── Animations + reduced motion ──────────────────────────── */

@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)} 40%{transform:translateX(6px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)} }
.entry.shake { animation: shake 0.4s ease; }

@keyframes pop { 0%{transform:scale(1)} 40%{transform:scale(1.18)} 100%{transform:scale(1)} }
.score-value.bump { animation: pop 0.32s ease; }

@keyframes celebrate { 0%{transform:scale(0.6);opacity:0} 50%{transform:scale(1.15);opacity:1} 100%{transform:scale(1);opacity:1} }
.pangram-flash {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 120;
}
.pangram-flash span {
  font-family: var(--serif); font-weight: 700; font-size: 3rem; color: var(--gold-bright);
  text-shadow: 0 2px 12px rgba(0,0,0,0.6); animation: celebrate 0.7s ease;
}

@media (prefers-reduced-motion: reduce) {
  .entry.shake, .score-value.bump, .pangram-flash span, .entry .caret, .rank-fill { animation: none !important; transition: none !important; }
  .win-overlay { transition: none !important; }
}
