/* Main Stylesheet for Ultrabericus Trail */

/* ACCESSIBILITY */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10000;
    padding: 0.75rem 1.5rem;
    background: var(--secondary-color);
    color: white;
    font-weight: bold;
    font-size: 0.875rem;
    text-decoration: none;
    border-radius: 0 0 8px 0;
}

.skip-link:focus {
    left: 0;
}

/* Focus indicators for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn-main:focus-visible,
.race-card:focus-visible {
    outline: 3px solid var(--secondary-color);
    outline-offset: 3px;
    border-radius: 4px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Screen-reader announcement for external links */
a[target="_blank"] {
    position: relative;
}
a[target="_blank"]:not([aria-label])::after {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
:lang(it) a[target="_blank"]:not([aria-label])::after {
    content: " (apre in nuova finestra)";
}
:lang(en) a[target="_blank"]:not([aria-label])::after {
    content: " (opens in new window)";
}

/* RESET & BASE */
body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.8s ease, color 0.5s ease;
    overflow-x: hidden;
    line-height: 1.6;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
    font-family: var(--font-heading);
    text-transform: none;
    letter-spacing: 1px;
    font-weight: normal;
}

/* HEADER */
header {
    background-color: var(--header-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--header-border);
    color: var(--header-text);
    transition: all 0.5s ease;
    height: 70px;
    display: flex;
    align-items: center;
}

/* DROPDOWN MENU */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--header-bg);
    border: 1px solid var(--header-border);
    border-radius: 8px;
    padding: 0.5rem 0;
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 100;
}

.group:hover .dropdown-menu,
.nav-item:focus-within .dropdown-menu {
    opacity: 1;
    visibility: visible;
}

/* Dropdown trigger button reset */
.nav-dropdown-trigger {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-transform: inherit;
    letter-spacing: inherit;
    font-size: inherit;
    font-weight: inherit;
}

.dropdown-item {
    display: block;
    padding: 0.6rem 1.2rem;
    color: var(--header-text);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: var(--primary-color);
    color: white;
}

/* MOBILE MENU & HAMBURGER */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 60;
    padding: 0;
}

@media(max-width: 1280px) {
    .hamburger { display: flex; }
}

.hamburger span {
    width: 100%;
    height: 2px;
    background: var(--header-text);
    transition: all 0.3s linear;
    position: relative;
    transform-origin: 1px;
}

/* Mobile Menu Container */
.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: var(--mobile-menu-bg);
    z-index: 55;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 80px 2rem 2rem 2rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mobile-menu.open {
    transform: translateX(0);
}

.hamburger.open span:nth-child(1) { transform: rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg); }

.mobile-nav-link {
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    color: var(--header-text);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.mobile-submenu-link {
    opacity: 0.8;
    transition: opacity 0.2s ease;
}
.mobile-submenu-link:hover,
.mobile-submenu-link:focus-visible {
    opacity: 1;
}

.mobile-menu.open .mobile-nav-link {
    opacity: 1;
    transform: translateY(0);
}
.mobile-menu.open .mobile-nav-link:nth-child(1) { transition-delay: 0.1s; }
.mobile-menu.open .mobile-nav-link:nth-child(2) { transition-delay: 0.2s; }
.mobile-menu.open .mobile-nav-link:nth-child(3) { transition-delay: 0.3s; }
.mobile-menu.open .mobile-nav-link:nth-child(4) { transition-delay: 0.4s; }

/* HERO SECTION */
.hero {
    position: relative;
    min-height: 85vh;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-size: cover;
    background-position: center;
    transition: background-image 0.8s ease-in-out;
    padding-top: 70px;
    padding-bottom: 60px;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--hero-overlay);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    padding: 1.5rem;
    max-width: 900px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* LOGO HERO STYLES */
.hero-logo-container {
    width: 80%;
    height: auto;
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.5));
    animation: fadeInDown 1s ease-out;
}

@media(min-width: 769px) {
    .hero-logo-container {
        width: 420px;
        margin-bottom: 2rem;
    }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Hero Date */
.hero-date {
    font-family: var(--font-heading);
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    color: #fff;
    display: inline-block;
    margin-bottom: 2rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.4);
    letter-spacing: 2px;
    opacity: 0.95;
}

/* SKYLINE SEPARATOR */
.skyline-divider {
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    overflow: hidden;
    line-height: 0;
    z-index: 3;
    pointer-events: none;
}

.skyline-divider svg {
    display: block;
    width: calc(100% + 1.3px);
    height: 60px;
}

@media(min-width: 769px) {
    .skyline-divider svg { height: 100px; }
}

.skyline-divider .shape-fill {
    fill: var(--bg-color);
    transition: fill 0.8s ease;
}
.skyline-path { transition: d 0.8s cubic-bezier(0.4, 0, 0.2, 1); }

/* BUTTONS */
.btn-main {
    background-color: var(--primary-color);
    color: var(--btn-text-color);
    padding: 1rem 2.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: none;
    border-radius: var(--border-radius);
    transform: var(--button-transform);
    transition: all 0.4s ease;
    display: inline-block;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.9rem;
    text-align: center;
}

.btn-main:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}
.btn-main:active { transform: scale(0.98); }
/* Ultrabericus: no skew transform on button text */
.btn-main span { display: block; }

/* TECH BAR */
.tech-bar {
    background-color: var(--card-bg);
    padding: 1.5rem 0;
    position: relative;
    z-index: 5;
    box-shadow: 0 10px 40px rgba(0,0,0,0.05);
    border-radius: var(--border-radius);
    margin: 0 1rem 3rem 1rem;
    border: 1px solid rgba(0,0,0,0.05);
}

@media(min-width: 769px) {
    .tech-bar {
        padding: 2.5rem 0;
        margin-left: 5%;
        margin-right: 5%;
        margin-bottom: 4rem;
    }
}

.tech-item {
    padding: 1rem;
    border-bottom: 1px solid rgba(128,128,128,0.1);
}
.tech-item:nth-last-child(-n+2) { border-bottom: none; }

@media(min-width: 769px) {
    .tech-item {
        border-bottom: none;
        border-right: 1px solid rgba(128,128,128,0.1);
    }
    .tech-item:last-child { border-right: none; }
}

/* CARDS */
.race-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: transform 0.4s ease;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.05);
    height: 100%;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.race-card:active { transform: scale(0.98); }
@media(min-width: 769px) {
    .race-card:hover { transform: translateY(-8px); }
}

.race-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    filter: var(--filter-img);
    transition: filter 0.5s ease;
}

/* Ultrabericus: styled card tag with secondary color and rounded */
.card-tag {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background-color: var(--secondary-color);
    color: #fff;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    text-transform: uppercase;
}

.altimetry-path {
    width: 100%;
    height: 100%;
    fill: var(--primary-color);
    opacity: 0.4;
}

/* MODAL */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

@media(max-width: 768px) {
    .modal-overlay { align-items: flex-end; }
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal-content {
    background: var(--card-bg);
    color: var(--text-color);
    width: 100%;
    max-width: 800px;
    border-radius: var(--border-radius);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

@media(max-width: 768px) {
    .modal-content { height: 100%; max-height: 100%; border-radius: 0; }
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 20;
    color: #333;
    background: rgba(255,255,255,0.9);
    width: 40px; height: 40px;
    border-radius: 50%;
    text-align: center;
    line-height: 40px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* SPONSORS */
.sponsors-section {
    padding: 3rem 0;
    background-color: var(--card-bg);
    border-top: 1px solid rgba(128,128,128,0.1);
    margin-top: 2rem;
}
.sponsor-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    align-items: center;
    justify-items: center;
}
@media(min-width: 768px) {
    .sponsor-grid { grid-template-columns: repeat(5, 1fr); }
}
.sponsor-logo {
    height: 30px;
    width: auto;
    opacity: var(--sponsor-opacity);
    filter: var(--sponsor-filter);
    color: #333;
}
@media(min-width: 768px) {
    .sponsor-logo { height: 40px; }
}

/* LANGUAGE SWITCHER */
.lang-option {
    transition: all 0.2s ease;
    opacity: 0.55;
}
.lang-option.active {
    opacity: 1;
}
a.lang-option:hover {
    opacity: 1;
    color: var(--primary-hover);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* PARALLAX BANNER (percorsi page) */
.parallax-banner {
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}
@media (max-width: 768px) {
    .parallax-banner {
        background-attachment: scroll;
    }
}

/* ELEVATION PROFILE */
.elevation-profile-container {
    position: relative;
}

.elevation-svg-wrap {
    position: relative;
    overflow: visible;
}

.elevation-tooltip {
    position: absolute;
    width: 220px;
    background: var(--card-bg);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    z-index: 50;
    overflow: hidden;
    pointer-events: auto;
}

.elevation-tooltip .tip-header {
    padding: 10px 12px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
}

.elevation-tooltip .tip-badge {
    background: rgba(255,255,255,0.25);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    white-space: nowrap;
}

.elevation-tooltip .tip-body {
    padding: 12px;
}

.elevation-tooltip .tip-stats {
    display: flex;
    gap: 8px;
}

.elevation-tooltip .tip-stat {
    flex: 1;
    text-align: center;
}

.elevation-tooltip .tip-val {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-color);
    font-family: var(--font-heading);
}

.elevation-tooltip .tip-lbl {
    font-size: 9px;
    color: var(--text-hint, #6F7B75);
    text-transform: uppercase;
}

.ep-cp circle:last-of-type {
    transition: transform 0.15s ease;
    transform-origin: center;
}

.ep-cp:hover circle:last-of-type {
    transform: scale(1.25);
}

/* LIGHTBOX OVERLAY (expand map / altimetry) */
.ubt-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.ubt-lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.ubt-lightbox-content {
    background: var(--card-bg);
    border-radius: 12px;
    width: 92vw;
    height: 85vh;
    max-width: 1200px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.ubt-lightbox-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.ubt-lightbox-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.ubt-lightbox-body {
    flex: 1;
    overflow: auto;
    padding: 0;
}

/* Expand button in header bars */
.expand-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.expand-btn:hover {
    background: var(--secondary-color);
}

/* Race map container — image fills available space */
.race-map-container {
    position: relative;
}

.race-map-container img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Lightbox elevation SVG */
.ubt-lightbox-body .elevation-svg-wrap {
    height: 100%;
}

.ubt-lightbox-body .elevation-svg-wrap svg {
    width: 100%;
    height: 100%;
}

@media (max-width: 768px) {
    .ubt-lightbox-content {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        max-width: none;
    }
}

/* ICONS & UTILS */
/* Ultrabericus: tech-icon uses secondary color */
.tech-icon {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--secondary-color);
}
