/* ===== LAYOUTS/GALLERY.CSS ===== */
/* Photo gallery layouts: grids, feed, circuits, car pages, photo detail */

/* Gallery Grid */
.gallery-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

.gallery-grid-1 {
    grid-template-columns: 1fr;
}

.gallery-grid-2 {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.gallery-grid-3 {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* Gallery Feed Post */
.gallery-feed-post {
    margin-bottom: 32px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
}

.gallery-feed-post:last-child {
    border-bottom: none;
}

.feed-post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.feed-post-date {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.feed-post-location {
    font-size: 11px;
    color: var(--text-muted);
}

.feed-post-caption {
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Daily snaps */
.gallery-daily-list {
    display: grid;
    gap: 18px;
}

.gallery-daily-entry {
    display: grid;
    grid-template-columns: minmax(260px, 48%) minmax(0, 1fr);
    gap: 18px;
    align-items: stretch;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.gallery-daily-entry:last-child {
    border-bottom: none;
}

.gallery-daily-copy {
    display: grid;
    align-content: center;
    gap: 10px;
    min-width: 0;
}

.gallery-daily-copy h2 {
    margin: 0;
    font-size: clamp(18px, 3vw, 30px);
    line-height: 1.12;
    letter-spacing: 0;
    text-transform: none;
}

.gallery-daily-copy h2::before,
.gallery-daily-copy h2::after {
    display: none;
}

.gallery-daily-date,
.gallery-daily-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.gallery-daily-date {
    font-size: clamp(16px, 2.4vw, 24px);
    line-height: 1.1;
    color: var(--text-primary);
    letter-spacing: 0;
    text-transform: none;
}

.gallery-daily-location {
    font-size: 11px;
    color: var(--text-muted);
}

.gallery-daily-copy p {
    max-width: 72ch;
    margin: 0;
    font-size: clamp(14px, 1.6vw, 18px);
    line-height: 1.6;
    color: var(--text-secondary);
}

.gallery-daily-cover {
    margin: 0;
    overflow: hidden;
    background: var(--bg-primary);
}

.gallery-daily-cover a {
    display: block;
    height: 100%;
}

.gallery-daily-cover img {
    display: block;
    width: 100%;
    height: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
}

.gallery-daily-empty-preview {
    min-height: 180px;
}

.gallery-daily-entry-description {
    max-width: 78ch;
    margin: 0 0 24px;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-secondary);
}

.gallery-daily-entry-photos {
    display: grid;
    gap: 28px;
}

.gallery-daily-entry-row {
    display: grid;
    gap: 28px;
    width: min(150%, calc(100vw - 48px));
    margin: 0 0 0 50%;
    transform: translateX(-50%);
}

.gallery-daily-entry-row-portrait-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.gallery-daily-entry-row-portrait-single {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.gallery-daily-entry-row-portrait-single .gallery-daily-entry-photo {
    grid-column: 1;
}

.gallery-daily-entry-photo {
    margin: 0;
    display: grid;
    gap: 0;
    padding: clamp(10px, 1vw, 16px);
    background: #fff;
}

.gallery-daily-entry-photo a {
    display: block;
    background: #fff;
}

.gallery-daily-entry-photo img {
    display: block;
    width: 100%;
    height: auto;
    border: none;
}

.gallery-daily-entry-photo figcaption {
    max-width: 78ch;
    margin: clamp(10px, 1vw, 16px) 0 0;
    padding-bottom: clamp(8px, 1vw, 16px);
    font-size: 13px;
    line-height: 1.6;
    color: #222;
}

.gallery-daily-entry-photo.has-caption {
    padding-bottom: clamp(18px, 2vw, 32px);
}

/* Gallery Photo */
.gallery-photo {
    position: relative;
    overflow: hidden;
}

.gallery-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    cursor: pointer;
}

.gallery-photo img:hover {
    opacity: 0.9;
}

.gallery-photo-placeholder {
    background: linear-gradient(
        135deg,
        var(--bg-primary) 0%,
        color-mix(in srgb, var(--accent) 4%, var(--bg-primary)) 100%
    );
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    font-size: 9px;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    padding: 8px;
    word-break: break-all;
    text-align: center;
}

/* Cars category sections */
.gallery-cars-section {
    margin-bottom: 32px;
}

.gallery-cars-section:last-child {
    margin-bottom: 0;
}

.gallery-section-heading {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 4px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.gallery-section-heading::before,
.gallery-section-heading::after {
    display: none;
}

.gallery-section-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0 0 12px 0;
}

.page-gallery-cars .gallery-section-heading {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    margin-bottom: 6px;
    padding-bottom: 0;
    border-bottom: none;
    border: none;
    background: none;
    padding: 0;
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
}

.page-gallery-cars .gallery-section-desc {
    max-width: 60ch;
    font-size: 11px;
    line-height: 1.6;
    margin-bottom: 14px;
    margin-top: 0;
}

/* Circuit Profile Page */
.circuit-photo {
    margin-bottom: 24px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.circuit-photo-img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    display: block;
}

.circuit-profile {
    margin-top: 8px;
}

.circuit-hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
}

.circuit-track-display {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    padding: 24px;
    min-height: 260px;
}

.circuit-track-img {
    max-width: 100%;
    max-height: 240px;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: var(--svg-invert, none);
    border: none;
    margin: 0;
}

.circuit-track-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.circuit-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
}

.circuit-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
    text-transform: none;
}

.circuit-name::before,
.circuit-name::after {
    display: none;
}

.circuit-location {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.circuit-specs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    border: 1px solid var(--border);
}

.circuit-spec {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    background: var(--bg-primary);
}

.spec-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.spec-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.circuit-description {
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin: 4px 0 0;
}

.circuit-albums {
    margin-top: 0;
}

.circuit-albums .gallery-section-heading {
    margin-bottom: 12px;
}

/* Photo Detail Page */
.photo-detail {
    width: min(96vw, 1480px);
    margin: 0 auto;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
}

.photo-shell {
    display: grid;
    gap: 18px;
}

.photo-stage {
    margin: 0;
    display: grid;
    gap: 12px;
    justify-items: center;
}

.photo-stage #img {
    scroll-margin-top: clamp(72px, 10vh, 128px);
}

.photo-detail-link {
    display: inline-block;
    width: min(100%, calc((100vh - 240px) * var(--photo-aspect, 1)));
    width: min(100%, calc((100dvh - 240px) * var(--photo-aspect, 1)));
    max-width: 100%;
    aspect-ratio: var(--photo-width, 1) / var(--photo-height, 1);
}

.photo-detail-img {
    width: 100%;
    height: auto;
    max-width: 100%;
    display: block;
    border: clamp(10px, 1vw, 16px) solid #fff;
    margin: 0;
    image-orientation: from-image;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #fff;
    box-sizing: border-box;
}

.photo-stage-caption {
    max-width: min(72ch, 100%);
    margin: 0;
    text-align: center;
    color: var(--text-muted);
    line-height: 1.6;
}

.photo-meta-card {
    padding: 14px 16px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-secondary) 65%, transparent);
}

.photo-stage-placeholder {
    width: min(100%, 1200px);
}

.photo-info {
    margin-top: 0;
}

.photo-detail-description {
    margin-bottom: 16px;
    max-width: 72ch;
}

.photo-detail-description p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

.photo-exif {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 28px;
    margin: 0;
    padding: 0;
}

.photo-exif-row {
    display: flex;
    gap: 8px;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}

.photo-exif dt {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    min-width: 60px;
    margin: 0;
}

.photo-exif dd {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}

/* Car Profile */
.car-profile {
    display: grid;
    grid-template-columns: minmax(220px, 420px) minmax(0, 1fr);
    gap: 18px;
    padding: 16px;
    border: 1px solid var(--border);
    background: linear-gradient(
        180deg,
        color-mix(in srgb, var(--accent) 8%, var(--bg-secondary)) 0%,
        color-mix(in srgb, var(--bg-secondary) 72%, transparent) 100%
    );
    margin-bottom: 20px;
}

.car-profile-media {
    min-width: 0;
}

.car-profile-media img {
    width: 100%;
    height: 100%;
    max-height: 320px;
    object-fit: cover;
    display: block;
    border: 1px solid var(--border);
}

.car-profile-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
    min-width: 0;
}

.car-profile-kicker {
    font-size: 10px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.car-profile-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px 20px;
    border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
    background: color-mix(in srgb, var(--bg-secondary) 76%, transparent);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--accent) 8%, transparent);
}

.car-profile-title {
    margin: 0;
    font-size: clamp(1.65rem, 2.8vw, 2.35rem);
    color: var(--text-primary);
    text-transform: none;
    letter-spacing: 0.02em;
    line-height: 1.05;
}

.car-profile-title::before,
.car-profile-title::after {
    display: none;
}

.car-profile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.car-profile-meta span {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 2px 8px;
    border: 1px solid var(--border);
}

.car-profile-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.car-profile-stats span {
    font-size: 10px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 9px;
    border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
    background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.car-profile-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.car-profile-notes {
    margin: 0;
    color: var(--text-secondary);
    max-width: 64ch;
}

/* Car Events */
.car-events {
    margin-bottom: 22px;
}

.car-events-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.car-events-copy {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 12px;
}

.car-events-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.car-event-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg-secondary) 62%, transparent);
    text-decoration: none;
}

.car-event-card:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, var(--bg-secondary));
    text-decoration: none;
}

.car-event-index {
    align-self: start;
    min-width: 34px;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.car-event-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.car-event-title {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
}

.car-event-meta {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.car-event-arrow {
    color: var(--text-muted);
    font-size: 14px;
}

/* Gallery car photo (compact) */
.gallery-car-photo {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
}

.gallery-car-photo-link {
    display: block;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--bg-primary);
}

.gallery-car-photo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.gallery-car-photo-meta {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding-right: 6px;
}

.gallery-car-photo-album {
    color: var(--text-primary);
    font-size: 12px;
    text-decoration: none;
}

.gallery-car-photo-album:hover {
    color: var(--accent);
}

.gallery-car-grid {
    align-items: start;
}

/* Responsive */
@media (max-width: 600px) {
    .gallery-grid-2 {
        grid-template-columns: 1fr;
    }

    .gallery-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .gallery-daily-entry {
        grid-template-columns: 1fr;
    }

    .gallery-daily-cover img {
        aspect-ratio: 16 / 9;
    }

    .gallery-daily-entry-row,
    .gallery-daily-entry-row-portrait-pair,
    .gallery-daily-entry-row-portrait-single {
        width: 100%;
        margin-left: 0;
        transform: none;
        grid-template-columns: 1fr;
    }

    .gallery-daily-entry-row-portrait-single .gallery-daily-entry-photo {
        grid-column: auto;
    }

    .circuit-photo-img {
        height: 180px;
    }

    .circuit-hero {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .circuit-track-display {
        min-height: 180px;
        padding: 16px;
    }

    .circuit-name {
        font-size: 16px;
    }

    .circuit-specs {
        grid-template-columns: 1fr 1fr;
    }

    .photo-detail {
        width: min(100%, calc(100vw - 16px));
    }

    .photo-shell {
        gap: 14px;
    }

    .photo-exif {
        grid-template-columns: 1fr;
    }

    .photo-detail-img {
        max-height: none;
    }

    .photo-detail-link {
        width: min(100%, calc((100vh - 280px) * var(--photo-aspect, 1)));
        width: min(100%, calc((100dvh - 280px) * var(--photo-aspect, 1)));
    }

    .car-profile {
        grid-template-columns: 1fr;
    }

    .car-profile-media img {
        max-height: 220px;
    }

    .car-events-header {
        align-items: start;
    }

    .car-event-card {
        grid-template-columns: 1fr;
    }

    .car-event-arrow,
    .car-event-index {
        display: none;
    }
}
