/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
ul[role="list"], ol[role="list"] { list-style: none; }

/* ---- Tokens (dark default) ---- */
:root {
  --bg:            #0b0b0c;
  --surface:       #111217;
  --border:        #2a2a2c;
  --text:          #f9fafb;
  --muted:         #9ca3af;
  --accent:        #7AB8FF;
  --accent-strong: #4C9EFF;

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --sp-xs:  0.5rem;
  --sp-sm:  0.75rem;
  --sp-md:  1rem;
  --sp-lg:  1.5rem;
  --sp-xl:  2rem;
  --sp-2xl: 3rem;

  --radius:    0.75rem;
  --radius-sm: 0.5rem;
}

/* ---- Light mode ---- */
@media (prefers-color-scheme: light) {
  :root {
    --bg:            #f9fafb;
    --surface:       #ffffff;
    --border:        #e5e7eb;
    --text:          #111217;
    --muted:         #6b7280;
    --accent:        #1d6fc4;
    --accent-strong: #1558a8;
  }
}

/* ---- Base ---- */
html { color-scheme: dark light; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Skip link ---- */
.skip-link {
  position: absolute;
  top: -4rem;
  left: var(--sp-md);
  background: var(--accent);
  color: var(--bg);
  padding: 0.5em 1em;
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
  z-index: 100;
  transition: top 0.15s;
}
.skip-link:focus { top: var(--sp-md); }

/* ---- Focus ---- */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ---- Links ---- */
a { color: var(--accent); }

/* ---- Container ---- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--sp-lg);
}

/* ---- Nav ---- */
.site-nav {
  border-bottom: 1px solid var(--border);
  padding: var(--sp-md) 0;
}
.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-md);
}
.nav-logo {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.nav-logo:hover,
.nav-logo:focus-visible { color: var(--accent); }
.nav-links {
  display: flex;
  gap: var(--sp-lg);
  list-style: none;
}
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}
.nav-links a:hover,
.nav-links a:focus-visible { color: var(--text); }

/* ---- Main ---- */
main { flex: 1; padding: var(--sp-2xl) 0; }

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--sp-xl) 0;
  font-size: 0.875rem;
  color: var(--muted);
}
.site-footer .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
  text-align: center;
}
.site-footer a {
  color: var(--muted);
  text-decoration: underline;
}
.site-footer a:hover,
.site-footer a:focus-visible { color: var(--text); }
.footer-store-links {
  display: flex;
  gap: var(--sp-lg);
  flex-wrap: wrap;
  justify-content: center;
}
.footer-copy { color: var(--muted); }

/* ---- Typography ---- */
h1 {
  font-size: clamp(1.75rem, 1.4rem + 1.5vw, 2.5rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.025em;
}
h2 {
  font-size: clamp(1.2rem, 1rem + 0.8vw, 1.6rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.015em;
}
h3 {
  font-size: clamp(0.95rem, 0.85rem + 0.4vw, 1.15rem);
  font-weight: 700;
  line-height: 1.3;
}
p { max-width: 65ch; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 0.2em 0.65em;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: capitalize;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge--accent {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65em 1.25em;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--accent);
  color: #0b0b0c; /* intentionally dark in both modes — ensures contrast on blue accent */
  border-color: var(--accent);
  width: 100%;
  padding: 0.9em 1.5em;
  font-size: 1rem;
  border-radius: var(--radius);
  margin-bottom: var(--sp-md);
}
.btn--primary:hover,
.btn--primary:focus-visible {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
  font-size: 0.78rem;
  padding: 0.35em 0.75em;
}
.btn--ghost:hover,
.btn--ghost:focus-visible {
  color: var(--text);
  border-color: var(--muted);
}

.btn--store {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  flex: 1;
  min-width: 130px;
}
.btn--store:hover,
.btn--store:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- Breadcrumb ---- */
.breadcrumb { margin-bottom: var(--sp-xl); }
.breadcrumb ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2em 0;
  list-style: none;
  font-size: 0.82rem;
  color: var(--muted);
}
.breadcrumb li + li::before {
  content: " / ";
  white-space: pre;
  opacity: 0.45;
}
.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}
.breadcrumb a:hover,
.breadcrumb a:focus-visible { color: var(--text); }
.breadcrumb [aria-current="page"] { color: var(--text); }

/* ---- Workout page ---- */
.workout-header { margin-bottom: var(--sp-lg); }
.workout-header h1 { margin-bottom: var(--sp-sm); }
.workout-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-xs);
}
.workout-description {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: var(--sp-xl);
}

/* ---- Script block ---- */
.script-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: var(--sp-lg);
}
.script-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm) var(--sp-md);
  border-bottom: 1px solid var(--border);
  gap: var(--sp-sm);
}
.script-block__label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
}
.script-block pre {
  margin: 0;
  padding: var(--sp-lg);
  font-family: var(--font-mono);
  font-size: clamp(0.85rem, 0.8rem + 0.2vw, 0.95rem);
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---- Download prompt ---- */
.download-prompt {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-lg);
  margin-bottom: var(--sp-xl);
  text-align: center;
}
.download-prompt p {
  color: var(--muted);
  margin: 0 auto var(--sp-md);
  font-size: 0.95rem;
  max-width: none;
}
.download-prompt__links {
  display: flex;
  gap: var(--sp-sm);
  justify-content: center;
  flex-wrap: wrap;
}

/* ---- Back link ---- */
.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
}
.back-link:hover,
.back-link:focus-visible { color: var(--text); }

/* ---- Workout card grid ---- */
.workout-grid {
  display: grid;
  gap: var(--sp-md);
  grid-template-columns: 1fr;
  list-style: none;
  margin-bottom: var(--sp-xl);
}
@media (min-width: 520px) {
  .workout-grid { grid-template-columns: 1fr 1fr; }
}
.workout-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
}
.workout-card:hover,
.workout-card:focus-within { border-color: var(--accent); }
.workout-card a {
  display: flex;
  flex-direction: column;
  gap: var(--sp-xs);
  padding: var(--sp-lg);
  text-decoration: none;
  color: inherit;
  height: 100%;
}
.workout-card a:focus-visible { outline: none; }
.workout-card__title {
  color: var(--text);
  font-size: 0.95rem;
}
.workout-card__desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  max-width: none;
  flex: 1;
}
.workout-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  margin-top: var(--sp-xs);
}

/* ---- Category page ---- */
.category-empty { color: var(--muted); }
.category-header { margin-bottom: var(--sp-xl); }
.category-header h1 { margin-bottom: var(--sp-sm); }
.category-description {
  color: var(--muted);
  font-size: 1.05rem;
  max-width: 55ch;
}

/* ---- Workouts index ---- */
.workouts-intro { color: var(--muted); margin-bottom: var(--sp-2xl); max-width: 55ch; }
.category-list { display: flex; flex-direction: column; gap: var(--sp-2xl); }
.category-section h2 { margin-bottom: var(--sp-lg); }
.view-all {
  display: inline-block;
  margin-top: var(--sp-xs);
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: none;
}
.view-all:hover,
.view-all:focus-visible { color: var(--accent); }

/* ---- Homepage hero ---- */
.hero {
  text-align: center;
  padding: var(--sp-2xl) 0;
  margin-bottom: var(--sp-2xl);
}
.hero h1 { margin-bottom: var(--sp-md); }
.hero p {
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0 auto var(--sp-xl);
  max-width: 48ch;
}
.hero-cta {
  display: flex;
  gap: var(--sp-sm);
  justify-content: center;
  flex-wrap: wrap;
}
.hero-cta .btn {
  min-width: 160px;
  width: auto;
}
.hero-cta .btn--ghost { padding: 0.65em 1.25em; }

.section-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: var(--sp-lg);
}

/* ---- GymScript about block ---- */
.about-gymscript {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-xl);
  margin-top: var(--sp-2xl);
  text-align: center;
}
.about-gymscript h2 { margin-bottom: var(--sp-sm); }
.about-gymscript p {
  color: var(--muted);
  margin: 0 auto var(--sp-lg);
  max-width: 48ch;
}
.about-gymscript__links {
  display: flex;
  gap: var(--sp-sm);
  justify-content: center;
  flex-wrap: wrap;
}
