/* buttdb theme: applied to the built pages by theme.py.
 *
 * Every selector is prefixed with .bdb (the class theme.py puts on <body>) so it
 * outranks the generator's own <style> blocks, including the category panel's,
 * which sits later in the document than this file's <link>.
 *
 * Children of <body> are centred by `.bdb > :not(.topbar)`, which sets only the
 * left/right margins; everything below sets margin-top/-bottom and never the
 * `margin` shorthand, or it would undo the centring.
 */
:root {
    --bg: #0b0a10;
    --panel: #13121a;
    --raise: #1c1a25;
    --hover: #231f2e;
    --line: #29253a;
    --text: #f2eff7;
    --muted: #a19bb0;
    --dim: #726c82;
    --a1: #ff9a62;
    --a2: #ff3d7f;
    --grad: linear-gradient(135deg, var(--a1), var(--a2));
    --glow: rgba(255, 61, 127, 0.55);
    --display: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color-scheme: dark;
}

/* Base rules the generator's own <style> gives the home page but a category
   page (pages.py) does not have; stated here so every page is self-sufficient. */
.bdb *, .bdb *::before, .bdb *::after { box-sizing: border-box; }
.bdb button {
    border: none;
    color: #fff;
    cursor: pointer;
    font-family: inherit;
    touch-action: manipulation;
}
.bdb .controls { display: flex; gap: 10px; flex-wrap: wrap; }
.bdb .url-card { display: flex; flex-direction: column; }
.bdb .url-actions { display: flex; gap: 8px; flex-wrap: wrap; }

body.bdb {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0 16px 40px;
    background:
        radial-gradient(1100px 520px at 50% -180px, rgba(255, 61, 127, 0.17), transparent 70%) no-repeat,
        radial-gradient(700px 380px at 85% 0, rgba(255, 154, 98, 0.08), transparent 70%) no-repeat,
        var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}
.bdb > :not(.topbar) { max-width: 1180px; margin-left: auto; margin-right: auto; }
.bdb ::selection { background: rgba(255, 61, 127, 0.35); }
.bdb a { color: inherit; }
.bdb button:focus-visible, .bdb a:focus-visible, .bdb .cat-opt:focus-visible {
    outline: 2px solid var(--a1);
    outline-offset: 2px;
}
.bdb .grad {
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* ---- top bar ------------------------------------------------------------ */
.bdb .topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    margin: 0 -16px;
    background: rgba(11, 10, 16, 0.78);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.bdb .topbar-in {
    max-width: 1180px;
    margin: 0 auto;
    padding: 11px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.bdb .logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--display);
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: -0.03em;
    text-decoration: none;
    color: var(--text);
}
.bdb .logo b {
    font-weight: 800;
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.bdb .logo-mark { font-size: 1.35rem; }
.bdb .topnav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.bdb .topnav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.92rem;
    padding: 7px 11px;
    border-radius: 9px;
}
.bdb .topnav a:hover { color: var(--text); background: var(--raise); }
.bdb button.top-rnd {
    flex: 0 0 auto;
    min-width: 0;
    margin-left: 6px;
    padding: 8px 15px;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 999px;
    background: var(--grad);
    box-shadow: 0 6px 18px -8px var(--glow);
}
.bdb .age {
    margin-left: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--muted);
    border: 1px solid var(--line);
    padding: 3px 7px;
    border-radius: 6px;
}

/* ---- hero --------------------------------------------------------------- */
.bdb .hero { padding: 64px 0 30px; text-align: center; }
.bdb .kicker {
    display: inline-block;
    margin: 0 0 18px;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    color: var(--muted);
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.bdb .hero h1 {
    font-family: var(--display);
    font-weight: 800;
    font-size: clamp(2.5rem, 8vw, 4.8rem);
    line-height: 1;
    letter-spacing: -0.04em;
    margin: 0 0 18px;
}
.bdb .lede {
    color: var(--muted);
    font-size: clamp(1rem, 2.3vw, 1.15rem);
    max-width: 600px;
    margin: 0 auto 26px;
}
.bdb .stats {
    list-style: none;
    padding: 0;
    margin: 0 0 24px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
}
.bdb .stats li {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 16px;
    color: var(--muted);
    font-size: 0.9rem;
}
.bdb .stats b { color: var(--text); font-weight: 700; margin-right: 5px; font-variant-numeric: tabular-nums; }
.bdb .popular {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 760px;
    margin: 0 auto;
}
.bdb .popular .lbl { color: var(--dim); font-size: 0.85rem; align-self: center; margin-right: 2px; }
.bdb .chip {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    flex: 0 0 auto;
    min-width: 0;
    padding: 7px 14px;
    font-size: 0.88rem;
    font-weight: 500;
    text-transform: capitalize;
    border-radius: 999px;
    background: var(--raise);
    border: 1px solid var(--line);
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}
.bdb .chip:hover { border-color: var(--a2); background: var(--hover); }

.bdb .cat-more { margin: 12px 0 0; }
.bdb .cat-more a { color: var(--a1); text-decoration: none; font-weight: 600; }
.bdb .cat-more a:hover { text-decoration: underline; }

/* ---- category pages (pages.py) ------------------------------------------- */
.bdb .hero-sm { padding: 34px 0 20px; }
.bdb .hero-sm h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); }
.bdb .crumbs { color: var(--dim); font-size: 0.85rem; margin: 0 0 14px; }
.bdb .crumbs a { color: var(--muted); text-decoration: none; }
.bdb .crumbs a:hover { color: var(--text); }
.bdb .more-cats { margin-top: 56px; }
.bdb .more-cats .sec-h { margin-bottom: 16px; }
.bdb #catFilter {
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 14px;
    padding: 13px 16px 13px 42px;
    background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23726c82' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") no-repeat 15px center;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    font-size: 1rem;
    -webkit-appearance: none;
    appearance: none;
}
.bdb #catFilter:focus { outline: none; border-color: var(--a2); box-shadow: 0 0 0 3px rgba(255, 61, 127, 0.18); }
.bdb .cat-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px;
}
.bdb .cat-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.12s, border-color 0.12s;
}
.bdb .cat-link:hover { background: var(--hover); border-color: var(--a2); }
.bdb .cat-link .n { color: var(--dim); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.bdb .cat-link[hidden] { display: none; }
.bdb .all-cats { display: inline-block; margin-top: 16px; color: var(--a1); font-weight: 600; text-decoration: none; }
.bdb .all-cats:hover { text-decoration: underline; }

/* ---- ad ------------------------------------------------------------------ */
.bdb .ad-slot { margin-top: 6px; margin-bottom: 12px; }
.bdb .ad-slot::before {
    content: "Advertisement";
    display: block;
    margin-bottom: 6px;
    font-size: 0.66rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--dim);
}

/* ---- random video --------------------------------------------------------- */
.bdb .controls { justify-content: center; margin-top: 22px; margin-bottom: 8px; }
.bdb .btn-random {
    flex: 0 1 440px;
    padding: 18px 28px;
    border-radius: 999px;
    background: var(--grad);
    font-family: var(--display);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: 0 14px 34px -12px var(--glow);
    transition: transform 0.15s, box-shadow 0.15s;
}
.bdb .btn-random:hover { transform: translateY(-1px); box-shadow: 0 18px 42px -12px var(--glow); }
.bdb .btn-random:active, .bdb .btn-open:active, .bdb .btn-cat-play:active, .bdb .btn-cat-rnd:active { transform: scale(0.98); }
.bdb .last-random { text-align: center; color: var(--dim); font-style: normal; overflow-wrap: anywhere; }

/* ---- categories ------------------------------------------------------------ */
.bdb .cat-box {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 22px;
    margin-top: 40px;
    margin-bottom: 44px;
    scroll-margin-top: 76px;
}
.bdb .cat-box h3 {
    font-family: var(--display);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 14px;
}
.bdb .cat-box h3 span {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--dim);
    margin-left: 6px;
}
.bdb #catSearch, .bdb #vidSearch {
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 10px;
    padding: 13px 16px 13px 42px;
    background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' fill='none' stroke='%23726c82' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='m13 13 4 4'/%3E%3C/svg%3E") no-repeat 15px center;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--text);
    font-size: 1rem;
    -webkit-appearance: none;
    appearance: none;
}
.bdb #catSearch:focus, .bdb #vidSearch:focus {
    outline: none;
    border-color: var(--a2);
    box-shadow: 0 0 0 3px rgba(255, 61, 127, 0.18);
}
.bdb #catList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 6px;
    align-content: start;
    padding: 8px;
    height: 36vh;
    min-height: 220px;
    max-height: 340px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 14px;
}
.bdb #catList:focus { outline: none; border-color: var(--a2); }
.bdb .cat-opt {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: var(--raise);
    font-size: 0.92rem;
    text-transform: capitalize;
    transition: background 0.12s, border-color 0.12s;
}
.bdb .cat-opt:last-child { border-bottom: 1px solid transparent; }
.bdb .cat-opt:hover { background: var(--hover); border-color: var(--line); }
.bdb .cat-opt .n { color: var(--dim); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.bdb .cat-opt[aria-selected="true"] { background: var(--grad); border-color: transparent; color: #fff; }
.bdb .cat-opt[aria-selected="true"] .n { color: rgba(255, 255, 255, 0.85); }
/* The home page's static rows (slim.py) are links to /c/ until home.js swaps in its own. */
.bdb a.cat-opt { color: #e0e0e0; text-decoration: none; }
.bdb .cat-none { grid-column: 1 / -1; color: var(--dim); }
.bdb .cat-actions { margin-top: 14px; }
.bdb .btn-cat-rnd, .bdb .btn-cat-play {
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 0.98rem;
    font-weight: 600;
    background: var(--raise);
    border: 1px solid var(--line);
}
.bdb .btn-cat-rnd:hover { background: var(--hover); }
.bdb .btn-cat-play { background: var(--grad); border-color: transparent; box-shadow: 0 10px 26px -14px var(--glow); }
.bdb #catStatus { text-align: left; color: var(--muted); margin-top: 12px; }
.bdb #catStatus a { color: var(--a1); }

/* ---- videos ------------------------------------------------------------------ */
.bdb .vid-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
    margin-bottom: 16px;
    scroll-margin-top: 76px;
}
.bdb .sec-h {
    font-family: var(--display);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.bdb #vidTitle { display: inline-block; }
.bdb #vidTitle::first-letter { text-transform: uppercase; }
.bdb #vidCount {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.9rem;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--dim);
    font-variant-numeric: tabular-nums;
}
.bdb .vid-tools { flex: 1 1 340px; display: flex; gap: 8px; }
.bdb .vid-tools #vidSearch { margin: 0; }
.bdb button#vidClear {
    flex: 0 0 auto;
    min-width: 0;
    padding: 0 16px;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--raise);
    border: 1px solid var(--line);
}
.bdb button#vidClear[hidden] { display: none; }
.bdb #vidEmpty { text-align: center; color: var(--dim); padding: 48px 0; margin-top: 0; margin-bottom: 0; }

.bdb #results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 12px;
}
.bdb .url-card {
    position: relative;
    overflow: hidden;
    margin: 0;
    padding: 16px;
    gap: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
    content-visibility: auto;
    contain-intrinsic-size: auto 150px;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.bdb .url-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--grad);
    opacity: 0;
    transition: opacity 0.15s;
}
.bdb .url-card:hover { background: var(--raise); border-color: #3a3550; transform: translateY(-2px); }
.bdb .url-card:hover::before { opacity: 1; }
.bdb .url-card[hidden] { display: none; }
.bdb .url-text {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--text);
    font-size: 0.98rem;
    line-height: 1.4;
    word-break: normal;
    overflow-wrap: anywhere;
}
.bdb .url-text .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 0.74rem; color: var(--dim); }
.bdb .url-text .num { font-variant-numeric: tabular-nums; letter-spacing: 0.03em; }
.bdb .url-text .t {
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.bdb .url-actions { margin-top: auto; }
.bdb .btn-open {
    flex: 1 1 auto;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 0.93rem;
    font-weight: 600;
    background: var(--raise);
    border: 1px solid var(--line);
    color: var(--text);
    transition: background 0.15s, border-color 0.15s;
}
.bdb .url-card:hover .btn-open { background: var(--grad); border-color: transparent; }

/* ---- footer ---------------------------------------------------------------------- */
.bdb .site-foot {
    display: grid;
    justify-items: center;
    gap: 12px;
    margin-top: 64px;
    padding: 30px 0 8px;
    border-top: 1px solid var(--line);
    color: var(--dim);
    font-size: 0.85rem;
    text-align: center;
}
.bdb .site-foot .logo { font-size: 1.15rem; }
.bdb .site-foot nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; }
.bdb .site-foot nav a { color: var(--muted); text-decoration: none; }
.bdb .site-foot nav a:hover { color: var(--text); }
.bdb .site-foot p { margin: 0; max-width: 620px; }

/* ---- phones ------------------------------------------------------------------------ */
@media (max-width: 640px) {
    .bdb .topnav .wide { display: none; }
    .bdb .hero { padding: 40px 0 22px; }
    .bdb .cat-box { padding: 14px; border-radius: 16px; margin-top: 30px; }
    .bdb #catList { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bdb #results { grid-template-columns: 1fr; }
    .bdb .cat-links { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bdb .url-card:hover { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .bdb * { transition: none !important; }
}

/* ---- home page (slim.py + home.js): the list arrives after the page ---- */
.bdb .bdb-loading, .bdb .bdb-load-fail, .bdb .bdb-noscript {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--dim);
    padding: 48px 0;
    margin: 0;
}
.bdb button#vidReroll {
    flex: 0 0 auto;
    min-width: 0;
    padding: 0 14px;
    border-radius: 12px;
    font-size: 1.05rem;
    background: var(--raise);
    border: 1px solid var(--line);
}
.bdb button#vidReroll:hover { background: var(--hover); }
.bdb button.vid-more {
    display: block;
    flex: none;
    min-width: 0;
    margin-top: 18px;
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--raise);
    border: 1px solid var(--line);
    color: var(--text);
}
.bdb button.vid-more[hidden] { display: none; }
