/* Layout and structure for F1 Rookie Insights */

/* Reset & box model */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base layout */
html {
    scroll-behavior: smooth;
}
body {
    line-height: 1.6;
}

/* Header & navigation layout */
header {
    padding: 1rem 1.25rem;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 2000;
    gap: 1rem;
    flex-wrap: wrap;
}
.logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo-mark {
    width: 28px;
    height: 28px;
}
nav ul {
    list-style: none;
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}
nav a {
    position: relative;
    padding-bottom: 0.2rem;
}
nav a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 0;
    transition: width 0.3s ease-out;
}
nav a:hover::after,
nav a.active::after {
    width: 100%;
}

/* -------------------------------------------------- */
/* Language switcher layout */
.language-switcher {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.lang-btn {
    padding: 0.35rem 0.7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    min-width: 44px;
    height: 36px;
}
.lang-btn > img, 
.lang-btn > svg {
    width: 20px;
    height: auto;
}

/* -------------------------------------------------- */
/* Main content layout */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

/* Hero section layout */
.hero {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: center;
    margin-bottom: 2.2rem;
}
.hero-text h1 {
    margin-bottom: 0.8rem;
}
.hero-text p {
    margin-bottom: 1.2rem;
}
.hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.2rem;
}
.badge {
    padding: 0.25rem 0.8rem;
}
.cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

/* Button layout */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1.3rem;
}

/* Hero visual layout */
.hero-visual {
    padding: 1.1rem;
    position: relative;
    overflow: hidden;
    min-height: 180px;
}
.hero-visual img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 100%;
    object-fit: cover;
}
.hero-visual figcaption {
    padding: 0.45rem 0.7rem 0.6rem;
}

/* Cards grid layout */
.sections-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.3rem;
}
.card {
    padding: 1.1rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.card h2 {
    margin-bottom: 0.6rem;
}
.card p {
    margin-bottom: 0.7rem;
}
.card ul {
    margin-left: 1.1rem;
    margin-bottom: 0.8rem;
}
.card-features {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: 0.8rem;
}
.feature-item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.8rem;
}
.feature-link {
    display: block;
}
.feature-icon {
    flex-shrink: 0;
    line-height: 1;
}
.feature-item h2 {
    margin: 0;
}
.card .btn {
    margin-top: 0.6rem;
    width: 100%;
    max-width: 280px;
}

/* Footer layout */
footer {
    padding: 1rem 1.25rem 2rem;
    text-align: center;
}

/* Back-to-top button layout */
.back-to-top {
    position: fixed;
    right: 1rem;
    bottom: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    z-index: 9999;
}
.back-to-top.hidden {
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
}

/* Mobile navigation layout */
.nav-toggle {
    display: none;
}
.nav-toggle-label {
    display: none;
}
.main-nav ul {
    list-style: none;
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

/* -------------------------------------------------- */
/* Basics page layout */
.page-basics {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.8rem 1.25rem 3rem;
}
.hero--subpage {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 1.8rem;
    align-items: center;
    margin-bottom: 2.3rem;
}
.hero--subpage .hero-text p {
    max-width: 36rem;
}
.hero-image {
    margin: 0;
    overflow: hidden;
}
.hero-image img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
}
.hero-image figcaption {
    padding: 0.45rem 0.7rem 0.6rem;
}
.basics-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.4rem;
    margin-bottom: 2.1rem;
}
.basics-card {
    position: relative;
}
.basics-card h2 {
    margin-bottom: 0.4rem;
}
.basics-card p {
    margin-bottom: 0.6rem;
}
.inline-image {
    margin-top: 0.8rem;
    overflow: hidden;
}
.inline-image img {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
}
.inline-image figcaption {
    padding: 0.4rem 0.6rem 0.55rem;
}
.basics-next {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}
.basics-next .btn {
    align-self: flex-start;
}

/* -------------------------------------------------- */
/* Teams page layout */
.page-teams {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.8rem 1.25rem 3rem;
}
.teams-intro {
    margin-bottom: 1.8rem;
}
.teams-intro p+p {
    margin-top: 0.4rem;
}
.teams-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2.1rem;
    margin-top: 2.1rem;
    margin-bottom: 2.1rem;
}
.team-card {
    padding-top: 0;
    position: relative;
    z-index: 0;
}
.team-header {
    padding: 0.9rem 1rem 0.7rem;
    margin: -1.2rem -1.2rem 0.8rem;
}
.team-header h2 {
    margin-bottom: 0.25rem;
}
.team-drivers {
    list-style: none;
    margin: 0 0 0.6rem;
    padding: 0;
}
.team-drivers li+li {
    margin-top: 0.2rem;
}
.team-drivers .number {
    display: inline-block;
    min-width: 2.4rem;
}
.teams-footer-card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.teams-footer-card .btn {
    align-self: flex-start;
}

/* -------------------------------------------------- */
/* Calendar page layout */
.page-races {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.8rem 1.25rem 3rem;
}
.races-intro {
    margin-bottom: 1.8rem;
}
.races-intro p+p {
    margin-top: 0.4rem;
}
.races-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.3rem;
    margin-bottom: 2.1rem;
}
.races-block--full {
    grid-column: 1 / -1;
}
.races-block h2 {
    margin-bottom: 0.6rem;
}
.race-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.race-list li {
    padding: 0.65rem 0.1rem;
}
.race-main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 0.8rem;
}
.race-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.8rem;
    margin-top: 0.15rem;
}
.race-podium {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
}
.podium-pos {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
}
.races-footer-card {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.races-footer-card .btn {
    align-self: flex-start;
}

/* -------------------------------------------------- */
/* Glossary page layout */
.page-glossory,
.page-glossary {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.8rem 1.25rem 3rem;
}
.glossary-section {
    margin-bottom: 1.8rem;
}
.glossary-list {
    margin: 0.4rem 0 0;
}
.glossary-item {
    padding: 0.6rem 0;
}
.glossary-item dt {
    margin-bottom: 0.2rem;
}
.glossary-item dd {
    margin: 0;
}
.faq-section {
    margin-top: 1.2rem;
}
.faq-item {
    padding: 0.5rem 0;
}
.faq-item summary {
    list-style: none;
}
.faq-item summary::-webkit-details-marker {
    display: none;
}
.faq-item summary::after {
    content: "+";
    float: right;
}
.faq-item[open] summary::after {
    content: "−";
}
.faq-item p {
    margin-top: 0.35rem;
}
.glossary-more {
    margin-top: 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.glossary-more .btn {
    align-self: flex-start;
}

/* -------------------------------------------------- */
/* Multimedia page layout */
.page-multimedia {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.8rem 1.25rem 3rem;
}
.multimedia-intro {
    margin-bottom: 1.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.multimedia-intro .btn {
    align-self: flex-start;
}
.multimedia-carousel {
    margin-bottom: 2.1rem;
}
.multimedia-carousel h2 {
    margin-bottom: 0.7rem;
}
.carousel-track {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.4rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.carousel-item {
    min-width: 260px;
    max-width: 320px;
    flex: 0 0 auto;
    padding: 1rem 1rem 1rem;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    gap: 0.225rem;
}
.video-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* Flag legend layout */
.flag-legend {
    margin: 0.8rem 0 1.2rem;
}
.flag-legend .legend-intro {
    margin-bottom: 0.6rem;
}
.flag-legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.6rem;
}
.flag-btn {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    padding: 0.6rem;
    width: 100%;
    text-align: left;
}
.flag-swatch {
    width: 36px;
    height: 22px;
    flex-shrink: 0;
}
.flag-tooltip {
    position: absolute;
    z-index: 1200;
    max-width: 28rem;
    padding: 0.6rem 0.8rem;
}

/* -------------------------------------------------- */
/* Responsive layout adjustments */
@media (max-width: 360px) {
    header {
        padding-inline: 0.8rem;
    }
    nav ul {
        gap: 0.8rem;
    }
}

@media (min-width: 480px) {
    main {
        padding-inline: 1.5rem;
    }
    .hero-visual {
        min-height: 200px;
    }
}

@media (max-width: 480px) {
    .back-to-top {
        right: 0.8rem;
        bottom: 0.9rem;
        width: 40px;
        height: 40px;
    }
    .page-basics,
    .page-teams,
    .page-races,
    .page-glossary,
    .page-multimedia {
        padding-inline: 1rem;
    }
    .hero--subpage {
        grid-template-columns: 1fr;
    }
    .hero-image {
        order: -1;
        margin-bottom: 0.4rem;
    }
    .race-meta {
        flex-direction: column;
    }
    .carousel-item {
        min-width: 230px;
    }
    .flag-swatch {
        width: 32px;
        height: 18px;
    }
}

@media (min-width: 768px) {
    header {
        padding-inline: 2rem;
    }
    .hero {
        grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
        gap: 2rem;
    }
    .hero-visual {
        min-height: 230px;
        padding: 1.3rem;
    }
    .sections-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .page-basics,
    .page-teams,
    .page-races,
    .page-glossary,
    .page-multimedia {
        padding-inline: 1.8rem;
    }
    .basics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .inline-image {
        margin-top: 1rem;
    }
    .teams-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .races-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 992px) {
    main {
        padding-inline: 2rem;
    }
    .sections-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .hero-visual {
        min-height: 260px;
    }
    .page-basics,
    .page-teams,
    .page-races,
    .page-glossary,
    .page-multimedia {
        padding-inline: 2rem;
    }
    .hero--subpage {
        margin-bottom: 2.6rem;
    }
}

@media (min-width: 1200px) {
    main {
        max-width: 1200px;
    }
}

/* Mobile navigation responsive layout */
@media (max-width: 991px) {
    header {
        padding-inline: 1rem;
    }
    .language-switcher {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
    }
    .main-nav {
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        z-index: 999;
        transform: translateY(-10px);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease-out, transform 0.2s ease-out, visibility 0.2s;
    }
    .main-nav ul {
        flex-direction: column;
        gap: 0;
    }
    .main-nav a {
        display: block;
        padding: 0.9rem 1.25rem;
    }
    .nav-toggle-label {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 32px;
        height: 28px;
        margin-left: auto;
    }
    .nav-toggle-label span {
        display: block;
        height: 2px;
        width: 100%;
        transition: transform 0.2s ease-out, opacity 0.2s ease-out;
    }
    .nav-toggle:checked ~ .main-nav {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    .nav-toggle:checked + .nav-toggle-label span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    .nav-toggle:checked + .nav-toggle-label span:nth-child(2) {
        opacity: 0;
    }
    .nav-toggle:checked + .nav-toggle-label span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }
}

@media (max-width: 991px) and (max-width: 600px) {
    header {
        display: grid;
        grid-template-columns: auto auto;
        grid-template-rows: auto;
        column-gap: 0.75rem;
    }
    .logo {
        align-items: center;
    }
    .nav-toggle-label {
        justify-self: end;
    }
}

@media (min-width: 992px) {
    .main-nav {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
    }
    .main-nav ul {
        flex-direction: row;
        gap: 1.25rem;
    }
    .main-nav a {
        padding: 0;
    }
    .nav-toggle-label {
        display: none;
    }
}