/* ==========================================================================
   FocusCue — app-specific styles  (layers on top of a4t-ui.css tokens)
   Accent is set inline in index.html: --accent: #FF8C42 (Focus orange).
   Mobile-first. Reduced motion respected (the design system handles most;
   the spark burst is explicitly disabled below too).
   ========================================================================== */

.a4t-brand__by { color: var(--text-faint); font-weight: var(--fw-medium); }
@media (max-width: 24rem) {
  .a4t-brand__by { display: none; } /* keep the brand tight on tiny phones */
}

.focus-intro { margin-bottom: var(--space-6); }

/* --------------------------------------------------------------------------
   First-run onboarding card (shown once; dismissed forever)
   -------------------------------------------------------------------------- */
.onboard { margin-bottom: var(--space-5); gap: var(--space-3); }
.onboard__steps {
  margin: 0;
  padding-left: 1.3em;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  color: var(--text-muted);
}
.onboard__steps strong { color: var(--text); }
.onboard .btn { align-self: start; }

/* --------------------------------------------------------------------------
   Timer card
   -------------------------------------------------------------------------- */
.timer-card {
  align-items: center;
  text-align: center;
  gap: var(--space-4);
  padding-block: var(--space-6);
}

/* Mode pill */
.timer-mode {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.3rem 0.9rem;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: var(--fw-bold);
  font-size: var(--fs-caption);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}
.timer-mode__dot {
  width: 0.6rem; height: 0.6rem;
  border-radius: var(--radius-pill);
  background: var(--accent);
  flex: none;
}
/* Break mode recolors the pill (teal = fresh/secondary brand color) */
.timer-card[data-mode="break"] .timer-mode {
  background: color-mix(in srgb, var(--c-teal) 16%, var(--c-white) 84%);
  color: color-mix(in srgb, var(--c-teal) 78%, #000 22%);
}
.timer-card[data-mode="break"] .timer-mode__dot { background: var(--c-teal); }

/* Cycle dots — progress through the run of blocks before the long break */
.cycle-dots {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: calc(-1 * var(--space-2));
}
.cycle-dots__dot {
  width: 0.55rem; height: 0.55rem;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  border: 1px solid var(--surface-line);
  transition: background var(--t-base), transform var(--t-base);
}
.cycle-dots__dot.is-done {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.15);
}

/* --------------------------------------------------------------------------
   Dial: SVG progress ring + big numeric time
   -------------------------------------------------------------------------- */
.timer-dial {
  position: relative;
  width: min(72vw, 18rem);
  aspect-ratio: 1 / 1;
  margin-block: var(--space-2);
}
.timer-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-ring__track {
  fill: none;
  stroke: var(--bg-sunken);
  stroke-width: 14;
}
.timer-ring__progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 14;
  stroke-linecap: round;
  /* circumference = 2*pi*r = 2*pi*110 ≈ 691.15; set via JS too as a fallback */
  stroke-dasharray: 691.15;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.95s linear, stroke var(--t-base);
}
.timer-card[data-mode="break"] .timer-ring__progress { stroke: var(--c-teal); }

.timer-time {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: var(--fw-black);
  font-size: clamp(2.75rem, 14vw, 4rem);
  letter-spacing: var(--ls-tight);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* Subtle pulse while running (motion-safe) */
.timer-card[data-running="true"] .timer-time { animation: timePulse 2s var(--ease-in-out) infinite; }
@keyframes timePulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.78; }
}

.timer-goal { width: 100%; max-width: 26rem; text-align: left; }

/* Controls */
.timer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: center;
  width: 100%;
}
.timer-controls__start { min-width: 9rem; }
.timer-hint { color: var(--text-faint); }
.timer-hint kbd {
  background: var(--bg-sunken);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-xs);
  padding: 0.05rem 0.35rem;
  font-size: 0.85em;
}

/* --------------------------------------------------------------------------
   Presets
   -------------------------------------------------------------------------- */
.presets { margin-top: var(--space-7); }
.presets__head { margin-bottom: var(--space-4); }
.presets__chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.preset-chip { min-height: var(--tap-min); padding-inline: var(--space-4); }

.presets__head { align-items: start; flex-wrap: wrap; gap: var(--space-2) var(--space-4); }
.presets__toggles {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  align-items: flex-end;
}
@media (max-width: 30rem) {
  .presets__toggles { align-items: flex-start; }
}
.sound-toggle, .notify-toggle { font-size: var(--fs-caption); color: var(--text-muted); }
.notify-hint { margin-top: var(--space-2); }

.custom-panel { margin-top: var(--space-4); gap: var(--space-4); }
.custom-panel__fields {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 30rem) {
  .custom-panel__fields { grid-template-columns: 1fr 1fr; }
}
.custom-panel .btn { align-self: start; }
.custom-panel .field__hint[role="alert"] { color: var(--c-danger); font-weight: var(--fw-medium); }

/* --------------------------------------------------------------------------
   Session log
   -------------------------------------------------------------------------- */
.log { margin-top: var(--space-7); scroll-margin-top: 4.5rem; }
.log__head { margin-bottom: var(--space-4); }

.log__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-3);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.stat__num {
  font-family: var(--font-display);
  font-weight: var(--fw-black);
  font-size: var(--fs-h2);
  color: var(--accent);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat__label { font-size: var(--fs-caption); color: var(--text-muted); line-height: var(--lh-snug); }

.log__list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.log__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--surface-line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
}
.log__item-time { font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); color: var(--text); flex: none; }
.log__item-goal { color: var(--text-muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log__item-dur { color: var(--text-faint); font-size: var(--fs-caption); flex: none; }

.log__empty { color: var(--text-faint); padding-block: var(--space-3); }

/* --------------------------------------------------------------------------
   Last 7 days — tiny on-device history bars (today highlighted)
   -------------------------------------------------------------------------- */
.week { margin-top: var(--space-6); }
.week__head { margin-bottom: var(--space-3); align-items: baseline; }
.week__total { color: var(--text-faint); }

/* --------------------------------------------------------------------------
   Your data — backup / restore / move (on-device, never a server)
   -------------------------------------------------------------------------- */
.databox { margin-top: var(--space-7); scroll-margin-top: 4.5rem; }
.databox__head { margin-bottom: var(--space-2); align-items: baseline; flex-wrap: wrap; gap: var(--space-1) var(--space-4); }
.databox__summary { font-weight: var(--fw-bold); color: var(--text-muted); }
.databox__note { margin-bottom: var(--space-4); }
.databox__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.databox__restore { cursor: pointer; }
.databox__msg { margin-top: var(--space-3); }
.databox__qr { margin-top: var(--space-4); }
.databox__qr-box {
  background: #fff;
  border-radius: var(--radius-lg, 16px);
  padding: var(--space-4);
  max-width: 300px;
  line-height: 0;
}
.databox__qr-box svg { width: 100%; height: auto; display: block; }
.databox__qr-note { margin-top: var(--space-3); max-width: 46ch; }
.week__bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--space-2);
  align-items: end;
  height: 5.5rem;
  padding: var(--space-3) var(--space-3) var(--space-2);
  background: var(--bg-elevated);
  border: 1px solid var(--surface-line);
  border-radius: var(--radius-md);
}
.week__day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
  height: 100%;
  min-width: 0;
}
.week__bar {
  width: min(100%, 1.4rem);
  background: color-mix(in srgb, var(--accent) 35%, var(--bg-sunken));
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  transition: height var(--t-base);
}
.week__day.is-today .week__bar { background: var(--accent); }
.week__label {
  font-size: var(--fs-caption);
  color: var(--text-faint);
  line-height: 1;
}
.week__day.is-today .week__label { color: var(--accent-strong); font-weight: var(--fw-bold); }

/* --------------------------------------------------------------------------
   Spark completion moment (delight — used sparingly, one per block end)
   -------------------------------------------------------------------------- */
.spark-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-toast);
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: color-mix(in srgb, var(--c-navy-dark) 30%, transparent);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base), visibility var(--t-base);
  pointer-events: none;
}
.spark-overlay.is-open { opacity: 1; visibility: visible; pointer-events: auto; }
.spark-overlay__card {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border-top: 4px solid var(--accent);
  padding: var(--space-6) var(--space-7);
  text-align: center;
  transform: translateY(10px) scale(0.96);
  transition: transform var(--t-slow);
}
.spark-overlay.is-open .spark-overlay__card { transform: none; }
.spark-overlay__burst {
  font-size: 3rem;
  color: var(--accent);
  line-height: 1;
  margin-bottom: var(--space-3);
  animation: sparkPop 0.6s var(--ease-spring) both;
}
@keyframes sparkPop {
  0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
  60%  { transform: scale(1.25) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.spark-overlay__title { font-family: var(--font-display); font-weight: var(--fw-black); font-size: var(--fs-h2); }
.spark-overlay__sub { color: var(--text-muted); margin-top: var(--space-1); }

/* --------------------------------------------------------------------------
   Legal pages (terms.html / privacy.html / disclaimer.html) shared layout
   -------------------------------------------------------------------------- */
.legal-doc { line-height: var(--lh-relaxed); }
.legal-doc h1 { margin-bottom: var(--space-2); }
.legal-doc h2 { margin-top: var(--space-6); margin-bottom: var(--space-2); font-size: var(--fs-h3); }
.legal-doc h3 { margin-top: var(--space-4); margin-bottom: var(--space-1); }
.legal-doc p, .legal-doc ul, .legal-doc ol { margin-bottom: var(--space-4); }
.legal-doc ul, .legal-doc ol { padding-left: 1.4em; }
.legal-doc li { margin-bottom: var(--space-2); }
.legal-doc hr { margin-block: var(--space-6); }
.legal-draft {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--surface-line));
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-weight: var(--fw-bold);
  color: var(--accent-strong);
  margin-bottom: var(--space-5);
}
.legal-meta { color: var(--text-muted); font-size: var(--fs-caption); }
.legal-back { margin-bottom: var(--space-5); display: inline-flex; }

/* --------------------------------------------------------------------------
   Reduced motion: kill the celebratory animations explicitly
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .timer-card[data-running="true"] .timer-time { animation: none; }
  .spark-overlay__burst { animation: none; }
  .timer-ring__progress { transition: none; }
  .spark-overlay__card { transition: opacity var(--t-base); transform: none; }
}
