/* HuronXC — mobile-first. Athletes log runs on a phone; everything else follows. */

:root {
  --bg: #f8f6f6;
  --surface: #ffffff;
  --surface-2: #f1eded;
  --border: #e0d9d9;
  --text: #1f1717;
  --text-dim: #6b5e5e;
  --accent: #a4161a;
  --accent-soft: #fbe9e9;
  --accent-text: #ffffff;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #8a1c14;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(24 16 16 / 6%), 0 4px 14px rgb(24 16 16 / 5%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141010;
    --surface: #1d1818;
    --surface-2: #272020;
    --border: #3a3131;
    --text: #ede8e8;
    --text-dim: #a89a9a;
    --accent: #ef4444;
    --accent-soft: #291415;
    --accent-text: #180a0b;
    --warn: #e0a355;
    --warn-soft: #2a2116;
    --danger: #ef4444;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 14px rgb(0 0 0 / 30%);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px 64px;
}
.wrap--wide { max-width: 1180px; }

/* --- Header --------------------------------------------------------------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar__brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
  margin-right: auto;
}
.topbar__brand span { color: var(--accent); }
.topbar nav { display: flex; gap: 14px; align-items: center; }
.topbar nav a { font-size: 14px; text-decoration: none; color: var(--text-dim); }
.topbar nav a:hover { color: var(--text); }

/* --- Cards ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-top: 18px;
}
.card__title {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* --- Today's workout ------------------------------------------------------ */

.plan {
  /* Accent edge marks this as coach-authored, not the athlete's own data. */
  border-left: 3px solid var(--accent);
  padding-top: 14px;
}
.plan--empty { border-left-color: var(--border); }
.plan__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.plan__eyebrow {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  white-space: nowrap;
}
.plan__select {
  width: auto;
  max-width: 60%;
  padding: 8px 10px;
  border-radius: 8px;
  font-weight: 600;
}
.plan__title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.plan__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.plan__meta:empty { display: none; }
.plan__loc {
  display: inline-block;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 650;
  border-radius: 20px;
  background: var(--accent-soft);
  color: var(--accent);
}
.plan__desc {
  margin-top: 13px;
  padding-top: 13px;
  border-top: 1px solid var(--border);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-dim);
  /* Coaches type one interval per line; keep the breaks they typed. */
  white-space: pre-line;
}
.plan__none { font-size: 15px; color: var(--text-dim); }

/* --- Entry form ----------------------------------------------------------- */

.entry { padding-bottom: 20px; }
.entry__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.entry__grid .full { grid-column: 1 / -1; }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 12px;
  font-size: 16px; /* 16px prevents iOS zoom-on-focus. */
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
textarea { resize: vertical; }

.miles-input input { font-size: 24px; font-weight: 650; padding: 14px 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 18px;
  min-height: 46px; /* Thumb-sized tap target. */
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.06); }
.btn--block { width: 100%; }
.btn--ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
}
.btn--link {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 4px 6px;
  min-height: 0;
  font-size: 13px;
  text-decoration: underline;
}
.btn--danger { color: var(--danger); }

.errors {
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  color: var(--warn);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 12px;
}
.errors ul { margin: 0; padding-left: 18px; }

.field-error { color: var(--danger); font-size: 13px; margin-top: 4px; }

/* --- Week strip ----------------------------------------------------------- */

.weeknav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 22px;
}
.weeknav__label { font-weight: 650; font-size: 15px; }
.weeknav__total {
  font-size: 13px;
  color: var(--text-dim);
}
.weeknav__btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 40px;
  min-height: 40px;
  font-size: 18px;
  color: var(--text);
  cursor: pointer;
}
.weeknav__btn[disabled] { opacity: 0.3; cursor: default; }
/* The coach week view navigates with links, not HTMX buttons. */
a.weeknav__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.total-banner {
  display: flex;
  padding: 15px 18px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 14px;
}
.stat { flex: 1; min-width: 0; }
.stat + .stat {
  border-left: 1px solid var(--border);
  padding-left: 18px;
  margin-left: 18px;
}
.stat__num {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1.1;
}
.stat--muted .stat__num { color: var(--text); opacity: 0.75; }
.stat__label { font-size: 13px; color: var(--text-dim); }

.day {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.day:last-child { border-bottom: none; }
.day__date {
  width: 62px;
  flex: none;
  font-size: 13px;
  color: var(--text-dim);
}
.day__date b { display: block; font-size: 15px; color: var(--text); font-weight: 650; }
.day--today .day__date b { color: var(--accent); }
.day--empty { opacity: 0.55; }
.day__runs { flex: 1; min-width: 0; }
.run {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding: 2px 0;
}
.run__miles { font-weight: 650; }
.run__meta { font-size: 13px; color: var(--text-dim); }
.run__notes { font-size: 13px; color: var(--text-dim); width: 100%; }
.run__actions { margin-left: auto; display: flex; gap: 2px; }

.tag {
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--surface-2);
  color: var(--text-dim);
}
.tag--race { background: var(--accent-soft); color: var(--accent); }
.tag--workout { background: var(--warn-soft); color: var(--warn); }
.tag--flag { background: var(--warn-soft); color: var(--warn); text-transform: none; }

.empty { color: var(--text-dim); font-size: 14px; padding: 8px 0; }

.toast {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* --- Tables (coach) ------------------------------------------------------- */

.scroller { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td {
  padding: 9px 10px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  font-weight: 650;
}
th:first-child, td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
}
tbody tr:hover td { background: var(--surface-2); }
tbody tr:hover td:first-child { background: var(--surface-2); }
td.zero { color: var(--text-dim); opacity: 0.45; }
tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: none; }
.col-total { font-weight: 700; }

.rowlink { color: var(--text); text-decoration: none; font-weight: 600; }
.rowlink:hover { color: var(--accent); }

/* Week headers drill into that week's day-by-day grid. */
.collink {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--text-dim);
}
.collink:hover { color: var(--accent); border-bottom-color: var(--accent); }

.gridnote { color: var(--text-dim); font-size: 13px; margin: 18px 0 0; }

.alert {
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 18px;
}
.alert__title { font-weight: 650; color: var(--warn); margin: 0 0 8px; font-size: 14px; }
.alert ul { margin: 0; padding-left: 18px; font-size: 14px; }
.alert li { margin-bottom: 3px; }

.muted { color: var(--text-dim); font-size: 13px; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 5px;
  word-break: break-all;
}

/* --- Season progress chart ------------------------------------------------ */

/* Chart.js sizes to the parent, so the parent is what sets the height. */
.chart {
  position: relative;
  height: 260px;
  margin-top: 4px;
}

.chart__delta {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 8px;
}
.chart__delta--ahead { color: var(--accent); background: var(--accent-soft); }
.chart__delta--behind { color: var(--warn); background: var(--warn-soft); }

.chart__note { color: var(--text-dim); font-size: 13px; margin: 12px 0 0; }

@media (min-width: 640px) {
  .chart { height: 320px; }
}

/* --- Centered auth pages -------------------------------------------------- */

.narrow { max-width: 400px; margin: 48px auto; padding: 0 16px; }
.narrow h1 { font-size: 22px; letter-spacing: -0.02em; }

.htmx-request .btn { opacity: 0.6; pointer-events: none; }

@media print {
  .topbar, .btn, .no-print { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
}

@media (min-width: 640px) {
  .entry__grid { grid-template-columns: repeat(4, 1fr); }
  .entry__grid .full { grid-column: 1 / -1; }
  .entry__grid .span2 { grid-column: span 2; }
}
