/* ===================================================================
   Apex theme - tuning garage & motorsport
   Version: 1.0.1
   Author: Reveloni
   For: CMS 6.0.2+

   Characteristics: the workshop and the racetrack. Carbon-fibre weave,
   checkered-flag accents, a glowing redline tachometer, start numbers on
   the cards and racing stripes in the team colour. Leans to the tuning
   side - carbon, wheels, livery decals - over pure F1, but keeps the
   speed. Sharp angles, engineered precision, adrenaline.

   The admin colour scheme becomes the TEAM COLOUR: racing stripes, start
   numbers, redline glow and buttons all take it, so one theme runs a red,
   a blue, an orange and a green livery without touching the CSS. The base
   is asphalt silver (light) or garage graphite (dark).

   Light mode is the paddock by day; dark mode is the track at night -
   deep graphite, glowing stripes and telemetry.

   Signature devices, all pure CSS: a carbon-weave panel texture, the
   redline tachometer hero, checkered-flag section rules, angular livery
   cuts, start-number counters, and three motorsport dials (speedometer,
   checkered flag, wheel) as page-card placeholders.

   For tuning shops, performance dealers, karting and race circuits, car
   clubs, parts stores, detailing studios and motorsport brands.

   Changelog:
     1.0.1 - The hamburger button used --ap-ink as its background, which
             inverts between modes: in dark mode it turned near-white and the
             white label was almost invisible. It now takes the team colour
             (like the other livery accents), legible in both modes; hover
             brightens it instead of colouring it.
     1.0.0 - Initial release. Built with auto-fit grids, .page-card-image
             styled as the image itself, the crop-safe gallery pipeline and
             a header-anchored dropdown from day one.
   =================================================================== */

/* === RESET === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* === PALETTE ===
   Engine injects --primary / --secondary / --accent on :root (inline).
   --ap-team is the livery colour (from --primary); --ap-redline the
   tachometer's danger zone (from --accent, but kept hot). */
:root {
    /* Asphalt / silver surfaces */
    --ap-surface: #eceef1;
    --ap-surface-raised: #f7f8fa;
    --ap-surface-deep: #dde1e6;

    /* Carbon ink */
    --ap-ink: #14171c;
    --ap-ink-soft: #464c56;
    --ap-ink-faint: #878e99;

    /* Team colour (livery) + redline, scheme-aware */
    --ap-team: color-mix(in srgb, var(--primary, #d81f26) 76%, #b81820);
    --ap-team-bright: color-mix(in srgb, var(--primary, #ff2d36) 62%, #ff2d36);
    --ap-team-soft: color-mix(in srgb, var(--ap-team) 14%, transparent);
    --ap-redline: color-mix(in srgb, var(--accent, #ff3b30) 60%, #ff2a20);

    /* Carbon weave tint */
    --ap-carbon-a: #2a2e35;
    --ap-carbon-b: #1c1f24;

    /* Structure */
    --ap-line: color-mix(in srgb, var(--ap-ink) 18%, transparent);
    --ap-line-soft: color-mix(in srgb, var(--ap-ink) 9%, transparent);

    /* The tachometer face is dark in both modes */
    --ap-gauge: #16191f;
    --ap-gauge-edge: #2e333c;
    --ap-gauge-text: #f4f6f8;

    --ap-shadow-sm: 0 2px 6px rgba(20, 23, 28, 0.10);
    --ap-shadow-md: 0 10px 28px rgba(20, 23, 28, 0.16);
    --ap-shadow-lg: 0 20px 50px rgba(20, 23, 28, 0.22);

    --ap-radius: 4px;
    --ap-radius-lg: 8px;
    --ap-pill: 999px;

    /* sharp, quick easing - a snap, not a glide */
    --ap-transition: 0.25s cubic-bezier(0.4, 0, 0.1, 1);

    --font-display: 'Rajdhani', 'Oswald', 'Arial Narrow', sans-serif;
    --font-number: 'Oswald', 'Rajdhani', 'Arial Narrow', sans-serif;
    --font-body: 'Titillium Web', 'Segoe UI', 'Helvetica Neue', sans-serif;

    /* Aliases some engine snippets rely on */
    --text: var(--ap-ink);
    --text-light: var(--ap-ink-soft);
}

/* Track at night / garage */
[data-theme="dark"] {
    --ap-surface: #0e1013;
    --ap-surface-raised: #171a20;
    --ap-surface-deep: #090b0d;

    --ap-ink: #eef1f5;
    --ap-ink-soft: #a6adb8;
    --ap-ink-faint: #6b727d;

    --ap-team: color-mix(in srgb, var(--primary, #ff2d36) 70%, #ff2d36);
    --ap-team-bright: color-mix(in srgb, var(--primary, #ff5b62) 62%, #ff5b62);
    --ap-team-soft: color-mix(in srgb, var(--ap-team) 20%, transparent);
    --ap-redline: color-mix(in srgb, var(--accent, #ff453a) 62%, #ff453a);

    --ap-carbon-a: #23272e;
    --ap-carbon-b: #15181d;

    --ap-line: color-mix(in srgb, #ffffff 16%, transparent);
    --ap-line-soft: color-mix(in srgb, #ffffff 8%, transparent);

    --ap-gauge: #05070a;
    --ap-gauge-edge: #262b33;
    --ap-gauge-text: #f4f6f8;

    --ap-shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.5);
    --ap-shadow-md: 0 10px 28px rgba(0, 0, 0, 0.6);
    --ap-shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.7);
}

/* Carbon-fibre weave, reused as a background layer on dark panels.
   A 2x2 herringbone from two greys, small tile. */
:root {
    --ap-carbon:
        repeating-linear-gradient(45deg, var(--ap-carbon-a) 0 3px, var(--ap-carbon-b) 3px 6px),
        repeating-linear-gradient(-45deg, rgba(255,255,255,0.03) 0 3px, transparent 3px 6px);
}

/* === BASE === */
html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--ap-ink);
    background: var(--ap-surface);
    transition: background var(--ap-transition), color var(--ap-transition);
}

::selection {
    background: var(--ap-team-soft);
    color: var(--ap-ink);
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 1.5rem;
    position: relative;
}

img {
    max-width: 100%;
}

/* === ANIMATIONS (CMS framework) === */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(var(--animation-offset, 20px));
    transition: opacity 0.6s ease, transform 0.6s ease;
}

body.js-ready[data-animations-enabled="true"] .animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

body:not([data-animations-enabled="true"]) .animate-on-scroll {
    opacity: 1;
    transform: none;
}

/* === TYPOGRAPHY === */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--ap-ink);
    line-height: 1.05;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

p {
    margin-bottom: 1rem;
}

a {
    color: var(--ap-team);
    text-decoration: none;
    transition: color var(--ap-transition);
}

a:hover {
    color: var(--ap-team-bright);
}

/* Technical lettering for labels and UI */
.site-title,
.breadcrumbs,
.btn,
.cta-button,
.page-card-link,
.footer-section h3,
.hamburger-btn,
.form-group label,
.lightbox-counter {
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

/* === HEADER - carbon fascia === */
header {
    position: relative;
    z-index: 100;
    background: var(--ap-surface-raised);
    border-bottom: 3px solid var(--ap-ink);
    transition: background var(--ap-transition);
}

/* Team-colour racing stripe riding the bottom edge */
header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -3px;
    height: 3px;
    background: var(--ap-team);
    box-shadow: 0 0 10px var(--ap-team-soft);
    pointer-events: none;
}

/* The dropdown anchors to this box, so `top: 100%` is the bottom of the
   bar regardless of logo height. */
header .container {
    position: relative;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 0;
    gap: 1rem;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-container img {
    height: 80px;
    width: auto;
    display: block;
}

.site-title {
    font-family: var(--font-display);
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: var(--ap-ink);
}

/* === NAV / HAMBURGER === */
nav ul {
    list-style: none;
    display: flex;
    align-items: center;
}

.hamburger-menu {
    /* static on purpose: the header container is the anchor */
    position: static;
}

.hamburger-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    /* Team colour, not --ap-ink: --ap-ink inverts between modes, so in dark
       mode it turned near-white and the white label vanished into it. The
       livery colour keeps the white text legible in both modes (1.0.1). */
    background: var(--ap-team);
    border: none;
    border-radius: var(--ap-radius);
    color: #fff;
    font-size: 0.8rem;
    padding: 0.6rem 1.35rem;
    cursor: pointer;
    transition: background var(--ap-transition), transform var(--ap-transition);
}

.hamburger-btn:hover {
    background: var(--ap-team-bright);
    transform: translateY(-1px);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    /* aligns with the button: the container's padding box ends 1.5rem outside it */
    right: 1.5rem;
    min-width: 252px;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--ap-surface-raised);
    border: 1px solid var(--ap-line);
    border-top: 3px solid var(--ap-team);
    border-radius: var(--ap-radius);
    box-shadow: var(--ap-shadow-lg);
    z-index: 300;
}

.dropdown-menu.active {
    display: block;
}

.dropdown-menu ul {
    display: block;
    padding: 0.5rem 0;
}

.dropdown-menu li {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 0.62rem 1.4rem;
    color: var(--ap-ink);
    font-family: var(--font-body);
    font-size: 0.98rem;
    font-weight: 600;
    border-left: 3px solid transparent;
    transition: background var(--ap-transition), border-color var(--ap-transition), color var(--ap-transition);
}

.dropdown-menu a:hover {
    background: var(--ap-team-soft);
    border-left-color: var(--ap-team);
}

.dropdown-menu a.active {
    border-left-color: var(--ap-team);
    color: var(--ap-team);
}

/* === BREADCRUMBS === */
.breadcrumbs {
    background: var(--ap-surface-deep);
    border-bottom: 1px solid var(--ap-line-soft);
    font-size: 0.76rem;
}

.breadcrumbs .container {
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.breadcrumbs a {
    color: var(--ap-ink-soft);
}

.breadcrumbs a:hover {
    color: var(--ap-team);
}

.breadcrumbs span {
    color: var(--ap-team);
}

.breadcrumbs strong {
    color: var(--ap-ink);
    font-weight: 700;
}

/* === HERO - the tachometer === */
.hero {
    position: relative;
    padding: 5.25rem 1.5rem 5rem;
    text-align: center;
    background: var(--ap-surface);
    overflow: hidden;
}

/* Angular livery cut behind the hero */
.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    background: linear-gradient(115deg, transparent 0 62%, var(--ap-team-soft) 62% 66%, transparent 66% 70%, var(--ap-team-soft) 70% 72%, transparent 72%);
    opacity: 0.7;
    pointer-events: none;
}

.hero .container {
    position: relative;
    z-index: 1;
    max-width: 860px;
    padding: 3.5rem 2.75rem 3.25rem;
    border-radius: var(--ap-radius-lg);
    /* carbon-weave gauge face, dark in both modes */
    background: var(--ap-carbon), var(--ap-gauge);
    border: 1px solid var(--ap-gauge-edge);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03), var(--ap-shadow-lg);
}

/* Redline sweep across the top of the gauge: team colour into hot red */
.hero .container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 8%;
    right: 8%;
    height: 4px;
    border-radius: var(--ap-pill);
    background: linear-gradient(90deg,
        var(--ap-team) 0%,
        var(--ap-team-bright) 62%,
        var(--ap-redline) 82%,
        #fff 100%);
    box-shadow: 0 0 16px var(--ap-redline);
}

/* Tick marks under the redline, like a rev counter */
.hero .container::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 8%;
    right: 8%;
    height: 8px;
    background: repeating-linear-gradient(90deg,
        var(--ap-gauge-text) 0 1px, transparent 1px 22px);
    opacity: 0.35;
    pointer-events: none;
}

.hero h1 {
    font-size: clamp(2.5rem, 6.5vw, 4.6rem);
    font-weight: 700;
    color: var(--ap-gauge-text);
    letter-spacing: 0.03em;
    margin-bottom: 1rem;
    text-shadow: 0 0 26px rgba(255, 255, 255, 0.1);
}

/* Checkered underline */
.hero h1::after {
    content: '';
    display: block;
    width: 120px;
    height: 14px;
    margin: 1.35rem auto 0;
    background:
        repeating-conic-gradient(var(--ap-gauge-text) 0% 25%, transparent 0% 50%) 0 0 / 14px 14px;
    opacity: 0.9;
}

.hero p {
    font-size: 1.15rem;
    color: rgba(244, 246, 248, 0.78);
    max-width: 54ch;
    margin: 0 auto 1.35rem;
}

/* === HERO WITH BACKGROUND IMAGE - trackside === */
.hero--has-bg {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    min-height: 58vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 5.5rem 2rem;
    margin: 1.25rem auto 0;
    max-width: 1180px;
    border-radius: var(--ap-radius-lg);
    border-bottom: 4px solid var(--ap-team);
}

.hero--has-bg::before {
    display: none;
}

.hero--has-bg .container {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
}

.hero--has-bg .container::before,
.hero--has-bg .container::after {
    display: none;
}

.hero--has-bg .hero-bg-media {
    position: absolute;
    inset: 0;
    z-index: -2;
    display: block;
}

.hero--has-bg .hero-bg-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.hero--has-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(180deg, rgba(9, 11, 13, 0.30) 0%, rgba(9, 11, 13, 0.70) 100%);
}

.hero--overlay-none::after   { background: linear-gradient(180deg, transparent 0%, rgba(9, 11, 13, 0.28) 100%); }
.hero--overlay-light::after  { background: linear-gradient(180deg, rgba(9, 11, 13, 0.14) 0%, rgba(9, 11, 13, 0.44) 100%); }
.hero--overlay-medium::after { background: linear-gradient(180deg, rgba(9, 11, 13, 0.30) 0%, rgba(9, 11, 13, 0.70) 100%); }
.hero--overlay-strong::after { background: linear-gradient(180deg, rgba(9, 11, 13, 0.50) 0%, rgba(9, 11, 13, 0.84) 100%); }

.hero--has-bg h1 {
    color: #fff;
    text-shadow: 0 3px 22px rgba(0, 0, 0, 0.6);
    max-width: 22ch;
    margin-left: auto;
    margin-right: auto;
}

.hero--has-bg p {
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 1px 14px rgba(0, 0, 0, 0.55);
}

/* === BUTTONS === */
.btn,
.cta-button {
    display: inline-block;
    position: relative;
    background: var(--ap-team);
    border: none;
    border-radius: var(--ap-radius);
    color: #fff;
    font-family: var(--font-display);
    font-size: 0.86rem;
    padding: 0.85rem 2.2rem;
    cursor: pointer;
    /* angular clip on the trailing corner, like a livery decal */
    clip-path: polygon(0 0, 100% 0, 100% 65%, calc(100% - 12px) 100%, 0 100%);
    box-shadow: var(--ap-shadow-sm);
    transition: background var(--ap-transition), transform var(--ap-transition), box-shadow var(--ap-transition);
}

.btn:hover,
.cta-button:hover {
    background: var(--ap-team-bright);
    transform: translateY(-2px);
    box-shadow: var(--ap-shadow-md);
}

.cta-button {
    margin-top: 0.8rem;
}

.hero--has-bg .cta-button {
    background: var(--ap-team);
    color: #fff;
}

.hero--has-bg .cta-button:hover {
    background: var(--ap-team-bright);
}

/* === CONTENT === */
main {
    background: var(--ap-surface);
}

.content-section {
    padding: 3.25rem 0;
}

.content-section h1 {
    font-size: clamp(2rem, 4.4vw, 3.1rem);
    margin-bottom: 1.25rem;
}

.content-section h2 {
    font-size: 1.9rem;
    margin: 2.25rem 0 1rem;
}

/* Checkered-flag rule under section headings */
.content-section h2::after {
    content: '';
    display: block;
    width: 96px;
    height: 12px;
    margin-top: 0.6rem;
    background:
        repeating-conic-gradient(var(--ap-ink) 0% 25%, transparent 0% 50%) 0 0 / 12px 12px;
    /* team-colour tab at the start */
    border-left: 6px solid var(--ap-team);
    padding-left: 4px;
}

.content-section h3 {
    font-size: 1.4rem;
    margin: 1.8rem 0 0.7rem;
}

.content-section ul,
.content-section ol {
    margin: 0 0 1.15rem 1.5rem;
}

.content-section ul li::marker {
    content: '\25B8  ';
    color: var(--ap-team);
}

.content-section ol li::marker {
    color: var(--ap-team);
    font-family: var(--font-number);
}

.content-section blockquote {
    margin: 1.85rem 0;
    padding: 1.15rem 1.5rem;
    background: var(--ap-surface-raised);
    border-left: 4px solid var(--ap-team);
    border-radius: var(--ap-radius);
    color: var(--ap-ink-soft);
    box-shadow: var(--ap-shadow-sm);
}

/* === PAGE CARDS - the starting grid === */
.page-cards-grid {
    display: grid;
    /* auto-fit: a lone subpage fills the row, pairs split it evenly */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2.25rem;
    margin: 2.5rem 0;
    counter-reset: grid;
}

.page-card {
    counter-increment: grid;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--ap-surface-raised);
    border: 1px solid var(--ap-line);
    border-radius: var(--ap-radius-lg);
    overflow: hidden;
    box-shadow: var(--ap-shadow-sm);
    transition: transform var(--ap-transition), box-shadow var(--ap-transition);
}

/* Start number, printed like a bonnet number */
.page-card::before {
    content: counter(grid, decimal-leading-zero);
    position: absolute;
    top: 0.6rem;
    left: 0.8rem;
    z-index: 3;
    font-family: var(--font-number);
    font-size: 2rem;
    line-height: 1;
    font-weight: 700;
    color: #fff;
    padding: 0.3rem 0.6rem 0.1rem;
    background: var(--ap-team);
    border-radius: var(--ap-radius);
    box-shadow: var(--ap-shadow-sm);
    /* angular decal cut */
    clip-path: polygon(0 0, 100% 0, 100% 72%, calc(100% - 9px) 100%, 0 100%);
}

.page-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--ap-shadow-md);
}

/* The engine puts .page-card-image on the element ITSELF: an <img> for a
   thumbnail (optionally inside an unclassed <picture>), or a <div> for the
   placeholder. Style it as the image - object-fit is a no-op on the div. */
.page-card-image {
    display: block;
    width: 100%;
    height: 208px;
    object-fit: cover;
    object-position: center;
    background: var(--ap-surface-deep);
    border-bottom: 3px solid var(--ap-team);
}

/* <picture> carries no class; make it a block so the image spans the card */
.page-card > picture {
    display: block;
    line-height: 0;
}

img.page-card-image {
    filter: saturate(1.02);
    transition: transform var(--ap-transition), filter var(--ap-transition);
}

.page-card:hover img.page-card-image {
    transform: scale(1.05);
    filter: saturate(1.12);
}

/* --- Placeholders: three motorsport dials on a carbon face --- */
.page-card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: var(--ap-carbon), var(--ap-gauge);
}

/* Hide the engine emoji */
.page-card-placeholder span {
    display: none;
}

/* --- Dial 1: SPEEDOMETER - arc scale + redline needle --- */
.page-card:nth-child(3n+1) .page-card-placeholder::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 108px;
    height: 108px;
    border-radius: 50%;
    background:
        /* scale ticks around the rim */
        repeating-conic-gradient(from 135deg,
            rgba(244,246,248,0.85) 0deg 1.4deg, transparent 1.4deg 18deg),
        /* redline zone from ~9 o'clock sweep */
        conic-gradient(from 135deg, transparent 0deg 200deg, var(--ap-redline) 200deg 270deg, transparent 270deg),
        radial-gradient(circle, #0c0e12 0 46px, transparent 46px);
    -webkit-mask: radial-gradient(circle, #000 0 53px, transparent 53px);
            mask: radial-gradient(circle, #000 0 53px, transparent 53px);
    border: 2px solid var(--ap-gauge-edge);
    box-shadow: inset 0 0 18px rgba(0,0,0,0.6);
}

.page-card:nth-child(3n+1) .page-card-placeholder::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 44px;
    transform-origin: bottom center;
    transform: translate(-50%, -100%) rotate(48deg);
    background: linear-gradient(var(--ap-redline), var(--ap-team-bright));
    border-radius: var(--ap-pill);
    box-shadow: 0 0 8px var(--ap-redline);
}

/* --- Dial 2: CHECKERED FLAG - folded triangle --- */
.page-card:nth-child(3n+2) .page-card-placeholder::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-8deg);
    width: 112px;
    height: 96px;
    background:
        repeating-conic-gradient(#f4f6f8 0% 25%, #14171c 0% 50%) 0 0 / 20px 20px;
    clip-path: polygon(0 0, 100% 14%, 88% 100%, 8% 82%);
    box-shadow: var(--ap-shadow-md);
    border: 1px solid var(--ap-gauge-edge);
}

/* flag pole */
.page-card:nth-child(3n+2) .page-card-placeholder::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 104px;
    transform: translate(-72px, -50%) rotate(-8deg);
    background: linear-gradient(var(--ap-ink-faint), var(--ap-gauge-edge));
    border-radius: var(--ap-pill);
}

/* --- Dial 3: WHEEL - tyre + five-spoke rim --- */
.page-card:nth-child(3n) .page-card-placeholder::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background:
        /* five spokes */
        repeating-conic-gradient(from 0deg,
            var(--ap-ink-faint) 0deg 3deg, transparent 3deg 72deg),
        /* hub */
        radial-gradient(circle, #3a4048 0 14px, transparent 14px),
        /* rim ring */
        radial-gradient(circle, transparent 0 34px, #c9ced4 34px 38px, transparent 38px),
        /* tyre */
        radial-gradient(circle, transparent 0 42px, #1a1d22 42px 54px, #0c0e11 54px);
    border: 2px solid #0a0c0f;
    box-shadow: inset 0 0 16px rgba(0,0,0,0.7), var(--ap-shadow-sm);
}

/* brake caliper in team colour */
.page-card:nth-child(3n) .page-card-placeholder::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 22px;
    transform: translate(20px, -50%);
    background: var(--ap-team);
    border-radius: 2px;
    box-shadow: 0 0 6px var(--ap-team-soft);
}

.page-card:hover .page-card-placeholder::before {
    filter: brightness(1.12);
    transition: filter var(--ap-transition);
}

.page-card-content {
    padding: 1.7rem 1.6rem 1.6rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.page-card h3,
.page-card-title {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.65rem;
    color: var(--ap-ink);
}

.page-card-excerpt {
    color: var(--ap-ink-soft);
    font-size: 1rem;
    flex: 1;
    margin-bottom: 1.1rem;
}

.page-card-link {
    align-self: flex-start;
    color: var(--ap-team);
    font-size: 0.78rem;
    padding-bottom: 3px;
    border-bottom: 2px solid var(--ap-team-soft);
    transition: color var(--ap-transition), border-color var(--ap-transition);
}

.page-card-link:hover {
    color: var(--ap-team-bright);
    border-color: currentColor;
}

/* === GALLERY === */
.gallery-grid {
    display: grid;
    /* auto-fit so one image spans the width and pairs split it evenly */
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1.75rem;
    margin: 2.25rem 0 2.75rem;
}

.gallery-item {
    position: relative;
    cursor: pointer;
    border-radius: var(--ap-radius-lg);
    overflow: hidden;
    background: var(--ap-surface-deep);
    border: 1px solid var(--ap-line);
    box-shadow: var(--ap-shadow-sm);
    transition: transform var(--ap-transition), box-shadow var(--ap-transition);
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--ap-shadow-md);
}

/* Team-colour bar sweeping in from the left on hover */
.gallery-item::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: var(--ap-team);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--ap-transition);
    z-index: 2;
}

.gallery-item:hover::after {
    transform: scaleX(1);
}

/* The 4:3 window carries the ratio; the child fills it. Explicit
   height:auto overrides the engine's height attribute so portraits and
   squares crop to 4:3 instead of collapsing into vertical strips. */
.gallery-item > img,
.gallery-item > picture {
    display: block;
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    height: auto;
    overflow: hidden;
    transition: transform 0.4s ease;
}

.gallery-item > img {
    object-fit: cover;
}

.gallery-item > picture img {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item source {
    display: none;
}

.gallery-item:hover > img,
.gallery-item:hover > picture {
    transform: scale(1.04);
}

/* === LIGHTBOX === */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 8, 10, 0.95);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 88vw;
    max-height: 84vh;
    border-radius: var(--ap-radius);
    border-bottom: 4px solid var(--ap-team);
    box-shadow: 0 26px 74px rgba(0, 0, 0, 0.65);
}

.lightbox-close,
.lightbox-nav {
    position: absolute;
    background: var(--ap-team);
    border: none;
    border-radius: var(--ap-radius);
    color: #fff;
    font-family: var(--font-display);
    cursor: pointer;
    box-shadow: var(--ap-shadow-md);
    transition: background var(--ap-transition), transform var(--ap-transition);
}

.lightbox-close:hover,
.lightbox-nav:hover {
    background: var(--ap-team-bright);
    transform: scale(1.08);
}

.lightbox-close {
    top: 1.5rem;
    right: 1.7rem;
    width: 46px;
    height: 46px;
    font-size: 1.35rem;
    line-height: 1;
}

.lightbox-nav {
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    font-size: 1.5rem;
}

.lightbox-nav:hover {
    transform: translateY(-50%) scale(1.08);
}

.lightbox-prev { left: 1.5rem; }
.lightbox-next { right: 1.5rem; }

.lightbox-counter {
    position: absolute;
    bottom: 1.6rem;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-family: var(--font-number);
    font-size: 1.1rem;
    letter-spacing: 0.2em;
}

/* === PRICE TAG - timing board === */
.price-tag {
    display: inline-block;
    position: relative;
    background: var(--ap-gauge);
    border: 1px solid var(--ap-gauge-edge);
    border-left: 4px solid var(--ap-team);
    border-radius: var(--ap-radius);
    color: var(--ap-team-bright);
    font-family: var(--font-number);
    font-size: 1.7rem;
    line-height: 1;
    letter-spacing: 0.06em;
    padding: 0.6rem 1.4rem 0.5rem;
    margin: 0.9rem 0 1.1rem;
    text-shadow: 0 0 12px var(--ap-team-soft);
    box-shadow: var(--ap-shadow-sm);
}

a.price-tag:hover {
    color: #fff;
    text-shadow: 0 0 14px #fff;
}

/* === TESTIMONIALS - pit reports === */
.testimonials-grid {
    display: grid;
    /* auto-fit for consistent stretching with one or two testimonials */
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2.25rem;
    margin: 2.5rem 0;
}

.testimonial-card {
    position: relative;
    background: var(--ap-surface-raised);
    border: 1px solid var(--ap-line);
    border-radius: var(--ap-radius-lg);
    padding: 2rem 1.7rem 1.6rem;
    box-shadow: var(--ap-shadow-sm);
    overflow: hidden;
    transition: transform var(--ap-transition), box-shadow var(--ap-transition);
}

/* Checkered strip across the top */
.testimonial-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: repeating-conic-gradient(var(--ap-ink) 0% 25%, transparent 0% 50%) 0 0 / 12px 12px;
}

.testimonial-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--ap-shadow-md);
}

.testimonial-rating {
    color: var(--ap-team);
    letter-spacing: 0.18em;
    margin-bottom: 0.6rem;
    font-size: 0.95rem;
}

.testimonial-text {
    color: var(--ap-ink-soft);
    margin-bottom: 0.9rem;
}

.testimonial-author {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ap-ink);
}

.testimonial-author::before {
    content: '\2014\00a0';
    color: var(--ap-team);
}

/* === CONTACT FORM === */
.contact-form {
    max-width: 680px;
    margin: 2.75rem auto;
    background: var(--ap-surface-raised);
    border: 1px solid var(--ap-line);
    border-top: 4px solid var(--ap-team);
    border-radius: var(--ap-radius-lg);
    padding: 2.6rem 2.3rem;
    box-shadow: var(--ap-shadow-md);
}

.contact-form h2 {
    text-align: center;
}

.contact-form h2::after {
    margin-left: auto;
    margin-right: auto;
}

.form-group {
    margin-bottom: 1.35rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.45rem;
    font-size: 0.74rem;
    color: var(--ap-ink-soft);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--ap-surface);
    border: 2px solid var(--ap-line-soft);
    border-radius: var(--ap-radius);
    color: var(--ap-ink);
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 0.75rem 0.95rem;
    transition: border-color var(--ap-transition), box-shadow var(--ap-transition);
}

.form-group textarea {
    min-height: 155px;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--ap-team);
    box-shadow: 0 0 0 4px var(--ap-team-soft);
}

/* === ALERTS === */
.error,
.success {
    border-radius: var(--ap-radius);
    padding: 0.9rem 1.2rem;
    margin-bottom: 1.25rem;
    font-size: 0.98rem;
    border-left: 4px solid;
}

.error {
    background: color-mix(in srgb, #d92b1f 12%, var(--ap-surface-raised));
    border-color: #d92b1f;
    color: color-mix(in srgb, #a81f16 76%, var(--ap-ink));
}

.success {
    background: color-mix(in srgb, #1f9d4d 12%, var(--ap-surface-raised));
    border-color: #1f9d4d;
    color: var(--ap-ink);
}

/* === FOOTER - carbon undertray === */
footer {
    position: relative;
    background: var(--ap-carbon), var(--ap-gauge);
    color: rgba(244, 246, 248, 0.72);
    margin-top: 3.5rem;
    overflow: hidden;
}

/* Checkered strip at the very top */
footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 8px;
    background: repeating-conic-gradient(#f4f6f8 0% 25%, #14171c 0% 50%) 0 0 / 16px 16px;
    z-index: 1;
}

/* Team-colour glow line under the checkers */
footer::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--ap-team);
    box-shadow: 0 0 14px var(--ap-team);
    z-index: 1;
}

.footer-content {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 2.25rem;
    padding: 3.25rem 0 2.25rem;
}

.footer-section h3 {
    font-size: 0.86rem;
    color: #fff;
    margin-bottom: 0.9rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--ap-team);
}

.footer-section p {
    margin-bottom: 0.45rem;
    font-size: 0.98rem;
}

.footer-section a {
    color: rgba(244, 246, 248, 0.72);
}

.footer-section a:hover {
    color: var(--ap-team-bright);
}

.footer-menu {
    list-style: none;
    margin: 0;
}

.footer-menu li {
    margin-bottom: 0.4rem;
}

.social-links {
    display: flex;
    gap: 0.7rem;
    margin-top: 0.6rem;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--ap-radius);
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    transition: background var(--ap-transition), transform var(--ap-transition);
}

.social-links a:hover {
    background: var(--ap-team);
    transform: translateY(-2px);
}

.copyright {
    position: relative;
    z-index: 2;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
    padding: 1.1rem 0 1.3rem;
    text-align: center;
    font-size: 0.84rem;
    color: rgba(244, 246, 248, 0.5);
}

/* === DARK MODE TOGGLE - ignition button === */
.dark-mode-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1200;
    width: 48px;
    height: 48px;
    border: 2px solid var(--ap-team);
    border-radius: 50%;
    background: var(--ap-gauge);
    box-shadow: var(--ap-shadow-md), 0 0 0 4px var(--ap-team-soft);
    cursor: pointer;
    font-size: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--ap-transition), box-shadow var(--ap-transition);
}

.dark-mode-toggle::before {
    content: '\263C';
    font-size: 1.2rem;
    line-height: 1;
    color: var(--ap-team-bright);
}

html[data-theme="dark"] .dark-mode-toggle::before {
    content: '\263E';
}

.dark-mode-toggle:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--ap-shadow-lg), 0 0 0 5px var(--ap-team-soft);
}

/* === RESPONSIVE === */
@media (max-width: 900px) {
    .hero {
        padding: 3.75rem 1rem 3.5rem;
    }

    .hero .container {
        padding: 2.5rem 1.5rem 2.25rem;
    }

    .hero--has-bg {
        min-height: 46vh;
        margin: 1rem 1rem 0;
    }

    .page-cards-grid,
    .testimonials-grid {
        gap: 1.85rem;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 1rem;
    }

    .header-content {
        padding: 0.85rem 0;
    }

    .logo-container img {
        height: 56px;
    }

    .site-title {
        font-size: 1.35rem;
    }

    .dropdown-menu {
        /* position and top come from the base rule (anchored to the header
           container); on small screens the menu spans the width */
        left: 1.5rem;
        right: 1.5rem;
        min-width: 0;
    }

    .hero h1 {
        font-size: 2.4rem;
    }

    .content-section {
        padding: 2.25rem 0;
    }

    .gallery-grid {
        /* auto-fit here too, tighter columns on small screens */
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1.25rem;
    }

    .page-card::before {
        font-size: 1.6rem;
    }

    .contact-form {
        padding: 1.9rem 1.3rem;
    }

    .lightbox-nav {
        width: 44px;
        height: 44px;
    }

    .lightbox-prev { left: 0.6rem; }
    .lightbox-next { right: 0.6rem; }

    .dark-mode-toggle {
        bottom: 1.1rem;
        right: 1.1rem;
        width: 44px;
        height: 44px;
    }

    .footer-content {
        gap: 1.75rem;
        padding: 2.5rem 0 1.75rem;
    }
}

/* Reduced motion: kill the sweep */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    .animate-on-scroll,
    .page-card,
    .gallery-item,
    .gallery-item > img,
    .gallery-item > picture,
    .gallery-item::after,
    .testimonial-card,
    .dark-mode-toggle {
        transition: none;
    }
}
