/* ------------------------------------------------------------------ *
 * Trail Valley Challenge — foglio di stile
 *
 * Grafica ripresa da trailvalley.it:
 *   teal   #0F5C70  colore istituzionale, header e testo
 *   oro    #B09241  titoli di sezione e fasce delle card gara
 *   magenta#E71D73  accento vivo, pulsanti e punteggi
 *   sfondo #F2F3F5  con isoipse appena accennate
 *   titoli in Bebas Neue, testo in Roboto Condensed
 * Il sito di riferimento e' solo chiaro: niente tema scuro.
 * ------------------------------------------------------------------ */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Roboto+Condensed:ital,wght@0,300..700;1,400&display=swap');

:root {
  --teal: #0f5c70;
  --teal-dark: #0a4353;
  --teal-soft: #e3edf0;
  --gold: #b09241;
  --gold-dark: #94792f;
  --magenta: #e71d73;
  --magenta-dark: #d60b52;

  --bg: #f2f3f5;
  --panel: #ffffff;
  --panel-2: #f7f8f9;
  --line: #dde2e5;
  --text: #212121;
  --muted: #6b7780;

  --silver: #9aa7b0;
  --bronze: #b5714a;
  --danger: #d33a34;

  --radius: 22px;
  --radius-lg: 30px;
  --shadow: 0 4px 20px rgba(15, 92, 112, .09);
  --shadow-lg: 0 10px 34px rgba(15, 92, 112, .14);

  --display: 'Bebas Neue', 'Oswald', 'Haettenschweiler', 'Arial Narrow', sans-serif;
  --body: 'Roboto Condensed', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;

  color-scheme: light;
}

* { box-sizing: border-box; }

/* l'intestazione e' fissa: lascia spazio quando si salta a una sezione */
html { scroll-padding-top: 100px; }

/* .btn e .race-card impostano display: senza questo l'attributo hidden non basta */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 16px;
  background-color: var(--bg);
  /* isoipse: richiamo discreto alle curve di livello del sito */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='320' viewBox='0 0 320 320'%3E%3Cg fill='none' stroke='%230f5c70' stroke-opacity='.055' stroke-width='1.2'%3E%3Cpath d='M-20 60C40 20 90 96 160 70s120 30 180-10'/%3E%3Cpath d='M-20 96C40 56 90 132 160 106s120 30 180-10'/%3E%3Cpath d='M-20 132C40 92 90 168 160 142s120 30 180-10'/%3E%3Cpath d='M-20 200C50 172 96 236 168 214s112 22 172-14'/%3E%3Cpath d='M-20 236C50 208 96 272 168 250s112 22 172-14'/%3E%3Cpath d='M-20 272C50 244 96 308 168 286s112 22 172-14'/%3E%3C/g%3E%3C/svg%3E");
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--magenta); }
a:hover { color: var(--magenta-dark); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 18px; }

h1, h2, h3, .display {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: -.015em;
  line-height: 1.05;
}

/* ---------- intestazione ---------- */

.site-header {
  background: var(--teal);
  color: #fff;
  border-bottom: 4px solid var(--gold);
  box-shadow: 0 2px 14px rgba(10, 67, 83, .28);
  position: sticky;
  top: 0;
  z-index: 20;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 14px;
  padding-bottom: 14px;
}

/* marchio: montagna magenta su pastiglia oro, come il tondo "Challenge" */
.logo {
  width: 54px; height: 54px; flex: 0 0 auto;
  border-radius: 50%;
  background: var(--gold);
  display: grid; place-items: center;
  color: var(--magenta);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .28);
}
.logo svg { display: block; }

.site-header h1 {
  font-size: 1.9rem;
  margin: 0;
  color: #fff;
  text-transform: uppercase;
}
.site-header .sub {
  margin: 2px 0 0;
  color: rgba(255, 255, 255, .72);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 500;
}
.site-header .sub span { color: var(--gold); font-weight: 700; }
.header-spacer { flex: 1 1 auto; }

.site-header label { color: rgba(255, 255, 255, .75); }
.site-header select {
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .3);
  color: #fff;
}
.site-header select option { color: var(--text); }

/* ---------- controlli ---------- */

.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin: 24px 0 16px;
}

.tabs {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow);
}
.tabs button {
  border: 0; background: transparent; color: var(--teal);
  padding: 8px 22px; border-radius: 999px; cursor: pointer;
  font-family: var(--display); font-size: 1.05rem; letter-spacing: .02em;
  text-transform: uppercase;
}
.tabs button:hover { color: var(--magenta); }
.tabs button[aria-selected="true"] {
  background: var(--magenta); color: #fff;
  box-shadow: 0 2px 8px rgba(231, 29, 115, .35);
}

select, input[type="text"], input[type="search"], input[type="number"],
input[type="date"], input[type="password"], textarea {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; font: inherit; font-size: .95rem;
  min-width: 0;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--magenta); outline-offset: 1px;
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--magenta); color: #fff;
  border: 0; border-radius: 7px; padding: 9px 18px 7px;
  font-family: var(--display); font-size: 1rem; letter-spacing: .04em;
  text-transform: uppercase; cursor: pointer; text-decoration: none;
  transition: background-color .15s ease;
}
.btn:hover { background: var(--magenta-dark); color: #fff; }
.btn.ghost {
  background: var(--panel); color: var(--teal);
  border: 1px solid var(--line);
}
.btn.ghost:hover { background: var(--teal-soft); color: var(--teal-dark); }
/* L'oro pieno del sito con testo bianco resta sotto il rapporto di contrasto
   4,5:1, quindi per i pulsanti si usa la variante scura della stessa famiglia. */
.btn.gold { background: var(--gold-dark); }
.btn.gold:hover { background: #7d651f; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b32e29; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 6px 12px 4px; font-size: .88rem; }

.site-header .btn.ghost {
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .3);
  color: #fff;
}
.site-header .btn.ghost:hover { background: rgba(255, 255, 255, .22); color: #fff; }

/* ---------- pannelli e tabelle ---------- */

.panel {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 22px;
}
/* fascia di sezione in teal; l'oro resta alle schede gara e agli accenti */
.panel > h2 {
  margin: 0; padding: 16px 24px 13px;
  font-size: 1.5rem; text-transform: uppercase;
  color: #fff; background: var(--teal);
  border-bottom: 3px solid var(--gold);
}
.panel-body { padding: 20px 24px; }

.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
th {
  font-family: var(--display); font-size: .95rem; letter-spacing: .05em;
  text-transform: uppercase; color: var(--teal); font-weight: 400;
  white-space: nowrap; background: var(--teal-soft);
}
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

tr.athlete-row { cursor: pointer; }
tr.athlete-row:hover { background: var(--teal-soft); }

.pos {
  display: inline-grid; place-items: center;
  min-width: 32px; height: 28px; padding: 2px 8px 0;
  border-radius: 7px; background: var(--teal-soft); color: var(--teal);
  font-family: var(--display); font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.pos.p1 { background: var(--gold); color: #fff; }
.pos.p2 { background: var(--silver); color: #fff; }
.pos.p3 { background: var(--bronze); color: #fff; }

.athlete-name { font-weight: 600; color: var(--teal-dark); }
.athlete-club { color: var(--muted); font-size: .85rem; display: none; }
@media (max-width: 640px) { .athlete-club:not(:empty) { display: block; } }
.total {
  font-family: var(--display); font-size: 1.25rem;
  color: var(--magenta); letter-spacing: .01em;
}

.badge {
  display: inline-block; padding: 2px 9px 1px; border-radius: 999px;
  background: var(--teal-soft); border: 1px solid transparent;
  font-size: .78rem; font-weight: 600; color: var(--teal); white-space: nowrap;
}
.badge.ok { background: #e4f1e6; color: #2c6b34; }
.badge.warn { background: #f9efd8; color: var(--gold-dark); }

.detail-row > td { background: var(--panel-2); padding: 0; }
.detail-inner { padding: 14px 20px 18px; }
.detail-inner table { font-size: .88rem; }
.detail-inner th { background: transparent; }
.detail-inner .total { font-size: 1.05rem; }

.muted { color: var(--muted); }
.small { font-size: .88rem; }
.empty { padding: 46px 18px; text-align: center; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

/* card gara: fascia oro in testa, come le schede gara del sito */
.race-card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease;
  display: flex; flex-direction: column;
}
.race-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.race-card:focus-visible { outline: 3px solid var(--magenta); outline-offset: 2px; }
.race-card h3 {
  margin: 0; padding: 13px 16px 10px;
  background: var(--gold); color: #fff;
  font-size: 1.3rem; text-transform: uppercase;
}
.race-card .meta { color: var(--muted); font-size: .87rem; padding: 12px 16px 0; }
.race-card .pts { padding: 10px 16px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.race-card .count {
  margin-top: auto; padding: 12px 16px;
  color: var(--teal); font-weight: 600; font-size: .87rem;
}

.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field > label {
  font-family: var(--display); font-size: .95rem; letter-spacing: .04em;
  text-transform: uppercase; color: var(--teal);
}
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }

.notice {
  padding: 12px 16px; border-radius: 12px; margin-bottom: 14px;
  font-size: .93rem; border-left: 5px solid;
}
.notice.info { background: var(--teal-soft); border-color: var(--teal); }
.notice.ok { background: #e6f3e8; border-color: #3c8a45; }
.notice.err { background: #fbe9e8; border-color: var(--danger); }
.notice.warn { background: #fbf1dc; border-color: var(--gold); }

/* ---------- spiegazione punteggi ---------- */

.rules ul { margin: 10px 0; padding-left: 20px; }
.rules li { margin-bottom: 4px; }
.rules strong { color: var(--teal); }

footer.site-footer {
  background: var(--teal);
  color: rgba(255, 255, 255, .75);
  margin-top: 34px;
  padding: 26px 0 34px;
  font-size: .88rem;
}
footer.site-footer a { color: var(--gold); }
footer.site-footer a:hover { color: #fff; }

@media (max-width: 640px) {
  th, td { padding: 9px 10px; }
  .hide-sm { display: none; }
  .site-header h1 { font-size: 1.35rem; }
  .logo { width: 44px; height: 44px; }
  .panel-body { padding: 16px; }
  .panel > h2 { padding: 13px 16px 10px; font-size: 1.25rem; }
}
