/* ═══════════════════════════════════════════════════════
   SinnerTracker — Style v4.1
   Design system: light theme, Inter, 3-color system
   ═══════════════════════════════════════════════════════ */

/* ── SELF-HOSTED FONT (GDPR: no Google Fonts CDN) ── */
@font-face {
  font-family: 'Inter';
  src: url('fonts/inter-var.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ── DESIGN TOKENS ── */
:root {
  --orange: #FF7A00;
  --green: #2E9E5C;
  --red: #FF3B30;
  --gold: #C9A227;

  /* Versioni scure per testo piccolo (WCAG AA su bianco) */
  --orange-dark: #C25E00;
  --green-dark: #1E7A45;
  --red-dark: #CC2F26;

  --bg: #F5F2EE;
  --card: #FFFFFF;
  --border: #E8E3DC;
  --border-light: #F0EBE4;

  --text: #1A1A1A;
  --text-secondary: #555555;
  --text-muted: #717171;       /* 4.56:1 su bianco — WCAG AA pass */
  --text-on-dark: #FFFFFF;
  --text-on-dark-muted: #AAAAAA; /* 5.72:1 su #1A1A1A */

  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ── SKIP LINK ── */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--orange);
  color: #fff;
  padding: 8px 16px;
  z-index: 200;
  font-size: 14px;
  font-weight: 600;
  border-radius: 0 0 8px 0;
}
.skip-link:focus {
  left: 0;
}

/* ── HEADER ── */
header {
  background: var(--text);
  color: #fff;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 900px; margin: 0 auto;
  display: flex; align-items: center;
  justify-content: space-between;
  height: 56px;
}
.logo {
  font-size: 18px; font-weight: 800;
  letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
  color: #fff;
}
.logo:hover { opacity: 0.9; }
.flag { display: flex; height: 16px; width: 24px; border-radius: 2px; overflow: hidden; flex-shrink: 0; }
.flag span { flex: 1; }
.logo-accent { color: var(--orange); }

.live-badge {
  background: var(--red);
  color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 4px;
  letter-spacing: 0.5px;
  display: flex; align-items: center; gap: 6px;
}
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ── TABS ── */
.tab-bar {
  background: var(--card);
  border-bottom: 2px solid var(--border);
  padding: 0 24px;
  overflow-x: auto; scrollbar-width: none;
  position: relative;
}
.tab-bar::-webkit-scrollbar { display: none; }
.tabs { max-width: 900px; margin: 0 auto; display: flex; }

.tab {
  font-size: 13px; font-weight: 600;
  color: var(--text-muted); background: none; border: none;
  border-bottom: 3px solid transparent;
  padding: 14px 16px 11px;
  cursor: pointer; white-space: nowrap;
  margin-bottom: -2px;
  transition: color 0.15s;
  font-family: var(--font);
  min-height: 44px;
}
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }
.tab:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: -2px;
  border-radius: 4px;
}

/* Tab scroll fade indicator */
.tab-bar::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 40px;
  background: linear-gradient(to right, transparent, var(--card));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.tab-bar.has-scroll::after { opacity: 1; }
.tab-bar.scrolled-end::after { opacity: 0; }

/* ── MAIN ── */
main { max-width: 900px; margin: 0 auto; padding: 24px 24px 40px; }
.pane { display: none; }
.pane.active { display: block; }

/* ── CARDS ── */
.card {
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); margin-bottom: 14px;
}

/* ── HERO CARD (next match/tournament) ── */
.match-hero {
  background: var(--text);
  color: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
}
.match-hero-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--orange); margin-bottom: 18px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px;
}
.match-when { color: var(--text-on-dark-muted); font-weight: 500; text-transform: none; letter-spacing: 0; font-size: 12px; }

.match-players {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px; align-items: center;
  margin-bottom: 20px;
}
.player-name { font-size: 22px; font-weight: 800; }
.player-name.orange { color: var(--orange); }
.player-flag { font-size: 13px; color: var(--text-on-dark-muted); margin-top: 3px; }
.player-right { text-align: right; }
.vs-block { text-align: center; }
.vs { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: 2px; }
.round-label { font-size: 28px; font-weight: 800; color: var(--orange); line-height: 1.1; }

.match-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 1px solid #2E2E2E;
  padding-top: 16px;
}
.mstat { text-align: center; border-right: 1px solid #2E2E2E; padding: 0 12px; }
.mstat:last-child { border-right: none; }
.mstat-val { font-size: 22px; font-weight: 800; color: #fff; }
.mstat-lbl { font-size: 10px; color: var(--text-on-dark-muted); margin-top: 3px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── BRACKET ── */
.bracket-row {
  display: grid;
  grid-template-columns: 60px 1fr auto auto;
  gap: 12px; align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-light);
}
.bracket-row:last-child { border-bottom: none; }
.br-round { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.br-opp { font-size: 14px; font-weight: 600; }
.br-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.br-score { font-size: 14px; font-weight: 700; color: var(--green); text-align: right; }

.bracket-row.final-row { background: #FFFBF0; border-radius: 8px; padding: 11px 8px; }
.bracket-row.final-row .br-round { color: var(--gold); font-size: 13px; }
.bracket-row.final-row .br-opp { color: var(--gold); font-weight: 700; }
.bracket-row.final-row .br-score { color: var(--gold); }

.pill {
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700;
  white-space: nowrap;
}
.pill-green { background: #E8F7EF; color: var(--green-dark); }
.pill-orange { background: #FFF0E6; color: var(--orange-dark); }
.pill-gray { background: var(--border-light); color: var(--text-muted); }
.pill-red { background: #FEE8E8; color: var(--red-dark); }

/* ── RANKING BATTLE ── */
.battle {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 12px; align-items: center; margin-bottom: 16px;
}
.b-player { display: flex; flex-direction: column; gap: 2px; }
.b-player.right { align-items: flex-end; }
.b-name { font-size: 18px; font-weight: 800; }
.b-pts { font-size: 13px; color: var(--text-muted); }
.b-rank { font-size: 32px; font-weight: 800; line-height: 1; }
.rank-1 { color: var(--gold); }
.rank-2 { color: var(--orange); }

.b-gap { text-align: center; }
.b-gap-val { font-size: 28px; font-weight: 800; color: var(--orange); }
.b-gap-lbl { font-size: 11px; color: var(--text-muted); }

.bar { height: 8px; background: var(--border-light); border-radius: 4px; overflow: hidden; margin: 12px 0 6px; }
.bar-inner { height: 100%; border-radius: 4px; background: var(--orange); }

.note-box {
  background: #E8F7EF; border-left: 3px solid var(--green);
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  font-size: 13px; color: #1A5C36;
  line-height: 1.5; margin-top: 4px;
}

/* ── STAT ROW ── */
.stat-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 16px;
}

.stat-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 16px;
  border-top: 3px solid var(--orange);
}
.stat-box.green-top { border-top-color: var(--green); }
.stat-box.gray-top { border-top-color: #ccc; }
.stat-box.gold-top { border-top-color: var(--gold); }
.stat-num { font-size: 30px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-lbl { font-size: 11px; color: var(--text-muted); margin-top: 5px; }

/* ── NEWS ── */
.section-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-muted); margin: 20px 0 10px;
}

.news-item {
  background: var(--card); border-radius: 10px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  padding: 14px 16px; margin-bottom: 10px;
  display: flex; gap: 14px; align-items: flex-start;
}
.news-item.red { border-left-color: var(--red); }
.news-item.orange { border-left-color: var(--orange); }
.news-item.green { border-left-color: var(--green); }

.news-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }
.news-tag {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 4px;
}
/* Tag colors — versioni scure per WCAG su testo piccolo */
.tag-r { color: var(--red-dark); }
.tag-o { color: var(--orange-dark); }
.tag-g { color: var(--green-dark); }
.tag-gray { color: var(--text-muted); }
.news-headline { font-size: 14px; font-weight: 700; line-height: 1.35; margin-bottom: 5px; }
.news-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.55; }
.news-source { font-size: 10px; color: var(--text-muted); margin-top: 6px; }
.news-source a {
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 2px;
}
.news-source a:hover { color: var(--text-secondary); text-decoration-color: var(--text-muted); }

/* ── CALENDAR ── */
.cal-row {
  display: grid; grid-template-columns: 80px 1fr auto auto;
  gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border-light);
}
.cal-row:last-child { border-bottom: none; }
.cal-date { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.cal-name { font-size: 14px; font-weight: 600; }
.cal-surface { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.cal-pts { font-size: 16px; font-weight: 800; text-align: right; }
.cal-pts.pos { color: var(--green); }
.cal-pts.neg { color: var(--red); }
.cal-pts.neutral { color: var(--orange); }

/* ── SCENARIOS ── */
.sc-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 16px; }

.scenario {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 18px;
}
.scenario.best { border-top: 3px solid var(--green); }
.scenario.mid { border-top: 3px solid var(--orange); }
.scenario.worst { border-top: 3px solid #ccc; }
.sc-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.scenario.best .sc-tag { color: var(--green-dark); }
.scenario.mid .sc-tag { color: var(--orange-dark); }
.scenario.worst .sc-tag { color: var(--text-muted); }
.sc-date { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.sc-desc { font-size: 12px; color: var(--text-secondary); line-height: 1.55; }
.sc-prob { font-size: 12px; font-weight: 700; margin-top: 12px; }
.scenario.best .sc-prob { color: var(--green); }
.scenario.mid .sc-prob { color: var(--orange); }
.scenario.worst .sc-prob { color: var(--text-muted); }

/* ── PREDICTION TABLE ── */
.pred-header {
  display: grid; grid-template-columns: 120px 1fr 70px 80px;
  gap: 12px; font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border-light); margin-bottom: 10px;
}
.pred-row {
  display: grid; grid-template-columns: 120px 1fr 70px 80px;
  gap: 12px; align-items: center; padding: 8px 0;
  border-bottom: 1px solid var(--border-light); font-size: 13px;
}
.pred-row:last-child { border-bottom: none; }
.pred-name { font-weight: 600; }
.pred-bar { height: 6px; background: var(--border-light); border-radius: 3px; }
.pred-bar-inner { height: 100%; border-radius: 3px; }
.pred-val { text-align: right; font-weight: 700; }
.pred-val.pos { color: var(--green); }
.pred-val.neg { color: var(--red); }
.pred-val.neutral { color: var(--text-muted); }

/* ── ODDS ── */
.odds-row {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border-light);
}
.odds-row:last-child { border-bottom: none; }
.odds-match { font-size: 14px; font-weight: 600; }
.odds-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.odds-block { text-align: center; min-width: 52px; }
.odds-val { font-size: 20px; font-weight: 800; color: var(--orange); }
.odds-val.secondary { color: var(--text-muted); }
.odds-lbl { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.odds-tag { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 4px; white-space: nowrap; }
.ot-green { background: #E8F7EF; color: var(--green-dark); }
.ot-orange { background: #FFF0E6; color: var(--orange-dark); }

.disclaimer {
  font-size: 11px; color: var(--text-muted); padding: 10px 14px;
  background: var(--card); border: 1px solid var(--border-light);
  border-radius: 8px; margin-top: 12px; line-height: 1.6;
}

/* ── FORM DOTS ── */
.form-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.fd {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; cursor: default;
}
.fd.w { background: #E8F7EF; color: var(--green-dark); border: 1.5px solid #B8E8CC; }
.fd.l { background: #FEE8E8; color: var(--red-dark); border: 1.5px solid #FACACA; }

/* ── TOP 5 ── */
.top5-row {
  display: grid; grid-template-columns: 32px 1fr auto;
  gap: 10px; align-items: center;
  padding: 10px 12px; border-radius: 8px;
  margin-bottom: 6px;
}
.top5-row.highlight { background: #FFF0E6; border: 1px solid #FFD4B0; }
.top5-row.plain { background: #F7F4F0; }
.top5-pos { font-size: 20px; font-weight: 800; }
.pos-gold { color: var(--gold); }
.pos-orange { color: var(--orange); }
.pos-gray { color: #ccc; }
.top5-name { font-size: 14px; font-weight: 600; }
.top5-status { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.top5-pts { font-size: 16px; font-weight: 800; text-align: right; }

/* ── FOOTER ── */
footer {
  background: var(--text);
  color: var(--text-on-dark-muted);
  padding: 24px;
  font-size: 12px;
  line-height: 1.7;
}
.footer-inner {
  max-width: 900px; margin: 0 auto;
}
.footer-inner p { margin-bottom: 8px; }
.footer-updated { color: #fff; font-weight: 600; margin-bottom: 12px; }
.footer-legal { font-size: 11px; color: #888; }
.footer-legal strong { color: var(--text-on-dark-muted); }

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .sc-grid { grid-template-columns: 1fr; }
  .match-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .match-players { grid-template-columns: 1fr; text-align: center; gap: 8px; }
  .player-right { text-align: center; }
  .vs-block { order: -1; }
  .battle { grid-template-columns: 1fr; text-align: center; gap: 8px; }
  .b-player.right { align-items: center; }
  .b-gap { order: -1; }
  .fd { width: 44px; height: 44px; font-size: 15px; }
  .cal-row { grid-template-columns: 60px 1fr auto; }
  .cal-row .cal-pts { display: none; }
  .odds-row { grid-template-columns: 1fr; gap: 8px; }
  .odds-row > div:first-child { grid-column: 1 / -1; }
  .pred-header, .pred-row { grid-template-columns: 90px 1fr 60px 70px; }
}

@media (max-width: 400px) {
  main { padding: 16px 16px 32px; }
  .match-hero { padding: 16px; }
  .mstat-val { font-size: 18px; }
  .stat-num { font-size: 24px; }
}
