/**
 * public/css/main.css
 * =============================================================================
 * Mobile-first responsive stylesheet for Apex Athletics.
 *
 * Approach: every rule is written for mobile first (≤ 480px), then
 * progressively enhanced for tablet (≥ 640px) and desktop (≥ 1024px)
 * via min-width media queries. This means the base CSS is what phones
 * render — no override juggling needed for small screens.
 *
 * PWA note: safe-area-inset variables are used throughout to respect
 * the iPhone notch / home-indicator on devices that have them.
 * =============================================================================
 */

/* --- Design tokens --------------------------------------------------- */
:root {
  /* Palette derived from the club badge: near-black ink, badge gold,
     and the lightning-bolt/eye cyan. Variable NAMES are kept as
     --navy/--orange for backward compatibility with every existing
     rule and inline style across the app — only the underlying hex
     values changed, so the whole site re-skins from this one place. */
  --navy:        #14141A;  /* was #0f1b2d — now the badge's near-black */
  --navy-light:  #1f1f28;  /* was #16263d */
  --charcoal:    #0d0d10;
  --orange:      #F0C214;  /* was #ff5a1f — now the badge gold */
  --orange-dark: #B8930A;  /* was #d9460f — darkened gold for hover/contrast */
  --cyan:        #17B4DC;  /* new: the badge's lightning-bolt / eye cyan */
  --cyan-dark:   #0E8CB0;
  --white:       #ffffff;
  --gray-50:     #f7f7f8;
  --gray-100:    #ececef;
  --gray-300:    #c7c9d1;
  --gray-500:    #7a7e8c;
  --gray-700:    #3f4250;
  --success:     #1f9d55;
  --danger:      #d92d20;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 2px 8px rgba(15,27,45,0.08);
  --shadow-md:   0 4px 16px rgba(15,27,45,0.12);
  --font-display:'Oswald','Arial Narrow',sans-serif;
  --font-body:   'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  /* PWA / iPhone safe area */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left,  0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}

/* --- Reset & base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  /* Prevent font scaling on orientation change in iOS */
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--gray-700);
  background: var(--gray-50);
  line-height: 1.6;
  /* Push content below the iOS status bar when installed as PWA */
  padding-top: var(--safe-top);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--navy);
  margin: 0 0 0.5em;
}

a { color: var(--orange-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* Tap target minimum size (WCAG / Apple HIG: 44px) */
button, [role="button"], a.btn { min-height: 44px; }

/* --- Layout container ------------------------------------------------- */
.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
  padding-left:  max(1rem, var(--safe-left));
  padding-right: max(1rem, var(--safe-right));
}
@media (min-width: 640px)  { .container { padding: 0 1.5rem; } }
@media (min-width: 1024px) { .container { padding: 0 2rem;   } }

/* --- Top navigation -------------------------------------------------- */
.site-header {
  background: var(--navy);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 200;
  /* Ensure header spans full width including safe areas */
  padding-left:  var(--safe-left);
  padding-right: var(--safe-right);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 56px;
  max-width: 1100px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--white);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  flex-shrink: 0;
  object-fit: cover;
}
.brand-accent { color: var(--orange); }
.brand:hover { text-decoration: none; }

/* Hamburger button (mobile only) */
.nav-hamburger {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  min-height: unset;
}
.nav-hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.nav-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger.open span:nth-child(2) { opacity: 0; }
.nav-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile nav drawer */
.nav-links {
  display: none;
  position: fixed;
  top: calc(56px + var(--safe-top));
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--navy);
  list-style: none;
  margin: 0;
  padding: 1rem 1rem calc(1rem + var(--safe-bottom));
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  z-index: 199;
}
.nav-links.open { display: flex; }
.nav-links li a {
  display: block;
  color: var(--gray-100);
  font-size: 1.05rem;
  font-weight: 500;
  padding: 0.9rem 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.nav-links li a:hover { color: var(--white); text-decoration: none; }
.nav-links li:last-child a { border-bottom: none; }
.nav-links .nav-logout button {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  color: var(--gray-300);
  font-size: 1.05rem;
  font-weight: 500;
  padding: 0.9rem 0.5rem;
  cursor: pointer;
  font-family: var(--font-body);
  min-height: 44px;
}

/* Desktop: inline nav — but ONLY for logged-out visitors on the public
   marketing pages. Once someone is logged in (body.is-authed), the
   hamburger + drawer pattern is used on desktop too, rather than
   switching back to an inline list — see the next block. */
@media (min-width: 768px) {
  body:not(.is-authed) .nav-hamburger { display: none; }
  body:not(.is-authed) .nav-links {
    display: flex !important;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
    background: none;
    padding: 0;
    overflow: visible;
  }
  body:not(.is-authed) .nav-links li a {
    font-size: 0.88rem;
    padding: 0.4rem 0.75rem;
    border-bottom: none;
    border-radius: var(--radius-sm);
  }
  body:not(.is-authed) .nav-links .nav-logout button {
    font-size: 0.88rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: var(--radius-sm);
    width: auto;
    color: var(--gray-100);
  }
  body:not(.is-authed) .nav-links .nav-logout button:hover { background: rgba(255,255,255,0.1); }
}

/* Desktop, logged in: hamburger stays, but the drawer becomes a
   right-anchored slide-in panel instead of a full-width mobile-style
   overlay — feels like a proper app sidebar rather than a phone menu
   stretched across a wide screen. A dimmed backdrop appears behind it
   so it reads clearly as an overlay on top of page content. */
@media (min-width: 768px) {
  body.is-authed .nav-links {
    left: auto;
    width: 320px;
    box-shadow: -12px 0 32px rgba(15,27,45,0.25);
  }
  body.is-authed .nav-links li a,
  body.is-authed .nav-links .nav-logout button {
    font-size: 0.98rem;
  }
}

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,27,45,0.45);
  z-index: 197; /* just below .nav-links (198) and .nav-hamburger context */
}
.nav-backdrop.open { display: block; }

/* --- Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.3rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  min-height: 44px;
}
.btn:active { transform: scale(0.98); }
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--orange);  color: var(--navy); }
.btn-primary:hover  { background: var(--orange-dark); color: var(--navy); }
.btn-secondary { background: var(--white); color: var(--navy); border-color: var(--gray-300); }
.btn-secondary:hover { border-color: var(--navy); }
.btn-danger   { background: var(--danger);  color: var(--white); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.82rem; min-height: 36px; }
.btn-full { width: 100%; }

/* --- Forms ----------------------------------------------------------- */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow);
  padding: 1.5rem 1rem;
  width: 100%;
  max-width: 480px;
  margin: 1.5rem auto;
}
@media (min-width: 640px) { .form-card { padding: 2rem; } }

.form-group { margin-bottom: 1.1rem; }
label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--navy);
  margin-bottom: 0.3rem;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem; /* 16px prevents iOS auto-zoom */
  background: var(--white);
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
  border-color: var(--orange);
}
.help-text   { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.25rem; }
.error-banner {
  background: #fdecea;
  border: 1px solid #f5c2c0;
  color: var(--danger);
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.2rem;
  font-size: 0.9rem;
}
.alert { padding: 0.8rem 1rem; border-radius: var(--radius-sm); font-size: 0.9rem; margin-bottom: 1rem; }
.alert-success { background: #e3f6e9; border: 1px solid #a3d9b1; color: var(--success); }

/* --- Hero (public homepage) ------------------------------------------ */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--white);
  padding: 3rem 1rem 2.5rem;
  text-align: center;
}
@media (min-width: 640px) { .hero { padding: 5rem 1.5rem; } }

.hero h1 {
  color: var(--white);
  font-size: clamp(2rem, 8vw, 3.6rem);
  margin-bottom: 0.3em;
}
.hero h1 span { color: var(--orange); }
.hero p { font-size: 1rem; color: var(--gray-300); max-width: 540px; margin: 0 auto 1.5rem; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

/* --- Cards ----------------------------------------------------------- */
.section { padding: 2rem 0; }
@media (min-width: 640px) { .section { padding: 3.5rem 0; } }

.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 480px) { .card-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { .card-grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

/* --- Dashboard header bar -------------------------------------------- */
.dash-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
  padding: 1rem 0;
}
.dash-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.dash-header h1 { margin-bottom: 0.15rem; }
.dash-header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* --- View switcher (day / week / month) -------------------------------- */
.view-switcher {
  display: flex;
  gap: 0;
  background: var(--gray-100);
  padding: 3px;
  border-radius: 999px;
}
.view-switcher a {
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--gray-700);
  white-space: nowrap;
  min-height: unset;
}
.view-switcher a.active { background: var(--navy); color: var(--white); }
.view-switcher a:hover  { text-decoration: none; }

.range-label { font-size: 0.85rem; color: var(--gray-500); }

/* --- Athlete progress rows (coach dashboard) --------------------------- */
.athlete-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--gray-100);
  flex-wrap: wrap;
}
.athlete-row:last-child { border-bottom: none; }
.athlete-name { font-weight: 600; color: var(--navy); min-width: 140px; flex: 1; font-size: 0.95rem; }
.progress-track {
  flex: 1;
  min-width: 80px;
  height: 8px;
  background: var(--gray-100);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill { height: 100%; background: var(--orange); border-radius: 4px; }
.progress-stat { font-size: 0.78rem; color: var(--gray-500); white-space: nowrap; }

.athlete-row-link {
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  margin: 0 -0.5rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}
.athlete-row-link:hover { background: var(--gray-50); text-decoration: none; }
.athlete-row-arrow { color: var(--gray-300); font-size: 1.1rem; margin-left: auto; }

/* --- Workout cards (member dashboard) --------------------------------- */
.workout-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}
.workout-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
  gap: 0.5rem;
}
/* When the header is a <button> (workout cards are now collapsible),
   reset the default button chrome so it still looks exactly like the
   plain header div did before, just with a pointer cursor and a tap
   highlight suppressed. */
.workout-card-toggle {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  font-family: var(--font-body);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.workout-card-toggle:hover { background: var(--gray-100); }
.workout-card-head h3 { margin: 0; font-size: 1rem; }
.workout-date { font-size: 0.78rem; color: var(--gray-500); margin-top: 2px; }
.workout-progress-pill {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-700);
  white-space: nowrap;
  flex-shrink: 0;
}
.workout-progress-pill.complete { background: #e3f6e9; color: var(--success); }

/* Chevron indicating expand/collapse state, matching the pattern used
   for the coach dashboard's "today's training" block. */
.workout-chevron {
  font-size: 1.4rem;
  color: var(--gray-500);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.workout-chevron.rotated { transform: rotate(90deg); }

/* Workout cards start collapsed — the exercise list is hidden until
   the header is tapped, so the dashboard reads as a scannable list of
   session titles rather than every exercise expanded at once. */
.workout-card-body { display: none; }
.workout-card-body.open { display: block; }

/* Exercise technique-cue text, shown under the sets/reps line. */
.exercise-details {
  font-size: 0.78rem;
  color: var(--gray-500);
  margin-top: 3px;
  line-height: 1.4;
}

/* Exercise row inside a workout card */
.exercise-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--gray-100);
}
.exercise-row:last-child { border-bottom: none; }

.exercise-thumb {
  width: 64px;
  height: 50px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--navy);
  flex-shrink: 0;
}
.exercise-thumb img { width: 100%; height: 100%; object-fit: cover; }
.exercise-category-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--orange-dark);
  margin-bottom: 0.2rem;
}
.exercise-name { font-weight: 600; color: var(--navy); font-size: 0.9rem; line-height: 1.3; }
.exercise-meta { font-size: 0.78rem; color: var(--gray-500); margin-top: 2px; }

.complete-toggle form { display: inline-flex; }
.complete-toggle button {
  border: 1px solid var(--gray-300);
  background: var(--white);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--gray-700);
  min-height: 36px;
  font-family: var(--font-body);
  white-space: nowrap;
}
.complete-toggle button.is-done {
  background: var(--success);
  border-color: var(--success);
  color: var(--white);
}

/* --- Personal bests grid ---------------------------------------------- */
.pb-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}
@media (min-width: 400px) { .pb-grid { grid-template-columns: repeat(5, 1fr); } }

/* Category-filtered PB groups (Race distance / Training distance /
   Starts / Flies) — only the .active one is shown at a time, toggled
   by the dropdown filter above the grid. Each group already carries
   the .pb-grid class for its own layout; this just controls which
   group is visible. */
.pb-category-group { display: none; margin-bottom: 0; }
.pb-category-group.active { display: grid; }

.pb-card {
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius);
  padding: 0.85rem 0.5rem;
  text-align: center;
}
.pb-event { font-size: 0.72rem; color: var(--gray-300); text-transform: uppercase; letter-spacing: 0.05em; }
.pb-time  { font-family: var(--font-display); font-size: 1.45rem; color: var(--orange); margin-top: 0.2rem; line-height: 1.1; }
@media (min-width: 400px) { .pb-time { font-size: 1.7rem; } }

.pb-card-link {
  display: block;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.pb-card-link:active, .pb-card-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(15,27,45,0.2);
  text-decoration: none;
}
.pb-card-hint {
  font-size: 0.6rem;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.35rem;
  opacity: 0.8;
}
.pb-card-empty { cursor: default; }
.pb-empty { color: var(--gray-500); font-size: 0.85rem; }

/* --- Race times table ------------------------------------------------- */
.times-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.times-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table.times-table th,
table.times-table td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--gray-100);
}
table.times-table th {
  background: var(--gray-50);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--gray-500);
}
table.times-table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
}
.badge-electronic { background: #e6f0fd; color: #1e5fbf; }
.badge-hand        { background: #fdf3e3; color: #a3690a; }

/* --- Athlete progress chart page -------------------------------------- */
.event-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.event-tab {
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 600;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
  background: var(--white);
  text-decoration: none;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.event-tab:hover  { border-color: var(--navy); color: var(--navy); text-decoration: none; }
.event-tab.active { background: var(--navy); color: var(--white); border-color: var(--navy); }
.event-tab.has-data { border-color: var(--orange); color: var(--orange-dark); }
.event-tab.active.has-data { background: var(--orange); border-color: var(--orange); color: var(--navy); }

.pb-banner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.pb-banner-time   { font-family: var(--font-display); font-size: 2.2rem; color: var(--orange); line-height: 1; }
.pb-banner-label  { font-size: 0.75rem; color: var(--gray-300); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.2rem; }
.pb-banner-detail { font-size: 0.85rem; color: var(--gray-300); margin-top: 0.2rem; }

.chart-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1.25rem;
}
@media (min-width: 640px) { .chart-card { padding: 1.5rem; } }
.chart-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--gray-500);
  font-size: 0.95rem;
}

/* --- Exercise library table ------------------------------------------- */
.library-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.library-table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
table.library-table th,
table.library-table td { text-align: left; padding: 0.65rem 0.85rem; font-size: 0.85rem; border-bottom: 1px solid var(--gray-100); vertical-align: top; }
table.library-table th { background: var(--gray-50); text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.04em; color: var(--gray-500); }
.library-video-thumb { width: 60px; height: 44px; border-radius: 6px; overflow: hidden; background: var(--navy); flex-shrink: 0; }
.library-video-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* --- Workout builder -------------------------------------------------- */
.exercise-picker-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-100);
}
@media (min-width: 640px) {
  .exercise-picker-row { grid-template-columns: 2fr 90px 90px auto; background: none; border: none; padding: 0; }
}
#exercise-rows-empty { color: var(--gray-500); font-size: 0.85rem; padding: 0.5rem 0; }
.remove-row-btn { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 0.85rem; font-weight: 600; font-family: var(--font-body); padding: 0.5rem 0; text-align: left; }

/* --- Member management (coach) --------------------------------------- */
.member-manage-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 0.85rem;
  overflow: hidden;
  transition: opacity 0.2s;
}
.member-manage-card.suspended { opacity: 0.6; }

.member-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.member-manage-card.suspended .member-card-head { background: var(--gray-50); }

.member-card-identity { display: flex; align-items: center; gap: 0.75rem; }
.member-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  font-family: var(--font-display);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.member-card-name  { font-weight: 600; color: var(--navy); font-size: 0.92rem; }
.member-card-email { font-size: 0.78rem; color: var(--gray-500); margin-top: 1px; }
.member-card-meta  { font-size: 0.75rem; color: var(--gray-500); margin-top: 1px; }
.status-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.active-badge    { background: #e3f6e9; color: var(--success); }
.suspended-badge { background: #fdecea; color: var(--danger); }

.member-card-stats { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.stat-pill {
  font-size: 0.75rem;
  color: var(--gray-500);
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
}
.stat-pill strong { color: var(--navy); }

.member-card-actions {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--gray-100);
  flex-wrap: wrap;
}
.action-toggle-btn {
  background: none;
  border: none;
  border-right: 1px solid var(--gray-100);
  padding: 0.65rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
  min-height: 44px;
}
.action-toggle-btn:hover { background: var(--gray-50); }
.danger-toggle  { color: var(--danger); }
.success-toggle { color: var(--success); }

.action-panel {
  width: 100%;
  border-top: 1px solid var(--gray-100);
  padding: 1rem;
  background: #fafafa;
}
.inline-form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: flex-start;
}
.inline-form-row .form-group { flex: 1; min-width: 150px; margin-bottom: 0; }
.danger-panel {
  background: #fdecea;
  border: 1px solid #f5c2c0;
  border-radius: var(--radius-sm);
  padding: 1rem;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.danger-panel p { margin: 0; flex: 1; color: var(--gray-700); }

/* --- Footer ---------------------------------------------------------- */
.site-footer {
  background: var(--charcoal);
  color: var(--gray-300);
  padding: 2rem 0;
  padding-bottom: calc(2rem + var(--safe-bottom));
  margin-top: 3rem;
  text-align: center;
  font-size: 0.82rem;
}
.site-footer a { color: var(--gray-100); }

/* --- Utilities ------------------------------------------------------- */
.text-muted { color: var(--gray-500); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex         { display: flex; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1        { gap: 0.5rem; }

/* --- PWA install prompt banner --------------------------------------- */
.pwa-install-banner {
  display: none;
  position: fixed;
  bottom: calc(1rem + var(--safe-bottom));
  left: 1rem;
  right: 1rem;
  background: var(--navy);
  color: var(--white);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow-md);
  z-index: 300;
  align-items: center;
  gap: 1rem;
  font-size: 0.88rem;
  max-width: 440px;
  margin: 0 auto;
}
.pwa-install-banner.visible { display: flex; }
.pwa-install-banner p { margin: 0; flex: 1; }
.pwa-install-banner strong { color: var(--orange); }
.pwa-install-banner .pwa-btns { display: flex; gap: 0.5rem; flex-shrink: 0; }
.pwa-dismiss { background: none; border: none; color: var(--gray-300); cursor: pointer; font-size: 1.2rem; padding: 0; line-height: 1; min-height: unset; }

/* ==========================================================================
   CALENDAR STYLES
   ========================================================================== */

/* --- Legend pills -------------------------------------------------------- */
.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 1rem;
  margin-bottom: 0;
}
.cal-legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  color: #fff;
}
.cal-legend-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; opacity: 0.9; }

/* --- Athlete selector (coach view) --------------------------------------- */
.cal-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.cal-filter-bar label { font-weight: 600; font-size: 0.85rem; color: var(--navy); margin: 0; }
.cal-filter-bar select { max-width: 220px; margin: 0; }

/* --- Calendar wrapper ---------------------------------------------------- */
.cal-wrapper {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem;
  position: relative;
}
@media (min-width: 640px) { .cal-wrapper { padding: 1.25rem; } }

/* Fullscreen button — a floating pill in the bottom-right corner
   rather than a tiny icon in the top-right. Bottom placement keeps it
   clear of FullCalendar's own top toolbar (prev/next/today, view
   switcher), so the two sets of controls never crowd each other, and
   a generous tap target with a text label makes it easy to hit and
   easy to understand what it does — especially important for exiting
   fullscreen, which previously was just a tiny "x" in the far corner. */
.cal-fullscreen-btn {
  position: absolute;
  bottom: calc(0.85rem + var(--safe-bottom, 0px));
  right: 0.85rem;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  line-height: 1;
  box-shadow: var(--shadow-md);
}
.cal-fullscreen-btn:active { transform: scale(0.96); }
.cal-fullscreen-btn span:first-child { font-size: 1.05rem; }

/* Fullscreen is a mobile/tablet convenience for viewing the calendar
   across the whole screen — on desktop there's already plenty of room,
   and the fixed-position overlay behaviour isn't needed there, so the
   control is hidden entirely rather than shown as dead weight. */
@media (min-width: 768px) {
  .cal-fullscreen-btn { display: none; }
}

/* Fullscreen mode */
.cal-wrapper.fullscreen {
  position: fixed;
  inset: 0;
  border-radius: 0;
  border: none;
  z-index: 500;
  overflow: auto;
  padding: var(--safe-top, 0) 0.5rem calc(0.5rem + var(--safe-bottom, 0));
  padding-top: calc(var(--safe-top) + 0.5rem);
}
body.cal-is-fullscreen { overflow: hidden; }

/* FullCalendar overrides — make it feel native on mobile */
.fc { font-family: var(--font-body) !important; font-size: 0.82rem; }
.fc .fc-toolbar-title { font-family: var(--font-display) !important; font-size: 1.1rem !important; text-transform: uppercase; letter-spacing: 0.02em; }
.fc .fc-button {
  background: var(--navy) !important;
  border-color: var(--navy) !important;
  font-family: var(--font-body) !important;
  font-size: 0.78rem !important;
  padding: 0.35rem 0.65rem !important;
  border-radius: var(--radius-sm) !important;
}
.fc .fc-button-active,
.fc .fc-button:focus  { background: var(--orange) !important; border-color: var(--orange) !important; box-shadow: none !important; color: var(--navy) !important; }
.fc .fc-daygrid-event { border-radius: 4px !important; font-size: 0.72rem !important; padding: 1px 4px !important; }
.fc .fc-event-title   { font-weight: 600 !important; }
.fc .fc-col-header-cell-cushion,
.fc .fc-daygrid-day-number { font-size: 0.78rem !important; }
.fc .fc-toolbar { flex-wrap: wrap; gap: 0.4rem; justify-content: space-between; }
@media (max-width: 480px) {
  .fc .fc-toolbar { justify-content: center; }
  .fc .fc-toolbar-title { font-size: 0.9rem !important; }
  .fc .fc-button { font-size: 0.72rem !important; padding: 0.28rem 0.5rem !important; }
}

/* Custom title bar, rendered below the toolbar buttons rather than
   inline with them — frees up the full toolbar width for the nav/view
   buttons on narrow phones, avoiding the wrapping/overlap that happened
   when FullCalendar's default title shared a row with the buttons. */
.cal-title-bar {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: 1.15rem;
  text-align: center;
  color: var(--navy);
  margin: 0.6rem 0 0.9rem;
}
/* On desktop there's plenty of room, so give the heading real
   presence — closer to how FullCalendar's own default title looked
   before it was pulled out into this separate line. */
@media (min-width: 768px) {
  .cal-title-bar { font-size: 1.85rem; margin: 0.75rem 0 1.1rem; }
}

/* Today indicator — made deliberately bold so "today" is unmistakable
   at a glance rather than a faint background tint. */
.fc-day-today { background: rgba(240,194,20,0.10) !important; }
.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-number {
  background: var(--orange);
  color: var(--navy) !important;
  font-weight: 700;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 3px;
  line-height: 1;
}
.fc-list-day.fc-day-today .fc-list-day-cushion { background: rgba(240,194,20,0.16) !important; font-weight: 700; }
.fc-timegrid-col.fc-day-today { background: rgba(240,194,20,0.08) !important; }

/* --- Event detail modal -------------------------------------------------- */
.cal-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,27,45,0.55);
  z-index: 600;
  align-items: flex-end;
  justify-content: center;
}
@media (min-width: 640px) { .cal-modal-overlay { align-items: center; } }
.cal-modal-overlay.open { display: flex; }

.cal-modal {
  background: var(--white);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.25rem 1.25rem calc(1.25rem + var(--safe-bottom));
  box-shadow: 0 -4px 32px rgba(15,27,45,0.18);
  animation: slideUp 0.22s ease;
}
@media (min-width: 640px) {
  .cal-modal { border-radius: var(--radius); max-height: 80vh; padding: 1.5rem; }
}
@keyframes slideUp { from { transform: translateY(60px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.cal-modal-type-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  color: #fff;
  margin-bottom: 0.6rem;
}
.cal-modal-title  { font-family: var(--font-display); font-size: 1.3rem; color: var(--navy); margin: 0 0 0.25rem; text-transform: uppercase; }
.cal-modal-dates  { font-size: 0.82rem; color: var(--gray-500); margin-bottom: 0.75rem; }
.cal-modal-detail { font-size: 0.9rem; color: var(--gray-700); margin-bottom: 1rem; }
.cal-modal-close  { float: right; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--gray-500); padding: 0; min-height: unset; line-height: 1; }

/* --- Add entry form (slide-up panel) ------------------------------------- */
.cal-add-panel {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1rem;
  margin-bottom: 1rem;
  display: none;
}
.cal-add-panel.open { display: block; }

/* --- Meets list ---------------------------------------------------------- */
.meet-card {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 0.85rem;
  overflow: hidden;
}
.meet-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.meet-card-title { font-family: var(--font-display); font-size: 1rem; color: var(--navy); margin: 0; text-transform: uppercase; }
.meet-card-date  { font-size: 0.78rem; color: var(--gray-500); margin-top: 2px; }
.meet-reg-count  { font-size: 0.75rem; font-weight: 600; padding: 0.2rem 0.65rem; border-radius: 999px; background: var(--gray-100); color: var(--gray-700); white-space: nowrap; }
.meet-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
  font-size: 0.85rem;
}
@media (min-width: 480px) { .meet-detail-grid { grid-template-columns: 1fr 1fr; } }
.meet-detail-item { display: flex; flex-direction: column; gap: 0.1rem; }
.meet-detail-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--gray-500); font-weight: 600; }
.meet-detail-value { color: var(--navy); font-weight: 500; }

/* Distances checkbox grid */
.distances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.distance-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.12s;
}
.distance-check input { margin: 0; width: 16px; height: 16px; accent-color: var(--orange); }
.distance-check:has(input:checked) { border-color: var(--orange); background: rgba(240,194,20,0.06); color: var(--orange-dark); }

/* ==========================================================================
   COACH DASHBOARD STAT BLOCKS
   ========================================================================== */

/* Row 1: Total athletes / Boys / Girls — always 3 across, even on
   mobile, since three roughly-equal blocks fit a phone width fine
   without needing to wrap. */
.stat-row-primary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

/* Row 2: age categories — 2 across on mobile, 4 across once there's
   enough room, so the four blocks read as one clean row on desktop
   (matching the width of the row above and the full-width block below). */
.stat-row-categories {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
@media (min-width: 480px) {
  .stat-row-categories { grid-template-columns: repeat(4, 1fr); }
}

.stat-block {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 0.9rem;
  text-align: left;
  cursor: pointer;
  font-family: var(--font-body);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.stat-block:hover, .stat-block:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-block-value {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--navy);
  line-height: 1;
}
.stat-block-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Colour accents per block type, matching the calendar's colour
   language so the two features feel like one cohesive app. */
.stat-block-boys .stat-block-value     { color: var(--cyan-dark); }
.stat-block-girls .stat-block-value    { color: #ec4899; }
.stat-block-category .stat-block-value { color: var(--orange); }

/* Row 3: Today's training — a single block spanning the full width of
   the grid above it (same container, no grid-column constraints), so
   it visually lines up edge-to-edge with the rows above rather than
   sitting narrower or wider than them. */
.stat-block-today-full {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.3rem 1.5rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: box-shadow 0.15s;
  margin-bottom: 0;
}
.stat-block-today-full:hover { box-shadow: var(--shadow-md); }

.today-full-main {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  text-align: left;
}
.today-full-value {
  font-family: var(--font-display);
  font-size: 2.6rem;
  color: var(--orange);
  line-height: 1;
  min-width: 90px;
}
.today-full-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--white);
}
.today-full-subtitle {
  font-size: 0.8rem;
  color: var(--gray-300);
  margin-top: 0.15rem;
}
.today-full-chevron {
  font-size: 1.8rem;
  color: var(--gray-300);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.today-full-chevron.rotated { transform: rotate(90deg); }

/* Inline expand panel for today's training breakdown — no modal, no
   CSV, just a table that slides into view directly under the block. */
.today-detail-panel {
  display: none;
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  margin-top: -4px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.today-detail-panel.open { display: block; }

.status-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}
.status-complete    { background: #e3f6e9; color: var(--success); }
.status-partial     { background: #fdf3e3; color: #a3690a; }
.status-not-started { background: #fdecea; color: var(--danger); }

/* ==========================================================================
   CLUB LEADERBOARD
   ========================================================================== */
.leaderboard-list {
  background: var(--white);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  text-decoration: none;
  color: inherit;
  transition: background 0.15s;
}
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-row:hover { background: var(--gray-50); text-decoration: none; }
.leaderboard-row.is-me { background: rgba(240,194,20,0.06); }
.leaderboard-row.is-me:hover { background: rgba(240,194,20,0.1); }

.leaderboard-rank {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--gray-500);
  text-align: center;
  width: 36px;
  flex-shrink: 0;
}
.leaderboard-info { flex: 1; min-width: 0; }
.leaderboard-name {
  font-weight: 600;
  color: var(--navy);
  font-size: 0.92rem;
}
.leaderboard-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--gray-500);
  font-weight: 400;
  margin-top: 1px;
}
.leaderboard-time {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--navy);
  flex-shrink: 0;
}
.you-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--orange);
  color: var(--navy);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  vertical-align: middle;
}

@media (max-width: 420px) {
  .leaderboard-row { gap: 0.5rem; padding: 0.7rem 0.85rem; }
  .leaderboard-rank { width: 28px; font-size: 1rem; }
  .leaderboard-time { font-size: 1.1rem; }
}

/* --- Hero: large logo + slogan (replaces the old headline treatment) --- */
.hero-logo {
  width: clamp(140px, 40vw, 220px);
  margin: 0 auto 1.5rem;
  border-radius: 16px;
}
.hero-slogan {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-weight: 700;
  font-size: clamp(1.5rem, 5vw, 2.4rem);
  color: var(--navy);
  margin-bottom: 1.5rem;
  line-height: 1.15;
}
.hero-slogan-accent { color: var(--orange); }