/* ============================================================
   PRODUCT — core design system · "liquid"
   Dark, crisp, organic. Warm blob ambience, film grain,
   spring physics. Fonts: Inter (everything) · JetBrains Mono (data)
   ============================================================ */

@import url('/fonts/fonts.css');
@import url('/css/tokens.css');

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

html { scrollbar-gutter: stable; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-head);
    font-weight: 900;
    letter-spacing: -0.5px;
}

a { color: var(--primary); }

::selection { background: var(--primary-dim); color: #fff; }

.microlabel {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2.5px;
    color: var(--text-faint);
}

/* ============================================================
   AMBIENT LAYER  (blob canvas + grain, injected by core.js)
   ============================================================ */
#app-blob {
    position: fixed; inset: 0;
    width: 100vw; height: 100vh;
    z-index: 0;
    /* radial gradients are already soft — a CSS blur here re-composites the full viewport every repaint */
    opacity: 0.4;
    pointer-events: none;
}
.app-grain {
    position: fixed; inset: -50%;
    z-index: 1;
    pointer-events: none;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    animation: app-grain-shift 0.9s steps(4) infinite;
}
@keyframes app-grain-shift {
    0% { transform: translate(0, 0); }
    25% { transform: translate(-2%, 1.4%); }
    50% { transform: translate(1.6%, -1%); }
    75% { transform: translate(-1%, -1.8%); }
    100% { transform: translate(0, 0); }
}
/* everything real sits above the ambience */
body > header, body > main, body > section, body > div, body > nav { position: relative; z-index: 2; }

/* The header this file used to style — .app-header, an animated gradient
   .brand, a .main-nav pill, .clip-it-btn, .live-badge, .viewer-count — came
   across in the fork and was never wired to anything here. Deleted rather
   than left lying around: it read like a design waiting to be switched on,
   and the next person to size the top bar would have adopted it by mistake.
   The bar that actually renders is built in js/core.js. */


/* ---------- Mobile bottom nav ---------- */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 10px; left: 12px; right: 12px;
    z-index: 1000;
    background: rgba(14, 14, 21, 0.94);
    border: 1px solid var(--border);
    border-radius: 30px;
    padding: 8px 6px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.mobile-nav-inner { display: flex; justify-content: space-around; align-items: center; }
.mobile-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-dim);
    font-size: 0.56rem;
    font-weight: 700;
    text-transform: lowercase;
    padding: 4px 10px;
    border-radius: 16px;
    transition: color 0.2s;
}
.mobile-nav-link svg { width: 20px; height: 20px; }
.mobile-nav-link.active { color: var(--primary); }

/* ============================================================
   BUTTONS / PILLS / INPUTS
   ============================================================ */
.btn {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.76rem;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 18px;
    border-radius: 40px;
    cursor: pointer;
    transition: transform 0.35s var(--spring), background 0.2s, border-color 0.2s, color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { background: var(--card-hover); border-color: var(--border-hi); color: #fff; transform: scale(1.05); }
.btn:active { transform: scale(0.94); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn.primary {
    background: #f4f2ee;
    border-color: #f4f2ee;
    color: #0b0a12;
    font-weight: 800;
}
.btn.primary:hover { background: #fff; color: #0b0a12; box-shadow: 0 0 24px rgba(244, 242, 238, 0.22); }

.btn.ghost-primary {
    background: var(--primary-glow);
    border-color: rgba(255, 177, 92, 0.4);
    color: var(--primary);
}
.btn.ghost-primary:hover { border-color: var(--primary); color: var(--gold); background: var(--primary-glow); }

.btn.danger {
    background: transparent;
    border-color: rgba(255, 92, 135, 0.35);
    color: var(--accent);
}
.btn.danger:hover { background: var(--accent-glow); border-color: var(--accent); color: #ff8aa8; }

.pill {
    font-family: var(--font-body);
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 8px 18px;
    border-radius: 40px;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: lowercase;
    cursor: pointer;
    transition: transform 0.35s var(--spring), background 0.2s, color 0.2s, border-color 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.pill:hover { transform: scale(1.08) rotate(-1deg); color: var(--text); }
.pill:active { transform: scale(0.92); }
.pill.active { background: #f4f2ee; color: #0b0a12; border-color: #f4f2ee; }

.input {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 40px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.input::placeholder { color: var(--text-faint); }
.input:focus { border-color: rgba(255, 177, 92, 0.5); box-shadow: 0 0 0 3px var(--primary-glow); background: rgba(255,255,255,0.06); }
select.input { cursor: pointer; border-radius: var(--radius-sm); }
select.input option { background: var(--surface); }

input[type="range"].slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    cursor: pointer;
}
input[type="range"].slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 15px; height: 15px;
    border-radius: 50%;
    background: #f4f2ee;
    cursor: grab;
}
input[type="range"].slider::-moz-range-thumb {
    width: 13px; height: 13px;
    border-radius: 50%;
    background: #f4f2ee;
    border: none;
    cursor: grab;
}
input[type="checkbox"] { accent-color: var(--primary); }

/* ============================================================
   PANELS / CARDS / SECTIONS
   ============================================================ */
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.8rem;
    margin-bottom: 1.3rem;
}
.section-header h2 { color: var(--text); font-size: 1.3rem; letter-spacing: -0.6px; }

/* ---------- Clip card ---------- */
.clip-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.45s var(--spring), border-color 0.25s, background 0.25s;
    text-decoration: none;
    display: block;
    position: relative;
    will-change: transform;
}
.clip-card:hover {
    transform: scale(1.025);
    border-color: var(--border-hi);
    background: var(--card-hover);
    z-index: 3;
}
.clip-card:active { transform: scale(0.98); }

.clip-thumb-wrap { position: relative; overflow: hidden; background: #000; }
.clip-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
    transition: transform 0.6s var(--spring);
}
.clip-card:hover .clip-thumb { transform: scale(1.05); }

.clip-thumb-wrap .thumb-badge {
    position: absolute;
    top: 10px; right: 12px;
    background: rgba(8, 8, 13, 0.8);
    color: var(--text-dim);
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 0.6rem;
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 0.5px;
    border: 1px solid var(--border);
}

.clip-meta { padding: 15px 18px 17px; }
.clip-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.clip-title-row .title {
    color: var(--text);
    font-weight: 800;
    font-size: 0.94rem;
    letter-spacing: -0.2px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.clip-game-label {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    text-transform: uppercase;
    font-weight: 700;
    margin-top: 8px;
    letter-spacing: 1.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.clip-game-label::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.clip-date {
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 0.62rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 10px;
}

.share-mini-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    cursor: pointer;
    padding: 7px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.3s var(--spring), color 0.2s, border-color 0.2s, background 0.2s;
}
.share-mini-btn:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-glow); transform: scale(1.12); }
.share-mini-btn svg { width: 12px; height: 12px; display: block; }

/* ---------- Tags ---------- */
.clip-tags, .viewer-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 9px; }
.clip-tag, .viewer-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(255, 177, 92, 0.08);
    border: 1px solid rgba(255, 177, 92, 0.22);
    color: #e8b47e;
    font-size: 0.6rem;
    font-family: var(--font-mono);
    font-weight: 700;
    text-transform: lowercase;
    letter-spacing: 0.5px;
}
.viewer-tag.removable { cursor: pointer; position: relative; padding-right: 18px; }
.viewer-tag.removable::after {
    content: '\00d7';
    position: absolute; right: 6px; top: 50%;
    transform: translateY(-50%);
    font-size: 0.72rem; opacity: 0.6;
}
.viewer-tag.removable:hover { background: var(--accent-glow); border-color: var(--accent); color: #ff9ab2; }
.viewer-tag-input {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.6rem;
    font-family: var(--font-mono);
    outline: none;
    width: 86px;
}
.viewer-tag-input:focus { border-color: var(--primary); }

/* ---------- Game pill (colored dot) ---------- */
.game-dot-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 13px;
    border-radius: 20px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 0.62rem;
    font-family: var(--font-mono);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    white-space: nowrap;
    flex-shrink: 0;
}
.game-dot-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); flex-shrink: 0; }

/* ============================================================
   MODAL SHELL
   ============================================================ */
.app-modal {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 9, 0.82);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    /* visibility (not just opacity) so the blur truly stops rendering when closed
       — Firefox/Safari still pay for backdrop-filter at opacity 0 */
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0s linear 0.22s;
    z-index: 2000;
}
.app-modal.active { opacity: 1; visibility: visible; transition: opacity 0.22s ease, visibility 0s; pointer-events: auto; }
.app-modal.active .app-modal-content { animation: app-modal-in 0.5s var(--spring); }
@keyframes app-modal-in {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to { opacity: 1; transform: none; }
}

.app-modal-content {
    width: 94%;
    max-width: 1200px;
    max-height: 94vh;
    background: var(--surface);
    border: 1px solid var(--border-hi);
    border-radius: var(--radius);
    box-shadow: var(--shadow-2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    min-height: 60px;
}
.app-modal-header .mh-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.app-modal-header .mh-title {
    color: #fff;
    font-weight: 800;
    font-size: 0.98rem;
    letter-spacing: -0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-modal-header .mh-meta {
    color: var(--text-faint);
    font-size: 0.66rem;
    font-family: var(--font-mono);
    margin-top: 3px;
    letter-spacing: 1px;
}
.app-modal-header .mh-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.modal-counter {
    color: var(--text-dim);
    font-size: 0.66rem;
    font-family: var(--font-mono);
    background: var(--card);
    border: 1px solid var(--border);
    padding: 4px 11px;
    border-radius: 20px;
    white-space: nowrap;
}

.modal-close-btn {
    background: transparent;
    color: var(--text-dim);
    border: none;
    font-size: 1.8rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s, transform 0.3s var(--spring);
    padding: 0 4px;
}
.modal-close-btn:hover { color: var(--accent); transform: scale(1.15) rotate(90deg); }

/* nav arrows over video */
.viewer-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    /* sits over a playing video — backdrop-filter here re-blurs every video frame */
    background: rgba(8, 8, 13, 0.82);
    border: 1px solid var(--border-hi);
    color: rgba(255, 255, 255, 0.85);
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, transform 0.35s var(--spring), background 0.2s;
    z-index: 10;
}
.viewer-nav-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: translateY(-50%) scale(1.12);
}
.viewer-nav-btn:disabled { opacity: 0 !important; cursor: default; pointer-events: none; }
.viewer-nav-btn svg { width: 18px; height: 18px; pointer-events: none; }
.viewer-prev { left: 14px; }
.viewer-next { right: 14px; }
.viewer-video-wrap:hover .viewer-nav-btn:not(:disabled) { opacity: 1; }
@media (hover: none) { .viewer-nav-btn:not(:disabled) { opacity: 1; } }

/* thumbnail strip */
.viewer-strip-wrap {
    overflow-x: auto;
    padding: 12px 16px max(14px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    scrollbar-width: thin;
    flex-shrink: 0;
}
.viewer-strip { display: flex; gap: 8px; width: max-content; }
.viewer-strip-item {
    width: 98px;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.35s var(--spring);
    background: var(--surface-bright);
}
.viewer-strip-item:hover { border-color: var(--border-hi); transform: scale(1.06); }
.viewer-strip-item.active { border-color: #f4f2ee; }
.viewer-strip-item img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }

/* ============================================================
   TOASTS
   ============================================================ */
#toast-container {
    position: fixed;
    bottom: 1.6rem;
    right: 1.6rem;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
}
.app-toast {
    background: rgba(20, 20, 30, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border-hi);
    color: var(--text);
    padding: 13px 20px;
    border-radius: 20px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.8rem;
    box-shadow: var(--shadow-1);
    transform: translateX(120%);
    transition: transform 0.45s var(--spring), opacity 0.3s;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 400px;
}
.app-toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.app-toast.visible { transform: translateX(0); }
.app-toast.leaving { opacity: 0; transform: translateX(20px); }
.app-toast.error::before { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.app-toast.success::before { background: var(--green); box-shadow: 0 0 10px var(--green); }
.app-toast.info::before { background: var(--primary); box-shadow: 0 0 10px var(--primary); }
.app-toast a { color: var(--primary); text-decoration: none; font-weight: 800; }
.app-toast a:hover { text-decoration: underline; }

/* ============================================================
   MISC
   ============================================================ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

.spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--primary-glow);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: app-spin 0.8s linear infinite;
}
@keyframes app-spin { to { transform: rotate(360deg); } }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 3.5rem 2rem;
    color: var(--text-faint);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    letter-spacing: 1.5px;
    text-align: center;
}
.empty-state svg { opacity: 0.3; }

mark {
    background: var(--primary-glow);
    color: var(--primary);
    padding: 0 3px;
    border-radius: 4px;
}

.conf-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.conf-high { background: var(--green); }
.conf-mid { background: var(--gold); }
.conf-low { background: var(--text-faint); }

.cat-banter   { --cat: var(--cat-banter); }
.cat-story    { --cat: var(--cat-story); }
.cat-rant     { --cat: var(--cat-rant); }
.cat-tangent  { --cat: var(--cat-tangent); }
.cat-reaction { --cat: var(--cat-reaction); }
.cat-gameplay { --cat: var(--cat-gameplay); }
.cat-laughter { --cat: var(--cat-laughter); }
.cat-rage     { --cat: var(--cat-rage); }
.cat-singing  { --cat: var(--cat-singing); }

/* card entrance (used by grids) */
@keyframes app-card-in {
    from { opacity: 0; transform: translateY(24px) scale(0.95); }
    to { opacity: 1; transform: none; }
}

/* page shell */
.page-wrap { max-width: 1500px; margin: 0 auto; width: 100%; padding: 2rem 2.2rem 5rem; }
.page-title { font-size: clamp(1.7rem, 3.4vw, 2.5rem); color: var(--text); letter-spacing: -1.2px; }
.page-title span { color: var(--text-faint); }
.page-subtitle { color: var(--text-dim); font-size: 0.86rem; margin-top: 6px; font-weight: 500; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
    .main-nav { display: none; }
    .mobile-nav { display: block; }
    body { padding-bottom: 84px; }
    header.app-header { padding: 0 14px; height: 56px; }
    .status-container { gap: 8px; }
    .clip-it-btn { padding: 8px 15px; font-size: 0.74rem; }
    .page-wrap { padding: 1.2rem 1rem 3rem; }
    .app-modal-content { width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; border: none; }
}

/* ── icons ──
   One <use> of the sprite core.js injects. Sized in em so an icon tracks
   the text it sits beside, and stroked with currentColor so it follows the
   theme — neither of which an emoji can do. */
.ic {
    width: 1em;
    height: 1em;
    vertical-align: -0.14em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.ic + * { margin-left: 0.45em; }
button .ic, a .ic { pointer-events: none; }   /* clicks belong to the control */
.ic.lg { width: 1.25em; height: 1.25em; }
.ic.dim { opacity: 0.62; }

/* ── hotkey capture ── */
input.hk-capture { cursor: pointer; font-family: var(--mono, ui-monospace, monospace); }
input.hk-capture.listening {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    cursor: text;
}
input.hk-capture.bad-combo { border-color: var(--accent, #ff5c87); }

/* ── a panel that could not load ──
   Shown instead of a placeholder that never resolves. The retry matters:
   most of these failures are a worker still starting or a network blip,
   and reloading the whole page to find out is a poor trade. */
.load-failed {
    display: flex; align-items: center; gap: 10px;
    font-size: 0.78rem; color: var(--text-dim); padding: 2px 0;
}
.load-failed span::before {
    content: ''; display: inline-block; width: 6px; height: 6px;
    border-radius: 50%; background: var(--accent); margin-right: 8px;
    vertical-align: 1px;
}
