/* ==========================================================================
   NorCal RallyCross
   ========================================================================== */

:root {
    --nrx-text: #111;
    --nrx-muted: #4a4a4a;
    --nrx-link: #1f5f9e;
    --nrx-link-hover: #123d68;
    --nrx-accent: #e32b2b;
    --nrx-facebook: #1a6eb5;
    --nrx-panel: rgba(255, 255, 255, 0.86);
    --nrx-font-body: 'EB Garamond', Garamond, 'Times New Roman', serif;
    --nrx-font-heading: 'Cormorant Garamond', 'EB Garamond', Garamond, serif;
    --nrx-max: 1200px;
    --nrx-gutter: clamp(20px, 5vw, 72px);
    --nrx-header-h: clamp(120px, 19vw, 270px);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--nrx-font-body);
    font-size: clamp(17px, 1.1vw + 10px, 19px);
    line-height: 1.75;
    color: var(--nrx-text);
    background: #fff;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
body.no-scroll { overflow: hidden; }

img, iframe, video { max-width: 100%; }
img { height: auto; }

a { color: var(--nrx-link); text-underline-offset: 3px; }
a:hover, a:focus-visible { color: var(--nrx-link-hover); }

h1, h2, h3, h4, h5, h6 {
    font-family: var(--nrx-font-heading);
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: 0.01em;
    margin: 1.4em 0 0.5em;
    color: var(--nrx-text);
}
h1 { font-size: clamp(2.2rem, 4vw, 3.4rem); }
h2 { font-size: clamp(1.9rem, 3vw, 2.6rem); }
h3 { font-size: clamp(1.45rem, 2vw, 1.8rem); font-weight: 600; }
h4 { font-size: 1.3rem; font-weight: 600; }

p { margin: 0 0 1em; }

.screen-reader-text {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    white-space: nowrap;
}
.skip-link:focus {
    clip: auto; width: auto; height: auto;
    z-index: 1000; top: 8px; left: 8px;
    background: #fff; padding: 8px 14px;
}

/* --------------------------------------------------------------------------
   Header: transparent, sits over the page background / hero
   -------------------------------------------------------------------------- */

.site-header {
    position: absolute;
    inset: 0 0 auto 0;
    z-index: 50;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.75) 45%, rgba(255, 255, 255, 0) 100%);
    padding-bottom: 40px;
}
body:not(.has-page-background):not(.is-front) .site-header {
    position: relative;
    background: #fff;
    padding-bottom: 0;
}

.site-header__inner {
    max-width: calc(var(--nrx-max) + 2 * var(--nrx-gutter) + 160px);
    margin: 0 auto;
    padding: clamp(16px, 2.5vw, 40px) var(--nrx-gutter) 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.site-logo { display: block; line-height: 0; flex: 0 1 auto; }
.site-logo__img { width: clamp(220px, 42vw, 590px); height: auto; }

.site-nav { display: flex; align-items: center; gap: 22px; }

.site-nav .menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 4px 20px;
}
.site-nav .menu > li { position: relative; }
.site-nav .menu a {
    color: var(--nrx-text);
    text-decoration: none;
    font-size: 1.05rem;
    padding: 4px 0;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease;
}
.site-nav .menu a:hover,
.site-nav .menu a:focus-visible,
.site-nav .menu .current-menu-item > a,
.site-nav .menu .current-menu-ancestor > a,
.site-nav .menu .current_page_item > a {
    border-bottom-color: currentColor;
}

/* Dropdown (Events folder) */
.site-nav .sub-menu {
    list-style: none;
    margin: 0;
    padding: 10px 0;
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 150px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s;
    text-align: center;
}
.site-nav .sub-menu li { padding: 4px 18px; }
.site-nav .menu-item-has-children:hover > .sub-menu,
.site-nav .menu-item-has-children:focus-within > .sub-menu,
.site-nav .menu-item-has-children.is-open > .sub-menu {
    opacity: 1;
    visibility: visible;
}

/* Social icons */
.social-icons { list-style: none; margin: 0; padding: 0; display: flex; gap: 10px; }
.social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 8px;
    color: #fff;
    background: var(--nrx-facebook);
    transition: transform 0.15s ease, filter 0.15s ease;
}
.social-icon--instagram { background: linear-gradient(45deg, #f09433, #dc2743 50%, #bc1888); }
.social-icon:hover, .social-icon:focus-visible { color: #fff; transform: translateY(-1px); filter: brightness(1.08); }
.social-icon svg { width: 24px; height: 24px; fill: currentColor; }
/* The Squarespace header only showed Facebook; Instagram shows in the footer */
.social-icons--header .social-icon--instagram { display: none; }

/* Mobile menu */
.menu-toggle {
    display: none;
    background: none;
    border: 0;
    padding: 10px;
    cursor: pointer;
    flex-direction: column;
    gap: 7px;
}
.menu-toggle__bar {
    display: block;
    width: 28px;
    height: 2px;
    background: var(--nrx-text);
    transition: transform 0.2s ease;
}

@media (max-width: 900px) {
    .menu-toggle { display: flex; position: relative; z-index: 60; }
    .site-nav {
        position: fixed;
        inset: 0;
        background: #fff;
        flex-direction: column;
        justify-content: center;
        gap: 32px;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.2s ease, visibility 0.2s;
        z-index: 55;
    }
    .is-menu-open .site-nav { opacity: 1; visibility: visible; }
    .is-menu-open .menu-toggle__bar:first-child { transform: translateY(4.5px) rotate(45deg); }
    .is-menu-open .menu-toggle__bar:nth-child(2) { transform: translateY(-4.5px) rotate(-45deg); }
    .site-nav .menu { flex-direction: column; gap: 14px; text-align: center; }
    .site-nav .menu a { font-size: 1.6rem; }
    .site-nav .sub-menu {
        position: static;
        transform: none;
        box-shadow: none;
        opacity: 1;
        visibility: visible;
        padding: 6px 0 0;
        background: transparent;
    }
    .site-nav .sub-menu a { font-size: 1.25rem; color: var(--nrx-muted); }
    .social-icons--header .social-icon--instagram { display: inline-flex; }
}

/* --------------------------------------------------------------------------
   Page background (Featured Image) with a readable wash
   -------------------------------------------------------------------------- */

.page-background {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}
.page-background__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.page-background::after {
    content: '';
    position: absolute;
    inset: 0;
}
.bg-tint-white .page-background::after { background: rgba(255, 255, 255, 0.72); }
.bg-tint-light-blue .page-background::after { background: rgba(214, 228, 243, 0.82); }
.bg-tint-blue .page-background::after { background: rgba(52, 98, 145, 0.62); }
.bg-tint-none .page-background::after { background: transparent; }

body.has-page-background { background: transparent; }
body.has-page-background .site-footer { background: rgba(255, 255, 255, 0.92); }

/* --------------------------------------------------------------------------
   Main content
   -------------------------------------------------------------------------- */

.site-main { flex: 1 0 auto; }

.page-content {
    max-width: calc(var(--nrx-max) + 2 * var(--nrx-gutter));
    margin: 0 auto;
    padding: 30px var(--nrx-gutter) 80px;
}
.has-page-background .page-content { padding-top: calc(var(--nrx-header-h) + 40px); }

.entry-content > *:first-child { margin-top: 0; }
.entry-content .alignwide { max-width: none; }
.entry-content .alignfull {
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    max-width: 100vw;
    width: 100vw;
}

/* Semi-opaque panel used on About and the results archive */
.nrx-panel { background: var(--nrx-panel); padding: clamp(24px, 4vw, 56px); border-radius: 4px; }
.nrx-panel > *:first-child { margin-top: 0; }
.bg-tint-white .nrx-panel { background: transparent; padding-left: 0; padding-right: 0; }

/* Results archive: Squarespace used bold labels followed by link lines */
.nrx-results-archive p { margin-bottom: 0.35em; }
.nrx-results-archive h2 { font-size: clamp(1.6rem, 2.4vw, 2.1rem); }
.nrx-results-archive p + h2 { margin-top: 1.6em; }

/* Schedule: big date lines (Squarespace auto-sized these to the column width) */
.nrx-schedule-list {
    list-style: none;
    padding: 0;
    margin: 0.5em 0 1.5em;
    font-family: var(--nrx-font-body);
    font-weight: 600;
    font-size: clamp(1.8rem, 5vw, 4rem);
    line-height: 1.15;
    color: #fff;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}
.nrx-schedule-list li { margin: 0.1em 0; }
.bg-tint-blue .entry-content > p em { color: #fff; }

/* SidewaysData events embed: white panel like on Squarespace */
.nrx-events-embed {
    background: #fff;
    margin: 1em 0 2em;
    min-height: 200px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}
.nrx-events-embed iframe { display: block; width: 100%; border: 0; }

/* --------------------------------------------------------------------------
   Homepage
   -------------------------------------------------------------------------- */

.hero {
    position: relative;
    height: 100vh;
    min-height: 520px;
    max-height: 1100px;
    overflow: hidden;
}
.hero__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 60%;
    display: block;
}
.site-main--front .page-content { padding-top: 60px; }
.nrx-section-title { text-align: center; margin-bottom: 1em; }

.nrx-venue {
    align-items: flex-start !important;
    gap: clamp(24px, 4vw, 56px) !important;
    margin-bottom: 1em;
}
.nrx-venue h3 { margin-top: 0; }
.nrx-venue p { margin-bottom: 0.5em; }

.nrx-map { position: relative; }
.nrx-map iframe {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    height: auto;
    border: 0;
    background: #e9ecef;
}
.nrx-map__directions {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.95rem;
}

.wp-block-embed-youtube { margin: 1.5em auto 2em; max-width: 820px; }

/* --------------------------------------------------------------------------
   FAQ: alternating photo / text rows
   -------------------------------------------------------------------------- */

.nrx-faq-item {
    margin: 0 0 clamp(24px, 4vw, 48px) !important;
    background: #fff;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.07);
    grid-template-columns: 45% 1fr !important;
}
.nrx-faq-item.has-media-on-the-right { grid-template-columns: 1fr 45% !important; }
.nrx-faq-item .wp-block-media-text__media { min-height: 360px; }
.nrx-faq-item .wp-block-media-text__content { padding: clamp(24px, 4vw, 56px) !important; }
.nrx-faq-item h2 { margin-top: 0; }
.nrx-faq-item h3 { font-size: 1.4rem; margin-top: 1.4em; }
.nrx-faq-item ul { padding-left: 1.2em; }
@media (max-width: 600px) {
    .nrx-faq-item, .nrx-faq-item.has-media-on-the-right { grid-template-columns: 100% !important; }
    .nrx-faq-item .wp-block-media-text__media { min-height: 240px; }
}

/* --------------------------------------------------------------------------
   Pictures
   -------------------------------------------------------------------------- */

.nrx-gallery { gap: 12px !important; }
.nrx-gallery .wp-block-image img { aspect-ratio: 3 / 2; object-fit: cover; cursor: zoom-in; transition: filter 0.2s ease; }
.nrx-gallery .wp-block-image img:hover { filter: brightness(1.06); }

/* --------------------------------------------------------------------------
   Buttons, posts, misc
   -------------------------------------------------------------------------- */

.button, .wp-block-button__link {
    display: inline-block;
    background: var(--nrx-text);
    color: #fff;
    padding: 12px 24px;
    text-decoration: none;
    font-family: var(--nrx-font-body);
    border: 1px solid var(--nrx-text);
    margin-right: 8px;
}
.button:hover, .wp-block-button__link:hover { background: #333; color: #fff; }
.button--ghost { background: transparent; color: var(--nrx-text); }
.button--ghost:hover { background: var(--nrx-text); color: #fff; }

.post-summary { margin-bottom: 2.5em; }
.post-summary h2 { margin-bottom: 0.2em; }
.post-summary h2 a { color: inherit; text-decoration: none; }
.post-summary__date { color: var(--nrx-muted); font-size: 0.95rem; }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.site-footer {
    flex-shrink: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff;
}
.site-footer__inner {
    max-width: calc(var(--nrx-max) + 2 * var(--nrx-gutter));
    margin: 0 auto;
    padding: 32px var(--nrx-gutter);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.site-footer__text { flex-basis: 100%; }
.site-footer__copy { margin: 0; color: var(--nrx-muted); font-size: 0.95rem; }
.social-icons--footer .social-icon { width: 38px; height: 38px; border-radius: 6px; }
.social-icons--footer .social-icon svg { width: 20px; height: 20px; }
