/* ROT.IT — base, layout, top bar, chips and the Shorts feed. */
:root {
  --bg: #0b0a12;
  --bg-2: #13111f;
  --panel: #181629;
  --panel-2: #211e36;
  --line: #2e2a4a;
  --text: #f3f1ff;
  --muted: #a49fc4;
  --green: #00c46a;
  --white: #ffffff;
  --red: #ff2d55;
  --accent: #ff2d55;
  --accent-2: #19e3c2;
  --gold: #ffcc33;
  --radius: 16px;
  --topbar-h: 64px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(0, 196, 106, 0.12), transparent 60%),
    radial-gradient(1000px 600px at 110% 110%, rgba(255, 45, 85, 0.14), transparent 60%),
    var(--bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel-2);
  font-size: 13px; font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: transform 0.12s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.btn:hover { border-color: #4a4475; background: #2a2645; }
.btn:active { transform: scale(0.95); }
.btn-primary { background: linear-gradient(135deg, var(--accent), #ff6b3d); border-color: transparent; color: #fff; }
.btn-primary:hover { background: linear-gradient(135deg, #ff4b6e, #ff8a5c); }
.btn-secondary { background: transparent; }
.btn-toggle.active, .btn-action.active {
  background: linear-gradient(135deg, var(--green), #0bb7a0); border-color: transparent; color: #04140c;
  box-shadow: 0 0 18px rgba(0, 196, 106, 0.45);
}
.btn-toggle.is-muted { border-color: rgba(255, 45, 85, 0.6); }
.btn-overdrive.active { background: linear-gradient(135deg, #ff00e5, #ff2d55, #ffcc33); color: #fff; box-shadow: 0 0 22px rgba(255, 0, 229, 0.6); }
.btn-icon, .icon-mini-btn {
  background: transparent; border: 1px solid var(--line); border-radius: 50%;
  width: 32px; height: 32px; display: inline-grid; place-items: center; font-size: 14px;
}
.icon-mini-btn { width: 24px; height: 24px; font-size: 11px; border: none; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px; min-height: var(--topbar-h);
  background: rgba(11, 10, 18, 0.85); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); position: relative; z-index: 30;
}
.brand-group { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 18px;
  background: linear-gradient(135deg, var(--green) 0 33%, var(--white) 33% 66%, var(--red) 66%);
  box-shadow: 0 0 20px rgba(255, 45, 85, 0.35);
}
.brand-text h1 { margin: 0; font-size: 22px; letter-spacing: 1px; font-weight: 900; line-height: 1; }
.accent-it { color: var(--accent); }
.brand-sub { font-size: 9px; letter-spacing: 2px; color: var(--muted); font-weight: 700; }

.search-cluster { display: flex; align-items: center; gap: 8px; flex: 1 1 220px; min-width: 0; }
.search-input-wrap {
  flex: 1; display: flex; align-items: center; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input-wrap:focus-within { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(25, 227, 194, 0.15); }
.search-input-wrap input { flex: 1; background: transparent; border: none; outline: none; padding: 9px 0; min-width: 0; font-size: 14px; }
.search-input-wrap input::-webkit-search-cancel-button { display: none; }
.search-icon { opacity: 0.7; font-size: 14px; }
.btn-live-search.loading { opacity: 0.7; pointer-events: none; }
.btn-live-search.loading::after { content: ""; width: 10px; height: 10px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.search-status { font-size: 11px; color: var(--muted); white-space: nowrap; min-width: 90px; }

.topbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.iq-badge {
  position: relative; display: flex; flex-direction: column; align-items: center;
  padding: 4px 12px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line); min-width: 104px;
}
.iq-top { display: flex; align-items: baseline; gap: 4px; }
.iq-number { font-size: 20px; font-weight: 900; color: var(--accent-2); font-variant-numeric: tabular-nums; transition: color 0.3s; }
.iq-unit { font-size: 10px; color: var(--muted); font-weight: 700; }
.iq-rank { font-size: 9px; color: var(--muted); white-space: nowrap; max-width: 130px; overflow: hidden; text-overflow: ellipsis; }
.iq-badge.iq-negative .iq-number { color: var(--accent); }

/* ---------- Category chips ---------- */
.category-bar {
  display: flex; gap: 8px; padding: 8px 16px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--line); background: rgba(11, 10, 18, 0.6); flex-shrink: 0;
}
.category-bar::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--panel); border: 1px solid var(--line); transition: all 0.2s;
}
.chip:hover { border-color: #4a4475; }
.chip.active { background: var(--text); color: #0b0a12; border-color: var(--text); }
.chip-count { opacity: 0.6; font-size: 10px; margin-left: 2px; }

/* ---------- Workspace grid ---------- */
.workspace {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 330px minmax(0, 1fr) 350px; gap: 14px; padding: 14px;
}
.center-stage { display: flex; flex-direction: column; min-height: 0; min-width: 0; gap: 10px; }
.feed-viewport-wrap { position: relative; flex: 1; min-height: 0; display: flex; justify-content: center; }

/* ---------- Feed ---------- */
.shorts-feed {
  position: relative; height: 100%; width: 100%;
  overflow-y: scroll; overscroll-behavior: contain;
  scroll-snap-type: y mandatory; scrollbar-width: none; outline: none;
  touch-action: none; /* swipe handled in JS for a one-Short-per-swipe feel */
}
.shorts-feed::-webkit-scrollbar { display: none; }
.short-card {
  position: relative; height: 100%; aspect-ratio: 9 / 16; max-width: 100%; margin: 0 auto;
  scroll-snap-align: start; scroll-snap-stop: always;
  border-radius: var(--radius); overflow: hidden; background: #000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.short-card + .short-card { margin-top: 0; }
.thumb { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: saturate(1.1); transition: opacity 0.4s; }
.video-slot { position: absolute; inset: 0; z-index: 1; }
.yt-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.short-card.is-playing .thumb { opacity: 0; }
.touch-shield { position: absolute; inset: 0 0 0 0; z-index: 2; cursor: pointer; }
.spinner {
  position: absolute; z-index: 3; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border: 4px solid rgba(255, 255, 255, 0.25); border-top-color: #fff; border-radius: 50%;
  animation: spin 0.8s linear infinite; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.short-card.is-mounted:not(.is-playing):not(.is-failed):not(.is-paused) .spinner { opacity: 1; }
.pause-indicator {
  position: absolute; z-index: 3; left: 50%; top: 50%; transform: translate(-50%, -50%);
  font-size: 44px; background: rgba(0, 0, 0, 0.45); border-radius: 50%; width: 84px; height: 84px;
  display: none; place-items: center; pointer-events: none;
}
.short-card.is-paused .pause-indicator { display: grid; }

.unmute-btn {
  position: absolute; z-index: 5; top: 14px; left: 14px;
  padding: 9px 14px; border-radius: 999px; border: none; font-weight: 800; font-size: 13px;
  background: rgba(255, 255, 255, 0.95); color: #111; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  animation: unmutePulse 1.8s ease-in-out infinite;
}
body.sound-on .unmute-btn { background: rgba(0, 0, 0, 0.55); color: #fff; animation: none; }

.card-meta {
  position: absolute; z-index: 4; left: 0; right: 64px; bottom: 0; padding: 60px 14px 16px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85), transparent); pointer-events: none;
}
.char-chip, .live-chip {
  display: inline-block; font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.16); backdrop-filter: blur(6px); margin-bottom: 6px;
}
.live-chip { background: var(--accent); }
.live-chip.custom { background: var(--accent-2); color: #04140c; }
.card-title { margin: 0 0 4px; font-size: 15px; line-height: 1.3; text-shadow: 0 1px 4px #000; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-author { margin: 0; font-size: 12px; color: #d8d4f0; }

.action-rail { position: absolute; z-index: 5; right: 8px; bottom: 18px; display: flex; flex-direction: column; gap: 12px; }
.rail-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: none;
  text-decoration: none; color: #fff; text-shadow: 0 1px 4px #000;
}
.rail-icon {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 20px;
  background: rgba(0, 0, 0, 0.45); backdrop-filter: blur(6px); transition: transform 0.15s, background 0.2s;
}
.rail-btn:hover .rail-icon { transform: scale(1.08); background: rgba(0, 0, 0, 0.65); }
.rail-btn:active .rail-icon { transform: scale(0.9); }
.rail-count { font-size: 11px; font-weight: 700; }
.like-btn.liked .rail-icon { color: var(--accent); background: rgba(255, 45, 85, 0.2); animation: pop 0.35s; }

.fallback-box {
  position: absolute; z-index: 6; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; text-align: center; padding: 24px; background: rgba(5, 4, 10, 0.82); backdrop-filter: blur(4px);
}
.short-card.is-failed .fallback-box { display: flex; }
.fallback-emoji { font-size: 48px; }
.fallback-box p { margin: 0; font-weight: 700; }
.fallback-box small { color: var(--muted); }

.feed-empty { height: 100%; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 8px; font-size: 15px; }
.feed-empty div { font-size: 56px; }

/* ---------- Feed nav (arrows + counter) ---------- */
.feed-nav-controls {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); z-index: 10;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.nav-arrow-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(24, 22, 41, 0.9); font-size: 16px; transition: transform 0.12s, background 0.2s;
}
.nav-arrow-btn:hover { background: var(--accent); border-color: var(--accent); }
.nav-arrow-btn:active { transform: scale(0.9); }
.feed-counter-badge { font-size: 11px; font-weight: 800; color: var(--muted); background: rgba(24, 22, 41, 0.9); padding: 4px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }

.autoscroll-progress-wrap { position: absolute; top: 0; left: 0; right: 0; height: 4px; z-index: 12; background: rgba(255, 255, 255, 0.1); border-radius: 4px; overflow: hidden; }
.autoscroll-progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--green), var(--accent-2)); transition: width 0.1s linear; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { 50% { transform: scale(1.3); } }
@keyframes nudge { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes unmutePulse {
  0%, 100% { box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4), 0 0 0 0 rgba(255, 45, 85, 0.55); }
  50% { box-shadow: 0 4px 22px rgba(0, 0, 0, 0.5), 0 0 0 8px rgba(255, 45, 85, 0); }
}
