/* ============================================================
   components_v3.css — Modernized component layer
   Sporty card system + pills + disc chips + bottom nav.
   Riippuvuus: fissi_v3.css (tokenit) ladattava ENNEN.
   ============================================================ */

/* ── App shell ─────────────────────────────────────────── */
.v3-app {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    padding-bottom: 96px;  /* room for bottom nav on mobile */
}

@media (min-width: 900px) {
    .v3-app { padding-bottom: 24px; }
}

/* ── Top bar ───────────────────────────────────────────── */
.v3-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: color-mix(in oklch, var(--bg) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    /* Push content below iOS status bar in standalone/PWA mode */
    padding-top: env(safe-area-inset-top, 0px);
}

.v3-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    max-width: 1280px;
    margin: 0 auto;
}

.v3-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.v3-brand-mark {
    width: 30px;
    height: 30px;
    background: var(--accent);
    border-radius: 7px;
    display: grid;
    place-items: center;
    color: var(--accent-ink);
    font-family: var(--font-display);
    font-size: 19px;
    line-height: 1;
}

.v3-brand-word {
    font-family: var(--font-display);
    font-size: 20px;
    letter-spacing: .04em;
}

.v3-top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Desktop top nav links */
.v3-topnav {
    display: none;
    align-items: center;
    gap: 4px;
    margin-left: 28px;
}
@media (min-width: 900px) {
    .v3-topnav { display: inline-flex; }
}
.v3-topnav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    text-decoration: none;
    transition: background .15s, color .15s;
}
.v3-topnav a:hover { background: var(--surface-2); color: var(--text); }
.v3-topnav a.active { background: var(--surface-2); color: var(--text); }
.v3-topnav a.active::before {
    content: '';
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent);
}

/* Icon button */
.v3-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    transition: color .15s, background .15s, border-color .15s;
}
.v3-icon-btn:hover {
    color: var(--text);
    background: var(--surface-2);
    border-color: var(--border-bright);
}

.v3-lang-toggle { display: inline-flex; gap: 2px; align-items: center;
    border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface); }
.v3-lang-toggle a {
    display: inline-flex; align-items: center; justify-content: center;
    height: 30px; padding: 0 10px;
    border-radius: 6px;
    font-size: 11px; font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    letter-spacing: .04em;
}
.v3-lang-toggle a.active { background: var(--surface-2); color: var(--text); }

/* ── Page hero / title block ───────────────────────────── */
.v3-page-head {
    padding: 18px 18px 14px;
    max-width: 1280px;
    margin: 0 auto;
}
.v3-eyebrow {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--muted);
}
.v3-page-title {
    font-family: var(--font-display);
    font-size: clamp(36px, 8vw, 56px);
    line-height: .9;
    letter-spacing: .01em;
    margin: 4px 0 0;
    color: var(--text);
}
.v3-page-sub {
    color: var(--muted);
    font-size: 14px;
    margin-top: 6px;
}

/* ── Segmented control / filter pills ─────────────────── */
.v3-segments {
    display: flex;
    gap: 6px;
    padding: 0 18px 8px;
    max-width: 1280px;
    margin: 0 auto;
    overflow-x: auto;
    scrollbar-width: none;
}
.v3-segments::-webkit-scrollbar { display: none; }
.v3-segment {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, color .15s, border-color .15s;
}
.v3-segment:hover { color: var(--text); border-color: var(--border-bright); }
.v3-segment.active {
    background: color-mix(in oklch, var(--accent) 22%, transparent);
    color: var(--accent);
    border-color: color-mix(in oklch, var(--accent) 50%, transparent);
}.v3-segment .count {
    font-family: var(--font-mono);
    font-size: 10px;
    opacity: .8;
    padding: 1px 6px;
    border-radius: 999px;
    background: color-mix(in oklch, var(--text) 8%, transparent);
}

/* ── Pills (status) ────────────────────────────────────── */
.v3-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .02em;
    background: var(--surface-2);
    color: var(--text-2);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.v3-pill.live {
    background: color-mix(in oklch, var(--danger) 18%, transparent);
    color: var(--danger);
    border-color: color-mix(in oklch, var(--danger) 35%, transparent);
}
.v3-pill.live::before {
    content: '';
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--danger);
    animation: v3-pulse 1.4s ease-in-out infinite;
}
.v3-pill.open {
    background: color-mix(in oklch, var(--accent) 22%, transparent);
    color: var(--accent);
    border-color: color-mix(in oklch, var(--accent) 50%, transparent);
}.v3-pill.soon {
    background: color-mix(in oklch, var(--info) 18%, transparent);
    color: var(--info);
    border-color: color-mix(in oklch, var(--info) 40%, transparent);
}
.v3-pill.upcoming { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.v3-pill.closed { background: var(--surface-2); color: var(--muted); }
.v3-pill.verified {
    background: color-mix(in oklch, var(--ok) 20%, transparent);
    color: var(--ok);
    border-color: color-mix(in oklch, var(--ok) 40%, transparent);
}

@keyframes v3-pulse {
    0%,100% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--danger) 60%, transparent); }
    50%     { box-shadow: 0 0 0 5px color-mix(in oklch, var(--danger) 0%, transparent); }
}

/* ── Discipline chip ───────────────────────────────────── */
.v3-disc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 22px;
    padding: 0 7px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    background: var(--surface-3);
    color: var(--text);
    border: 1px solid var(--border);
}
.v3-disc.sl { background: color-mix(in oklch, var(--d-sl) 18%, transparent); color: var(--d-sl); border-color: color-mix(in oklch, var(--d-sl) 35%, transparent); }
.v3-disc.gs { background: color-mix(in oklch, var(--d-gs) 18%, transparent); color: var(--d-gs); border-color: color-mix(in oklch, var(--d-gs) 35%, transparent); }
.v3-disc.sg { background: color-mix(in oklch, var(--d-sg) 18%, transparent); color: var(--d-sg); border-color: color-mix(in oklch, var(--d-sg) 35%, transparent); }
.v3-disc.dh { background: color-mix(in oklch, var(--d-dh) 18%, transparent); color: var(--d-dh); border-color: color-mix(in oklch, var(--d-dh) 35%, transparent); }
.v3-disc.ac { background: color-mix(in oklch, var(--d-ac) 18%, transparent); color: var(--d-ac); border-color: color-mix(in oklch, var(--d-ac) 40%, transparent); }
[data-theme="light"] .v3-disc.ac { color: #7a8f00; }

/* Discipline stripe (left edge accent) */
.v3-stripe {
    width: 4px;
    align-self: stretch;
    border-radius: 2px;
    background: var(--border-bright);
    flex-shrink: 0;
}
.v3-stripe.sl { background: var(--d-sl); }
.v3-stripe.gs { background: var(--d-gs); }
.v3-stripe.sg { background: var(--d-sg); }
.v3-stripe.dh { background: var(--d-dh); }
.v3-stripe.ac { background: var(--d-ac); }

/* ── Container & list ─────────────────────────────────── */
.v3-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 12px;
}

.v3-event-list {
    display: grid;
    gap: 22px;
    margin-top: 14px;
}

@media (min-width: 900px) {
    .v3-event-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 22px 16px;
        padding: 0 18px;
    }
}

@media (min-width: 1280px) {
    .v3-event-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ── Event group ──────────────────────────────────────── */
.v3-event-group { display: flex; flex-direction: column; gap: 8px; }

.v3-event-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 8px 4px;
}
.v3-event-head-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.v3-event-title {
    font-family: var(--font-display);
    font-size: 22px;
    letter-spacing: .02em;
    line-height: 1;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.v3-event-title .flag-icon { width: 22px; height: 16px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.15) inset; }
.v3-event-meta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 12.5px;
    flex-wrap: wrap;
}
.v3-event-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .5; }

.v3-event-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    transition: border-color .15s, transform .05s;
}
.v3-event-card:hover { border-color: var(--border-bright); }

/* Hero card (for LIVE events) */
.v3-hero {
    grid-column: 1 / -1;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid color-mix(in oklch, var(--danger) 40%, var(--border));
    background:
        linear-gradient(135deg, color-mix(in oklch, var(--danger) 18%, transparent), color-mix(in oklch, var(--accent) 8%, transparent) 60%),
        var(--surface);
    box-shadow: 0 0 0 1px color-mix(in oklch, var(--danger) 25%, transparent) inset;
    position: relative;
}
.v3-hero-inner {
    padding: 22px 22px 18px;
    display: grid;
    gap: 14px;
}
@media (min-width: 700px) {
    .v3-hero-inner {
        grid-template-columns: 1.5fr 1fr;
        align-items: end;
        padding: 28px;
    }
}
.v3-hero-title {
    font-family: var(--font-display);
    font-size: clamp(32px, 6vw, 48px);
    line-height: .95;
    letter-spacing: .01em;
    color: var(--text);
    margin: 0;
}
.v3-hero-meta { color: var(--text-2); font-size: 14px; margin-top: 6px; }
.v3-hero-races {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--surface);
    border-radius: 12px;
    padding: 10px;
    border: 1px solid var(--border);
}

/* ── Race row ─────────────────────────────────────────── */
.v3-races { display: flex; flex-direction: column; }

.v3-race-row {
    display: flex;
    align-items: stretch;
    gap: 12px;
    padding: 14px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background .12s;
}
.v3-race-row:hover { background: var(--surface-2); }
.v3-race-row:last-child { border-bottom: 0; }

.v3-race-time {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    min-width: 60px;
}
.v3-race-date {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    letter-spacing: .06em;
    text-transform: uppercase;
}
.v3-race-day {
    font-family: var(--font-display);
    font-size: 26px;
    line-height: 1;
    margin-top: 2px;
    color: var(--text);
}

.v3-race-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-width: 0;
}
.v3-race-line1 {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.v3-race-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}
.v3-race-codex {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    letter-spacing: .04em;
}
.v3-race-line2 {
    font-size: 12px;
    color: var(--muted);
}

.v3-race-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    min-width: 64px;
}
.v3-race-count {
    font-family: var(--font-display);
    font-size: 20px;
    line-height: 1;
    color: var(--text);
}
.v3-race-cap {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
}
.v3-race-bar {
    width: 56px;
    height: 3px;
    background: var(--surface-2);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}
.v3-race-bar > span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
}
.v3-race-bar.warn > span { background: var(--warn); }
.v3-race-bar.full > span { background: var(--danger); }

.v3-race-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    font-size: 18px;
}
.v3-race-action.disabled { color: var(--muted); }

/* ── Description card ─────────────────────────────────── */
.v3-event-desc {
    padding: 12px 16px;
    color: var(--text-2);
    font-size: 13.5px;
    line-height: 1.55;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

/* ── Buttons ──────────────────────────────────────────── */
.v3-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border: 1px solid var(--border-bright);
    background: var(--surface-2);
    color: var(--text);
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, transform .05s;
    font-family: var(--font-body);
}
.v3-btn:hover { background: var(--surface-3); }
.v3-btn:active { transform: translateY(1px); }
.v3-btn-primary {
    background: var(--accent);
    color: var(--accent-ink);
    border-color: var(--accent);
    font-weight: 700;
}
.v3-btn-primary:hover { background: color-mix(in oklch, var(--accent) 88%, white); }
.v3-btn-ghost { background: transparent; border-color: var(--border); }
.v3-btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; }
.v3-btn-lg { height: 48px; padding: 0 20px; font-size: 14px; }

/* ── Bottom navigation (mobile) ───────────────────────── */
.v3-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 90;
    background: color-mix(in oklch, var(--surface) 92%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 10px 8px calc(14px + env(safe-area-inset-bottom, 0px));
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
}
@media (min-width: 900px) {
    .v3-bottom-nav { display: none; }
}

.v3-bn-item {
    display: grid;
    place-items: center;
    color: var(--muted);
    text-decoration: none;
    padding: 6px 10px;
    transition: color .15s;
    min-width: 44px;
    min-height: 44px;
    font-size: 20px;
}
.v3-bn-item.active { color: var(--accent); }
.v3-bn-item:hover  { color: var(--text); }

.v3-bn-fab {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--accent);
    color: var(--accent-ink);
    display: grid;
    place-items: center;
    margin-top: -22px;
    font-size: 22px;
    box-shadow: 0 8px 22px color-mix(in oklch, var(--accent) 45%, transparent);
    text-decoration: none;
    transition: transform .08s;
}
.v3-bn-fab:active { transform: translateY(2px) scale(.98); }

/* ── Empty state ──────────────────────────────────────── */
.v3-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--muted);
}
.v3-empty i {
    font-size: 36px;
    color: var(--border-bright);
    margin-bottom: 14px;
    display: block;
}
.v3-empty h3 {
    font-family: var(--font-display);
    font-size: 22px;
    margin: 0 0 6px;
    color: var(--text);
}

/* ── Footer (modern) ──────────────────────────────────── */
.v3-footer {
    border-top: 1px solid var(--border);
    padding: 20px 18px 28px;
    margin-top: 40px;
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-between;
    align-items: center;
    font-size: 12.5px;
    color: var(--muted);
}
.v3-footer a { color: inherit; text-decoration: none; }
.v3-footer a:hover { color: var(--text); }

/* ── Help link + modal (reuse legacy classes if needed) ── */
.v3-help-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--surface);
}
.v3-help-btn:hover { color: var(--text); border-color: var(--border-bright); }

/* ── Utility ──────────────────────────────────────────── */
.v3-mono { font-family: var(--font-mono); }
.v3-disp { font-family: var(--font-display); }
.v3-muted { color: var(--muted); }
.v3-upper { text-transform: uppercase; letter-spacing: .08em; }
.v3-tiny { font-size: 11px; }
.v3-small { font-size: 12.5px; }
.v3-bold { font-weight: 700; }

/* Smaller screens — tighter padding */
@media (max-width: 480px) {
    .v3-topbar-inner { padding: 10px 14px; }
    .v3-page-head { padding: 14px 14px 10px; }
    .v3-segments { padding: 0 14px 8px; }
    .v3-container { padding: 0 8px; }
}
