:root {
    --color-primary: #1f5eff;
    --color-primary-soft: rgba(31, 94, 255, 0.12);
    --color-text: #111827;
    --color-muted: #6b7280;
    --color-background: #f6f7fb;
    --color-card-bg: rgba(255, 255, 255, 0.92);
    --shadow-soft: 0 18px 40px rgba(23, 37, 84, 0.12);
}

body.public-layout {
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top right, rgba(31, 94, 255, 0.14), transparent 55%),
        radial-gradient(circle at bottom left, rgba(66, 168, 255, 0.12), transparent 45%),
        linear-gradient(180deg, #fbfcff 0%, #f6f7fb 60%, #ffffff 100%);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.site-main {
    flex: 1;
    padding-bottom: 3rem;
}

.site-footer {
    border-top: 1px solid rgba(17, 24, 39, 0.05);
    padding: 2.5rem 0 3rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
}

.hero-section {
    position: relative;
    padding-top: clamp(4rem, 10vw, 6rem);
}

.hero-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(120deg, rgba(255, 255, 255, 0.75) 5%, rgba(255, 255, 255, 0.4) 45%, rgba(255, 255, 255, 0.85) 100%);
    border: 1px solid rgba(31, 94, 255, 0.14);
    border-radius: 32px;
    padding: clamp(2.5rem, 6vw, 3.5rem);
    box-shadow: 0 20px 45px rgba(15, 35, 95, 0.12);
    backdrop-filter: blur(22px);
}

.hero-card::before,
.hero-card::after {
    content: "";
    position: absolute;
    border-radius: 999px;
    filter: blur(0px);
    opacity: 0.7;
}

.hero-card::before {
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(31, 94, 255, 0.28) 0%, rgba(31, 94, 255, 0) 70%);
    top: -160px;
    right: -120px;
}

.hero-card::after {
    width: 260px;
    height: 260px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.22) 0%, rgba(99, 102, 241, 0) 70%);
    bottom: -140px;
    left: -100px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 1rem;
    border-radius: 999px;
    background: rgba(31, 94, 255, 0.1);
    color: var(--color-primary);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    position: relative;
}

.hero-title {
    position: relative;
    font-size: clamp(2.1rem, 5vw, 3rem);
    font-weight: 700;
    margin: 1.25rem 0 1rem;
    line-height: 1.1;
}

.hero-subtitle {
    position: relative;
    font-size: clamp(1rem, 2.5vw, 1.15rem);
    max-width: 520px;
    color: var(--color-muted);
    margin: 0;
}

.race-section {
    margin-top: clamp(2.5rem, 6vw, 3.5rem);
}

.race-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 575.98px) {
    .race-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (min-width: 992px) {
    .race-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.race-card {
    position: relative;
    background: var(--color-card-bg);
    border-radius: 22px;
    padding: 1.85rem;
    text-decoration: none;
    color: inherit;
    border: 1px solid rgba(17, 24, 39, 0.06);
    box-shadow: 0 12px 26px rgba(17, 24, 39, 0.08);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    display: block;
    backdrop-filter: blur(16px);
}

.race-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 22px;
    background: linear-gradient(135deg, transparent 40%, rgba(31, 94, 255, 0.08));
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.race-card:hover,
.race-card:focus {
    transform: translateY(-6px);
    box-shadow: 0 20px 34px rgba(31, 80, 180, 0.18);
    border-color: rgba(31, 94, 255, 0.35);
}

.race-card:hover::after,
.race-card:focus::after {
    opacity: 1;
}

.race-card__title {
    font-size: 1.12rem;
    font-weight: 600;
    margin-bottom: 1.05rem;
    line-height: 1.3;
}

.race-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    font-size: 0.95rem;
    color: var(--color-muted);
}

.race-card__photos {
    font-weight: 600;
    color: var(--color-primary);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.02);
    color: var(--color-muted);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 1rem;
    color: var(--color-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.back-link:hover,
.back-link:focus {
    color: var(--color-primary);
}

.race-summary {
    background: var(--color-card-bg);
    border-radius: 24px;
    padding: 2rem 2.25rem;
    border: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    box-shadow: var(--shadow-soft);
    flex-wrap: wrap;
}

.race-title {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.race-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--color-muted);
    font-weight: 500;
}

.race-meta__item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.search-card {
    background: var(--color-card-bg);
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(0, 0, 0, 0.04);
    margin-bottom: 2rem;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.search-field {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-field input {
    flex: 1 1 240px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 14px;
    padding: 0.85rem 1.1rem;
    font-size: 1.05rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-field input:focus {
    outline: none;
    border-color: rgba(31, 94, 255, 0.5);
    box-shadow: 0 0 0 4px rgba(31, 94, 255, 0.15);
}

.search-submit {
    padding: 0.85rem 1.8rem;
    border-radius: 14px;
    font-weight: 600;
    box-shadow: 0 12px 25px rgba(31, 94, 255, 0.2);
}

.search-hint {
    margin: 0;
    color: var(--color-muted);
}

.search-feedback {
    min-height: 1.5rem;
    font-weight: 500;
}

.search-feedback.error {
    color: #d94848;
}

.search-feedback.success {
    color: #198754;
}

.search-stats {
    font-weight: 600;
    color: var(--color-text);
}

.gallery-wrapper {
    position: relative;
}

.gallery-loader {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.photo-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.photo-grid a {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 18px;
    background: rgba(0, 0, 0, 0.06);
    box-shadow: 0 8px 18px rgba(20, 30, 80, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.photo-grid a:hover,
.photo-grid a:focus {
    transform: translateY(-3px);
    box-shadow: 0 15px 28px rgba(31, 80, 180, 0.18);
}

.photo-grid img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (min-width: 768px) {
    .photo-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1200px) {
    .photo-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

#load-more-btn {
    min-width: 200px;
    border-radius: 999px;
    font-weight: 600;
}

/* Photo viewer */
.photo-viewer {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1050;
}

.photo-viewer.is-open {
    display: flex;
}

.photo-viewer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 16, 32, 0.75);
    backdrop-filter: blur(6px);
}

.photo-viewer__content {
    position: relative;
    max-width: min(90vw, 1200px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    z-index: 1;
    color: #ffffff;
}

.photo-viewer__image-wrapper {
    position: relative;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-viewer__image {
    max-width: min(90vw, 1200px);
    max-height: 80vh;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.photo-viewer__controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.photo-viewer__button {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.photo-viewer__button:hover,
.photo-viewer__button:focus {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.photo-viewer__button[disabled] {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.photo-viewer__counter {
    font-weight: 600;
    letter-spacing: 0.02em;
}

.photo-viewer__close {
    position: absolute;
    top: -3.5rem;
    right: 0;
}

@media (max-width: 767.98px) {
    .site-header {
        position: static;
    }

    .race-summary {
        padding: 1.5rem;
    }

    .photo-viewer__button {
        width: 2.5rem;
        height: 2.5rem;
    }

    .photo-viewer__close {
        top: -3rem;
    }
}

body.photo-viewer-open {
    overflow: hidden;
}

.d-none {
    display: none !important;
}
