/* ==================================================================
   Reset, typography and the page frame
   ================================================================== */

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

/**
 * The `hidden` attribute is only display:none in the user-agent
 * stylesheet, so any author rule that sets `display` beats it. That is
 * not a nicety: a fixed full-screen scrim with display:grid will sit
 * invisibly over the whole app and swallow every tap.
 */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--wash), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  font-feature-settings: 'cv05' 1, 'cv11' 1, 'ss03' 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--topbar-h);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  overflow-wrap: break-word;
}

h1, h2, h3, h4 {
  margin: 0 0 var(--s-2);
  font-family: var(--font-sans);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  font-weight: 620;
  text-wrap: balance;
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); letter-spacing: var(--tracking-snug); }
h4 { font-size: var(--text-md); letter-spacing: var(--tracking-snug); }

p { margin: 0 0 var(--s-3); text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 32%, transparent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1.5px;
  transition: text-decoration-color var(--t-fast);
}
a:hover { text-decoration-color: currentColor; }

small { font-size: var(--text-sm); color: var(--ink-2); }

ul, ol { margin: 0 0 var(--s-3); padding-inline-start: var(--s-5); }
li { margin-bottom: var(--s-1); }

img, svg, video { max-width: 100%; display: block; }

button, input, select, textarea { font: inherit; color: inherit; }

code, kbd {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-3);
  border-radius: var(--r-xs);
  padding: 1px 5px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection { background: var(--accent-soft-2); color: var(--accent-ink); }

/* Numbers in stats and timers must not jitter as they tick. */
.tabular { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: var(--s-2) var(--s-4);
  border-radius: 0 0 var(--r-md) 0;
}
.skip-link:focus { left: 0; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------------
   Frame
   ------------------------------------------------------------------ */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-3);
  background: var(--glass);
  backdrop-filter: saturate(190%) blur(20px);
  -webkit-backdrop-filter: saturate(190%) blur(20px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  color: inherit;
  text-decoration: none;
  flex-shrink: 0;
  padding: var(--s-1);
  margin: calc(var(--s-1) * -1);
  border-radius: var(--r-sm);
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--accent) 5%, var(--g4) 60%, var(--teal) 130%);
  color: #fff;
  box-shadow: 0 2px 8px -2px rgb(var(--accent-glow) / 0.5);
  overflow: hidden;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 55%);
}
.brand-mark svg { width: 17px; height: 17px; stroke: currentColor; fill: none; position: relative; }

.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text strong {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 650;
  letter-spacing: var(--tracking-tight);
}
.brand-text small {
  font-size: var(--text-2xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--ink-3);
  font-weight: 600;
}

.crumb {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--ink-2);
  text-align: end;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-inline: var(--s-2);
}

/* With a back button showing, the wordmark collapses to its glyph so the
   breadcrumb keeps its room on a narrow phone. */
.topbar:has(#nav-back:not([hidden])) .brand-text { display: none; }

.view {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--s-5) var(--gutter) var(--s-16);
  outline: none;
}

.view > * { animation: rise var(--t-slow) var(--ease-out) both; }

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

/* ---- Tab bar ------------------------------------------------------- */

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  background: var(--glass-strong);
  backdrop-filter: saturate(190%) blur(20px);
  -webkit-backdrop-filter: saturate(190%) blur(20px);
  border-top: 1px solid var(--line);
}

.tabbar a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink-3);
  text-decoration: none;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.tabbar a svg {
  width: 21px; height: 21px;
  stroke: currentColor; fill: none;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
  transition: transform var(--t-base) var(--ease-spring), stroke-width var(--t-fast);
}
.tabbar a:active svg { transform: scale(0.88); }
.tabbar a[aria-current='page'] { color: var(--accent); }
.tabbar a[aria-current='page'] svg { stroke-width: 2.2; }

/* A short bar marks the current tab rather than a filled pill, which
   would fight the icons for attention. */
.tabbar a[aria-current='page']::before {
  content: '';
  position: absolute;
  top: 0;
  width: 24px;
  height: 2.5px;
  border-radius: 0 0 var(--r-full) var(--r-full);
  background: var(--accent);
  animation: tab-in var(--t-base) var(--ease-out) both;
}
@keyframes tab-in { from { width: 0; opacity: 0; } to { width: 24px; opacity: 1; } }

/* On a desktop the tab bar stops being phone chrome and becomes a quiet
   row of filters at the top of the content. */
@media (min-width: 900px) {
  body { padding-bottom: var(--s-10); }
  .tabbar {
    position: sticky;
    top: var(--topbar-h);
    inset-inline: auto;
    max-width: var(--measure);
    margin: 0 auto;
    height: auto;
    grid-auto-columns: auto;
    justify-content: start;
    gap: var(--s-1);
    padding: var(--s-3) var(--gutter) var(--s-1);
    background: transparent;
    backdrop-filter: none;
    border-top: 0;
  }
  .tabbar a {
    flex-direction: row;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-full);
    font-size: var(--text-sm);
  }
  .tabbar a:hover { color: var(--ink); background: var(--surface-2); }
  .tabbar a[aria-current='page'] { background: var(--accent-soft); color: var(--accent-ink); }
  .tabbar a[aria-current='page']::before { display: none; }
}

/* ---- Boot ---------------------------------------------------------- */
.boot {
  display: grid;
  place-items: center;
  gap: var(--s-4);
  min-height: 52vh;
  color: var(--ink-3);
  font-size: var(--text-sm);
}
.boot-pulse {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2.5px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
