/* Feed de vídeos estilo TikTok — tema escuro */
:root {
    --bg: #000;
    --side: #0a0a0a;
    --fg: #fff;
    --muted: rgba(255, 255, 255, .72);
    --accent: #fe2c55;
    --chip: rgba(255, 255, 255, .14);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--side);
    color: var(--fg);
    font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
}

/* Coluna central 9:16 (no celular ocupa a tela toda) */
.stage {
    position: relative;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    width: min(100vw, calc(100vh * 9 / 16));
    width: min(100vw, calc(100dvh * 9 / 16));
    background: var(--bg);
    overflow: hidden;
}

/* ---------- Barra de categorias ---------- */
.topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 10;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 0 28px;
    background: linear-gradient(rgba(0, 0, 0, .7), rgba(0, 0, 0, 0));
    pointer-events: none;
}
.chips {
    display: flex;
    gap: 8px;
    padding: 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: 0 0 auto;
    padding: 7px 14px;
    border-radius: 999px;
    background: var(--chip);
    color: var(--fg);
    text-decoration: none;
    font-weight: 600;
    font-size: .88rem;
    white-space: nowrap;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.chip.active { background: var(--fg); color: #000; }

/* ---------- Feed ---------- */
.feed {
    position: absolute;
    inset: 0;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    outline: none;
}
.feed::-webkit-scrollbar { display: none; }

.slide {
    position: relative;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    overflow: hidden;
    background: var(--bg);
}

.vid {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    cursor: pointer;
}

/* Degradê inferior para dar leitura ao texto */
.slide.video::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 42%;
    background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, .72));
    pointer-events: none;
}

/* ---------- Texto sobre o vídeo ---------- */
.info {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    z-index: 3;
    padding: 0 76px calc(env(safe-area-inset-bottom, 0px) + 22px) 16px;
    pointer-events: none;
}
.info > * { pointer-events: auto; }
.tag {
    display: inline-block;
    margin-bottom: 6px;
    font-size: .8rem;
    font-weight: 700;
    color: var(--muted);
}
.tag::before { content: "#"; }
.title {
    margin: 0 0 4px;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.25;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
.desc {
    margin: 0;
    color: var(--muted);
    font-size: .92rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: pre-line;
}
.desc.open { -webkit-line-clamp: unset; display: block; max-height: 32vh; overflow-y: auto; }
.more {
    background: none;
    border: 0;
    padding: 2px 0;
    color: var(--fg);
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
}
.cta {
    display: inline-block;
    margin-top: 12px;
    padding: 10px 22px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
}
.cta:active { transform: scale(.97); }

/* ---------- Barra de progresso ---------- */
.progress {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 3px;
    background: rgba(255, 255, 255, .18);
    z-index: 4;
}
.bar { height: 100%; width: 0; background: var(--fg); transition: width .25s linear; }

/* ---------- Estados do vídeo ---------- */
.play-icon {
    position: absolute;
    top: 50%; left: 50%;
    width: 84px; height: 84px;
    margin: -42px 0 0 -42px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
}
.slide.paused .play-icon { display: flex; }

.spin {
    position: absolute;
    top: 50%; left: 50%;
    width: 38px; height: 38px;
    margin: -19px 0 0 -19px;
    border: 3px solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    display: none;
    z-index: 2;
    pointer-events: none;
}
.slide.loading .spin { display: block; }
.slide.failed .spin { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.fail {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
    color: var(--muted);
    font-weight: 600;
    text-align: center;
    padding: 24px;
    background: #050505;
    pointer-events: none;
}
.slide.failed .fail { display: flex; }

/* ---------- Anúncios ---------- */
.slide.ad { background: #0a0a0a; }
.ad-label {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 58px);
    left: 16px;
    z-index: 3;
    font-size: .75rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    border: 1px solid rgba(255, 255, 255, .3);
    padding: 2px 8px;
    border-radius: 4px;
}
.ad-box {
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 92px);
    left: 0; right: 0;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
}
.ad-frame { flex: 1 1 auto; width: 100%; border: 0; background: #000; min-height: 0; }

/* ---------- Botão de som e dica ---------- */
.sound-btn {
    position: absolute;
    right: 12px;
    top: calc(env(safe-area-inset-top, 0px) + 58px);
    z-index: 11;
    width: 42px; height: 42px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.sound-btn .ico-on { display: none; }
.sound-btn.on .ico-on { display: block; }
.sound-btn.on .ico-off { display: none; }

.hint {
    position: absolute;
    right: 62px;
    top: calc(env(safe-area-inset-top, 0px) + 66px);
    z-index: 11;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .72);
    font-size: .8rem;
    font-weight: 600;
    pointer-events: none;
    animation: fade 5s forwards;
}
@keyframes fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Mensagens (vazio / erro) ---------- */
.state {
    position: absolute;
    inset: 0;
    z-index: 9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 24px;
    text-align: center;
    color: var(--muted);
    background: #000;
}
.state[hidden] { display: none; }
.state p { margin: 0; }
.btn {
    background: var(--fg);
    color: #000;
    border: 0;
    border-radius: 999px;
    padding: 10px 22px;
    font-weight: 700;
    cursor: pointer;
}

@media (min-width: 768px) {
    .stage { box-shadow: 0 0 0 1px #1c1c1c; }
}

@media (prefers-reduced-motion: reduce) {
    .bar { transition: none; }
}
