/* ============================================================
   RACE ARENA — coach.css
   AI Coach tab: controls, response, zone analysis cards
   ============================================================ */

/* ── COACHING LAYOUT ─────────────────────────────────────── */
.coaching-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── CONTROLS BAR ────────────────────────────────────────── */
.coaching-controls {
  display: flex;
  align-items: center;
  gap: 10px 18px;
  padding: 10px 20px;
  min-height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.cc-group {
  display: flex;
  align-items: center;
  gap: 7px;
}
.cc-label {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.cc-value {
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cc-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cc-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.cc-hint { font-size: 13px; color: var(--muted); }

/* ── COACHING MAIN SCROLL AREA ───────────────────────────── */
.coaching-main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: var(--bg);
}
.coaching-main > *, .tips-main > * { max-width: 980px; margin-left: auto; margin-right: auto; }

/* ── EMPTY / LOADING STATES ──────────────────────────────── */
.coaching-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  text-align: center;
  gap: 8px;
}
.coaching-empty-icon { font-size: 36px; opacity: 0.6; margin-bottom: 4px; }
.coaching-empty-title { font-size: 16px; font-weight: 600; color: var(--fg); }
.coaching-empty-desc { font-size: 14px; color: var(--muted); max-width: 420px; line-height: 1.6; }
.coaching-empty-desc strong { color: var(--text); font-weight: 600; }
.coaching-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  padding: 20px;
  font-size: 13px;
  letter-spacing: 0.3px;
}
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── AI RESPONSE CARD ────────────────────────────────────── */
.coaching-response {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
  line-height: 1.75;
}
.coaching-response.is-error { border-color: var(--accent); }
.coaching-response.is-error h2 { color: var(--accent-bright); }
.coaching-response.is-plain { border: 0; padding: 0; margin: 0; background: transparent; }
.report-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted2);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 14px;
}
.coaching-response h1,
.coaching-response h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--fg);
  margin-top: 22px;
  margin-bottom: 8px;
  letter-spacing: 0;
}
.coaching-response h2:first-child { margin-top: 0; }
.coaching-response h3 {
  font-family: var(--font-display);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--yellow);
  margin-top: 16px;
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}
.coaching-response p { color: var(--text); margin-bottom: 10px; font-size: 14.5px; line-height: 1.8; }
.coaching-response ul { margin-left: 20px; margin-bottom: 10px; }
.coaching-response li { color: var(--text); margin-bottom: 6px; font-size: 14.5px; line-height: 1.7; }
.coaching-response strong { color: var(--fg); }
.coaching-response em { color: var(--orange); font-style: normal; }
.coaching-response code {
  background: var(--card2);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--green);
}

/* ── ZONE ANALYSIS SECTION ───────────────────────────────── */
.zone-analysis-section { margin-top: 8px; }
.zone-analysis-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.zone-analysis-title {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--fg);
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.zone-skipped-note { font-size: 12px; color: var(--muted2); font-style: italic; }

.zone-legend-pills { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.zone-legend-pill { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.zone-legend-line  { width: 18px; height: 3px; border-radius: 2px; }
.zone-legend-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.zone-legend-diamond { width: 8px; height: 8px; background: var(--green); transform: rotate(45deg); flex-shrink: 0; }
.zone-legend-square  { width: 8px; height: 8px; background: #dc2626; flex-shrink: 0; }

/* ── CORNER CARDS ────────────────────────────────────────── */
.zone-cards { display: flex; flex-direction: column; gap: 20px; }
.zone-card {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.zone-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.zone-card-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.zone-card-dist { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }

.zone-card-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.zone-panel { position: relative; }
.zone-panel + .zone-panel { border-left: 1px solid var(--border); }
.zone-panel-label {
  position: absolute;
  top: 7px; left: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted2);
  pointer-events: none;
  z-index: 1;
}
.zone-panel canvas { display: block; width: 100%; height: auto; }

.chart-legend-row {
  display: flex; align-items: center; gap: 14px;
  padding: 6px 10px 4px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.chart-leg-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  color: var(--silver);
  white-space: nowrap;
}
.chart-leg-line {
  display: inline-block; width: 22px; height: 2px; border-radius: 1px;
}
.chart-leg-dashed {
  background: transparent !important;
  border-top: 2px dashed;
  height: 0;
  border-radius: 0;
}

/* ── BOTTOM STATS + COACHING TIP ─────────────────────────── */
.zone-card-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: 1px solid var(--border);
}
.zone-stats-col {
  padding: 10px 14px 12px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.zone-coaching-col { padding: 10px 14px 12px; }

.zone-stat { font-size: 13.5px; color: var(--silver); line-height: 1.7; }
.zs-label { color: var(--muted2); font-weight: 600; }
.zs-ref   { color: var(--lap-a); font-weight: 600; }
.zs-comp  { color: var(--lap-b); }
.zs-good  { color: var(--green); font-weight: 600; }
.zs-bad   { color: var(--accent); font-weight: 600; }

.zone-coaching-tip { font-size: 14.5px; color: var(--text); line-height: 1.75; }
.zone-coaching-tip p { margin: 0 0 6px 0; }
.zone-coaching-tip strong { color: var(--fg); font-weight: 700; }
.zone-coaching-header {
  font-family: var(--font-display);
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px;
}

/* ── MY RACING TIPS TAB ─────────────────────────────────── */
.tips-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tips-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  min-height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tips-header-left { display: flex; align-items: center; gap: 14px; }
.tips-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.tips-subtitle { font-size: 12.5px; color: var(--muted2); }
.tips-main {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  background: var(--bg);
}
.tips-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 16px;
  line-height: 1.75;
}
.tips-card-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 10px;
}
.tips-card-label::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.tips-focus .tips-card-label::before { background: var(--accent); }
.tips-patterns .tips-card-label::before { background: var(--orange); }
.tips-improvements .tips-card-label::before { background: var(--ink); }
.tips-analysis-count {
  font-size: 12px;
  color: var(--muted2);
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}
.tips-updating {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: none;
  border-left: 2px solid var(--ink);
  border-radius: 5px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--fg);
}

/* ── MARCUS LOGIN MODAL ──────────────────────────────────── */
.marcus-modal[hidden] {
  display: none !important;
}
.marcus-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.marcus-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}
.marcus-modal__panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  padding: 24px 28px 22px;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
}
.marcus-modal__close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}
.marcus-modal__close:hover {
  color: var(--text);
  background: var(--surface);
}
.marcus-modal__title {
  margin: 0 0 12px;
  font-family: var(--font-display, inherit);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.marcus-modal__text {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}
.marcus-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.marcus-modal__btn {
  flex: 1;
  min-width: 120px;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
}

/* ── LIGHT THEME OVERRIDES ───────────────────────────────── */
/* Section headings and labels use the wide-caps display style. */
.cc-label,
.report-label,
.zone-analysis-title,
.zone-card-title,
.zone-coaching-header,
.tips-title,
.tips-card-label,
.coaching-response h1,
.coaching-response h2 {
  font-family: var(--font-display);
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.cc-label { font-size: 10.5px; color: var(--muted); }
.cc-value { font-size: 15px; font-weight: 600; }
.coaching-controls { background: var(--bg); padding: 12px 24px; }
.coaching-main, .tips-main { padding: 28px 24px; }
.coaching-empty-title {
  font-family: var(--font-display);
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 15px;
  font-weight: 700;
}
.coaching-empty-desc { font-size: 15px; }
.coaching-empty-desc strong { color: var(--fg); }

.coaching-response {
  border: none;
  border-top: 2px solid var(--ink);
  padding: 24px 0 8px;
  background: transparent;
}
.coaching-response.is-error { border-top-color: var(--accent); }
.coaching-response h1,
.coaching-response h2 { font-size: 15px; font-weight: 700; color: var(--fg); margin-top: 28px; }
.coaching-response h3 { font-family: var(--font); font-size: 17px; font-weight: 700; color: var(--accent-bright); }
.coaching-response p,
.coaching-response li { font-size: 16px; line-height: 1.7; color: var(--text); }
.coaching-response em { color: var(--orange); }
.coaching-response code { background: var(--surface); color: var(--fg); }
.report-label { font-size: 11px; color: var(--muted); }

.zone-analysis-title { font-size: 14px; color: var(--fg); font-weight: 700; }
.zone-skipped-note { font-size: 13px; }
.zone-legend-pill { font-size: 13px; color: var(--muted); }
.zone-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 2px solid var(--ink);
  border-radius: 0;
}
.zone-card-header { background: var(--bg); padding: 12px 16px; }
.zone-card-title { font-size: 13px; color: var(--fg); }
.zone-card-dist { font-family: var(--font); font-size: 13px; }
.zone-panel-label { color: var(--muted2); }
.chart-legend-row { border-bottom-color: var(--border); }
.chart-leg-item { font-size: 13px; color: var(--silver); }
.zone-stat { font-size: 15px; color: var(--silver); }
.zs-label { color: var(--muted); font-weight: 600; }
.zs-good { color: var(--green); }
.zs-bad { color: var(--accent-bright); }
.zone-coaching-header { font-size: 10.5px; }
.zone-coaching-tip { font-size: 16px; }
.zone-coaching-tip strong { color: var(--fg); }

.tips-header { background: var(--bg); padding: 12px 24px; }
.tips-title { font-size: 13px; font-weight: 700; color: var(--fg); }
.tips-subtitle { font-size: 14px; }
.tips-card {
  border: none;
  border-top: 2px solid var(--ink);
  border-radius: 0;
  padding: 22px 0 6px;
  background: transparent;
}
.tips-card-label { font-size: 13px; font-weight: 700; }
.tips-card-label::before { border-radius: 0; width: 10px; height: 10px; }
.tips-analysis-count { font-size: 13px; }

.marcus-modal__panel { border: none; border-top: 3px solid var(--accent); border-radius: 0; background: var(--card); }
.marcus-modal__title {
  font-family: var(--font-display);
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 16px;
}
.marcus-modal__text { font-size: 15px; }
.marcus-modal__close { border-radius: 0; }

/* ── CORNER VIEW — picker + one corner at a time ─────────── */
.coaching-main > .corner-view { max-width: 1180px; }
.corner-view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.corner-view-sub { font-size: 14px; color: var(--muted); margin-top: 4px; }
.corner-picker { display: flex; align-items: stretch; gap: 6px; }
.corner-picker .btn { font-size: 16px; padding: 6px 12px; }
.corner-select {
  appearance: none;
  min-width: 260px;
  padding: 9px 40px 9px 14px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23111' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right 14px center;
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
}
.corner-select:focus-visible { box-shadow: var(--focus); }

/* Where-the-time-goes strip */
.corner-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(34px, 1fr);
  gap: 2px;
  border-top: 2px solid var(--ink);
  padding-top: 8px;
  overflow-x: auto;
}
.corner-strip-item {
  background: none;
  border: none;
  padding: 4px 0 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
}
.corner-strip-item:hover { background: var(--surface); }
.corner-strip-item.is-active { border-bottom-color: var(--ink); background: var(--surface); }
.corner-strip-bar {
  height: 44px;
  width: 14px;
  display: flex;
  align-items: flex-end;
  background: var(--card2);
}
.corner-strip-bar span { width: 100%; min-height: 2px; background: var(--muted2); }
.corner-strip-item.is-a-ahead .corner-strip-bar span { background: var(--lap-a); }
.corner-strip-item.is-b-ahead .corner-strip-bar span { background: var(--lap-b); }
.corner-strip-label {
  font-family: var(--font-display);
  font-stretch: 112%;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}
.corner-strip-item.is-active .corner-strip-label { color: var(--fg); }
.corner-strip-legend {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
  margin: 8px 0 22px;
}
.corner-strip-legend span { display: inline-block; width: 10px; height: 10px; margin-right: -8px; }
.corner-strip-legend .is-a-ahead { background: var(--lap-a); }
.corner-strip-legend .is-b-ahead { background: var(--lap-b); }

/* Detail */
.corner-detail { border-top: 2px solid var(--ink); padding-top: 18px; }
.corner-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.corner-title {
  font-family: var(--font-display);
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 26px;
  font-weight: 800;
  color: var(--fg);
  line-height: 1.1;
}
.corner-sub { font-size: 15px; color: var(--muted); margin-top: 4px; }
.corner-verdict { text-align: right; white-space: nowrap; }
.corner-verdict span { display: block; font-size: 12.5px; color: var(--muted); }
.corner-verdict strong {
  font-family: var(--font-display);
  font-stretch: 112%;
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.corner-verdict.is-a-ahead strong { color: var(--lap-a); }
.corner-verdict.is-b-ahead strong { color: var(--lap-b); }

.corner-visuals {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 0.9fr;
  gap: 12px;
  margin-bottom: 18px;
}
.corner-fig { margin: 0; border: 1px solid var(--border); background: var(--bg); min-width: 0; }
.corner-fig figcaption {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--fg);
}
.corner-fig .leg {
  font-family: var(--font);
  font-stretch: 100%;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.corner-fig .leg i { display: inline-block; width: 14px; height: 3px; }
.corner-fig .leg.muted { font-weight: 400; }
.corner-fig canvas { display: block; width: 100%; height: auto; }

.corner-body {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.metric-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.metric-table thead th {
  text-align: right;
  font-family: var(--font-display);
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--ink);
}
.metric-table .mt-group th {
  text-align: left;
  font-family: var(--font-display);
  font-stretch: 125%;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--fg);
  padding: 16px 0 6px;
}
.metric-table tbody tr:not(.mt-group) th {
  text-align: left;
  font-weight: 400;
  color: var(--silver);
  padding: 7px 12px 7px 0;
  border-bottom: 1px solid var(--border);
}
.metric-table td {
  text-align: right;
  padding: 7px 0 7px 12px;
  border-bottom: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  color: var(--lap-a);
}
.metric-table td.mt-b { color: var(--lap-b); }
.metric-table td.mt-delta { color: var(--muted); font-weight: 600; }
/* Difference column: coloured by which lap is better on that metric */
.metric-table td.mt-delta.is-a-better { color: var(--lap-a); }
.metric-table td.mt-delta.is-b-better { color: var(--lap-b); }
.mt-hint { color: var(--muted2); font-size: 12px; cursor: help; }
.corner-notes .zone-coaching-tip { font-size: 15.5px; }

@media (max-width: 1000px) {
  .corner-visuals { grid-template-columns: 1fr 1fr; }
  .corner-fig.is-square { grid-column: span 2; max-width: 420px; }
  .corner-body { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .corner-visuals { grid-template-columns: 1fr; }
  .corner-fig.is-square { grid-column: auto; }
  .corner-select { min-width: 0; flex: 1; }
  .corner-picker { width: 100%; }
  .corner-title, .corner-verdict strong { font-size: 21px; }
}
@media (max-width: 600px) {
  .coaching-controls { padding: 10px 16px; }
  .cc-actions { width: 100%; margin-left: 0; flex-wrap: wrap; }
  .cc-actions .btn { flex: 1; justify-content: center; }
  .cc-actions .cc-hint { width: 100%; }
}

/* Legends use the shared lap swatches */
.corner-fig .leg .lap-swatch { width: 20px; }
.corner-strip-legend em { font-style: normal; color: var(--muted2); }
.metric-table thead th:nth-child(2) { color: var(--lap-a); }
.metric-table thead th:nth-child(3) { color: var(--lap-b); }
.corner-verdict strong { font-size: 20px; }
