/* ==========================================================================
   Cryptoface's Soundboard — modern dark glass
   Single stylesheet. No build step, no preprocessor, no external references.
   (less/style.less is dead legacy; do not edit it, it is not compiled.)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
    --bg:            #05070c;
    --panel:         rgba(13, 16, 24, 0.60);
    --panel-opaque:  rgba(13, 16, 24, 0.92);
    --raise:         rgba(255, 255, 255, 0.05);
    --stroke:        rgba(255, 255, 255, 0.09);
    --stroke-strong: rgba(255, 255, 255, 0.18);

    --text:          #eef2f8;
    --text-dim:      #9aa7bd;

    --accent:        #00e0a4;
    --accent-soft:   rgba(0, 224, 164, 0.16);
    --accent-line:   rgba(0, 224, 164, 0.50);
    --focus:         #4cd6ff;

    --danger:        #ff4d5e;
    --danger-text:   #ffe3e6;

    --radius-lg:     18px;
    --radius-md:     12px;
    --radius-sm:     9px;

    --gutter:        clamp(12px, 2vw, 20px);

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
            Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

/* --------------------------------------------------------------------------
   2. Reset / base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
    height: 100%;
    /* Dark canvas: guarantees no white flash while the 30 MB video streams in,
       and a presentable page if the video 404s or autoplay is blocked. */
    background-color: var(--bg);
    color-scheme: dark;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100%;
    font-family: var(--font);
    color: var(--text);
    background: transparent;
    /* Do NOT add transform/filter/opacity to body — it would create a
       stacking context and trap the fixed background layer. */
}

h1, h2, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }

/* All <audio> elements live in a hidden library block; belt-and-braces. */
audio { display: none; }

:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   3. Background video layer
   Explicit positive z-index layers only — no negative z-index, which would
   risk the video painting behind the page canvas.
     .bg      z-index 0   (dark container + video + scrim)
     .app     z-index 1   (all UI)
   -------------------------------------------------------------------------- */
.bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;          /* never intercepts clicks on the buttons */
    background-color: var(--bg);
    background-image:
        radial-gradient(120% 100% at 50% 0%,   rgba(0, 224, 164, 0.10) 0%, rgba(0, 0, 0, 0) 55%),
        radial-gradient(100% 80%  at 80% 100%, rgba(76, 214, 255, 0.08) 0%, rgba(0, 0, 0, 0) 60%);
}

.bg-video {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    /* The fix: cover the viewport at every aspect ratio, never distorted,
       never letterboxed. */
    object-fit: cover;
    object-position: center center;
    border: 0;
    background-color: transparent;  /* let the dark .bg show until frame 1 */
}

/* Fallback for engines without object-fit: overscale + centre-crop. */
@supports not (object-fit: cover) {
    .bg-video {
        inset: auto;
        top: 50%;
        left: 50%;
        width: auto;
        height: auto;
        min-width: 100%;
        min-height: 100%;
        transform: translate(-50%, -50%);
    }
}

/* Legibility scrim — buttons stay readable over ANY frame of the video. */
.bg-scrim {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg,
            rgba(4, 6, 11, 0.86) 0%,
            rgba(4, 6, 11, 0.52) 26%,
            rgba(4, 6, 11, 0.55) 68%,
            rgba(4, 6, 11, 0.90) 100%),
        radial-gradient(130% 95% at 50% 45%,
            rgba(0, 0, 0, 0) 30%,
            rgba(0, 0, 0, 0.55) 100%);
}

/* --------------------------------------------------------------------------
   4. App shell — fills the viewport exactly; the board scrolls internally so
   the header (and STOP ALL) can never be scrolled off.
   -------------------------------------------------------------------------- */
.app {
    position: relative;
    z-index: 1;
    height: 100vh;
    height: 100dvh;              /* correct on mobile with dynamic toolbars */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: clamp(8px, 1.6vw, 20px);
}

.shell {
    /* Hugs its content, but never grows past the viewport — past that point
       the board below scrolls internally and the header stays put. */
    flex: 0 1 auto;
    max-height: 100%;
    min-height: 0;               /* required so the inner scroller can shrink */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
    max-width: 1440px;           /* keeps 21:9 from stretching the grid thin */
    margin: 0 auto;
    border: 1px solid var(--stroke);
    border-radius: var(--radius-lg);
    background: var(--panel);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    backdrop-filter: blur(16px) saturate(140%);
    box-shadow:
        0 30px 80px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* If backdrop-filter is unavailable, lean on opacity for legibility. */
@supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
    .shell { background: var(--panel-opaque); }
}

/* --------------------------------------------------------------------------
   5. Header
   -------------------------------------------------------------------------- */
.topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px var(--gutter);
    border-bottom: 1px solid var(--stroke);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    margin-right: auto;
}

.brand-mark {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--stroke);
    object-fit: contain;
    padding: 3px;
}

.brand-text { min-width: 0; }

.brand h1 {
    font-size: clamp(15px, 1.5vw, 19px);
    font-weight: 650;
    letter-spacing: -0.01em;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand h1 em {
    font-style: normal;
    color: var(--accent);
}

.brand-sub {
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-dim);
    line-height: 1.4;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

/* STOP ALL — always visible, never scrolls away, big enough to hit blind. */
.stop {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 10px 22px;
    border: 1px solid rgba(255, 77, 94, 0.55);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(255, 77, 94, 0.26), rgba(255, 77, 94, 0.11));
    color: var(--danger-text);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 8px 26px rgba(255, 60, 80, 0.16);
    transition: background .15s ease, color .15s ease, transform .10s ease, box-shadow .15s ease;
}
.stop:hover {
    background: linear-gradient(180deg, rgba(255, 77, 94, 0.42), rgba(255, 77, 94, 0.22));
    color: #fff;
    box-shadow: 0 10px 30px rgba(255, 60, 80, 0.28);
}
.stop:active { transform: scale(0.97); }
.stop.is-armed {
    background: var(--danger);
    border-color: var(--danger);
    color: #120407;
}

/* --------------------------------------------------------------------------
   6. Board (the internal scroller)
   -------------------------------------------------------------------------- */
.board {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 4px var(--gutter) 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.20) transparent;
}
.board::-webkit-scrollbar { width: 10px; }
.board::-webkit-scrollbar-track { background: transparent; }
.board::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 99px;
    border: 3px solid transparent;
    background-clip: content-box;
}
.board::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.28); background-clip: content-box; }

.cat + .cat { margin-top: 6px; }

/* Sticky category headings so you always know what you're looking at. */
.cat-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 calc(var(--gutter) * -1) 10px;
    padding: 12px var(--gutter) 9px;
    background: rgba(11, 14, 21, 0.88);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.cat-head h2 {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text);
    white-space: nowrap;
}

.cat-dot {
    width: 6px;
    height: 6px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(0, 224, 164, 0.7);
}

.cat-count {
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: var(--text-dim);
    padding: 2px 7px;
    border-radius: 99px;
    border: 1px solid var(--stroke);
    background: var(--raise);
}

.cat-rule {
    flex: 1 1 auto;
    height: 1px;
    background: linear-gradient(90deg, var(--stroke-strong), rgba(255, 255, 255, 0));
}

.pads {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
    gap: 10px;
    padding-bottom: 18px;
}

/* --------------------------------------------------------------------------
   7. Sound pads
   -------------------------------------------------------------------------- */
.pad {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 64px;
    padding: 12px 14px;
    text-align: left;
    border: 1px solid var(--stroke);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.02));
    color: var(--text);
    font: inherit;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1.3;
    cursor: pointer;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: transform .12s ease, border-color .15s ease,
                background .15s ease, box-shadow .15s ease;
}

.pad:hover {
    transform: translateY(-1px);
    border-color: var(--accent-line);
    background: linear-gradient(180deg, var(--accent-soft), rgba(0, 224, 164, 0.04));
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.38);
}

.pad:active { transform: translateY(0) scale(0.985); }

.pad-label {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;   /* long unbroken titles never blow out the grid */
    word-break: break-word;
}

/* Playing state — clips overlap, so feedback must be obvious at a glance. */
.pad.is-playing {
    border-color: var(--accent);
    background: linear-gradient(180deg, rgba(0, 224, 164, 0.24), rgba(0, 224, 164, 0.07));
    box-shadow:
        0 0 0 1px rgba(0, 224, 164, 0.35),
        0 0 26px rgba(0, 224, 164, 0.22);
}

.pad.is-playing::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 9px var(--accent);
    animation: padPulse 1.1s ease-in-out infinite;
}

@keyframes padPulse {
    0%, 100% { opacity: 1;   transform: scale(1);   }
    50%      { opacity: 0.35; transform: scale(0.7); }
}

/* Playback progress along the bottom edge of the pad. */
.pad-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--accent);
    transform: scaleX(var(--p, 0));
    transform-origin: left center;
    opacity: 0;
    transition: opacity .18s ease;
}
.pad.is-playing .pad-bar { opacity: 1; }

/* Optional per-sound class hook (kept from the original authoring contract:
   the class on <audio> is copied onto the generated button). */
.pad.Fucking-Windows-98:hover { border-color: rgba(76, 214, 255, 0.55); }

/* --------------------------------------------------------------------------
   8. Empty / no-JS states
   -------------------------------------------------------------------------- */
.notice {
    margin: 24px auto;
    max-width: 46ch;
    padding: 18px 20px;
    border: 1px solid var(--stroke);
    border-radius: var(--radius-md);
    background: var(--raise);
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

/* Hidden markup that holds the <audio> elements (the sound library). */
.sound-library { display: none; }

/* --------------------------------------------------------------------------
   9. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 700px) {
    .app { padding: 0; }
    .shell {
        border: 0;
        border-radius: 0;
        box-shadow: none;
        /* Full-bleed, but still translucent so the video reads through. */
        background: rgba(13, 16, 24, 0.72);
    }
    @supports not ((backdrop-filter: blur(2px)) or (-webkit-backdrop-filter: blur(2px))) {
        .shell { background: var(--panel-opaque); }
    }
    .topbar { border-radius: 0; }
}

@media (max-width: 560px) {
    .pads { grid-template-columns: repeat(auto-fill, minmax(min(100%, 148px), 1fr)); }
    .pad { min-height: 58px; font-size: 12.5px; padding: 10px 11px; }
    .brand-sub { display: none; }
    .stop { padding: 10px 16px; letter-spacing: 0.06em; }
}

/* Short landscape (small laptops, phone on its side): tighten the chrome so
   the scrolling board keeps as much room as possible. */
@media (max-height: 560px) {
    .topbar { padding-top: 8px; padding-bottom: 8px; }
    .brand-sub { display: none; }
    .brand-mark { width: 26px; height: 26px; }
    .pad { min-height: 54px; }
    .cat-head { padding-top: 9px; padding-bottom: 7px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    .pad:hover { transform: none; }
}

@media (prefers-contrast: more) {
    .shell    { background: rgba(6, 8, 13, 0.96); }
    .pad      { border-color: rgba(255, 255, 255, 0.35); }
    .cat-head { background: rgba(6, 8, 13, 0.98); }
}
