/* Dodatki: motyw ciemny, animacje, pokaz zdjęć w hero, kalendarz, oś czasu, rekordy, media kit. */

/* ---------- Motyw ciemny ---------- */
[data-theme="dark"] {
  --ink: #070d0a; --paper: #0d1611; --card: #15221a; --text: #e6eee8; --muted: #9db0a4; --line: #243629; --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ink: #070d0a; --paper: #0d1611; --card: #15221a; --text: #e6eee8; --muted: #9db0a4; --line: #243629; --shadow: 0 10px 30px rgba(0, 0, 0, .45); color-scheme: dark; }
  :root:not([data-theme="light"]) .achv.big li.hl { background: #1b2a14; }
  :root:not([data-theme="light"]) .tag, :root:not([data-theme="light"]) .team-card img { background: var(--card); }
  :root:not([data-theme="light"]) input, :root:not([data-theme="light"]) textarea, :root:not([data-theme="light"]) select { background: var(--card); color: var(--text); }
  :root:not([data-theme="light"]) .tbl tfoot th, :root:not([data-theme="light"]) .tbl tfoot td { background: #1a2a20; }
  :root:not([data-theme="light"]) .tile .num, :root:not([data-theme="light"]) .rec-time, :root:not([data-theme="light"]) .facts b, :root:not([data-theme="light"]) .achv.big strong, :root:not([data-theme="light"]) .facts-box dd, :root:not([data-theme="light"]) .cat .big { color: var(--lime); }
  :root:not([data-theme="light"]) .more { color: var(--lime); }
  :root:not([data-theme="light"]) .btn.ghost.dark { color: var(--text); border-color: var(--text); }
  :root:not([data-theme="light"]) .btn.ghost.dark:hover { background: var(--text); color: var(--ink); }
  :root:not([data-theme="light"]) .cal-date { background: #1d4a31; }
  :root:not([data-theme="light"]) .next-race { background: linear-gradient(120deg, #123021, #1d4a31); }
}
[data-theme="dark"] .achv.big li.hl { background: #1b2a14; }
[data-theme="dark"] .tag, [data-theme="dark"] .team-card img { background: var(--card); }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select { background: var(--card); color: var(--text); }
[data-theme="dark"] .tbl tfoot th, [data-theme="dark"] .tbl tfoot td { background: #1a2a20; }
[data-theme="dark"] .tile .num, [data-theme="dark"] .rec-time, [data-theme="dark"] .facts b, [data-theme="dark"] .achv.big strong, [data-theme="dark"] .facts-box dd, [data-theme="dark"] .cat .big { color: var(--lime); }
[data-theme="dark"] .more { color: var(--lime); }
[data-theme="dark"] .btn.ghost.dark { color: var(--text); border-color: var(--text); }
[data-theme="dark"] .btn.ghost.dark:hover { background: var(--text); color: var(--ink); }
[data-theme="dark"] .cal-date { background: #1d4a31; }
[data-theme="dark"] .next-race { background: linear-gradient(120deg, #123021, #1d4a31); }
.theme-toggle { background: transparent; border: 1px solid rgba(255, 255, 255, .35); color: #fff; width: 38px; height: 38px; border-radius: 999px; font-size: 1.1rem; cursor: pointer; margin-left: 6px; line-height: 1; }
.theme-toggle:hover { background: rgba(255, 255, 255, .15); }
html:not(.js) .theme-toggle { display: none; }

/* ---------- Animacje przy przewijaniu ---------- */
.js .reveal { opacity: 0; transform: translateY(26px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .7, .2, 1); }
.js .reveal.in { opacity: 1; transform: none; }
.js .reveal.d1 { transition-delay: .08s; } .js .reveal.d2 { transition-delay: .16s; } .js .reveal.d3 { transition-delay: .24s; }
@media (prefers-reduced-motion: reduce) { .js .reveal { opacity: 1; transform: none; transition: none; } html { scroll-behavior: auto; } }

/* ---------- Menu "Więcej" ---------- */
.more-menu { position: relative; }
.more-menu summary { list-style: none; cursor: pointer; padding: 8px 14px; border-radius: 999px; opacity: .9; }
.more-menu summary::-webkit-details-marker { display: none; }
.more-menu summary::after { content: ' \25BE'; }
.more-menu[open] summary, .more-menu summary:hover { background: rgba(255, 255, 255, .1); opacity: 1; }
.more-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; background: #12231a; border: 1px solid rgba(255, 255, 255, .12); border-radius: 14px; padding: 8px; display: grid; box-shadow: 0 18px 40px rgba(0, 0, 0, .4); }
.more-pop a { border-radius: 10px; }
@media (max-width: 900px) {
  .more-menu summary { display: none; }
  .more-pop { position: static; display: contents; background: none; border: 0; box-shadow: none; padding: 0; }
}

/* ---------- Hero: pokaz zdjęć z zawodów (6 slajdów po 7 s) ---------- */
.hero-slides { position: absolute; inset: 0; z-index: 0; }
.hero-slides img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 30%; opacity: 0; animation: heroSlide 42s infinite; animation-delay: calc(var(--i) * 7s); will-change: opacity, transform; }
@keyframes heroSlide {
  0% { opacity: 0; transform: scale(1.02); }
  3% { opacity: 1; }
  17% { opacity: 1; }
  21% { opacity: 0; transform: scale(1.14); }
  100% { opacity: 0; transform: scale(1.14); }
}
.hero.has-slides { background-image: none; }
.hero.has-slides::before { content: ''; position: absolute; inset: 0; z-index: 1; background: linear-gradient(90deg, rgba(7, 13, 10, .9) 0%, rgba(7, 13, 10, .6) 55%, rgba(7, 13, 10, .3) 100%), linear-gradient(180deg, rgba(7, 13, 10, .25), rgba(7, 13, 10, .75)); }
.hero.has-slides .hero-inner { position: relative; z-index: 2; }
@media (prefers-reduced-motion: reduce) { .hero-slides img { animation: none; } .hero-slides img:first-child { opacity: 1; } }

/* ---------- Odliczanie do startu ---------- */
.next-race { background: linear-gradient(120deg, var(--forest), var(--moss)); color: #fff; border-radius: var(--radius); padding: 28px clamp(18px, 4vw, 40px); display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center; box-shadow: var(--shadow); }
.next-race h2 { margin: 0 0 6px; color: #fff; }
.next-race .eyebrow { margin-bottom: 6px; }
.next-race p { margin: 0; opacity: .9; }
.cd { display: flex; gap: 10px; }
.cd div { background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18); border-radius: 14px; padding: 10px 14px; min-width: 74px; text-align: center; }
.cd b { display: block; font-size: 2rem; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--lime); }
.cd span { font-size: .78rem; opacity: .85; text-transform: uppercase; letter-spacing: .08em; }
@media (max-width: 760px) { .next-race { grid-template-columns: 1fr; } }

/* ---------- Kalendarz ---------- */
.cal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.cal-list li { display: grid; grid-template-columns: 92px 1fr auto; gap: 18px; align-items: center; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; }
.cal-date { text-align: center; background: var(--forest); color: #fff; border-radius: 14px; padding: 8px 4px; }
.cal-date b { display: block; font-size: 1.8rem; line-height: 1.05; }
.cal-date span { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; opacity: .9; }
.cal-list h3 { margin: 0 0 2px; }
.cal-list .muted { margin: 0; }
@media (max-width: 640px) { .cal-list li { grid-template-columns: 70px 1fr; } .cal-list li > :last-child { grid-column: 1 / -1; } }

/* ---------- Oś czasu ---------- */
.timeline { position: relative; margin: 20px 0 10px; padding-left: 34px; }
.timeline::before { content: ''; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 3px; background: linear-gradient(var(--lime), var(--moss)); border-radius: 3px; }
.tl-item { position: relative; margin-bottom: 36px; }
.tl-item::before { content: ''; position: absolute; left: -31px; top: 12px; width: 17px; height: 17px; border-radius: 50%; background: var(--lime); border: 4px solid var(--paper); box-shadow: 0 0 0 2px var(--moss); }
.tl-year { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 600; margin: 0 0 4px; }
.tl-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; color: var(--muted); margin-bottom: 14px; }
.tl-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.tl-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tl-pick { display: block; text-decoration: none; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; transition: transform .2s; }
.tl-pick:hover { transform: translateY(-3px); }
.tl-pick img, .tl-pick .ph { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--forest); }
.tl-pick div.tl-txt { padding: 10px 14px 12px; }
.tl-pick strong { display: block; line-height: 1.25; }
.tl-pick small { color: var(--muted); }

/* ---------- Rekordy ---------- */
.rec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.rec-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.rec-card h3 { margin: 0 0 6px; color: var(--muted); font-size: 1rem; text-transform: uppercase; letter-spacing: .1em; }
.rec-time { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 600; line-height: 1.05; color: var(--forest); font-variant-numeric: tabular-nums; }
.rec-card p { margin: 8px 0 0; color: var(--muted); font-size: .95rem; }
.bars { display: grid; gap: 6px; margin-top: 14px; }
.bar-row { display: grid; grid-template-columns: 44px 1fr 72px; gap: 10px; align-items: center; font-size: .88rem; font-variant-numeric: tabular-nums; }
.bar-row i { display: block; height: 10px; border-radius: 6px; background: linear-gradient(90deg, var(--moss), var(--lime)); }

/* ---------- Dla marek ---------- */
.kit-hero { background: linear-gradient(120deg, #070d0a, #14301f); color: #fff; padding: 64px 0 56px; }
.kit-hero h1 { color: #fff; }
.kit-hero .lead { color: rgba(255, 255, 255, .85); max-width: 720px; }
.kit-numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-top: 26px; }
.kit-numbers .tile { background: rgba(255, 255, 255, .08); box-shadow: none; border: 1px solid rgba(255, 255, 255, .15); }
.kit-numbers .tile .num { color: var(--lime); } .kit-numbers .tile .lbl { color: rgba(255, 255, 255, .8); }
.pkg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.pkg { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; border-top: 5px solid var(--lime); }
.pkg.hl { border-top-color: var(--sun); }
.pkg h3 { margin-bottom: 6px; }

/* ---------- Inne ---------- */
.lang-switch { font-size: .85rem; border: 1px solid rgba(255, 255, 255, .35); border-radius: 999px; padding: 5px 11px; text-decoration: none; margin-left: 6px; color: #fff; }
.share-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ---------- Mapa trasy (Leaflet + OpenStreetMap) ---------- */
.route-map { height: clamp(300px, 55vw, 460px); border-radius: var(--radius); overflow: hidden; background: #cfd8cf; box-shadow: var(--shadow); margin: 0 0 6px; position: relative; z-index: 0; }
.route-note { font-size: .85rem; margin-bottom: 1.4em; }
[data-theme="dark"] .route-map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .route-map .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); } }
.route-pin { width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
.route-pin.start { background: #2d8a4e; } .route-pin.finish { background: #ff6b2c; }
.route-map.big { height: clamp(380px, 70vh, 680px); }
.leaflet-popup-content a { color: #2d5a3d; font-weight: 600; }
.post-route { margin: 26px auto 10px; }

/* ---------- Wyszukiwarka na mapie startów ---------- */
.map-wrap { position: relative; }
.map-search { position: relative; display: flex; gap: 10px; margin-bottom: 12px; z-index: 5; }
.map-search input { flex: 1; min-height: 48px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 14px; font: inherit; background: var(--card); color: var(--text); }
.map-search input:focus { outline: 3px solid var(--lime); outline-offset: 1px; }
.map-clear { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 14px; padding: 0 16px; font: inherit; cursor: pointer; white-space: nowrap; }
.map-search ul { position: absolute; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 6px; list-style: none; background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); max-height: 340px; overflow: auto; }
.map-search li { padding: 9px 12px; border-radius: 10px; cursor: pointer; display: grid; gap: 1px; }
.map-search li small { color: var(--muted); }
.map-search li.on, .map-search li:hover { background: rgba(198, 244, 50, .35); }
.map-search li.none { color: var(--muted); cursor: default; }
.map-search [hidden] { display: none; }
@media (max-width: 560px) { .map-search { flex-direction: column; } }

/* ---------- Menu na telefonie: wszystkie pozycje widoczne, bez rozwijania ---------- */
.nav-tools { display: contents; }
.more-flat { display: none; }
@media (max-width: 900px) {
  .more-menu { display: none; }
  .more-flat { display: contents; }
  .nav { max-height: calc(100vh - 68px); max-height: calc(100dvh - 68px); overflow-y: auto; overscroll-behavior: contain; }
  .nav-tools { display: flex; gap: 12px; align-items: center; padding: 14px 0 4px; }
  .nav-tools .lang-switch, .nav-tools .theme-toggle { margin: 0; border-bottom: 1px solid rgba(255, 255, 255, .35); padding: 8px 16px; width: auto; height: 40px; display: inline-flex; align-items: center; justify-content: center; }
}

/* ---------- Galeria i lightbox ---------- */
.gal-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.gal-filter a { text-decoration: none; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
.gal-filter a.on { background: var(--lime); border-color: var(--lime-dark); color: #0e1a14; font-weight: 600; }
.gal { columns: 4 220px; column-gap: 12px; }
.gal-item { display: block; break-inside: avoid; margin-bottom: 12px; border-radius: 14px; overflow: hidden; background: var(--forest); }
.gal-item img { width: 100%; height: auto; transition: transform .35s ease, filter .35s ease; }
.gal-item:hover img { transform: scale(1.05); filter: brightness(1.08); }
.pager { display: flex; gap: 18px; justify-content: center; align-items: center; margin-top: 28px; }
.pager a { text-decoration: none; font-weight: 600; border-bottom: 2px solid var(--lime-dark); }
.lightbox { border: 0; padding: 0; background: transparent; width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; color: #fff; }
.lightbox::backdrop { background: rgba(5, 10, 8, .92); }
.lightbox[open] { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; justify-items: center; }
.lightbox figure { margin: 0; text-align: center; max-width: 100%; }
.lightbox figure img { max-width: min(92vw, 1400px); max-height: 80vh; width: auto; height: auto; border-radius: 10px; margin: 0 auto; }
.lightbox figcaption { margin-top: 10px; opacity: .9; }
.lightbox figcaption a { color: var(--lime); }
.lb-close, .lb-prev, .lb-next { background: rgba(255, 255, 255, .12); border: 0; color: #fff; font-size: 2rem; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; line-height: 1; }
.lb-close { position: fixed; top: 14px; right: 14px; }
.lb-prev:hover, .lb-next:hover, .lb-close:hover { background: rgba(255, 255, 255, .25); }
@media (max-width: 640px) { .lightbox[open] { grid-template-columns: 44px 1fr 44px; } .lb-prev, .lb-next { width: 38px; height: 38px; } }

/* ---------- Cel sezonu ---------- */
.goal { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; margin: 14px 0 8px; }
.goal-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.goal-bar { position: relative; height: 16px; border-radius: 999px; background: rgba(120, 140, 125, .25); margin: 10px 0 8px; overflow: visible; }
.goal-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: linear-gradient(90deg, var(--moss), var(--lime)); }
.goal-bar b { position: absolute; top: -5px; width: 3px; height: 26px; background: var(--sun); border-radius: 2px; }
.goal-note { margin: 0; color: var(--muted); font-size: .95rem; }

/* ---------- Wykresy wpisu (SVG po stronie serwera) ---------- */
.race-chart { margin: 26px 0; }
.race-chart figcaption { margin-bottom: 8px; }
.race-chart svg { width: 100%; height: auto; display: block; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.race-chart .grid { stroke: var(--line); stroke-width: 1; }
.race-chart .ax { fill: var(--muted); font-size: 11px; font-family: inherit; }
.race-chart .line { stroke: var(--forest); stroke-width: 2.2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
[data-theme="dark"] .race-chart .line { stroke: var(--lime); }
.race-chart .avg { stroke: var(--sun); stroke-width: 1.5; stroke-dasharray: 6 5; vector-effect: non-scaling-stroke; }
.race-chart-note { font-size: .85rem; margin-top: 6px; }
