/* style.css — Workout Tracker & Reminder
   Dark mode by default, mobile-first, no frameworks. */

/* ---------- Reset & tokens ---------- */
:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #1e293b;
  --border: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --accent: #22d3ee;
  --accent-strong: #0ea5e9;
  --good: #34d399;
  --danger: #f87171;
  --radius: 14px;
  --max-w: 920px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container { width: 100%; max-width: var(--max-w); margin: 0 auto; padding: 0 1rem; }

/* ---------- Accessibility ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent-strong);
  color: #03121a;
  padding: .6rem 1rem;
  border-radius: 0 0 8px 0;
  z-index: 50;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: .7rem;
  padding-bottom: .7rem;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
}
.nav { display: flex; gap: .4rem; flex-wrap: wrap; }
.nav a {
  color: var(--text-dim);
  text-decoration: none;
  padding: .5rem .75rem;
  border-radius: 8px;
  font-size: .92rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  touch-action: manipulation;
}
.nav a:hover { color: var(--text); background: var(--border); }
.nav a[aria-current="page"] {
  color: var(--accent);
  background: rgba(34, 211, 238, .1);
}

/* ---------- Breadcrumb ---------- */
.breadcrumb { padding-top: 1rem; padding-bottom: 0; }
.breadcrumb ol {
  list-style: none;
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  font-size: .85rem;
  color: var(--text-dim);
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ---------- Main ---------- */
main { flex: 1; padding-top: 1.25rem; padding-bottom: 2rem; }

h1 {
  font-size: 1.7rem;
  margin-bottom: 1rem;
  letter-spacing: -.01em;
}
h2 { font-size: 1.15rem; margin-bottom: .4rem; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin-bottom: 1rem;
}
.card-hint { color: var(--text-dim); font-size: .9rem; margin-bottom: .8rem; }

.today-date { color: var(--text-dim); font-size: .9rem; margin-bottom: .3rem; }
.today-title { color: var(--accent); }
.today-subtitle { color: var(--text-dim); margin-bottom: .9rem; }

/* ---------- Exercise list ---------- */
.exercise-list { list-style: none; }
.exercise-item + .exercise-item { border-top: 1px solid var(--border); }
.exercise-item label {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem .2rem;
  cursor: pointer;
  border-radius: 8px;
}
.exercise-item label:hover { background: rgba(148, 163, 184, .07); }

.exercise-check {
  width: 1.4rem;
  height: 1.4rem;
  accent-color: var(--good);
  flex-shrink: 0;
  touch-action: manipulation;
}
.exercise-name { flex: 1; }
.exercise-sets { color: var(--text-dim); font-size: .88rem; }

.exercise-item:has(.exercise-check:checked) .exercise-name {
  color: var(--text-dim);
  text-decoration: line-through;
}

.rest-message {
  padding: .6rem 0;
  color: var(--text-dim);
}

.progress-note { margin-top: .5rem; font-size: .9rem; color: var(--good); }
.progress-note:empty { display: none; }

/* ---------- Week grid ---------- */
.week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: .5rem;
}
.week-day {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .5rem;
  text-align: center;
  min-height: 5.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.week-day.today { outline: 2px solid var(--accent); }
.week-day-name { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.week-day-badge { font-size: 1.1rem; font-weight: 700; color: var(--text-dim); }
.week-day-badge.done { color: var(--good); }
.week-day-badge.rest { color: var(--text-dim); font-size: .72rem; font-weight: 500; }
.week-day-plan { font-size: .68rem; color: var(--text-dim); line-height: 1.25; overflow: hidden; }
.week-day-track { height: 4px; background: var(--border); border-radius: 4px; overflow: hidden; margin-top: .3rem; }
.week-day-bar { height: 100%; background: var(--accent); width: 0; transition: width .25s ease; }

.streak-note { margin-top: .8rem; font-size: .9rem; color: var(--text-dim); }

/* ---------- Notification note ---------- */
.notification-note {
  font-size: .85rem;
  color: var(--text-dim);
  background: rgba(34, 211, 238, .07);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: .7rem .9rem;
}
.notification-note:empty { display: none; }

/* ---------- Footer ---------- */
.site-footer { background: var(--bg-soft); border-top: 1px solid var(--border); padding: 1rem 0; }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .7rem;
  font-size: .86rem;
  color: var(--text-dim);
}
.footer-nav { display: flex; gap: .9rem; }
.footer-nav a { color: var(--text-dim); text-decoration: none; }
.footer-nav a:hover { color: var(--accent); }

/* ---------- Content pages ---------- */
.prose { max-width: 680px; }
.prose h2 { margin-top: 1.4rem; color: var(--accent); }
.prose h3 { margin-top: 1rem; font-size: 1rem; }
.prose p, .prose li { color: var(--text-dim); margin-bottom: .6rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose strong { color: var(--text); }
.full-week { width: 100%; border-collapse: collapse; font-size: .9rem; }
.full-week th, .full-week td { border: 1px solid var(--border); padding: .45rem .6rem; text-align: left; }
.full-week th { background: var(--bg-soft); }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 3.5rem 1rem; }
.notfound .nf-code { font-size: 4rem; color: var(--accent); font-weight: 800; }
.notfound p { color: var(--text-dim); margin-bottom: 1.2rem; }
.btn {
  display: inline-block;
  background: var(--accent-strong);
  color: #03121a;
  font-weight: 600;
  text-decoration: none;
  padding: .6rem 1.1rem;
  border-radius: 10px;
}
.btn:hover { background: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .container { padding-left: max(1rem, env(safe-area-inset-left, 0px)); padding-right: max(1rem, env(safe-area-inset-right, 0px)); }
  .header-inner { flex-direction: column; align-items: flex-start; }
  .nav { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: .25rem; }
  .nav a { justify-content: center; text-align: center; }
  .week-grid { grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); }
  h1 { font-size: 1.45rem; }
  .prose { padding-left: .3rem; }
  .btn-icon { width: 44px; height: 44px; min-width: 44px; }
  .week-label { min-width: 0; }
}

/* ---------- Light theme ---------- */
[data-theme="light"] {
  --bg: #f8fafc;
  --bg-soft: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-dim: #475569;
  --accent: #0284c7;
  --accent-strong: #0369a1;
  --good: #059669;
  --danger: #dc2626;
}
[data-theme="light"] .notification-note {
  background: rgba(2, 132, 199, .07);
}

/* ---------- Mobile height + tap polish ---------- */
body { min-height: 100vh; }
@supports (min-height: 100dvh) { body { min-height: 100dvh; } }
button, a, input, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  padding: .6rem 1.1rem;
  border-radius: 10px;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--accent-strong); color: #03121a; }
.btn-primary:hover { background: var(--accent); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--bg-soft); }
.btn-danger { color: var(--danger); border-color: rgba(248, 113, 113, .4); }
.btn-danger:hover { background: rgba(248, 113, 113, .08); }
.btn-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}
.btn-icon:disabled { opacity: .35; cursor: default; }

/* ---------- Quick actions (today card) ---------- */
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .9rem; }
.actions[hidden] { display: none; }
.actions .btn { flex: 1 1 auto; }

/* ---------- Week head + navigation ---------- */
.week-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; }
.week-nav { display: inline-flex; align-items: center; gap: .6rem; }
.week-label { font-size: .9rem; color: var(--text-dim); min-width: 8rem; text-align: center; }

/* ---------- Settings form ---------- */
.settings-form { display: flex; flex-direction: column; gap: 1rem; }
.settings-form h2 { margin: .4rem 0 0; }
.field { display: flex; flex-direction: column; gap: .35rem; }
.field.check { flex-direction: row; align-items: center; gap: .6rem; }
.field.check label { margin: 0; }
.field input[type="time"], .field select {
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .7rem .8rem;
  font-family: inherit;
  font-size: 1rem;
  min-height: 44px;
}
.field input[type="checkbox"] { width: 1.3rem; height: 1.3rem; accent-color: var(--accent-strong); }
.field-btn { margin-top: .4rem; }
.saved-note { color: var(--good); font-size: .9rem; min-height: 1.2em; }
.danger-zone { border-color: rgba(248, 113, 113, .35); }

/* ---------- Safe area (notched phones) ---------- */
@supports (padding: env(safe-area-inset-bottom)) {
  .site-header .container {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  .site-footer { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
}

/* ---------- Today card: ring + info ---------- */
.today-wrap { display: flex; align-items: flex-start; gap: 1rem; }
.today-info { flex: 1; min-width: 0; }
.ring-wrap {
  --pct: 0;
  position: relative;
  width: 62px;
  height: 62px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--bg-soft) 0);
}
.ring-wrap::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--card);
}
.ring-wrap span {
  position: relative;
  z-index: 1;
  font-size: .72rem;
  font-weight: 700;
  color: var(--text);
}

/* ---------- Stats ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: .6rem;
}
.stat {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .9rem .5rem;
  text-align: center;
}
.stat-value { display: block; font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.stat-label { display: block; font-size: .78rem; color: var(--text-dim); margin-top: .25rem; }

/* ---------- Backup actions ---------- */
.backup-actions { align-items: stretch; }
.backup-actions .btn { flex: 1 1 auto; }