/* ──────────────────────────────────────────────────────────────
   PEAK SUITE — SHARED DESIGN SYSTEM
   Single source of truth for tokens, typography and base
   components used across hub, coach, courtside-pro
   and courtside-basic. Apps include this via:
     <link rel="stylesheet" href="/shared/peak.css">
   ────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* Smooth crossfade between pages (Hub ↔ Coach ↔ Courtside). Cross-document
   view transitions; ignored by browsers that don't support it. */
@view-transition { navigation: auto; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }

:root {
  /* Surfaces */
  --bg:        #0b0d10;
  --surface:   #111318;
  --surface2:  #181b22;
  --surface3:  #20242d;

  /* Text */
  --text:      #eef0f4;
  --text2:     #a0a8b6;
  --text3:     #78808e;

  /* Borders */
  --border:    #282c36;
  --border2:   #353a47;

  /* Brand accent */
  --accent:        #e8ff3e;
  --accent-dim:    rgba(232, 255, 62, 0.12);
  --accent-text:   #0b0d10;

  /* Semantic */
  --made:      #2ef89a;
  --made-bg:   rgba(46, 248, 154, 0.10);
  --missed:    #f25757;
  --missed-bg: rgba(242, 87, 87, 0.10);
  --blue:      #6eaaff;
  --orange:    #ffa85a;
  --warn:      #ffb83a;
  /* Aliases used by Courtside — kept here so all apps share one palette */
  --neutral:    #6eaaff;
  --neutral-bg: rgba(110, 170, 255, 0.10);
  --sub:        #ffb347;
  --sub-bg:     rgba(255, 179, 71, 0.10);

  /* Typography */
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-display: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;

  /* Radii */
  --r-sm: 4px;
  --r-md: 7px;
  --r-lg: 12px;
  --r-pill: 999px;
  --radius:    7px;
  --radius-lg: 12px;

  /* Transitions */
  --tx-fast:  0.12s;
  --tx:       0.18s;
  --tx-slow:  0.28s;

  /* Header */
  --header-h: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
}

/* ── Reset / base ───────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all var(--tx-fast);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-accent { background: var(--accent); color: var(--accent-text); }
.btn-accent:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.btn-accent:active:not(:disabled) { transform: translateY(0); }

.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); border-color: var(--accent); }

.btn-danger { background: var(--missed-bg); color: var(--missed); border: 1px solid rgba(242,87,87,0.45); }
.btn-danger:hover:not(:disabled) { background: rgba(242,87,87,0.22); border-color: var(--missed); }

.btn-sm { padding: 6px 12px; font-size: 11px; }
.btn-pill { border-radius: 999px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s-4);
}
.card-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: var(--s-3);
}

/* ── Input ──────────────────────────────────────────────────── */
input, select, textarea {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--tx-fast);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

/* ── Modal overlay (used by every app) ──────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--s-4);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: var(--s-5);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--s-3);
}
.modal-footer {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  margin-top: var(--s-4);
}

/* ── Toast (universal) ──────────────────────────────────────── */
.peak-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  color: var(--text);
  border: 0.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all var(--tx);
  z-index: 2000;
  max-width: 80vw;
}
.peak-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.peak-toast.success { border-color: var(--made); }
.peak-toast.error   { border-color: var(--missed); }

/* ── Suite chrome / hub header ──────────────────────────────── */
.suite-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-3) var(--s-5);
  /* Push the header content down under the iOS status bar / notch
     when running as an installed PWA (apple-mobile-web-app-status-
     bar-style: black-translucent makes the bar overlay the page). */
  padding-top: calc(var(--s-3) + env(safe-area-inset-top, 0px));
  padding-left:  calc(var(--s-5) + env(safe-area-inset-left,  0px));
  padding-right: calc(var(--s-5) + env(safe-area-inset-right, 0px));
  border-bottom: 0.5px solid var(--border);
  background: var(--surface);
}
.suite-brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--accent);
  text-transform: uppercase;
}
.suite-brand .brand-icon {
  width: 24px; height: 24px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ── Utilities ──────────────────────────────────────────────── */
.text-mono { font-family: var(--font-mono); }
.text-2 { color: var(--text2); }
.text-3 { color: var(--text3); }
.text-accent { color: var(--accent); }
.text-made { color: var(--made); }
.text-missed { color: var(--missed); }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--s-1); }
.gap-2 { gap: var(--s-2); }
.gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); }

.hidden { display: none !important; }

/* Pro / Basic mode toggles (used by Courtside) */
body.mode-basic .pro-only { display: none !important; }
body.mode-pro   .basic-only { display: none !important; }

/* ── Splash / buffering screen ─────────────────────────────── */
.peak-splash {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px;
  z-index: 9000;
  transition: opacity 0.25s ease;
  /* Safe area so the logo doesn't slide under the iOS status bar */
  padding-top: env(safe-area-inset-top, 0px);
}
.peak-splash.hide { opacity: 0; pointer-events: none; }
.peak-splash-logo { height: 96px; width: 96px; object-fit: contain; }
.peak-splash-title {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent);
}
.peak-splash-dots { display: flex; gap: 6px; margin-top: 6px; }
.peak-splash-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); opacity: 0.35;
  animation: peakSplashDot 1.1s ease-in-out infinite;
}
.peak-splash-dots span:nth-child(2) { animation-delay: 0.18s; }
.peak-splash-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes peakSplashDot {
  0%, 80%, 100% { opacity: 0.35; transform: scale(0.85); }
  40%           { opacity: 1;    transform: scale(1.15); }
}

/* ── PWA update banner ──────────────────────────────────────── */
.peak-update {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface);
  border: 0.5px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 0 1px var(--accent-dim);
  opacity: 0; pointer-events: none;
  transition: all var(--tx);
  z-index: 3000;
  max-width: calc(100vw - 32px);
}
.peak-update.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.peak-update-text { display: flex; flex-direction: column; }
.peak-update-title { font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: 0.02em; color: var(--text); }
.peak-update-sub   { font-family: var(--font-mono); font-size: 10px; color: var(--text3); margin-top: 2px; }

/* ── Settings modal (PEAK.openSettings) ────────────────────── */
.peak-settings-section {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 14px;
  margin-bottom: 12px;
}
.peak-settings-section:last-child { margin-bottom: 0; }
.peak-settings-label {
  font-family: var(--font-display); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text3); padding: 10px 0 4px;
}
.peak-settings-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 40px; padding: 9px 0; border-top: 1px solid var(--border);
  font-family: var(--font-body); font-size: 13px; color: var(--text2);
}
/* First row sits right under the label — no divider needed there. */
.peak-settings-label + .peak-settings-row { border-top: none; }
.peak-settings-val {
  font-family: var(--font-mono); font-size: 12px; color: var(--text);
  text-align: right; word-break: break-word;
}
/* Stacked, full-width action buttons (Report / Update / Sign out / Delete). */
.peak-settings-actions { display: flex; flex-direction: column; gap: 8px; padding: 10px 0 12px; }
.peak-settings-actions .btn { width: 100%; justify-content: center; }
.peak-settings-danger-link {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: 12px; color: var(--text3);
  padding: 6px; margin-top: 2px; text-align: center; align-self: center;
}
.peak-settings-danger-link:hover { color: var(--missed); text-decoration: underline; }
/* Org-colour swatch picker (Settings) */
.peak-color-picker { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.peak-swatch {
  width: 26px; height: 26px; flex: 0 0 26px; box-sizing: border-box;
  aspect-ratio: 1 / 1; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35);
  transition: transform 100ms;
}
.peak-swatch:hover { transform: scale(1.1); }
.peak-swatch.sel { border-color: var(--text); }
.peak-swatch-custom {
  background: conic-gradient(red, orange, yellow, lime, cyan, blue, magenta, red);
  display: inline-flex; align-items: center; justify-content: center; overflow: hidden;
}
.peak-swatch-custom input[type="color"] { opacity: 0; width: 100%; height: 100%; border: none; padding: 0; margin: 0; cursor: pointer; }
/* Team-colour button (Settings) — shows the current colour as a dot and
   opens the native picker (the input behind it is hidden). */
.peak-color-btn {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border: 1px solid var(--border2); border-radius: 8px;
  background: var(--surface); color: var(--text); cursor: pointer;
  font-family: var(--font-display); font-size: 12px; font-weight: 700;
  transition: border-color 0.12s;
}
.peak-color-btn:hover { border-color: var(--accent); }
.peak-color-btn .peak-color-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--c, var(--accent)); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35);
}
/* No dot until a colour has actually been picked. */
.peak-color-btn:not(.has-color) .peak-color-dot { display: none; }

/* Custom HSV colour picker (Settings) */
.peak-cp {
  margin: 4px 0 10px; padding: 12px;
  background: var(--surface); border: 1px solid var(--border2); border-radius: 10px;
}
.peak-cp[hidden] { display: none; }
.peak-cp-sv {
  position: relative; width: 100%; height: 150px; border-radius: 8px;
  cursor: crosshair; touch-action: none;
  background: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent), hsl(210 100% 50%);
}
.peak-cp-thumb {
  position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.55);
  transform: translate(-50%, -50%); pointer-events: none;
}
.peak-cp-hue {
  -webkit-appearance: none; appearance: none; width: 100%; height: 14px;
  border-radius: 7px; margin-top: 14px; cursor: pointer; outline: none;
  background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);
}
.peak-cp-hue::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid rgba(0,0,0,0.4); cursor: pointer;
}
.peak-cp-hue::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 2px solid rgba(0,0,0,0.4); cursor: pointer;
}
.peak-cp-foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.peak-cp-preview {
  width: 28px; height: 28px; border-radius: 6px; flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.35);
}
.peak-cp-hex {
  width: 92px; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 6px; padding: 6px 8px; color: var(--text);
  font-family: var(--font-mono); font-size: 12px;
}

/* ── Inline spinner (PEAK.spinner HTML helper) ────────────── */
.peak-spin {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: peak-spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
.peak-spin.lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes peak-spin { to { transform: rotate(360deg); } }
.peak-loading {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 24px 0;
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text3); letter-spacing: 0.04em; text-transform: uppercase;
}

/* ── Shared empty-state (PEAK.emptyState HTML helper) ─────── */
.peak-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 28px 16px; text-align: center;
}
.peak-empty .peak-empty-icon {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface2); color: var(--text3);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.peak-empty .peak-empty-title {
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  color: var(--text2);
}
.peak-empty .peak-empty-sub {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text3); max-width: 320px;
}

/* ── Floating "Report issue" button (PEAK.installReportButton) ─ */
.peak-report-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 80;
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--font-display); font-size: 11px; font-weight: 700;
  color: var(--text2); text-transform: uppercase; letter-spacing: 0.06em;
  cursor: pointer; transition: all 0.15s;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.peak-report-fab:hover { border-color: var(--accent); color: var(--accent); }
@media (max-width: 600px) {
  .peak-report-fab { font-size: 10px; padding: 7px 11px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}

/* ── Mobile polish ──────────────────────────────────────────── */
/* Tablet + medium phones */
@media (max-width: 720px) {
  :root { --header-h: 46px; }
  .card { padding: 14px; }
  .modal { padding: 18px; max-width: calc(100vw - 24px); }
  .modal-overlay { padding: 12px; }
  .modal-footer { flex-wrap: wrap; gap: 8px; }
  .modal-footer .btn { flex: 1 1 auto; }
  .suite-header {
    padding: 10px 14px;
    /* Make sure safe-area still applies on top */
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    padding-left:  calc(14px + env(safe-area-inset-left,  0px));
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
    gap: 8px;
    flex-wrap: wrap;
  }
  .suite-brand { font-size: 13px; gap: 6px; }
  .suite-brand .brand-icon { width: 22px; height: 22px; }
  .peak-update { left: 12px; right: 12px; bottom: 12px; transform: none; max-width: none; }
  .peak-update.show { transform: none; }
}

/* Phones */
@media (max-width: 600px) {
  body { font-size: 13px; }
  .btn { padding: 9px 14px; min-height: 40px; font-size: 11px; }
  .btn-sm { min-height: 34px; padding: 7px 11px; font-size: 10px; }
  .peak-splash-logo { height: 72px; width: 72px; }
  .peak-splash-title { font-size: 14px; }
}

/* Narrow phones (iPhone SE etc.) */
@media (max-width: 380px) {
  .card { padding: 12px; }
  .modal { padding: 14px; }
  .suite-header { padding-left: calc(12px + env(safe-area-inset-left, 0px)); padding-right: calc(12px + env(safe-area-inset-right, 0px)); }
}

/* Tap targets — at least 40px on touch devices, prevent iOS auto-zoom */
@media (hover: none) and (pointer: coarse) {
  .btn, button, select, input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="time"], input[type="tel"] {
    min-height: 40px;
  }
  input, select, textarea { font-size: 16px; }
  /* Normalise native date/time controls so the field doesn't change height
     once a value is picked (iOS/Android render empty vs filled differently). */
  input[type="date"], input[type="datetime-local"], input[type="time"], input[type="month"] {
    -webkit-appearance: none; appearance: none; box-sizing: border-box;
  }
}

/* Soft fade-in for newly-shown panels / cards */
@keyframes peak-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card, .modal, .panel.active { animation: peak-fade-in 0.18s ease-out; }
