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

:root {
    --bg:       #0a0a0a;
    --surface:  #141414;
    --border:   #252525;
    --text:     #e0e0e0;
    --muted:    #777;
    --accent:   #1a6b3c;   /* overridden per site via inline style in layout.php */
    --radius:   6px;
    --thumb-w:  360px;     /* min tile width — auto-fill respects this */
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Headings (SEO H1/H2) ──
   Browser-default <h1>/<h2> sizing crowded the cards on home + performer
   + recording pages after the 2026-05-09 SEO header pass. Tighter rules:
   slightly smaller than default, lighter weight than default's 700. */
h1, h2, h3 {
    font-family: system-ui, -apple-system, sans-serif;
    font-weight: 500;
    line-height: 1.3;
}
h1 { font-size: 1.4rem;  margin: 0.5rem 0 1rem;  }
h2 { font-size: 1.15rem; margin: 0.4rem 0 0.6rem; }
h3 { font-size: 1rem;    margin: 0.3rem 0 0.5rem; }
.page-title       { text-align: center; margin: 0.75rem auto 1.5rem; }
.recording-title  { font-weight: 500; }

/* ── Header ── */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-inner {
    max-width: 1800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.logo {
    color: var(--accent);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    transition: opacity 0.15s;
}
.logo:hover { text-decoration: none; opacity: 0.85; }
.site-logo  { display: block; height: 30px; width: auto; }

/* ── Search ── */
.search-form {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    max-width: 480px;
}
.search-wrap {
    position: relative;
    flex: 1;
}
.search-form input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.45rem 0.75rem;
    font-size: 0.95rem;
}
.search-form input:focus { outline: none; border-color: var(--accent); }
.search-form button {
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    padding: 0.45rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
}
.search-form button:hover { filter: brightness(1.15); }

/* ── Suggest dropdown ── */
.suggest-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    list-style: none;
    max-height: 320px;
    overflow-y: auto;
    z-index: 200;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}
.suggest-dropdown li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.9rem;
    cursor: pointer;
}
.suggest-dropdown li:hover,
.suggest-dropdown li.active { background: var(--border); }
.suggest-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.suggest-name { color: var(--text); flex: 1; }
.suggest-count { color: var(--muted); font-size: 0.82rem; flex-shrink: 0; }

/* ── Main ──
   Native cga_images are 2132×1274 (~4.35M of the 12-month subset). 2150px
   gives the single-image recording page native-size display, and 2-col
   grid cards land at ~1055px each (~50% of native). */
main {
    flex: 1;
    max-width: 2150px;
    width: 100%;
    margin: 0 auto;
    padding: 1rem 0.75rem;
}

main:has(.recording-page) {
    max-width: 2150px;
}

/* ── Image grid — 2-wide on desktop, expands cards with viewport ── */
/* Cross-alias merge toggle (performer pages). Pill, centred above the grid —
   same placement ultron uses. */
.alias-toggle { margin: 0 0 16px; text-align: center; }
.alias-toggle a {
    display: inline-block;
    padding: 10px 18px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}
.alias-toggle a:hover { border-color: var(--accent); color: var(--accent); }

.image-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* ── Image card ── */
.image-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}
.card-image-link { display: block; }
/* Same treatment as .tile-img above -- see the note there. This is the
   performer page's grid; leaving it uncontained would make newsites show two
   different card behaviours. */
.card-image-link img,
.card-image-link video {
    width: 100%;
    height: auto;
    aspect-ratio: 511 / 292;
    object-fit: contain;
    background: var(--bg);
    display: block;
}
.card-info {
    padding: 0.6rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 0.75rem;
    font-size: 0.85rem;
    color: var(--muted);
}
.card-performer { color: var(--accent); font-weight: 500; }
.card-date, .card-platform, .card-gender { color: var(--muted); }
.card-download {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.download-btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius);
    text-decoration: none;
    white-space: nowrap;
    transition: filter 0.15s;
}
.download-btn:hover { filter: brightness(1.2); text-decoration: none; }
.short-url {
    font-size: 0.8rem;
    color: var(--muted);
    font-family: monospace;
    word-break: break-all;
}

/* ── Home performer grid — 2-wide on desktop ── */
.performer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.performer-tile {
    display: block;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    color: var(--text);
    transition: border-color 0.15s;
}
.performer-tile:hover { border-color: var(--accent); text-decoration: none; }
.tile-img { display: block; }

/* Collage geometry. Cache::collageDims() derives the contact-sheet HEIGHT from
   the SOURCE VIDEO's aspect ratio -- 4 rows for landscape, 2 for portrait -- so
   the width is always 2044 but the height is not. Measured on die.bz home
   2026-09-08: 90 cards at 2044x1168, 26 at 1370, 3 at 1544, 3 at 1814. With
   `height: auto` the grid faithfully reproduced all of that and every row came
   out ragged.
   Pin the box to the dominant 2044x1168 and CONTAIN rather than cover: uniform
   card heights with no cropping, so a taller contact sheet letterboxes instead
   of losing its bottom row(s). The bars use --bg so they read as part of the
   media area rather than a hole in the card.
   MUST apply to <video> as well as <img>: preview.js swaps the two on hover,
   and a video without the same box would resize the card mid-hover. */
.tile-img img,
.tile-img video {
    width: 100%;
    height: auto;
    aspect-ratio: 511 / 292;   /* 2044x1168, the dominant collage */
    object-fit: contain;
    background: var(--bg);
    display: block;
}
.tile-info {
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.tile-name { font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meta { font-size: 0.78rem; color: var(--muted); }

/* ── "You might also like" tiles on recording page ── */
.you-might-like { margin-top: 2.5rem; }
.you-might-like h2 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
    color: var(--muted);
}
/* Denser grid than the home 2-wide — fits 16 tiles in 4 rows × 4 cols
   on desktop, collapses to 2 cols on narrow viewports. */
.you-might-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.6rem;
}

/* ── Performer page ── */
.performer-header {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.performer-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--border);
}
.performer-header-info h1 { font-size: 1.5rem; margin-bottom: 0.4rem; }
.performer-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 1rem;
    font-size: 0.85rem;
    color: var(--muted);
}

/* ── Recording page ── */
.recording-page { display: flex; flex-direction: column; gap: 0.75rem; }
.recording-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    font-size: 0.9rem;
}
.meta-performer { font-weight: 600; color: var(--accent); }
.meta-date, .meta-platform, .meta-gender { color: var(--muted); }

/* Spec panel — same rules as fastimages/stripcams so the three read alike. */
.meta-list { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; margin-top: 0.65rem; }
.meta-list dt { color: var(--muted); font-size: 0.85rem; margin-right: 0.3rem; }
.meta-list dt::after { content: ':'; }
.meta-list dd { font-size: 0.9rem; margin-right: 0.5rem; }
.recording-image img,
.recording-image video { max-width: 100%; height: auto; border-radius: var(--radius); display: block; }

/* ── Pagination ── */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 2rem;
    justify-content: center;
}
.pagination a,
.pagination .ellipsis,
.pagination .dots,
.pagination .current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.6rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.9rem;
    background: var(--surface);
}
.pagination a:hover { border-color: var(--accent); text-decoration: none; }
.pagination .current,
.pagination a.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .ellipsis,
.pagination .dots     { border: none; background: none; color: var(--muted); }
.pagination .prev, .pagination .next { padding: 0 0.9rem; }
.pagination .page-jump {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--muted);
    border: none;
    background: none;
    padding: 0 0.5rem;
    font-size: 0.85rem;
}
.pagination .page-jump input {
    width: 64px;
    padding: 4px 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    text-align: center;
    background: var(--surface);
    color: var(--text);
}
.pagination .page-jump input:focus { outline: none; border-color: var(--accent); }

/* ── Search ── */
.search-page h1 { font-size: 1.4rem; margin-bottom: 1rem; }
.result-count { color: var(--muted); margin-bottom: 0.75rem; font-size: 0.9rem; }
.no-results { color: var(--muted); }
.performer-list { list-style: none; }
.performer-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}
.result-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.performer-list .count { color: var(--muted); font-size: 0.82rem; margin-left: auto; flex-shrink: 0; }
.performer-list .platform { color: var(--muted); font-size: 0.82rem; flex-shrink: 0; }

/* ── 404 ── */
.error-page { text-align: center; padding: 4rem 1rem; }
.error-page h1 { font-size: 2.5rem; margin-bottom: 1rem; }

/* ── Footer ── */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    :root { --thumb-w: 220px; }
    main { padding: 0.75rem; }
    .performer-header { flex-direction: column; }
    /* Single-column home grid on mobile — only the first tile is above
       the fold, so the fetchpriority="high" on tile 1 cleanly maps to the
       LCP element. With 2 columns at this width Lighthouse sometimes
       picked tile 2 as LCP based on paint-completion timing. */
    .performer-grid { grid-template-columns: 1fr; }
}

/* ── Back-to-top floating button ── */
/* ── Back to top ──
   A full-width ACCENT bar that slides down from behind the top edge once
   scrolled. Modelled on ultron's control, and deliberately loud.
   
   The first version of this was a 44px circular button in the bottom-right
   corner. It worked correctly and went unnoticed; the second was a bar in
   --surface, which was still too quiet against a dark page. An affordance that
   has to be hunted for has failed even when it functions, so this uses the same
   accent-on-white treatment as .download-btn -- the app's existing
   primary-action styling -- rather than inventing a third, subtler one.

   transform rather than margin so the slide is composited, not a layout pass. */
.backtotop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: 0.85rem 0;
    text-align: center;
    background: var(--accent);
    color: var(--on-accent, #fff);
    border: 0;
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-decoration: none;
    cursor: pointer;
    z-index: 200;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}
.backtotop:hover { filter: brightness(1.12); text-decoration: none; color: var(--on-accent, #fff); }
.backtotop:focus-visible { outline: 2px solid var(--on-accent, #fff); outline-offset: -4px; }
.backtotop.active { transform: translateY(0); }
@media (prefers-reduced-motion: reduce) { .backtotop { transition: none; } }

@media (max-width: 768px) {
    .backtotop { padding: 0.7rem 0; font-size: 0.9rem; }
}

/* ── Category nav (#229) — platform buttons + gender hover-dropdowns ── */
.cat-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.cat-nav-list {
    list-style: none;
    margin: 0;
    padding: 0 1rem;
    max-width: 1280px;
    margin-inline: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}
.cat-item { position: relative; }
.cat-link {
    display: block;
    padding: 0.6rem 0.9rem;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    border-bottom: 2px solid transparent;
}
.cat-item:hover > .cat-link { color: var(--accent); border-bottom-color: var(--accent); }
.cat-dropdown {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 160px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 150;
}
.cat-item:hover > .cat-dropdown,
.cat-item:focus-within > .cat-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.cat-dropdown a {
    display: block;
    padding: 0.5rem 0.9rem;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
}
.cat-dropdown a:hover { background: var(--border); color: var(--accent); }

/* Breadcrumb (category pages) */
.breadcrumb {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

@media (max-width: 768px) {
    .cat-nav-list { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    /* Touch: dropdowns expand on tap via :focus-within (link is focusable). */
    .cat-dropdown { position: static; opacity: 1; visibility: visible; transform: none;
                    box-shadow: none; border: 0; min-width: 0; display: none; }
    .cat-item:focus-within > .cat-dropdown { display: block; }
}


/* ── Locale switcher ──
   HOVER dropdown, matching .cat-item/.cat-dropdown beside it rather than a
   click toggle. Lives in the SHARED header so the site and the landing both
   get it. Endonyms only — a flag is a country, not a language. */
.langsel { position: relative; margin-left: auto; flex-shrink: 0; }
.langsel-btn {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--bg); color: var(--muted);
    padding: 0.4rem 0.7rem; font-size: 0.85rem; white-space: nowrap;
}
.langsel:hover > .langsel-btn,
.langsel:focus-within > .langsel-btn { border-color: var(--accent); color: var(--text); }
.langsel-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.langsel-caret { font-size: 10px; opacity: .8; transition: transform .12s ease; }
.langsel:hover .langsel-caret,
.langsel:focus-within .langsel-caret { transform: rotate(180deg); }
.langsel-menu {
    display: none;
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 200;
    margin: 0; padding: 0.35rem; list-style: none; min-width: 170px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius);
}
/* The 6px gap above would drop the hover on the way down, so the menu is
   padded into it with a transparent bridge rather than sitting flush. */
.langsel-menu::before { content: ""; position: absolute; left: 0; right: 0; top: -8px; height: 8px; }
.langsel:hover > .langsel-menu,
.langsel:focus-within > .langsel-menu { display: block; }
.langsel-menu li { margin: 0; }
.langsel-menu a { display: block; padding: 0.45rem 0.6rem; border-radius: var(--radius); font-size: 0.9rem; }
.langsel-menu a:hover { background: var(--bg); color: var(--accent); text-decoration: none; }
.langsel-menu a[aria-current="true"] { color: var(--accent); font-weight: 600; }

@media (max-width: 640px) {
    .langsel { margin-left: 0; }
    .langsel-menu { right: auto; left: 0; }
}
@media (prefers-reduced-motion: reduce) { .langsel-caret { transition: none; } }
