/*
  style.css — All visual styles. Mobile-first (base = 375px).
  CSS custom properties drive every colour, size, and timing value.
  data-mode on .app switches the accent theme; .switching fades the ring
  interior on mode change. Scales up cleanly at 500px+ (desktop).
*/

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Palette */
  --bg:          #111113;
  --surface:     #1A1A1E;
  --surface-2:   #25252B;
  --accent:      #E8572A;
  --accent-dim:  rgba(232, 87, 42, 0.20);
  --text:        #F0ECE8;
  --text-muted:  #68687A;
  --ring-track:  #252530;

  /* Ring geometry — keep r in sync with SVG r="120" */
  --ring-size:   252px;

  /* Timing */
  --t-fast: 0.14s;
  --t-med:  0.28s;
  --t-ring: 1s linear;
}

/* ── Mode accent overrides ── */
.app[data-mode="short-break"] {
  --accent:     #2DD4BF;
  --accent-dim: rgba(45, 212, 191, 0.17);
}
.app[data-mode="long-break"] {
  --accent:     #818CF8;
  --accent-dim: rgba(129, 140, 248, 0.17);
}

/* ── Base ── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* ── App card ── */
.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  padding: 32px 20px 36px;
  background: var(--surface);
  border-radius: 28px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 16px 56px rgba(0, 0, 0, 0.55);
}

/* ── Mode nav ── */
.mode-nav {
  display: flex;
  gap: 3px;
  background: var(--surface-2);
  border-radius: 100px;
  padding: 4px;
  width: 100%;
}

.mode-btn {
  flex: 1;
  padding: 8px 4px;
  border: none;
  border-radius: 100px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.mode-btn:hover:not(.active) { color: var(--text); }
.mode-btn.active {
  background: var(--accent);
  color: #fff;
  transition: background var(--t-med), color var(--t-fast);
}

/* ── Ring wrapper ── */
.ring-wrapper {
  position: relative;
  width: var(--ring-size);
  height: var(--ring-size);
}

/* SVG rotated so arc starts at 12 o'clock */
.ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 0 14px var(--accent-dim));
  transition: filter var(--t-med);
  overflow: visible;
}

.ring-track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 12;
}

.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 12;
  stroke-linecap: round;
  /* dasharray/dashoffset initialised in app.js */
  transition: stroke-dashoffset var(--t-ring),
              stroke var(--t-med) ease;
}

/* ── Ring inner (time + mode label) ── */
.ring-inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity var(--t-fast);
}

/* Subtle fade when switching modes */
.app.switching .ring-inner { opacity: 0.35; }

.time-display {
  font-size: clamp(3rem, 15vw, 3.8rem);
  font-weight: 700;
  letter-spacing: -3px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
}

.mode-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Controls ── */
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-start {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 100px;
  padding: 15px 54px;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity var(--t-fast), transform var(--t-fast),
              background var(--t-med);
}
.btn-start:hover  { opacity: 0.87; }
.btn-start:active { transform: scale(0.96); }

.btn-reset {
  background: transparent;
  border: 1.5px solid var(--surface-2);
  color: var(--text-muted);
  border-radius: 100px;
  padding: 13px 22px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.btn-reset:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

/* ── Session label ── */
.session-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-align: center;
  transition: opacity var(--t-med);
}

/* ── Footer ── */
.app-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.6;
  text-align: center;
  line-height: 1.6;
}
.footer-sep   { opacity: 0.5; }
.footer-hints { letter-spacing: 0.02em; }

/* ── Toolbar (sound + notification toggles) ── */
.toolbar {
  display: flex;
  gap: 6px;
  align-self: flex-end;
  margin-top: -14px; /* tuck up against the mode-nav */
}

.toolbar-btn {
  background: transparent;
  border: 1px solid var(--surface-2);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  transition: border-color var(--t-fast), opacity var(--t-fast);
}
.toolbar-btn:hover:not(:disabled)              { border-color: var(--text-muted); }
.toolbar-btn[aria-pressed="false"]             { opacity: 0.28; }
.toolbar-btn:disabled                          { opacity: 0.18; cursor: not-allowed; }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
}

.stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 14px 8px 12px;
  background: var(--bg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  box-shadow: 0 0 18px var(--accent-dim), inset 0 1px 0 rgba(255,255,255,0.04);
  transition: box-shadow var(--t-med), border-color var(--t-med);
}
.stat-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 28px var(--accent-dim), inset 0 1px 0 rgba(255,255,255,0.06);
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}

/* ── Session history ── */
.history-panel {
  width: 100%;
  border-top: 1px solid var(--surface-2);
  padding-top: 2px;
}

.history-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 2px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.history-toggle::-webkit-details-marker { display: none; }

.history-toggle-label { flex: 1; }

.history-count {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  font-variant-numeric: tabular-nums;
}

.history-chevron {
  font-size: 1.1rem;
  line-height: 1;
  transition: transform var(--t-fast);
  display: inline-block;
}
.history-panel[open] .history-chevron { transform: rotate(90deg); }

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 250px;
  overflow-y: auto;
  margin: 4px 0 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-2) transparent;
}

.history-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 20px 0;
  opacity: 0.55;
}

.history-row {
  display: grid;
  grid-template-columns: 2.2rem auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 6px;
  border-radius: 8px;
  transition: background var(--t-fast);
}
.history-row:hover { background: var(--surface-2); }

.history-num {
  color: var(--text-muted);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.7;
  text-align: right;
}

.history-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 100px;
  white-space: nowrap;
}
.badge-focus       { background: rgba(232, 87, 42,  0.14); color: #E8572A; }
.badge-short-break { background: rgba(45,  212, 191, 0.14); color: #2DD4BF; }
.badge-long-break  { background: rgba(129, 140, 248, 0.14); color: #818CF8; }

.history-dur {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  opacity: 0.7;
}

.history-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0.6;
  white-space: nowrap;
  text-align: right;
}

.btn-clear-history {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid var(--surface-2);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast);
  margin-bottom: 4px;
}
.btn-clear-history:hover {
  border-color: rgba(232, 87, 42, 0.5);
  color: #E8572A;
}

/* ── Keyboard hint badges ── */
kbd {
  display: inline-block;
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 0.65rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* ── Settings overlay ── */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-med);
}
.settings-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ── Settings drawer ── */
.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 90vw);
  background: var(--surface);
  border-left: 1px solid var(--surface-2);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.26s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}
.settings-drawer.open { transform: translateX(0); }

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--surface-2);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.settings-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}

.settings-close {
  background: transparent;
  border: 1px solid var(--surface-2);
  border-radius: 8px;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.settings-close:hover { border-color: var(--text-muted); color: var(--text); }

.settings-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.7;
  margin-bottom: -8px;
}

.settings-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.settings-val {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
  transition: color var(--t-med);
}

/* ── Range slider ── */
.settings-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
  border: none;
}
.settings-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 1px 6px rgba(0,0,0,0.4);
  transition: background var(--t-med), transform var(--t-fast);
}
.settings-range::-webkit-slider-thumb:hover { transform: scale(1.15); }
.settings-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 6px rgba(0,0,0,0.4);
}

/* ── Desktop scale-up ── */
@media (min-width: 500px) {
  :root         { --ring-size: 284px; }
  .app          { gap: 30px; padding: 40px 36px 44px; max-width: 440px; }
  .mode-btn     { font-size: 0.82rem; padding: 9px 10px; }
  .time-display { font-size: 3.8rem; }
  .stats-grid   { grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .stat-value   { font-size: 2rem; }
}
