/* site/app/ui.css — the Apple interface layer, in The Rally Grounds' colours.
 * Depends on tokens.css. Load tokens.css first.
 *
 * The components here are the iOS vocabulary: a large title that collapses into a compact
 * translucent bar, grouped inset lists, a segmented control, a bottom tab bar, sheets.
 * They are here because they are what people already know — familiarity is a design
 * principle, not a shortcut. A player who has used any iPhone app can already use this one.
 */

/* ── The device frame, for the preview only ───────────────────────────────── */
.stage {
  min-height: 100dvh;
  background:
    radial-gradient(120% 90% at 50% -10%, #0A3057 0%, transparent 60%),
    var(--navy);
  padding: var(--s-6) var(--s-4) var(--s-8);
}

.phone {
  width: 390px; max-width: 100%;
  height: 844px; max-height: 84dvh;
  border-radius: 46px;
  background: var(--bg);
  position: relative; overflow: hidden;
  box-shadow:
    0 0 0 11px #0B1B2B,
    0 0 0 13px #223448,
    0 40px 90px -20px rgba(0,0,0,.7);
  display: flex; flex-direction: column;
  isolation: isolate;
}

/* The notch. Present because the safe-area padding below only reads as considered when
   there is visibly something to avoid. */
.phone::before {
  content: ""; position: absolute; z-index: 60;
  top: 9px; left: 50%; transform: translateX(-50%);
  width: 122px; height: 33px; border-radius: 20px; background: #000;
}

.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }

/* ── Status bar ───────────────────────────────────────────────────────────── */
.statusbar {
  height: 52px; flex: none; display: flex; align-items: flex-end;
  justify-content: space-between; padding: 0 26px 2px;
  font: 600 14px/1 var(--font-ui); letter-spacing: -0.01em;
  color: var(--ink); position: relative; z-index: 50;
}
.statusbar .glyphs { display: flex; gap: 5px; align-items: center; }
.statusbar svg { display: block; }

/* ── Navigation: the large title that collapses ───────────────────────────── */
/* ⚠ The compact bar is TRANSLUCENT and content scrolls UNDER it — not an opaque strip that
   eats 44px of a phone screen. The bright top edge is light catching the material. */
.navbar {
  position: absolute; inset: 52px 0 auto 0; z-index: 40;
  height: 46px; display: flex; align-items: center; justify-content: center;
  background: var(--chrome);
  backdrop-filter: var(--chrome-blur); -webkit-backdrop-filter: var(--chrome-blur);
  border-bottom: 1px solid transparent;
  opacity: 0; pointer-events: none;
  transition: opacity 200ms var(--ease-out), border-color 200ms var(--ease-out);
}
.navbar.is-shown { opacity: 1; pointer-events: auto; border-bottom-color: var(--rule); }
.navbar h2 {
  font: 600 17px/1 var(--font-ui); letter-spacing: -0.012em;
  color: var(--ink); margin: 0;
}

.scroll {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 calc(var(--s-8) + 64px);
}

.largetitle {
  padding: 8px 20px 10px;
  font-family: var(--font-display); font-weight: 600;
  font-size: 34px; line-height: 1.08; letter-spacing: -0.02em;
  color: var(--ink); text-wrap: balance;
}
.largetitle .sub {
  display: block; margin-top: 4px;
  font: 400 15px/1.4 var(--font-ui); letter-spacing: 0;
  color: var(--ink-tertiary);
}

/* ── Grouped inset list ───────────────────────────────────────────────────── */
.group { margin: 0 16px 22px; }
.group-label {
  font: 600 12px/1 var(--font-ui); letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-tertiary); padding: 0 6px 8px;
}
.list {
  background: var(--bg-raised); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow-1);
}
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; min-height: var(--tap-min);
  border-bottom: 1px solid var(--rule);
  transition: transform var(--t-press) var(--ease-out),
              background-color var(--t-press) var(--ease-out);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font: 500 16px/1.3 var(--font-ui); letter-spacing: -.006em; color: var(--ink); }
.row .meta  { font: 400 13px/1.35 var(--font-ui); color: var(--ink-tertiary); margin-top: 2px; }
.row .value { font: 400 16px/1 var(--font-ui); color: var(--ink-tertiary); font-variant-numeric: tabular-nums; }
.chev { width: 8px; height: 13px; flex: none; opacity: .3; }

@media (hover: hover) and (pointer: fine) {
  .row[data-press]:hover { background: var(--bg-sunken); }
}

/* ── Segmented control ────────────────────────────────────────────────────── */
.segmented {
  display: flex; margin: 0 16px 20px; padding: 2px; gap: 2px;
  background: var(--bg-sunken); border-radius: 10px; position: relative;
}
.segmented button {
  flex: 1; border: 0; background: transparent; z-index: 1;
  font: 500 14px/1 var(--font-ui); letter-spacing: -.006em; color: var(--ink);
  padding: 8px 4px; border-radius: 8px; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.segmented .thumb {
  position: absolute; top: 2px; bottom: 2px; left: 2px;
  background: var(--bg-raised); border-radius: 8px; box-shadow: var(--shadow-1);
  z-index: 0; will-change: transform, width;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap-min); padding: 13px 22px; border: 0; border-radius: var(--r-full);
  font: 600 17px/1 var(--font-ui); letter-spacing: -.012em; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: transform var(--t-press) var(--ease-out), background-color var(--t-press) var(--ease-out);
}
.btn-primary { background: var(--action); color: var(--action-ink); }
.btn-quiet   { background: var(--bg-sunken); color: var(--ink); }
.btn-full    { display: flex; width: 100%; }

/* ── Live badge. Chartreuse is ENERGY, never "success". ───────────────────── */
.live {
  display: inline-flex; align-items: center; gap: 6px;
  font: 600 11px/1 var(--font-ui); letter-spacing: .08em; text-transform: uppercase;
  color: var(--navy); background: var(--live);
  padding: 5px 9px 5px 7px; border-radius: var(--r-full);
}
.live .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--navy); }
@media (prefers-reduced-motion: no-preference) {
  .live .dot { animation: pulse 2s var(--ease-in-out) infinite; }
}
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* ── Tab bar ──────────────────────────────────────────────────────────────── */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 45;
  display: flex; padding: 8px 8px calc(8px + 18px);
  background: var(--chrome);
  backdrop-filter: var(--chrome-blur); -webkit-backdrop-filter: var(--chrome-blur);
  border-top: 1px solid var(--rule);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: transparent; cursor: pointer; padding: 5px 0;
  font: 500 10px/1 var(--font-ui); letter-spacing: .01em;
  color: var(--ink-tertiary);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  transition: color var(--t-press) var(--ease-out);
}
.tab[aria-selected="true"] { color: var(--action); }
.tab svg { width: 25px; height: 25px; }

/* The home indicator. */
.homebar {
  position: absolute; z-index: 46; bottom: 7px; left: 50%; transform: translateX(-50%);
  width: 138px; height: 5px; border-radius: 3px; background: var(--ink); opacity: .28;
}

/* ── Sheet ────────────────────────────────────────────────────────────────── */
.scrim {
  position: absolute; inset: 0; z-index: 70; background: rgba(0,10,22,.42);
  opacity: 0; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.sheet-panel {
  position: absolute; z-index: 71; left: 0; right: 0; bottom: 0;
  background: var(--bg-raised);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: 0 -8px 40px rgba(0,0,0,.28);
  padding: 10px 20px calc(20px + 22px);
  will-change: transform; touch-action: none;
}
.grabber {
  width: 36px; height: 5px; border-radius: 3px; background: var(--ink);
  opacity: .18; margin: 0 auto 14px;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-raised); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); padding: 18px; margin: 0 16px 16px;
}
.card.navy { background: var(--navy); color: var(--cream); box-shadow: var(--shadow-2); }
.card.navy .muted { color: #9FB3C6; }

.hero-number {
  font-family: var(--font-display); font-weight: 600;
  font-size: 76px; line-height: .9; letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}

.divider { height: 1px; background: var(--rule); margin: 14px 0; }
.muted { color: var(--ink-tertiary); }
.mono-nums { font-variant-numeric: tabular-nums; }

/* Avatar */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; overflow: hidden;
  background: var(--navy-70); color: var(--cream);
  font: 600 15px/1 var(--font-ui); letter-spacing: -.01em;
}
.avatar.lg { width: 108px; height: 108px; font-size: 40px; }

/* ── Reduced motion ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .navbar { transition-duration: 1ms; }
  .live .dot { animation: none; }
  * { scroll-behavior: auto !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .navbar, .tabbar { background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
