/* ==========================================================================
   Atletica il Colle — tema "macchia rossa"
   Strato di override caricato DOPO bootstrap.min.css.
   Compatibile Bootstrap 4.x e 5.x (usa solo classi, + variabili --bs-* per BS5).
   Non richiede build: un solo file statico.
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  --colle-red: #D42A20;
  --colle-red-dark: #A81E17;
  --colle-red-tint: #FCEDEB;
  --colle-red-on-dark: #FF8A80;   /* rosso leggibile su sfondo scuro */
  --colle-ink: #14161A;
  --colle-ink-2: #2A2E35;
  --colle-muted: #5A616E;
  --colle-line: #E5E7EB;
  --colle-line-soft: #F0F1F3;
  --colle-bg: #F5F6F8;
  --colle-white: #FFFFFF;

  --colle-font-display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --colle-font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --colle-radius: 14px;
  --colle-radius-sm: 10px;
  --colle-radius-pill: 999px;
  --colle-nav-h: 72px;
  --colle-gutter: 16px;
  --colle-section-y: 80px;

  /* Bootstrap 5: rimappa le variabili native (ignorate da BS4) */
  --bs-primary: var(--colle-red);
  --bs-primary-rgb: 212, 42, 32;
  --bs-body-font-family: var(--colle-font-body);
  --bs-body-color: var(--colle-ink);
  --bs-border-color: var(--colle-line);
  --bs-border-radius: var(--colle-radius-sm);
  --bs-link-color: var(--colle-red);
  --bs-link-color-rgb: 212, 42, 32;
  --bs-link-hover-color: var(--colle-red-dark);
  --bs-link-hover-color-rgb: 168, 30, 23;
}
@media (max-width: 767.98px) {
  :root { --colle-nav-h: 60px; --colle-section-y: 48px; }
}

/* ---------- 2. Base ---------- */
html { scroll-padding-top: calc(var(--colle-nav-h) + 8px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  font-family: var(--colle-font-body);
  color: var(--colle-ink);
  background: var(--colle-white);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
h1, h2, h3, .h1, .h2, .h3, .display-1, .display-2, .display-3, .display-4 {
  font-family: var(--colle-font-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.005em;
  line-height: 1;
}
h4, h5, h6, .h4, .h5, .h6 { font-family: var(--colle-font-body); font-weight: 700; }
a { color: var(--colle-red); }
a:hover { color: var(--colle-red-dark); }
.text-muted { color: var(--colle-muted) !important; }
.text-primary { color: var(--colle-red) !important; }
.bg-primary { background-color: var(--colle-red) !important; }
.bg-dark { background-color: var(--colle-ink) !important; }
.bg-light { background-color: var(--colle-bg) !important; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid rgba(212, 42, 32, .45); outline-offset: 2px; }

/* ---------- 3. Sezioni e titoli (classi nuove da aggiungere al markup) ---------- */
.colle-section { padding-block: var(--colle-section-y); }
.colle-section--alt { background: var(--colle-bg); }
.colle-section--dark { background: var(--colle-ink); color: #C9CDD4; }
.colle-eyebrow {
  margin: 0 0 8px; font-size: 13px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--colle-red);
}
.colle-section--dark .colle-eyebrow { color: var(--colle-red-on-dark); }
.colle-title { font-size: clamp(40px, 6vw, 56px); margin: 0 0 32px; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- 4. Navbar ---------- */
.navbar {
  min-height: var(--colle-nav-h);
  background: rgba(255, 255, 255, .94) !important;
  border-bottom: 1px solid var(--colle-line);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  backdrop-filter: saturate(1.4) blur(8px);
  padding-block: 0;
}
.navbar.navbar-dark { /* se oggi la navbar è dark, la portiamo chiara */
  --bs-navbar-color: var(--colle-ink);
}
.navbar .navbar-brand {
  font-family: var(--colle-font-display); font-weight: 800; font-size: 22px;
  text-transform: uppercase; color: var(--colle-ink) !important;
  display: flex; align-items: center; gap: 10px;
}
.navbar .navbar-brand img { height: 40px; width: auto; }
.navbar .nav-link { color: var(--colle-ink) !important; font-weight: 500; padding: 10px 12px !important; }
.navbar .nav-link:hover, .navbar .nav-link.active { color: var(--colle-red) !important; }
.navbar .dropdown-menu {
  border: 1px solid var(--colle-line); border-radius: var(--colle-radius-sm);
  box-shadow: 0 12px 32px rgba(20, 22, 26, .12); padding: 6px;
}
.navbar .dropdown-item { border-radius: 8px; padding: 10px 12px; }
.navbar .dropdown-item:active { background: var(--colle-red); }
.navbar-toggler {
  border: 0; width: 44px; height: 44px; border-radius: var(--colle-radius-sm);
  background: var(--colle-ink); padding: 0;
}
.navbar-toggler:focus { box-shadow: none; }
.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%23fff' stroke-width='2.4' stroke-linecap='round' d='M5 8h20M5 15h20M5 22h20'/%3e%3c/svg%3e") !important;
}
@media (max-width: 991.98px) {
  .navbar .navbar-collapse {
    background: var(--colle-ink); margin: 0 calc(var(--colle-gutter) * -1);
    padding: 8px var(--colle-gutter) 20px;
  }
  .navbar .navbar-collapse .nav-link {
    color: #fff !important; font-family: var(--colle-font-display);
    font-size: 26px; font-weight: 700; text-transform: uppercase;
    border-bottom: 1px solid var(--colle-ink-2); padding: 14px 4px !important;
  }
  .navbar .navbar-collapse .dropdown-menu { background: var(--colle-ink-2); border: 0; }
  .navbar .navbar-collapse .dropdown-item { color: #fff; }
  .navbar .navbar-collapse .btn { width: 100%; margin-top: 16px; }
}

/* ---------- 5. Bottoni ---------- */
.btn {
  border-radius: var(--colle-radius-sm); font-weight: 600;
  padding: 12px 20px; min-height: 44px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-sm { padding: 8px 14px; min-height: 36px; }
.btn-primary, .btn-danger {
  background: var(--colle-red); border-color: var(--colle-red); color: #fff;
}
.btn-primary:hover, .btn-primary:focus, .btn-danger:hover, .btn-danger:focus,
.btn-primary:not(:disabled):not(.disabled):active {
  background: var(--colle-red-dark); border-color: var(--colle-red-dark); color: #fff;
}
.btn-dark, .btn-secondary { background: var(--colle-ink); border-color: var(--colle-ink); color: #fff; }
.btn-outline-primary, .btn-outline-danger { color: var(--colle-red); border-color: var(--colle-red); }
.btn-outline-primary:hover, .btn-outline-danger:hover { background: var(--colle-red); color: #fff; }
.btn-outline-light { border-color: #3A3F47; color: #fff; }
.btn-link { color: var(--colle-red); text-decoration: none; padding-inline: 0; }

/* ---------- 6. Hero / carosello ---------- */
.carousel { background: var(--colle-ink); }
.carousel-item { min-height: min(78svh, 680px); }
/* slide con immagine come background-image (markup attuale del sito) */
.carousel-item { background-size: cover; background-position: center; }
.carousel-item::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background: rgba(0, 0, 0, .45); pointer-events: none;
}
.carousel-item > * { position: relative; z-index: 1; }
.carousel-item > .carousel-caption { position: absolute; }
.carousel-item > img { object-fit: cover; height: min(78svh, 680px); width: 100%; filter: brightness(.55); }
.carousel-caption {
  left: 0; right: 0; bottom: 0; text-align: left;
  padding: 48px max(var(--colle-gutter), calc((100% - 1240px) / 2 + 24px));
  background: linear-gradient(transparent, rgba(0, 0, 0, .65));
}
.carousel-caption h1, .carousel-caption h2 { font-size: clamp(48px, 9vw, 96px); color: #fff; }
.carousel-caption h3, .carousel-caption h5 {
  font-family: var(--colle-font-body); font-size: 14px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--colle-red-on-dark);
}
.carousel-indicators { justify-content: flex-start; margin-left: max(var(--colle-gutter), calc((100% - 1240px) / 2 + 24px)); }
.carousel-indicators li, .carousel-indicators [data-bs-target] {
  width: 12px; height: 4px; border-radius: 2px; border: 0; opacity: 1; background: #4A5059;
}
.carousel-indicators .active { width: 28px; background: var(--colle-red); }
@media (max-width: 767.98px) {
  .carousel-item, .carousel-item > img { min-height: 0; height: 64svh; }
  .carousel-control-prev, .carousel-control-next { display: none; } /* su mobile si usa lo swipe */
}

/* ---------- 7. Card ---------- */
.card {
  border: 1px solid var(--colle-line); border-radius: var(--colle-radius);
  box-shadow: none; overflow: hidden;
}
.card-header { background: transparent; border-bottom-color: var(--colle-line); font-weight: 700; }
.card-title { font-family: var(--colle-font-display); font-weight: 700; font-size: 28px; text-transform: uppercase; }
.card-body { padding: 22px; }
.card-img-top { aspect-ratio: 16 / 9; object-fit: cover; }
.card.colle-card--accent { background: var(--colle-red); border-color: var(--colle-red); color: #fff; }
.card.colle-card--accent .btn { background: #fff; color: var(--colle-red-dark); border-color: #fff; }

/* ---------- 8. Gare / preiscrizioni (markup nuovo in index.php) ---------- */
.colle-race {
  background: #fff; border: 1px solid var(--colle-line); border-radius: var(--colle-radius);
  padding: 16px; display: flex; gap: 16px; margin-bottom: 12px;
}
.colle-date {
  flex: 0 0 60px; height: 64px; border-radius: var(--colle-radius-sm);
  background: var(--colle-red-tint); color: var(--colle-red-dark);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
}
.colle-date__d { font-family: var(--colle-font-display); font-weight: 800; font-size: 28px; }
.colle-date__m { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.colle-race__body { flex: 1 1 auto; min-width: 0; }
.colle-race__name { margin: 0; font-size: 17px; font-weight: 700; font-family: var(--colle-font-body); text-transform: none; }
.colle-race__place { color: var(--colle-muted); font-size: 14px; }
.colle-race__dist { display: flex; gap: 10px; align-items: flex-start; margin-top: 8px; font-size: 14px; }
.colle-race__names { color: var(--colle-muted); }
.colle-race__empty { color: var(--colle-muted); font-style: italic; }
.colle-race details > summary { cursor: pointer; list-style: none; }
.colle-race details > summary::-webkit-details-marker { display: none; }
.colle-chip, .badge-colle {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--colle-ink); color: #fff; padding: 3px 10px; border-radius: var(--colle-radius-pill);
  white-space: nowrap;
}
.colle-chip--soft { background: var(--colle-red-tint); color: var(--colle-red-dark); }

/* ---------- 9. Classifica: podio + barre ---------- */
.colle-podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-items: end; margin-bottom: 16px; }
.colle-podium__step {
  border-radius: 12px 12px 0 0; background: #fff; border: 1px solid var(--colle-line); border-bottom: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.colle-podium__step--1 { height: 100px; background: var(--colle-red); border-color: var(--colle-red); color: #fff; }
.colle-podium__step--2 { height: 72px; }
.colle-podium__step--3 { height: 58px; }
.colle-podium__pos { font-family: var(--colle-font-display); font-weight: 800; font-size: 30px; line-height: 1; }
.colle-podium__name { font-size: 13px; font-weight: 600; text-align: center; margin-bottom: 6px; }
.colle-bar { display: block; height: 6px; border-radius: 3px; background: var(--colle-line-soft); overflow: hidden; min-width: 60px; }
.colle-bar > span { display: block; height: 100%; background: var(--colle-ink); }
tr:nth-child(-n+3) .colle-bar > span { background: var(--colle-red); }

/* ---------- 10. Tabelle ---------- */
.table { color: var(--colle-ink); margin-bottom: 0; }
.table thead th {
  background: var(--colle-bg); color: var(--colle-muted);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  border-bottom: 1px solid var(--colle-line); border-top: 0; white-space: nowrap;
  position: sticky; top: var(--colle-nav-h); z-index: 1;
}
.table td, .table th { vertical-align: middle; padding: 12px 14px; border-top-color: var(--colle-line-soft); }
.table td { font-variant-numeric: tabular-nums; }
.table-striped tbody tr:nth-of-type(odd), .table-striped > tbody > tr:nth-of-type(odd) > * {
  background-color: transparent; --bs-table-accent-bg: transparent; --bs-table-striped-bg: transparent;
}
.table-hover tbody tr:hover { background: #FAFAFB; }
.colle-table-wrap {
  background: #fff; border: 1px solid var(--colle-line); border-radius: var(--colle-radius); overflow: hidden;
}
.colle-table-wrap .table-responsive { margin: 0; }
.table .colle-total { font-weight: 800; font-size: 16px; text-align: right; }
.table tbody tr:nth-child(1) td:first-child,
.table tbody tr:nth-child(2) td:first-child,
.table tbody tr:nth-child(3) td:first-child { color: var(--colle-red); font-weight: 800; }

/* Colonne secondarie: nascoste sotto 768px (classe da aggiungere a th/td) */
@media (max-width: 767.98px) {
  .colle-col-secondary { display: none !important; }
  .table td, .table th { padding: 10px; }
}

/* ---------- 11. Tab e pill → controllo segmentato ---------- */
.nav-tabs, .nav-pills.colle-segmented {
  border: 0; background: #E9EBEE; border-radius: 12px; padding: 4px; gap: 4px;
  display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs .nav-item { flex: 1 0 auto; margin: 0; }
.nav-tabs .nav-link, .colle-segmented .nav-link {
  border: 0 !important; border-radius: 9px; min-height: 40px; white-space: nowrap;
  color: var(--colle-muted); font-weight: 600; font-size: 14px; text-align: center;
  background: transparent; display: flex; align-items: center; justify-content: center;
}
.nav-tabs .nav-link.active, .colle-segmented .nav-link.active {
  background: #fff !important; color: var(--colle-ink) !important; box-shadow: 0 1px 2px rgba(20, 22, 26, .12);
}

/* ---------- 12. List group (elenchi atleti, foto, ecc.) ---------- */
.list-group { border-radius: var(--colle-radius); }
.list-group-item { border-color: var(--colle-line-soft); padding: 12px 16px; min-height: 56px; display: flex; align-items: center; gap: 12px; }
.list-group-item-action:hover { background: #FAFAFB; }
.colle-avatar {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%;
  background: var(--colle-red-tint); color: var(--colle-red-dark);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
  object-fit: cover;
}

/* ---------- 13. Form ---------- */
.form-control, .form-select, .custom-select {
  border-radius: 12px; border-color: #D9DCE1; min-height: 48px; font-size: 16px; /* 16px evita lo zoom su iOS */
}
.form-control:focus, .form-select:focus { border-color: var(--colle-red); box-shadow: 0 0 0 3px rgba(212, 42, 32, .18); }
.colle-search { position: relative; }
.colle-search > svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.colle-search > .form-control { padding-left: 42px; }

/* ---------- 14. Chip filtro convenzioni ---------- */
.colle-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.colle-filter .nav-link, .colle-filter .btn {
  min-height: 44px; padding: 0 16px; border-radius: var(--colle-radius-pill);
  border: 1px solid var(--colle-line); background: #fff; color: var(--colle-ink); font-weight: 600;
}
.colle-filter .nav-link.active, .colle-filter .btn.active { background: var(--colle-ink); border-color: var(--colle-ink); color: #fff; }
@media (max-width: 767.98px) {
  .colle-filter { flex-wrap: nowrap; overflow-x: auto; margin-inline: calc(var(--colle-gutter) * -1); padding-inline: var(--colle-gutter); scrollbar-width: none; }
  .colle-filter > * { flex: 0 0 auto; }
}

/* ---------- 15. Modali → bottom sheet su mobile ---------- */
.modal-content { border: 0; border-radius: 18px; }
.modal-header { border-bottom: 0; padding: 20px 22px 8px; }
.modal-title { font-family: var(--colle-font-display); font-weight: 800; font-size: 28px; text-transform: uppercase; }
.modal-footer { border-top: 0; }
@media (max-width: 575.98px) {
  .modal-dialog { margin: 0; position: fixed; bottom: 0; left: 0; right: 0; max-width: none; }
  .modal.fade .modal-dialog { transform: translateY(100%); transition: transform .25s ease-out; }
  .modal.show .modal-dialog { transform: none; }
  .modal-content { border-radius: 20px 20px 0 0; max-height: 88svh; overflow-y: auto; }
  .modal-content::before {
    content: ""; display: block; width: 40px; height: 4px; border-radius: 2px;
    background: #D9DCE1; margin: 10px auto 0;
  }
}

/* ---------- 16. Footer + sponsor ---------- */
.colle-footer { background: var(--colle-ink); color: #C9CDD4; padding: 64px 0 28px; }
.colle-footer a { color: #fff; }
.colle-footer h2, .colle-footer h3 { color: #fff; font-size: 32px; }
.colle-sponsors { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.colle-sponsors > * {
  background: #fff; border-radius: var(--colle-radius-sm); height: 72px; padding: 12px;
  display: flex; align-items: center; justify-content: center;
}
.colle-sponsors img { max-height: 100%; width: auto; filter: grayscale(1); opacity: .85; transition: filter .2s, opacity .2s; }
.colle-sponsors > *:hover img { filter: none; opacity: 1; }
.colle-social { display: flex; gap: 10px; }
.colle-social a {
  width: 44px; height: 44px; border-radius: var(--colle-radius-sm); border: 1px solid var(--colle-ink-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.colle-footer__bottom { border-top: 1px solid var(--colle-ink-2); margin-top: 40px; padding-top: 20px; font-size: 14px; }
@media (max-width: 767.98px) { .colle-sponsors { grid-template-columns: repeat(3, minmax(0, 1fr)); } .colle-sponsors > * { height: 56px; } }

/* ---------- 17. Statistiche rapide ---------- */
.colle-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 24px; padding-block: 28px; border-bottom: 1px solid var(--colle-line); }
.colle-stats__num { font-family: var(--colle-font-display); font-weight: 800; font-size: 40px; color: var(--colle-red); line-height: 1; }
.colle-stats__label { color: var(--colle-muted); font-size: 14px; }

/* ---------- 18. Riduzione movimento ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
