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

:root {
    --bg:       #0f0f0f;
    --surface:  #1a1a1a;
    --border:   #2d2d2d;
    --text:     #e0e0e0;
    --muted:    #888;
    --accent:   #d4006b;
    --radius:   6px;
    --thumb-w:  320px;
    --thumb-h:  240px;
}

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 + gallery
   + image pages after the 2026-05-09 SEO header pass. Tighter rules:
   slightly smaller than default, lighter weight than default's 700.
   Existing .gallery-header h1 (1.5rem) further down overrides for that
   one specific page. */
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; }
.image-meta h1 { font-size: 1.3rem; }

/* ── 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: 1400px;
    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 {
    position: relative;
    flex: 1;
    max-width: 480px;
    display: flex;
    gap: 0.5rem;
}
.search-form input {
    flex: 1;
    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); }

/* ── Suggester 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.5);
}
.suggest-dropdown li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.55rem 0.9rem;
    cursor: pointer;
    gap: 1rem;
}
.suggest-dropdown li:hover,
.suggest-dropdown li.active { background: var(--border); }
.suggest-name { color: var(--text); }
.suggest-count { color: var(--muted); font-size: 0.85rem; flex-shrink: 0; }

/* ── Main ── */
main {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ── Image grid ── */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--thumb-w), 1fr));
    gap: 8px;
}
.image-card {
    display: block;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 4/3;
}
.image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.2s;
}
.image-card:hover img { opacity: 0.85; }
[data-slideshow] video {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Gallery header ── */
.gallery-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.gallery-header h1 { font-size: 1.5rem; }
.gallery-count { color: var(--muted); font-size: 0.9rem; }

/* ── Pagination ── */
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 2rem;
    justify-content: center;
}
.pagination a, .pagination .ellipsis {
    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 a.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.pagination .prev, .pagination .next { padding: 0 0.9rem; }
.pagination .ellipsis { border: none; background: none; color: var(--muted); }

/* ── Individual image page ── */
main:has(.image-page) {
    /* Native cga_images are 2132×1274; 2150px lets the single-image
       view display close to native size on wide monitors. */
    max-width: 2150px;
    padding: 0.75rem;
}

.image-page {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.image-meta h1 { font-size: 1.25rem; margin-bottom: 0.75rem; word-break: break-word; }
.image-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}
.download-btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.25;
    padding: 0.6rem 1.4rem;
    /* Transparent 1px border so the outlined secondary buttons below sit
       exactly level with this one in .image-meta-row's flex row -- without it
       they are 2px taller and the row reads crooked. */
    border: 1px solid transparent;
    border-radius: var(--radius);
    text-decoration: none;
    transition: filter 0.15s;
    white-space: nowrap;
}
.download-btn:hover { filter: brightness(1.2); text-decoration: none; }
.download-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ── Secondary button ──
   The alias toggle and the "view all previews" gallery link were bare <a>s in
   a <p>, so they rendered as running text next to a filled Download button.
   Same metrics as .download-btn so they sit level; OUTLINED rather than filled
   so the primary action on the page stays visually dominant. Matches the rule
   set newsites already ships (playbook #15 -- the estate is the reference
   implementation), adapted to fastimages' tokens. */
.alias-toggle a,
.performer-link a {
    display: inline-block;
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.25;
    padding: 0.6rem 1.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.alias-toggle a:hover,
.performer-link a:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}
.alias-toggle a:focus-visible,
.performer-link a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
/* Not nowrap: both labels are long sentences and would overflow a phone. */
.alias-toggle { margin: 0 0 1.25rem; }
.performer-link { margin: 0; }
.meta-list { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; }
.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; }
.image-wrap img { max-width: 100%; height: auto; border-radius: var(--radius); display: block; }

/* ── Search page ── */
.search-page h1 { font-size: 1.4rem; margin-bottom: 1.25rem; }
.result-count { color: var(--muted); margin-bottom: 1rem; }
.no-results { color: var(--muted); }
.performer-list { list-style: none; }
.performer-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}
.performer-list .count { color: var(--muted); font-size: 0.85rem; flex-shrink: 0; }

/* ── Home page ── */
.home-search-bar {
    display: flex;
    justify-content: center;
    padding: 1.5rem 0 2rem;
}
.home-search-bar .search-form {
    max-width: 520px;
    width: 100%;
}

.browse-section { padding-bottom: 3rem; }
.browse-heading {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1.25rem;
}

.performer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--thumb-w), 1fr));
    gap: 8px;
}
.performer-tile {
    display: block;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    transition: opacity 0.2s;
}
.performer-tile:hover { opacity: 0.85; text-decoration: none; }
.performer-tile-img {
    aspect-ratio: 4/3;
    overflow: hidden;
}
.performer-tile-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.performer-tile-info {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    border-top: 1px solid var(--border);
}
.performer-tile-name {
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.performer-tile-count {
    color: var(--muted);
    font-size: 0.78rem;
    flex-shrink: 0;
}

/* ── "You might also like" section (single-image 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;
}

/* ── 404 ── */
.error-page { text-align: center; padding: 4rem 1rem; }
.error-page h1 { font-size: 2rem; 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) {
    .image-page { grid-template-columns: 1fr; }
    .image-grid { --thumb-w: 160px; }
    main { padding: 1rem; }
}

/* ── Category nav ──────────────────────────────────────────────────────────
   Ported verbatim from bwv, whose class names and behaviour in turn match
   stripcams' render_category_nav, so the four apps stay visually consistent.
   fastimages already defines every variable it uses (--surface, --border,
   --text, --accent, --radius), so nothing needed remapping. */
.cat-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.cat-nav-inner {
    /* 1.5rem side padding, not 12px: it puts the first button on the same left
       edge as <main>'s content, which is max-width:1400px + padding:1.5rem.
       At 12px the nav sat 12px inboard of the page content and read as ragged. */
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 1.5rem;
}
.cat-item { position: relative; }
.cat-btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}
.cat-item:hover > .cat-btn,
.cat-btn:hover,
.cat-btn.active { background: var(--accent); color: #fff; }
.cat-caret { font-size: 10px; opacity: .8; }
.cat-drop {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 170px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    /* Above the sticky header (z-index:100) -- otherwise a dropdown opened
       after scrolling renders behind it. */
    z-index: 120;
}
.cat-item:hover .cat-drop,
.cat-item:focus-within .cat-drop { display: block; }
.cat-drop a {
    display: block;
    padding: 7px 12px;
    border-radius: 4px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
}
.cat-drop a:hover,
.cat-drop a.active { background: var(--accent); color: #fff; }

/* ── Category grid: performer cards ────────────────────────────────────────
   Separate from .image-card on purpose. That class is aspect-ratio:4/3 with
   overflow:hidden and an img at height:100%, which is right for a pure image
   tile but clips any caption. A performer card needs a thumbnail AND a name,
   so the ratio lives on the thumbnail wrapper and the card itself grows to fit
   its text. */
.perf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--thumb-w), 1fr));
    gap: 8px;
}
.perf-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
}
.perf-thumb {
    display: block;
    aspect-ratio: 4/3;
    overflow: hidden;
}
.perf-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity .2s;
}
.perf-card:hover .perf-thumb img { opacity: .85; }
.perf-name {
    display: block;
    padding: 7px 9px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.perf-meta {
    display: block;
    padding: 1px 9px 8px;
    font-size: 12px;
    color: var(--muted);
}

/* ── 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; } }


/* ── Locale switcher ──
   Lives in the SHARED header, so the site and the landing both get it the
   moment a second locale goes live. <details>, so no JavaScript. Endonyms
   only — a flag is a country, not a language. */
.langsel { position: relative; margin-left: auto; flex-shrink: 0; }
.langsel > summary {
    list-style: none; 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 > summary::-webkit-details-marker { display: none; }
.langsel > summary:hover { border-color: var(--accent); color: var(--text); }
.langsel ul {
    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);
}
.langsel li a { display: block; padding: 0.45rem 0.6rem; border-radius: var(--radius); font-size: 0.9rem; }
.langsel li a:hover { background: var(--bg); color: var(--accent); text-decoration: none; }
.langsel li a[aria-current="true"] { color: var(--accent); font-weight: 600; }
