/* =============================================================================
   BIRDIE PLATFORM — Stylesheet
   birdie-style.css
   ============================================================================= */

/* ── Variables ───────────────────────────────────────────────────────────────── */
:root {
  /* Birdie brand — distinct from CourtDesk green, uses deep teal/navy */
  --primary:        #0d3b5e;
  --primary-dark:   #082a45;
  --primary-light:  #1a5a8a;
  --accent:         #f59e0b;      /* amber — energy, warmth */
  --accent-light:   #fef3c7;

  --bg:             #f0f4f8;
  --white:          #ffffff;
  --text:           #1a1a2e;
  --text-muted:     #64748b;
  --border:         #dde5ee;
  --shadow:         0 2px 10px rgba(13,59,94,0.10);
  --shadow-lg:      0 4px 20px rgba(13,59,94,0.15);
  --radius:         12px;
  --radius-sm:      8px;
  --nav-height:     60px;

  /* Tier colours (matches TIERS in birdie-config.js) */
  --tier-peregrine-bg: #e8e8f0; --tier-peregrine-fg: #1a1a2e;
  --tier-osprey-bg:    #f5eef8; --tier-osprey-fg:    #6c3483;
  --tier-eagle-bg:     #fef9e7; --tier-eagle-fg:     #b7770d;
  --tier-falcon-bg:    #eaf4fb; --tier-falcon-fg:    #1a5276;
  --tier-robin-bg:     #fdedec; --tier-robin-fg:     #922b21;
  --tier-fledgling-bg: #fdf2e9; --tier-fledgling-fg: #6e4c2a;
  --tier-calibrating-bg: #f5f5f5; --tier-calibrating-fg: #888;
}

/* ── Reset ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
input, button, select, textarea { font-family: inherit; font-size: inherit; }

/* ── Navigation ──────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--primary);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.nav-brand {
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-brand span { color: var(--accent); }
.nav-links { display: flex; gap: 4px; align-items: center; }
.nav-links a {
  color: rgba(255,255,255,0.85);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-links a:hover, .nav-links a.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  text-decoration: none;
}
.nav-user {
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-user a {
  color: var(--accent);
  font-weight: 600;
}
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
}

@media (max-width: 600px) {
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0; right: 0;
    background: var(--primary-dark);
    flex-direction: column;
    padding: 12px;
    gap: 4px;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 10px 16px; }
  .nav-user { display: none; }
}

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}
.container-wide {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}
.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.page-header p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(13,59,94,0.25);
}
.btn-primary:hover { background: var(--primary-light); box-shadow: var(--shadow); text-decoration: none; color: #fff; }
.btn-accent {
  background: var(--accent);
  color: var(--primary-dark);
  box-shadow: 0 2px 6px rgba(245,158,11,0.3);
}
.btn-accent:hover { background: #d97706; text-decoration: none; color: var(--primary-dark); }
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); text-decoration: none; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-label .hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 4px;
}
.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;   /* 16px prevents iOS zoom */
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,59,94,0.12);
}
.form-input.error { border-color: #e74c3c; }
.form-input::placeholder { color: var(--text-muted); opacity: 0.7; }

/* PIN input — large digits */
.pin-input {
  font-size: 28px;
  letter-spacing: 10px;
  text-align: center;
  font-weight: 700;
  max-width: 200px;
}

.form-error {
  display: none;
  color: #c0392b;
  font-size: 13px;
  margin-top: 6px;
  padding: 8px 12px;
  background: #fdecea;
  border-radius: var(--radius-sm);
  border-left: 3px solid #e74c3c;
}
.form-success {
  display: none;
  color: #1a7a3c;
  font-size: 13px;
  margin-top: 6px;
  padding: 8px 12px;
  background: #e8f5e9;
  border-radius: var(--radius-sm);
  border-left: 3px solid #27ae60;
}

/* ── Tier badges ─────────────────────────────────────────────────────────────── */
.tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.tier-badge.large {
  padding: 8px 18px;
  font-size: 16px;
  border-radius: 24px;
}

/* ── Profile hero ────────────────────────────────────────────────────────────── */
.profile-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: var(--radius);
  padding: 28px 24px;
  color: #fff;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}
.profile-hero::before {
  content: '🏸';
  position: absolute;
  right: -10px;
  top: -10px;
  font-size: 100px;
  opacity: 0.07;
  transform: rotate(20deg);
  pointer-events: none;
}
.profile-hero .player-name {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 2px;
}
.profile-hero .player-username {
  font-size: 14px;
  opacity: 0.75;
  margin-bottom: 16px;
}
.profile-hero .hero-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.hero-stat { text-align: center; }
.hero-stat .value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
}
.hero-stat .label {
  font-size: 11px;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ── Stat grid ───────────────────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.stat-cell {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
}
.stat-cell .val { font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-cell .lbl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 4px; }

/* ── Social links ────────────────────────────────────────────────────────────── */
.social-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.social-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.15s, background 0.15s;
}
.social-link:hover { border-color: var(--primary); background: var(--bg); text-decoration: none; }

/* ── Progress bar (Elo to next tier) ────────────────────────────────────────── */
.progress-wrap { margin-top: 12px; }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--primary-light) 100%);
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* ── Auth pages (signup, login, pin-reset) ───────────────────────────────────── */
.auth-wrap {
  min-height: calc(100vh - var(--nav-height));
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px 60px;
}
.auth-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
}
.auth-logo {
  text-align: center;
  font-size: 40px;
  margin-bottom: 8px;
}
.auth-title {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 6px;
  letter-spacing: -0.4px;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}
.auth-footer a { color: var(--primary); font-weight: 600; }

/* Step indicator */
.steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}
.step-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s;
}
.step-dot.active { background: var(--primary); }
.step-dot.done   { background: var(--accent); }

/* ── Spinner ─────────────────────────────────────────────────────────────────── */
.spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
  gap: 10px;
}
.spinner::before {
  content: '';
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Match history rows ──────────────────────────────────────────────────────── */
.match-row {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.match-row:last-child { border-bottom: none; }
.match-result {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
}
.match-result.win  { background: #e8f5e9; color: #1a7a3c; }
.match-result.loss { background: #fdecea; color: #c0392b; }
.match-meta { flex: 1; min-width: 0; }
.match-meta .partners { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match-meta .date     { font-size: 12px; color: var(--text-muted); }
.match-elo-change { font-size: 13px; font-weight: 700; white-space: nowrap; }
.match-elo-change.pos { color: #1a7a3c; }
.match-elo-change.neg { color: #c0392b; }

/* ── Responsive tweaks ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .auth-card { padding: 24px 18px; }
  .profile-hero { padding: 22px 16px; }
  .profile-hero .player-name { font-size: 22px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .hero-stats { gap: 16px; }
}
