/* =============================================================================
   styles.css  —  Pushups  (clean dark, near-monochrome: one energetic accent)
   -----------------------------------------------------------------------------
   The progress ring is the signature element — the accent lives there, on the
   "hit" bars, and on the streak. Everything else stays quiet near-monochrome.
   ========================================================================== */

:root {
  --bg:          #0B0B0D;   /* app background (near-black)            */
  --surface:     #151517;   /* cards                                  */
  --surface-2:   #202024;   /* inputs, segmented track                */
  --surface-3:   #2A2A30;   /* pressed / hover                        */
  --border:      rgba(255, 255, 255, 0.08);
  --border-2:    rgba(255, 255, 255, 0.14);

  --text:        #F5F5F7;   /* primary text                           */
  --text-dim:    #9A9AA1;   /* secondary                              */
  --text-faint:  #67676E;   /* labels, captions                       */

  --accent:      #FF6B2C;   /* the ONE color — energy / strength      */
  --accent-2:    #FF9A52;   /* lighter accent (ring gradient top)     */
  --accent-dim:  rgba(255, 107, 44, 0.16);
  --danger:      #FF453A;   /* destructive (delete) only              */
  --miss:        #FF453A;   /* alias used by the confirm dialog       */
  --bar-miss:    rgba(255, 255, 255, 0.18);  /* faded "missed" bars   */

  --r:    18px;
  --r-sm: 13px;
  --r-xs: 10px;
  --pill: 999px;

  --maxw: 520px;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  /* intentional type pairing: a rounded display face for the big numbers
     (SF Pro Rounded on iPhone — this app's target), plain text face for UI. */
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-display: ui-rounded, "SF Pro Rounded", "SF Pro Display", "Segoe UI", system-ui, sans-serif;
}

/* ---------------------------------------------------------------- reset */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; background: var(--bg); }

body {
  font-family: var(--font-ui);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }

.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

[hidden] { display: none !important; }

/* keyboard focus is always visible */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------------------------------------------------------------- shell */
#app {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 100%;
  padding: calc(var(--safe-top) + 8px) 18px calc(var(--safe-bottom) + 40px);
  position: relative;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  margin-bottom: 4px;
}
.app-header .title { font-size: 18px; font-weight: 700; letter-spacing: 0.2px; }
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: var(--pill);
  color: var(--text-dim);
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.icon-btn:active { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 21px; height: 21px; }

/* ---------------------------------------------------------------- hero / ring */
.hero { text-align: center; padding: 10px 0 6px; }

.ring-wrap {
  position: relative;
  width: min(64vw, 260px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}
.ring { width: 100%; height: 100%; display: block; overflow: visible; }
.ring-track { stroke: var(--surface-2); }
.ring-fill {
  stroke: url(#ringGrad);
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  transition: stroke-dashoffset 0.7s var(--ease);
}
/* the gradient is injected once by app.js into the same <svg> */

.ring-wrap.done .ring-fill { filter: drop-shadow(0 0 9px rgba(255, 107, 44, 0.55)); }

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.ring-value {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  display: flex;
  align-items: baseline;
  gap: 2px;
  line-height: 1;
}
.ring-value #todayCount {
  font-size: clamp(52px, 17vw, 76px);
  font-weight: 800;
  letter-spacing: -2px;
  color: var(--text);
}
.ring-goal { font-size: 19px; font-weight: 700; color: var(--text-faint); }
.ring-state {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.6px;
  color: var(--text-faint);
  transition: color 0.3s var(--ease);
}
.ring-wrap.done + .streak .streak-flame,
.ring-wrap.done .ring-state { color: var(--accent); }
.ring-wrap.done .ring-value #todayCount { color: var(--accent); }

/* rest day — a calm, monochrome state; the moon carries the meaning, never the
   orange "hit" accent. Shown in place of the "0 / 100" value. */
.ring-rest { display: none; flex-direction: column; align-items: center; gap: 6px; }
.ring-rest-glyph { width: 40px; height: 40px; color: var(--text-dim); }
.ring-rest-text {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.6px;
  color: var(--text-faint);
}
.ring-wrap.rest .ring-value,
.ring-wrap.rest .ring-state { display: none; }
.ring-wrap.rest .ring-rest { display: flex; }
.ring-wrap.rest .ring-fill { stroke: var(--surface-3); filter: none; }

/* streak block */
.streak { margin-top: 16px; }
.streak-main {
  font-family: var(--font-display);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.streak-flame { font-size: 22px; line-height: 1; filter: saturate(1.1); }
.streak-num { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.streak-word { font-size: 18px; font-weight: 600; color: var(--text-dim); }
.streak-sub { margin-top: 6px; font-size: 13px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- quick add */
.quick { margin-top: 22px; }

.quick-add {
  width: 100%;
  height: 76px;
  border-radius: var(--r);
  background: var(--accent);
  color: #1A0A02;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 10px 28px rgba(255, 107, 44, 0.28), 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s var(--ease), box-shadow 0.2s var(--ease), filter 0.12s var(--ease);
}
.quick-add:active { transform: scale(0.975); filter: brightness(1.05); }
.quick-add.pop { animation: qaPop 0.32s var(--ease); }
@keyframes qaPop { 0% { transform: scale(1); } 40% { transform: scale(1.035); } 100% { transform: scale(1); } }
.qa-plus { font-family: var(--font-display); font-size: 30px; font-weight: 800; line-height: 1; }
.qa-num  { font-family: var(--font-display); font-size: 34px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.qa-label { font-size: 16px; font-weight: 700; opacity: 0.7; margin-left: 2px; align-self: flex-end; margin-bottom: 12px; }

.custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.custom .step {
  width: 48px; height: 48px;
  flex: none;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 24px;
  font-weight: 600;
  display: grid; place-items: center;
  transition: background 0.12s var(--ease);
}
.custom .step:active { background: var(--surface-3); }
.custom-input {
  flex: 1;
  min-width: 0;
  height: 48px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.custom-input:focus { outline: none; border-color: var(--border-2); background: var(--surface-3); }
.custom-add {
  flex: none;
  height: 48px;
  padding: 0 20px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  transition: background 0.12s var(--ease), transform 0.1s var(--ease);
}
.custom-add:active { background: var(--surface-3); transform: scale(0.97); }

/* rest-day button — quiet secondary action, distinct from the bold orange
   quick-add. Neutral by default; a calm filled state when today is marked. */
.rest-btn {
  width: 100%;
  height: 50px;
  margin-top: 10px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.1s var(--ease);
}
.rest-btn:active { transform: scale(0.985); background: var(--surface-2); }
.rest-btn .rest-icon { width: 18px; height: 18px; flex: none; }
.rest-btn.active {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text);
}

/* ---------------------------------------------------------------- chart */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 12px 10px;
  margin-top: 26px;
}
.chart-wrap {
  position: relative;
  width: 100%;
  height: 170px;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.chart-wrap svg { display: block; width: 100%; height: 100%; overflow: visible; }

.scrub-readout {
  position: absolute;
  top: 6px; left: 0;
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 5px 10px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--pill);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.scrub-readout .sr-date { font-size: 12px; color: var(--text-dim); }
.scrub-readout .sr-val  { font-size: 14px; font-weight: 700; }
.scrub-readout .sr-val.hit  { color: var(--accent); }
.scrub-readout .sr-val.miss { color: var(--text); }
.scrub-readout .sr-val.rest { color: var(--text-dim); }

.chart-empty {
  height: 170px;
  display: grid; place-items: center;
  color: var(--text-faint);
  font-size: 14px; text-align: center; line-height: 1.5;
}

.timeframe {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  background: var(--surface-2);
  border-radius: var(--pill);
  padding: 4px;
}
.timeframe button {
  flex: 1;
  height: 34px;
  border-radius: var(--pill);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  transition: color 0.15s var(--ease), background 0.2s var(--ease);
}
.timeframe button.active { background: var(--text); color: var(--bg); }

/* ---------------------------------------------------------------- day list */
.list-section { margin-top: 26px; }
.list-title {
  font-size: 13px; font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  padding-left: 4px;
}

.month-group { margin-bottom: 18px; }
.month-head {
  font-size: 12px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  padding: 0 4px 8px;
}
.rows {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.day-block:not(:last-child) { border-bottom: 1px solid var(--border); }

.day-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 11px 16px;
  text-align: left;
  transition: background 0.12s var(--ease);
}
.day-row:active { background: var(--surface-2); }
.day-row.static { cursor: default; }
.day-row.static:active { background: transparent; }
.day-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.day-date { font-size: 16px; font-weight: 600; color: var(--text); }
.day-meta { font-size: 13px; color: var(--text-faint); display: flex; align-items: center; gap: 7px; }
.day-meta .chev { transition: transform 0.2s var(--ease); display: inline-flex; color: var(--text-faint); }
.day-meta .chev svg { width: 13px; height: 13px; }
.day-row.open .day-meta .chev { transform: rotate(90deg); }

.day-right { display: flex; align-items: center; gap: 10px; }
.day-total { font-family: var(--font-display); font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.day-total.hit  { color: var(--accent); }
.day-total.miss { color: var(--text-dim); }
.day-total.rest { color: var(--text-faint); font-weight: 700; }
.day-badge {
  width: 22px; height: 22px;
  flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
}
.day-badge.hit  { background: var(--accent-dim); color: var(--accent); }
.day-badge.miss { background: var(--surface-2); color: var(--text-faint); }
.day-badge.rest { background: var(--surface-2); color: var(--text-dim); }
.day-badge svg { width: 13px; height: 13px; }

/* expanded sets under a day */
.day-sets {
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 8px 16px 8px 22px;
  text-align: left;
  transition: background 0.12s var(--ease);
}
.set-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.set-row:active { background: var(--surface-2); }
.set-time { font-size: 14px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.set-right { display: flex; align-items: center; gap: 8px; color: var(--text-faint); }
.set-count { font-size: 15px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.set-edit svg { width: 15px; height: 15px; }

/* empty state */
.empty { text-align: center; padding: 36px 20px; color: var(--text-faint); }
.empty .big { font-size: 15px; color: var(--text-dim); margin-bottom: 4px; }
.empty .small { font-size: 13px; }

/* ---------------------------------------------------------------- overlays */
.scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s var(--ease);
  z-index: 40;
  backdrop-filter: blur(2px);
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 50%; bottom: 0;
  transform: translate(-50%, 100%);
  width: 100%;
  max-width: var(--maxw);
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--border-2);
  padding: 10px 18px calc(var(--safe-bottom) + 22px);
  transition: transform 0.28s var(--ease);
  z-index: 50;
  max-height: 92vh;
  overflow-y: auto;
}
.sheet.open { transform: translate(-50%, 0); }
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 6px auto 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.sheet-title { font-size: 19px; font-weight: 700; }
.sheet-cancel { font-size: 16px; color: var(--text-dim); padding: 6px 2px; }

/* ---------------------------------------------------------------- form bits */
.field { margin-bottom: 18px; }
.field-label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
  padding-left: 2px;
}

.stepper-big { display: flex; align-items: center; gap: 10px; }
.step-big {
  width: 64px; height: 64px;
  flex: none;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 30px; font-weight: 500;
  display: grid; place-items: center;
  transition: background 0.12s var(--ease), transform 0.1s var(--ease);
}
.step-big:active { background: var(--surface-3); transform: scale(0.96); }
.count-input {
  flex: 1;
  min-width: 0;
  height: 64px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-size: 30px; font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.count-input:focus { outline: none; border-color: var(--border-2); background: var(--surface-3); }
.set-when { margin-top: 10px; font-size: 13px; color: var(--text-faint); text-align: center; }

/* ---------------------------------------------------------------- buttons */
.btn {
  width: 100%;
  height: 54px;
  border-radius: var(--r-sm);
  font-size: 17px; font-weight: 700;
  transition: transform 0.1s var(--ease), opacity 0.15s var(--ease), background 0.15s var(--ease);
}
.btn:active { transform: scale(0.985); }
.btn-primary { background: var(--accent); color: #1A0A02; }
.btn-primary:disabled { opacity: 0.4; }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--border-2); }
.btn-row { display: flex; gap: 12px; margin-top: 4px; }
.btn-row .btn { margin-top: 0; }

.menu-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 0 6px;
  font-size: 16px; font-weight: 500;
  color: var(--text);
  text-align: left;
  border-radius: var(--r-sm);
  transition: background 0.12s var(--ease);
}
.menu-item:active { background: var(--surface-2); }
.menu-item .mi-icon { width: 40px; height: 40px; border-radius: var(--r-xs); background: var(--surface-2); display: grid; place-items: center; color: var(--text-dim); flex: none; }
.menu-item .mi-icon svg { width: 20px; height: 20px; }
.menu-item .mi-text { display: flex; flex-direction: column; gap: 2px; }
.menu-item .mi-sub { font-size: 13px; color: var(--text-faint); font-weight: 400; }
.menu-sep { height: 1px; background: var(--border); margin: 8px 0; }
.about-line { text-align: center; color: var(--text-faint); font-size: 12px; padding: 6px 0 2px; }

/* ---------------------------------------------------------------- dialog */
.dialog {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(0.94);
  width: calc(100% - 64px);
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r);
  padding: 22px 20px 18px;
  z-index: 60;
  opacity: 0; pointer-events: none;
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
  text-align: center;
}
.dialog.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.dialog-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.dialog-msg { font-size: 14px; color: var(--text-dim); line-height: 1.45; margin-bottom: 20px; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--safe-bottom) + 28px);
  transform: translate(-50%, 16px);
  max-width: calc(var(--maxw) - 36px);
  width: max-content;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  padding: 12px 18px;
  border-radius: var(--pill);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 80;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--danger); }

/* ---------------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .ring-fill { transition: none; }
}
