/* ==========================================================================
   Festivus Hunger Games — mobile-first shell
   Phase 1. Layout is driven by phone constraints first: a fixed bottom tab
   bar inside the home-indicator safe area, 48px minimum touch targets, and a
   scroll container that never produces horizontal overflow.
   ========================================================================== */

:root {
  color-scheme: dark;

  --bg:            #0b1614;
  --bg-elev:       #112220;
  --bg-elev-2:     #16302c;
  --line:          #22413c;
  --line-soft:     #1b332f;

  --text:          #eaf3f0;
  --text-dim:      #9fb8b2;
  --text-faint:    #6d8882;

  --metal:         #d8e3e0;
  --metal-dim:     #8fa6a1;
  --accent:        #4fd1a5;
  --accent-dim:    #2f8f72;
  --warn:          #f0b429;
  --danger:        #f2706b;

  --radius:        16px;
  --radius-sm:     10px;
  --tap:           48px;

  --gutter:        16px;
  --tabbar-h:      62px;

  --safe-top:      env(safe-area-inset-top, 0px);
  --safe-bottom:   env(safe-area-inset-bottom, 0px);
  --safe-left:     env(safe-area-inset-left, 0px);
  --safe-right:    env(safe-area-inset-right, 0px);

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text",
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

/*
 * The hidden attribute must win.
 *
 * The UA rule is `[hidden] { display: none }`, which any author rule setting
 * `display` beats -- so a `.gate { display: flex }` element stays on screen
 * after its `hidden` attribute is set, silently covering the page. This is the
 * single line that keeps every show/hide in the shell honest.
 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  /* A faint vertical wash so the dark theme is not flat on an OLED phone. */
  background-image: radial-gradient(120% 60% at 50% 0%, #15302b 0%, var(--bg) 62%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  /* iOS: let the bottom bar sit over the home indicator without jitter. */
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

svg { fill: currentColor; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  padding: 12px 16px;
  background: var(--accent);
  color: #06201a;
  border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* --------------------------------- app bar ------------------------------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.appbar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px calc(var(--gutter) + var(--safe-right)) 10px calc(var(--gutter) + var(--safe-left));
  max-width: 720px;
  margin: 0 auto;
}

.appbar__mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex: 0 0 auto;
}

.appbar__titles { min-width: 0; flex: 1 1 auto; }

.appbar__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appbar__sub {
  margin: 1px 0 0;
  font-size: 0.72rem;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  flex: 0 0 auto;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.badge--dev {
  color: #2a1c00;
  background: var(--warn);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--warn) 55%, transparent),
              0 2px 10px color-mix(in srgb, var(--warn) 25%, transparent);
}

/* ---------------------------------- main --------------------------------- */

.main {
  max-width: 720px;
  margin: 0 auto;
  padding:
    18px
    calc(var(--gutter) + var(--safe-right))
    calc(var(--tabbar-h) + var(--safe-bottom) + 28px)
    calc(var(--gutter) + var(--safe-left));
}

.main:focus { outline: none; }

.view { animation: rise 220ms ease-out; }

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

@media (prefers-reduced-motion: reduce) {
  .view { animation: none; }
}

/* ---------------------------------- hero --------------------------------- */

.hero {
  position: relative;
  padding: 26px 20px 24px;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, var(--bg-elev-2) 0%, var(--bg-elev) 100%);
  border: 1px solid var(--line);
  overflow: hidden;
}

/* The Festivus pole, as a background flourish. */
.hero::after {
  content: "";
  position: absolute;
  top: -10%;
  right: 22px;
  width: 10px;
  height: 120%;
  border-radius: 6px;
  background: linear-gradient(90deg, #5d6d6a 0%, var(--metal) 42%, #7f908c 100%);
  opacity: 0.5;
}

.hero__eyebrow {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero__title {
  margin: 6px 0 0;
  font-size: clamp(1.9rem, 9vw, 2.6rem);
  line-height: 1.05;
  font-weight: 750;
  letter-spacing: -0.025em;
  background: linear-gradient(180deg, #ffffff 0%, var(--metal-dim) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__tagline {
  margin: 12px 0 0;
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text);
}

.hero__note {
  margin: 14px 0 0;
  font-size: 0.88rem;
  color: var(--text-dim);
  max-width: 44ch;
}

/* --------------------------------- notice -------------------------------- */

.notice {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: #f7e4b8;
  background: color-mix(in srgb, var(--warn) 12%, var(--bg-elev));
  border: 1px solid color-mix(in srgb, var(--warn) 34%, transparent);
}

.notice strong { color: var(--warn); }

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

.card {
  margin-top: 18px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  overflow: hidden;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.card__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 650;
}

.card__foot {
  margin: 0;
  padding: 0 16px 14px;
  font-size: 0.72rem;
  color: var(--text-faint);
  word-break: break-word;
}

.btn {
  /*
   * 44px is the smallest target a thumb hits reliably on a phone. This was 40px
   * from Phase 1 and Phase 4 only raised .btn--small, so every "Back" and
   * "Refresh" in a card header sat 4px short -- which the Phase 5 phone sweep
   * measured. Raising the base lifts them all; nothing gets smaller.
   */
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.btn:active { transform: scale(0.97); }

.btn--ghost { background: transparent; color: var(--accent); }

.btn:focus-visible,
.tab:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --------------------------------- status -------------------------------- */

.status { margin: 0; padding: 4px 0; }

.status__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.status__row:last-child { border-bottom: 0; }

.status dt { color: var(--text-dim); font-size: 0.88rem; }
.status dd { margin: 0; font-size: 0.88rem; text-align: right; }

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 650;
  white-space: nowrap;
}

.pill--ok     { color: #04241b; background: var(--accent); }
.pill--wait   { color: var(--text-dim); background: var(--bg-elev-2); }
.pill--bad    { color: #2a0b0a; background: var(--danger); }

.mono { font-family: var(--mono); font-size: 0.8rem; color: var(--text-dim); }

/* ------------------------------ placeholders ----------------------------- */

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 56px 20px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px dashed var(--line);
}

.placeholder__icon { width: 40px; height: 40px; color: var(--accent-dim); }

.placeholder h2 { margin: 4px 0 0; font-size: 1.25rem; font-weight: 700; }

.placeholder p { margin: 0; color: var(--text-dim); font-size: 0.92rem; max-width: 34ch; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--bg-elev-2);
  border: 1px solid var(--line-soft);
}

.chip svg { width: 13px; height: 13px; }

/* --------------------------------- tab bar ------------------------------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding:
    6px
    calc(6px + var(--safe-right))
    calc(6px + var(--safe-bottom))
    calc(6px + var(--safe-left));
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  /* Minimum 48px touch target, per platform guidance. */
  min-height: var(--tap);
  padding: 4px 2px;
  border-radius: 12px;
  color: var(--text-faint);
  text-decoration: none;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.tab__icon { width: 22px; height: 22px; }

.tab__label { line-height: 1; }

.tab[aria-current="page"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.tab:active { background: color-mix(in srgb, var(--accent) 18%, transparent); }

/* ------------------------------ wider screens ---------------------------- */

@media (min-width: 760px) {
  :root { --gutter: 24px; }

  .main { padding-bottom: 40px; }

  /* On a desktop width the bar stops being a phone tab bar and becomes a
     centred, pill-shaped segment control. Phone layout stays the default. */
  .tabbar {
    position: sticky;
    bottom: 18px;
    max-width: 560px;
    margin: 0 auto 18px;
    border-radius: 999px;
    border: 1px solid var(--line);
    box-shadow: 0 10px 30px rgb(0 0 0 / 0.45);
  }
}
