/* Rig Console — presentation layer.
   Theme tokens live on :root and are overridden by [data-theme="light"].
   Nothing in this stylesheet hides the #site-footer marker. */

:root {
  --bg: #0b1020;
  --bg-glow-a: rgba(96, 165, 250, 0.22);
  --bg-glow-b: rgba(167, 139, 250, 0.20);
  --surface: rgba(20, 27, 48, 0.78);
  --surface-2: rgba(31, 41, 68, 0.72);
  --border: rgba(148, 163, 184, 0.20);
  --border-strong: rgba(148, 163, 184, 0.36);
  --text: #e8ecf8;
  --text-dim: #a3aec6;
  --accent: #6ea8ff;
  --accent-2: #a78bfa;
  --accent-ink: #071022;
  --track: rgba(148, 163, 184, 0.22);
  --shadow: 0 24px 60px rgba(3, 7, 18, 0.55);
  --radius: 18px;
  --radius-sm: 12px;
  --maxw: 62rem;
}

[data-theme="light"] {
  --bg: #eef2fb;
  --bg-glow-a: rgba(59, 130, 246, 0.18);
  --bg-glow-b: rgba(139, 92, 246, 0.16);
  --surface: rgba(255, 255, 255, 0.86);
  --surface-2: rgba(248, 250, 255, 0.92);
  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.20);
  --text: #101733;
  --text-dim: #55617d;
  --accent: #2f6fed;
  --accent-2: #7c3aed;
  --accent-ink: #ffffff;
  --track: rgba(15, 23, 42, 0.12);
  --shadow: 0 20px 48px rgba(15, 23, 42, 0.14);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(58rem 34rem at 12% -12%, var(--bg-glow-a), transparent 62%),
    radial-gradient(46rem 30rem at 96% 6%, var(--bg-glow-b), transparent 58%);
  background-attachment: fixed;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 20;
  padding: 0.55rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 650;
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 140ms ease;
}

.skip-link:focus-visible {
  transform: translateY(0);
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1rem clamp(1rem, 4vw, 2rem);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 11px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 0.98rem;
  font-weight: 680;
  letter-spacing: 0.01em;
}

.brand-text em {
  font-style: normal;
  font-size: 0.74rem;
  color: var(--text-dim);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}

.theme-toggle:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.theme-toggle-icon {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: inset -4px -1px 0 0 var(--surface);
}

[data-theme="light"] .theme-toggle-icon {
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.18);
}

/* ---------- layout ---------- */

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.5rem clamp(1rem, 4vw, 2rem) 3rem;
  display: grid;
  gap: clamp(1rem, 2.4vw, 1.5rem);
  align-content: start;
}

.hero {
  text-align: center;
  padding: clamp(1rem, 3vw, 2rem) 0 0.25rem;
}

h1 {
  margin: 0 0 0.7rem;
  font-size: clamp(2.1rem, 6vw, 3.6rem);
  font-weight: 760;
  letter-spacing: -0.02em;
  line-height: 1.05;
  background: linear-gradient(120deg, var(--text) 18%, var(--accent) 62%, var(--accent-2) 96%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.9rem;
  padding: 0.34em 0.95em;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 640;
  letter-spacing: 0.04em;
}

#plan-badge::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.22);
}

.lede {
  max-width: 46rem;
  margin: 0 auto;
  color: var(--text-dim);
  font-size: clamp(0.95rem, 1.6vw, 1.05rem);
}

/* ---------- cards ---------- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: clamp(1.1rem, 3vw, 1.75rem);
  backdrop-filter: blur(14px);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.card-head h2 {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 660;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.pill {
  padding: 0.22em 0.7em;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.76rem;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
}

/* ---------- counter dial ---------- */

.counter-card {
  display: grid;
  justify-items: center;
  gap: 1.25rem;
}

.counter-card .card-head {
  width: 100%;
  margin-bottom: 0;
}

.dial {
  position: relative;
  width: clamp(13rem, 42vw, 16rem);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
}

.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 9;
  stroke-linecap: round;
}

.ring-track {
  stroke: var(--track);
}

.ring-value {
  stroke: var(--accent);
  stroke-dasharray: 326.726;
  stroke-dashoffset: 326.726;
  transition: stroke-dashoffset 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.dial-readout {
  position: relative;
  text-align: center;
}

#counter {
  font-size: clamp(3rem, 11vw, 4.4rem);
  font-weight: 740;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  min-width: 3ch;
}

#counter.bump {
  animation: bump 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes bump {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.dial-goal {
  margin: 0.4rem 0 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- buttons ---------- */

.controls {
  display: grid;
  grid-template-columns: auto minmax(9rem, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  width: min(26rem, 100%);
}

.btn {
  appearance: none;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  padding: 0.72em 1.2em;
  font: inherit;
  font-size: 1rem;
  font-weight: 650;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 160ms ease, border-color 140ms ease,
    background 140ms ease;
}

.btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px) scale(0.99);
}

.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
  box-shadow: 0 12px 26px rgba(110, 168, 255, 0.28);
}

.btn-primary:hover {
  box-shadow: 0 16px 32px rgba(110, 168, 255, 0.38);
}

.btn-ghost {
  min-width: 3.1rem;
  background: transparent;
  color: var(--text-dim);
}

.btn-ghost:hover {
  color: var(--text);
}

.btn-wide {
  min-width: 5.4rem;
  font-size: 0.9rem;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 620;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 1px solid transparent;
}

.link-btn:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.steps {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.steps-label {
  margin-right: 0.25rem;
  color: var(--text-dim);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chip {
  min-width: 2.6rem;
  padding: 0.35em 0.75em;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 640;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease;
}

.chip:hover {
  color: var(--text);
  border-color: var(--accent);
}

.chip[aria-pressed="true"] {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-ink);
}

.hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.82rem;
  text-align: center;
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 0.1em 0.42em;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: var(--surface-2);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78em;
  text-align: center;
}

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.6rem, 2vw, 1rem);
}

.stat {
  display: grid;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.stat-label {
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 640;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.stat-value {
  font-size: clamp(1.25rem, 3.4vw, 1.6rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- activity ---------- */

.activity {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  max-height: 15rem;
  overflow-y: auto;
}

.activity li {
  display: grid;
  grid-template-columns: 2.1rem 1fr auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.9rem;
  animation: slide-in 220ms ease;
}

@keyframes slide-in {
  from { transform: translateY(-4px); }
  to { transform: translateY(0); }
}

.activity .glyph {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  color: var(--accent);
  font-weight: 700;
}

.activity .value {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-size: 0.84rem;
}

.activity-empty {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.is-gone {
  display: none;
}

/* ---------- footer ---------- */

#site-footer {
  flex: 0 0 auto;
  margin-top: auto;
  padding: 1.15rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-align: center;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.75rem;
  z-index: 30;
  padding: 0.6rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 620;
  transform: translate(-50%, 1.5rem);
  opacity: 0;
  pointer-events: none;
  transition: transform 200ms ease, opacity 200ms ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ---------- focus + motion ---------- */

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

@media (max-width: 34rem) {
  .controls {
    grid-template-columns: auto 1fr;
    grid-template-areas: "dec inc" "reset reset";
  }

  #dec { grid-area: dec; }
  #inc { grid-area: inc; }
  #reset { grid-area: reset; }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats .stat:last-child {
    grid-column: span 2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ring-value,
  .btn,
  .chip,
  .toast,
  .theme-toggle,
  .skip-link {
    transition-duration: 1ms;
  }

  .activity li,
  #counter.bump {
    animation-duration: 1ms;
  }
}
