/* Sections that pages are built from. Colours come from the values in base.css. */

.section {
    padding-block: var(--space-8);
}

.section--surface {
    background: var(--color-surface);
}

/* Re-pointing the values makes everything inside work on a dark band. */
.section--dark {
    --color-text: var(--color-footer-text);
    --color-text-muted: var(--color-footer-muted);
    --color-border: var(--color-footer-border);
    --color-accent-text: var(--color-footer-accent);
    --color-focus: var(--color-footer-focus);

    background: var(--color-footer-bg);
    color: var(--color-footer-text);
}

.section__head {
    display: grid;
    gap: var(--space-2);
    max-width: 44rem;
    margin-bottom: var(--space-6);
}

.section__head:last-child {
    margin-bottom: 0;
}

.section__head + .button-row {
    margin-top: calc(var(--space-3) * -1);
}

.section__foot {
    margin-top: var(--space-6);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}

/* Text written in the admin: paragraphs, lists, links and line breaks. */
.rich-text {
    max-width: 70ch;
    font-size: var(--text-lg);
    overflow-wrap: anywhere;
}

.rich-text :is(ul, ol) {
    margin-block: 0;
    padding-inline-start: 1.25em;
}

.rich-text > :not(:first-child) {
    margin-top: var(--space-4);
}

.rich-text li + li {
    margin-top: var(--space-2);
}

.rich-text li::marker {
    color: var(--color-accent-text);
}


/* Home hero
   ========================================================================== */

.home-hero {
    --color-text: var(--color-hero-text);
    --color-bg: var(--color-footer-bg);
    --color-focus: var(--color-footer-focus);

    position: relative;
    isolation: isolate;
    display: flex;
    align-items: center;
    min-height: clamp(480px, calc(100svh - var(--header-height)), 760px);
    background: var(--color-footer-bg);
    color: var(--color-hero-text);
}

.home-hero__video {
    position: absolute;
    inset: 0;
    z-index: -2;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* On a phone the text fills the width, so the whole picture needs the fade. */
.home-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--hero-scrim-small);
}

@media (min-width: 768px) {
    .home-hero::after {
        background: var(--hero-scrim);
    }
}

.home-hero__inner {
    display: grid;
    justify-items: start;
    gap: var(--space-4);
    padding-block: var(--space-7);
}

.home-hero h1 {
    max-width: 16ch;
    font-size: clamp(2.5rem, 1.5rem + 4.4vw, 5rem);
}

.home-hero__inner .button-row {
    margin-top: var(--space-2);
}

.home-hero__toggle {
    position: absolute;
    right: var(--page-gutter);
    bottom: 1rem;
    min-height: 36px;
    padding: var(--space-1) var(--space-3);
    border: 1px solid var(--color-hero-text);
    border-radius: var(--radius-button);
    background: var(--color-hero-chip);
    color: var(--color-hero-text);
    font: inherit;
    font-size: var(--text-sm);
    cursor: pointer;
}


/* Type tiles
   ========================================================================== */

.type-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
    gap: var(--space-4);
}

.type-tile {
    display: block;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface-raised);
    color: var(--color-text);
    text-decoration: none;
}

.type-tile:hover {
    border-color: var(--card-hover-border);
}

.type-tile img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.type-tile__label {
    display: block;
    padding: var(--space-3);
    font-family: var(--font-heading);
    font-weight: var(--heading-weight);
    line-height: 1.2;
    letter-spacing: var(--heading-tracking);
    text-transform: var(--heading-transform);
}


/* Text cards
   ========================================================================== */

.text-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    gap: var(--space-5);
}

@media (min-width: 1024px) {
    .text-cards--threes {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.text-card {
    display: grid;
    align-content: start;
    gap: var(--space-2);
    padding: var(--space-5);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
}

.text-card__number {
    color: var(--color-accent-text);
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: var(--heading-weight);
    line-height: 1;
}

.text-card__icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: var(--space-2);
    border: 1px solid currentColor;
    border-radius: var(--radius-card);
    color: var(--color-accent-text);
}

.text-card__points {
    margin-top: var(--space-1);
    font-size: var(--text-sm);
}

.text-card__detail {
    color: var(--color-accent-text);
    font-size: var(--text-sm);
    font-weight: 600;
}

/* Cards that are only a line: on a phone the icon or number sits beside it, so a list of ten stays short. */
@media (max-width: 639.98px) {
    .text-cards--short {
        gap: var(--space-3);
    }

    .text-cards--short .text-card {
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
        gap: var(--space-4);
        padding: var(--space-4);
    }

    .text-cards--short .text-card__icon {
        width: 44px;
        height: 44px;
        margin-bottom: 0;
    }

    .text-cards--short h3 {
        font-size: var(--text-lg);
    }
}

/* A photo across the top of the card, to its edges. */
.text-card--photo {
    overflow: hidden;
}

.text-card__photo {
    width: calc(100% + var(--space-5) * 2);
    max-width: none;
    aspect-ratio: 16 / 10;
    margin: calc(var(--space-5) * -1) calc(var(--space-5) * -1) var(--space-3);
    object-fit: cover;
    background: var(--color-surface-raised);
}


/* Split: text beside a picture
   ========================================================================== */

.split {
    display: grid;
    gap: var(--space-6);
}

.split__lead {
    margin-block: var(--space-2) var(--space-3);
    font-weight: 600;
}

.split__media {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-card);
}

.split__media img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.split__media .play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.check-list {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-4) 0 0;
    padding: 0;
    list-style: none;
}

.check-list li {
    position: relative;
    padding-inline-start: var(--space-5);
}

.check-list li::before {
    content: "";
    position: absolute;
    top: 0.4em;
    left: 2px;
    width: 12px;
    height: 7px;
    border-bottom: 2px solid var(--color-accent-text);
    border-left: 2px solid var(--color-accent-text);
    transform: rotate(-45deg);
}

@media (min-width: 900px) {
    .split {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: center;
        gap: var(--space-8);
    }
}


/* Logo row
   ========================================================================== */

.logo-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
    gap: var(--space-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

.logo-row__item {
    display: grid;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    text-align: center;
}

/* Logos are made for white, so this stays white in both modes. */
.logo-row__logo {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 112px;
    padding: var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-media);
}

.logo-row__logo img {
    width: auto;
    max-height: 64px;
}


/* Play button and video popup
   ========================================================================== */

.play {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: var(--radius-play);
    background: var(--color-primary);
    color: var(--color-on-primary);
}

.play:hover {
    background: var(--color-primary-hover);
}

.video-dialog {
    width: min(100% - 2rem, 960px);
    padding: 0;
    overflow: visible;
    border: 0;
    background: var(--color-footer-bg);
}

.video-dialog::backdrop {
    background: rgb(0 0 0 / 0.8);
}

.video-dialog iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
}

.video-dialog__close {
    position: absolute;
    top: -48px;
    right: 0;
    width: 44px;
    height: 44px;
    border: 0;
    background: none;
    color: var(--color-hero-text);
    cursor: pointer;
}


/* Post card
   ========================================================================== */

.post-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface);
}

.post-card:hover {
    border-color: var(--card-hover-border);
}

.post-card:has(a:focus-visible) {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

.post-card img {
    width: 100%;
    aspect-ratio: 8 / 5;
    object-fit: cover;
}

.post-card__body {
    display: grid;
    gap: var(--space-2);
    padding: var(--space-5);
}

.post-card__date {
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}

.post-card h3 a {
    color: inherit;
    text-decoration: none;
}

/* Makes the whole card one link. */
.post-card h3 a::after {
    content: "";
    position: absolute;
    inset: 0;
}

.post-card h3 a:focus-visible {
    outline: none;
}

/* With details, on the blog pages: components/cards/post-card */

.post-card--details {
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.post-card--details:hover {
    box-shadow: var(--shadow-card-hover);
}

.post-card--details .post-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-2);
}

/* A brand's widest letter spacing would push a long topic onto two lines. */
.post-card__label {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-accent-text);
    font-family: var(--font-label);
    font-size: var(--text-sm);
    font-weight: 700;
    letter-spacing: min(var(--eyebrow-tracking), 0.12em);
    text-transform: uppercase;
}

.post-card__flag {
    padding: 2px var(--space-2);
    border-radius: var(--radius-badge);
    background: var(--color-primary);
    color: var(--color-on-primary);
    font-size: 0.75rem;
}

.post-card--details h3 {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.post-card__excerpt {
    display: -webkit-box;
    overflow: hidden;
    color: var(--color-text-muted);
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* The date sits at the foot, so it lines up across a row. */
.post-card--details .post-card__date {
    margin-top: auto;
    padding-top: var(--space-2);
}

/* The newest post, across the whole grid. */
.post-card--lead {
    grid-column: 1 / -1;
}

@media (min-width: 900px) {
    .post-card--lead {
        display: grid;
        grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    }

    .post-card--lead img {
        height: 100%;
        min-height: 320px;
        max-height: 480px;
        aspect-ratio: auto;
    }

    .post-card--lead .post-card__body {
        justify-content: center;
        gap: var(--space-3);
        padding: var(--space-7) var(--space-6);
    }

    .post-card--lead h3 {
        font-size: clamp(1.5rem, 1.1rem + 1vw, 2.25rem);
        -webkit-line-clamp: 4;
    }

    .post-card--lead .post-card__excerpt {
        font-size: var(--text-lg);
        -webkit-line-clamp: 4;
    }

    .post-card--lead .post-card__date {
        margin-top: var(--space-2);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .post-card--details img {
        transition: transform 0.3s;
    }

    .post-card--details:hover img {
        transform: scale(1.03);
    }
}


/* Photo viewer, from components/ui/lightbox
   ========================================================================== */

.lightbox {
    width: min(100% - 2rem, 1200px);
    max-height: calc(100dvh - 2rem);
    padding: 0;
    overflow: visible;
    border: 0;
    background: var(--color-media);
}

.lightbox::backdrop {
    background: rgb(0 0 0 / 0.85);
}

.lightbox img {
    width: 100%;
    max-height: calc(100dvh - 2rem);
    object-fit: contain;
}

.lightbox__button {
    position: absolute;
    top: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    border: 0;
    background: var(--color-footer-bg);
    color: var(--color-footer-text);
    cursor: pointer;
}

.lightbox__button--prev {
    left: var(--space-2);
}

.lightbox__button--next {
    right: var(--space-2);
}

.lightbox__button--close {
    top: var(--space-2);
    right: var(--space-2);
    margin-top: 0;
}

.lightbox__button[hidden] {
    display: none;
}

/* A picture in an article opens in the viewer. */
[data-lightbox-area] img:not(a img) {
    cursor: zoom-in;
}


/* Section bar: links to the parts of a long page, under the header
   ========================================================================== */

.section-nav {
    position: sticky;
    top: var(--header-height);
    z-index: 50;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.section-nav__inner {
    display: flex;
    gap: var(--space-5);
    overflow-x: auto;
    scrollbar-width: none;
}

.section-nav a {
    flex: none;
    padding-block: var(--space-3);
    border-bottom: 2px solid transparent;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    font-weight: 600;
    text-decoration: none;
}

.section-nav a[aria-current="true"] {
    border-bottom-color: var(--color-primary);
    color: var(--color-text);
}


/* Share links, from components/ui/share
   ========================================================================== */

.share-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.share-links__label {
    margin-inline-end: var(--space-1);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    font-weight: 600;
}


/* Video card, from components/cards/video-card
   ========================================================================== */

.video-card {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.video-card:hover {
    border-color: var(--card-hover-border);
    box-shadow: var(--shadow-card-hover);
}

.video-card:has(.play:focus-visible) {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

/* The still and the play button share one cell. */
.video-card__media {
    display: grid;
    place-items: center;
    overflow: hidden;
    background: #000000;
}

.video-card__media > * {
    grid-area: 1 / 1;
}

.video-card__media img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.video-card .play {
    z-index: 1;
    width: 60px;
    height: 60px;
}

/* The whole card plays the video. */
.video-card .play::after {
    content: "";
    position: absolute;
    inset: 0;
}

.video-card .play:focus-visible {
    outline: none;
}

.video-card:hover .play {
    background: var(--color-primary-hover);
}

.video-card__body {
    display: grid;
    align-content: start;
    gap: var(--space-1);
    padding: var(--space-4) var(--space-5) var(--space-5);
}

.video-card__label {
    color: var(--color-accent-text);
    font-family: var(--font-label);
    font-size: var(--text-sm);
    font-weight: 700;
    letter-spacing: min(var(--eyebrow-tracking), 0.12em);
    text-transform: uppercase;
}

.video-card__title {
    display: -webkit-box;
    overflow: hidden;
    font-size: var(--text-lg);
    line-height: 1.3;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

@media (prefers-reduced-motion: no-preference) {
    .video-card__media img {
        transition: transform 0.3s;
    }

    .video-card:hover .video-card__media img {
        transform: scale(1.03);
    }
}


/* Divider, from components/ui/divider
   ==========================================================================
   A line on the seam between two parts of a page. It takes no room: its box is
   pulled up and down by half its height, so it sits half over each side. A brand
   picks the style in its config (divider.style) and tunes it with the --divider-*
   values in base.css. */

.divider {
    /* The height the line and its glow have to work in. */
    --divider-room: 64px;

    position: relative;
    z-index: 3;
    height: var(--divider-room);
    margin-block: calc(var(--divider-room) / -2);
    overflow: hidden;
    pointer-events: none;
}

/* The parts lie along the track, which takes the tilt. */
.divider__track {
    position: absolute;
    top: 50%;
    right: 0;
    left: 0;
    height: 0;
    transform: rotate(var(--divider-tilt));
}

/* Mirrored, so a line that rises left to right falls instead. */
.divider--flip .divider__track {
    transform: scaleX(-1) rotate(var(--divider-tilt));
}

.divider__track > span {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    translate: 0 -50%;
}


/* Neon: a blade of light that hums, flickers now and then like a neon tube,
   and has a flash run along it. QJMotor's, after its old site. */

/* A wide, soft haze behind the line. */
.divider--neon .divider__track::before {
    content: "";
    position: absolute;
    right: 0;
    left: 0;
    height: calc(var(--divider-thickness) * 9);
    translate: 0 -50%;
    background: radial-gradient(60% 50% at 62% 50%, color-mix(in srgb, var(--divider-color) 38%, transparent), transparent 75%);
}

.divider--neon .divider__glow,
.divider--neon .divider__line {
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 90%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 12%, #000 90%, transparent);
}

/* A streak of light: widest just past the middle, drawn to a point at each end,
   with a white-hot core. */
.divider--neon .divider__line {
    height: var(--divider-thickness);
    background: linear-gradient(to bottom, var(--divider-color) 10%, color-mix(in srgb, var(--divider-color) 25%, #FFFFFF) 50%, var(--divider-color) 90%);
    clip-path: polygon(0 50%, 62% 0, 100% 50%, 62% 100%);
}

.divider--neon .divider__glow {
    height: calc(var(--divider-thickness) * 3);
    background: var(--divider-color);
    box-shadow: 0 0 calc(var(--divider-thickness) * 6) var(--divider-thickness) var(--divider-color);
    filter: blur(var(--divider-thickness));
    opacity: 0.75;
}

.divider--neon .divider__mark {
    right: auto;
    width: 18%;
    height: calc(var(--divider-thickness) + 1px);
    background: linear-gradient(90deg, transparent, #FFFFFF 50%, transparent);
    filter: blur(0.5px);
    opacity: 0;
}

@media (prefers-reduced-motion: no-preference) {
    .divider--neon .divider__glow {
        animation: divider-hum 3.2s ease-in-out infinite;
    }

    .divider--neon .divider__line {
        animation: divider-flicker 9s infinite;
    }

    .divider--neon .divider__mark {
        animation: divider-flash 6s cubic-bezier(0.45, 0, 0.2, 1) infinite;
    }
}

@keyframes divider-hum {
    0%,
    100% {
        opacity: 0.55;
    }

    50% {
        opacity: 0.95;
    }
}

/* Two quick dips near the end of each round, as a neon tube does. */
@keyframes divider-flicker {
    0%,
    87.9%,
    89%,
    90.4%,
    91.5%,
    100% {
        opacity: 1;
    }

    88% {
        opacity: 0.4;
    }

    90.5% {
        opacity: 0.2;
    }
}

/* Runs the length of the line, then rests. */
@keyframes divider-flash {
    0% {
        transform: translateX(-100%);
        opacity: 0;
    }

    8% {
        opacity: 1;
    }

    45% {
        transform: translateX(560%);
        opacity: 1;
    }

    50%,
    100% {
        transform: translateX(560%);
        opacity: 0;
    }
}


/* Ornament: a short line with a diamond at its centre. Moto Morini's old site had this. */

.divider--ornament {
    --divider-room: 24px;
}

.divider--ornament .divider__glow {
    display: none;
}

.divider--ornament .divider__line,
.divider--ornament .divider__mark {
    right: auto;
    left: 50%;
    translate: -50% -50%;
}

.divider--ornament .divider__line {
    width: min(240px, 60%);
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-accent-text) 20%, var(--divider-color) 50%, var(--color-accent-text) 80%, transparent);
}

.divider--ornament .divider__mark {
    width: 9px;
    height: 9px;
    background: var(--color-accent-text);
    rotate: 45deg;
}


/* Hairline: a thin line across with a short piece in the brand colour at the
   start of the page's text. Kove's old site had this. */

.divider--hairline {
    --divider-room: 2px;
}

.divider--hairline .divider__glow {
    display: none;
}

.divider--hairline .divider__line {
    height: 1px;
    background: var(--color-border);
}

.divider--hairline .divider__mark {
    right: auto;
    left: var(--page-edge);
    width: 120px;
    height: 2px;
    background: var(--divider-color);
}
