/* ============================================================
   TeraPlay Design System
   Tokens: deep indigo base, violet→cyan signature gradient,
   asymmetric half-rounded shapes, glass surfaces.
   ============================================================ */

:root {
  --bg: #0a0a12;
  --bg-elevated: #0f0f1a;
  --surface: rgba(255,255,255,0.045);
  --surface-hover: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.09);
  --text: #f1f0f6;
  --text-muted: #9a97ae;
  --accent-1: #7c5cfc;   /* violet */
  --accent-2: #22d3ee;   /* cyan */
  --accent-grad: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  --danger: #fb7185;
  --success: #34d399;
  --radius-half: 22px 22px 8px 8px;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(124,92,252,0.18), transparent 60%),
              radial-gradient(1000px 500px at -10% 20%, rgba(34,211,238,0.10), transparent 55%),
              var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0 0 .5em; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
.container { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: var(--radius-half); border: 1px solid var(--border);
  font-family: var(--font-body); font-weight: 600; font-size: 14px; cursor: pointer;
  background: var(--surface); color: var(--text); transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.btn:hover { transform: translateY(-2px); background: var(--surface-hover); }
.btn-primary { background: var(--accent-grad); border: none; color: #08060f; }
.btn-primary:hover { box-shadow: 0 8px 28px -6px rgba(124,92,252,.55); }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: rgba(251,113,133,.35); }

/* ---------- Header / Nav ---------- */
.site-header { position: sticky; top: 0; z-index: 50; backdrop-filter: blur(16px); background: rgba(10,10,18,.65); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.site-nav { display: flex; align-items: center; gap: 26px; }
.site-nav > a { font-size: 14px; font-weight: 500; color: var(--text-muted); position: relative; padding: 4px 0; }
.site-nav > a:hover { color: var(--text); }
.site-nav > a:not(.btn)::after {
  content: ''; position: absolute; left: 0; bottom: -2px; height: 1.5px; width: 0;
  background: var(--accent-grad); transition: width .25s ease;
}
.site-nav > a:not(.btn):hover::after { width: 100%; }
.nav-toggle { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; }
.nav-toggle span { width: 22px; height: 2px; background: var(--text); border-radius: 2px; }
.nav-profile { position: relative; }
.nav-profile-btn { display: flex; align-items: center; gap: 6px; background: none; border: none; color: var(--text); font-family: var(--font-body); font-size: 14px; cursor: pointer; }
.nav-profile-menu {
  position: absolute; right: 0; top: calc(100% + 10px); min-width: 190px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px 14px 6px 14px;
  padding: 6px; opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity .18s ease, transform .18s ease; box-shadow: 0 20px 40px -12px rgba(0,0,0,.6);
}
.nav-profile-menu.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.nav-profile-menu a { display: block; padding: 9px 12px; border-radius: 8px; font-size: 13.5px; color: var(--text-muted); }
.nav-profile-menu a:hover { background: var(--surface-hover); color: var(--text); }

/* ---------- Hero ---------- */
.hero { padding: 88px 0 70px; text-align: center; position: relative; overflow: hidden; }
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); margin-bottom: 22px;
  animation: floatIn .7s ease both;
}
.hero h1 {
  font-size: clamp(34px, 6vw, 62px); line-height: 1.05; max-width: 820px; margin: 0 auto 20px;
  animation: floatIn .8s .05s ease both;
}
.hero h1 .grad { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p.lead { color: var(--text-muted); font-size: 17px; max-width: 560px; margin: 0 auto 34px; animation: floatIn .8s .1s ease both; }
.hero-ctas { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; animation: floatIn .8s .15s ease both; }

@keyframes floatIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.hero-mock {
  margin: 60px auto 0; max-width: 820px; border-radius: 26px 26px 10px 10px; border: 1px solid var(--border);
  background: var(--surface); backdrop-filter: blur(10px); padding: 14px; animation: floatIn 1s .2s ease both;
}
.hero-mock-bar { display: flex; gap: 6px; padding: 4px 8px 14px; }
.hero-mock-bar span { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,.14); }
.hero-mock-player {
  aspect-ratio: 16/8; border-radius: 16px 16px 6px 6px; background: linear-gradient(135deg, #14101f, #0a1620);
  display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
}
.hero-mock-player .pulse-ring {
  width: 62px; height: 62px; border-radius: 50%; background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 0 rgba(124,92,252,.5);
  animation: pulse 2.4s infinite;
}
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(124,92,252,.45); } 70% { box-shadow: 0 0 0 22px rgba(124,92,252,0); } 100% { box-shadow: 0 0 0 0 rgba(124,92,252,0); } }

/* ---------- Sections / Cards ---------- */
section { padding: 70px 0; }
.section-head { text-align: center; max-width: 560px; margin: 0 auto 44px; }
.section-head p { color: var(--text-muted); }

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-half);
  padding: 26px; transition: transform .25s ease, border-color .25s ease, background .25s ease;
  position: relative; overflow: hidden;
}
.card::before {
  content: ''; position: absolute; inset: 0; padding: 1px; border-radius: inherit;
  background: var(--accent-grad); opacity: 0; transition: opacity .25s ease;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none;
}
.card:hover { transform: translateY(-4px); }
.card:hover::before { opacity: 1; }
.card .icon-badge {
  width: 42px; height: 42px; border-radius: 12px 12px 4px 12px; background: var(--accent-grad);
  display: flex; align-items: center; justify-content: center; margin-bottom: 16px; color: #08060f;
}
.card h3 { font-size: 17px; }
.card p { color: var(--text-muted); font-size: 14.5px; line-height: 1.55; margin: 0; }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; counter-reset: step; }
.step { position: relative; padding-top: 8px; }
.step .num { font-family: var(--font-display); font-size: 34px; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.step h3 { margin-top: 6px; font-size: 16px; }
.step p { color: var(--text-muted); font-size: 14px; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: calc(100vh - 68px); display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 26px 26px 10px 10px; padding: 34px 30px; backdrop-filter: blur(10px);
}
.auth-card h1 { font-size: 24px; }
.auth-card .sub { color: var(--text-muted); font-size: 14px; margin-bottom: 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: rgba(255,255,255,.03); color: var(--text); font-size: 14.5px; transition: border-color .2s ease, background .2s ease;
}
.field input:focus { border-color: var(--accent-1); background: rgba(255,255,255,.055); outline: none; }
.field-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 12.5px; margin: 20px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.alert { padding: 12px 14px; border-radius: 12px; font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: rgba(251,113,133,.1); border: 1px solid rgba(251,113,133,.3); color: #fca5a5; }
.alert-success { background: rgba(52,211,153,.1); border: 1px solid rgba(52,211,153,.3); color: #6ee7b7; }
.auth-footer-link { text-align: center; font-size: 13.5px; color: var(--text-muted); margin-top: 18px; }
.auth-footer-link a { color: var(--accent-2); font-weight: 600; }

/* ---------- Dashboard / paste bar ---------- */
.paste-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 26px 26px 10px 10px;
  padding: 26px; margin-bottom: 34px;
}
.paste-row { display: flex; gap: 10px; }
.paste-row input {
  flex: 1; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border);
  background: rgba(255,255,255,.03); color: var(--text); font-size: 14.5px;
}
.paste-row input:focus { outline: none; border-color: var(--accent-1); }
.resolve-status { margin-top: 14px; font-size: 13.5px; color: var(--text-muted); display: none; align-items: center; gap: 10px; }
.resolve-status.active { display: flex; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent-1); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.buffer-shimmer {
  height: 4px; width: 100%; border-radius: 4px; overflow: hidden; background: var(--border); margin-top: 12px; display: none;
}
.buffer-shimmer.active { display: block; }
.buffer-shimmer::after {
  content: ''; display: block; height: 100%; width: 40%; background: var(--accent-grad);
  animation: shimmerMove 1.1s ease-in-out infinite;
}
@keyframes shimmerMove { 0% { transform: translateX(-100%); } 100% { transform: translateX(350%); } }

/* Video card grid */
.video-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px 20px 8px 8px;
  overflow: hidden; cursor: pointer; transition: transform .25s ease, border-color .25s ease;
  position: relative;
}
.video-card:hover { transform: translateY(-5px) scale(1.015); border-color: rgba(124,92,252,.4); }
.video-card .thumb { aspect-ratio: 16/9; background: #14101f url('data:,') center/cover; position: relative; overflow: hidden; }
.video-card .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.video-card:hover .thumb img { transform: scale(1.06); }
.video-card .duration-badge { position: absolute; bottom: 8px; right: 8px; background: rgba(0,0,0,.65); font-size: 11.5px; padding: 3px 7px; border-radius: 6px; }
.video-card .meta { padding: 12px 14px; }
.video-card .meta .name { font-size: 13.5px; font-weight: 600; line-height: 1.3; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-card .meta .sub { font-size: 12px; color: var(--text-muted); }
.video-card .fav-toggle {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,.55); backdrop-filter: blur(4px); border: none; display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #fff; transition: transform .18s ease, background .18s ease;
}
.video-card .fav-toggle:hover { transform: scale(1.12); }
.video-card .fav-toggle.active { color: #fb7185; background: rgba(251,113,133,.18); }

/* ---------- Player ---------- */
.player-wrap { max-width: 980px; margin: 0 auto; }
.player-shell {
  position: relative; background: #000; border-radius: 22px 22px 8px 8px; overflow: hidden;
  border: 1px solid var(--border); aspect-ratio: 16/9;
}
.player-shell video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.player-overlay-speed {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.7);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; opacity: 0; transition: opacity .15s ease; pointer-events: none;
}
.player-overlay-speed.show { opacity: 1; }
.player-controls {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 34px 16px 14px;
  background: linear-gradient(0deg, rgba(0,0,0,.82), transparent);
  opacity: 1; transition: opacity .3s ease;
}
.player-controls.hidden { opacity: 0; pointer-events: none; }
.seek-bar { width: 100%; height: 5px; border-radius: 3px; background: rgba(255,255,255,.2); position: relative; cursor: pointer; margin-bottom: 12px; }
.seek-bar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--accent-grad); width: 0%; }
.controls-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.controls-row .spacer { flex: 1; }
.ctrl-btn { background: none; border: none; color: #fff; cursor: pointer; display: flex; align-items: center; padding: 4px; opacity: .92; transition: opacity .15s ease, transform .15s ease; }
.ctrl-btn:hover { opacity: 1; transform: scale(1.08); }
.time-label { font-size: 12.5px; color: rgba(255,255,255,.85); min-width: 92px; }
.select-quality {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15); color: #fff;
  border-radius: 8px; padding: 5px 8px; font-size: 12.5px; cursor: pointer;
}
.pip-window {
  position: fixed; bottom: 20px; right: 20px; width: 300px; aspect-ratio: 16/9; z-index: 200;
  border-radius: 16px 16px 6px 16px; overflow: hidden; border: 1px solid var(--border); box-shadow: 0 20px 50px -10px rgba(0,0,0,.6);
  cursor: grab; display: none;
}
.pip-window.active { display: block; }
.pip-window video { width: 100%; height: 100%; object-fit: cover; }
.pip-close { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.6); border: none; color: #fff; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; }

/* ---------- Library toolbar ---------- */
.lib-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.lib-search { flex: 1; min-width: 200px; padding: 11px 15px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.view-toggle { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.view-toggle button { background: none; border: none; color: var(--text-muted); padding: 6px 10px; border-radius: 7px; cursor: pointer; }
.view-toggle button.active { background: var(--surface-hover); color: var(--text); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 90px; padding: 56px 0 26px; background: rgba(255,255,255,.015); }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 30px; }
.footer-brand p { color: var(--text-muted); font-size: 13.5px; margin: 12px 0 16px; max-width: 240px; }
.footer-col h4 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 14px; }
.footer-col a { display: block; font-size: 13.5px; color: var(--text-muted); margin-bottom: 10px; transition: color .15s ease; }
.footer-col a:hover { color: var(--text); }
.social-row { display: flex; gap: 10px; }
.social-icon { width: 34px; height: 34px; border-radius: 10px 10px 4px 10px; background: var(--surface); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: color .15s ease, border-color .15s ease; }
.social-icon:hover { color: var(--accent-2); border-color: rgba(34,211,238,.4); }
.footer-bottom { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 40px; padding-top: 22px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted); }

/* ---------- Legal pages ---------- */
.legal-page { max-width: 780px; margin: 0 auto; padding: 60px 0 90px; }
.legal-page h1 { font-size: 30px; margin-bottom: 6px; }
.legal-page .updated { color: var(--text-muted); font-size: 13px; margin-bottom: 34px; }
.legal-page h2 { font-size: 18px; margin-top: 30px; }
.legal-page p, .legal-page li { color: var(--text-muted); font-size: 14.5px; line-height: 1.7; }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 70px 20px; color: var(--text-muted); }
.empty-state svg { margin-bottom: 16px; opacity: .5; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .grid-3, .grid-4, .steps { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .nav-toggle { display: flex; }
  .site-nav {
    position: fixed; top: 68px; left: 0; right: 0; background: var(--bg-elevated); border-bottom: 1px solid var(--border);
    flex-direction: column; align-items: stretch; padding: 16px 20px; gap: 4px;
    transform: translateY(-8px); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  }
  .site-nav.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .site-nav > a { padding: 12px 4px; border-bottom: 1px solid var(--border); }
  .grid-3, .grid-4, .steps { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .pip-window { width: 220px; }
}
