/*
 * Birds Daily — the house system.
 * Design tokens and shared components used by every game in the suite
 * (hub, Spotted., Flock.). Migration keeps its own older storybook styling.
 */

:root {
  --paper: #EDF1EA;
  --ink: #22301F;
  --ink-soft: #4C5A48;
  --rim: #17201A;
  --sky-hi: #D6E3E7;
  --sky-lo: #9DB2BA;
  --ochre: #C9971C;
  --moss: #5A6E3A;
  --good: #4C7A46;
  --bad: #A4543B;
  --card: #F7F8F4;
  --sky: #6E93A3;
  --rust: #A4543B;

  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --ui: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

button { font-family: inherit; cursor: pointer; }

.shell {
  max-width: 480px;
  margin: 0 auto;
  padding: 8px 14px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* ---- Masthead ---- */

.house-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0 10px;
}

.back-link {
  font-size: 20px;
  line-height: 1;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 4px 6px 4px 0;
}

.wordmark {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
  flex: 1;
}

.puzzle-no {
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ---- Score bar ---- */

.scorebar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0 12px;
  position: relative;
}

.score {
  font-family: var(--display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s;
}

.score.ding { color: var(--bad); }

.score-label {
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink-soft);
  flex: 1;
}

.float-minus {
  position: absolute;
  left: 6px;
  top: 4px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 19px;
  color: var(--bad);
  pointer-events: none;
  animation: float-up 0.85s ease-out forwards;
}

@keyframes float-up {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-26px); }
}

/* ---- Mistake dots ---- */

.dots { display: flex; gap: 6px; align-items: center; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 0.3s, opacity 0.3s;
}

.dot.used { opacity: 0.16; transform: scale(0.7); }

/* ---- Buttons ---- */

.btn {
  border: 1.5px solid var(--ink);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 11px 18px;
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.btn:disabled { opacity: 0.32; cursor: default; }

.btn.filled { background: var(--ink); color: var(--paper); }

.btn:focus-visible { outline: 3px solid var(--ochre); outline-offset: 2px; }

/* ---- Toast ---- */

.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  z-index: 40;
  animation: toast-in 0.18s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- Result card ---- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(34, 48, 31, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  z-index: 30;
  animation: fade-in 0.25s;
}

.overlay[hidden] { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.result {
  background: var(--card);
  border-radius: 20px;
  padding: 24px 22px 20px;
  width: 100%;
  max-width: 350px;
  text-align: center;
  box-shadow: 0 14px 44px rgba(23, 32, 26, 0.32);
  animation: card-pop 0.3s ease;
}

@keyframes card-pop {
  from { transform: translateY(14px) scale(0.97); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.result h2 {
  font-family: var(--display);
  font-size: 25px;
  font-weight: 700;
  margin-bottom: 2px;
}

.result .sub {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

.feathers {
  font-size: 34px;
  letter-spacing: 8px;
  margin: 6px 0 4px;
  height: 44px;
}

.feathers span {
  display: inline-block;
  opacity: 0.18;
  filter: grayscale(1);
}

.feathers span.earned {
  opacity: 0;
  filter: none;
  animation: feather-pop 0.42s cubic-bezier(0.2, 1.5, 0.4, 1) forwards;
}

@keyframes feather-pop {
  from { opacity: 0; transform: scale(0.3) rotate(-18deg); }
  to { opacity: 1; transform: none; }
}

.result .rating {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 700;
  color: var(--moss);
  margin-bottom: 4px;
}

.result .score-line {
  font-size: 14px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  margin-bottom: 12px;
}

.result .fact {
  font-size: 13.5px;
  font-style: italic;
  line-height: 1.5;
  color: var(--ink-soft);
  background: rgba(90, 110, 58, 0.1);
  border-radius: 12px;
  padding: 11px 13px;
  margin-bottom: 14px;
  text-align: left;
}

.result .grid-preview {
  font-size: 15px;
  line-height: 1.35;
  letter-spacing: 2px;
  margin-bottom: 14px;
}

.result .btn-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.result .btn-row .btn { flex: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    transition-duration: 0.001s !important;
  }
}
