/* =========================================================
   KUROSTREAM — design tokens
   ========================================================= */
:root {
  --bg: #0a0a10;
  --surface: #14141d;
  --surface-2: #1c1c28;
  --border: #2a2a38;
  --text: #f2f2f6;
  --text-muted: #9494a6;
  --accent: #ff3d68;
  --accent-2: #7c5cff;
  --accent-gradient: linear-gradient(135deg, #ff3d68 0%, #7c5cff 100%);
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-lg: 0 20px 50px rgba(0,0,0,.55);
  --font-display: "Anton", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 10px; }

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

/* View Transitions */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: kuro-fade-out .25s ease both; }
::view-transition-new(root) { animation: kuro-fade-in .35s ease both; }
@keyframes kuro-fade-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes kuro-fade-in { from { opacity: 0; transform: translateY(8px); } }

/* =========================================================
   NAVBAR
   ========================================================= */
.navbar {
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(14px);
  background: rgba(10,10,16,.72);
  border-bottom: 1px solid var(--border);
  transition: background .3s ease;
}
.navbar-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 28px;
  padding: 14px 32px;
}
.brand { font-family: var(--font-display); font-size: 22px; letter-spacing: .5px; white-space: nowrap; }
.brand-mark { color: var(--text); }
.brand-mark-alt { color: var(--accent); }

.nav-links { display: flex; gap: 22px; }
.nav-links a {
  font-size: 14px; font-weight: 600; color: var(--text-muted);
  position: relative; padding: 4px 0;
  transition: color .2s ease;
}
.nav-links a:hover { color: var(--text); }
.nav-links a::after {
  content: ""; position: absolute; left: 0; bottom: -2px; height: 2px; width: 0;
  background: var(--accent-gradient); transition: width .25s ease;
}
.nav-links a:hover::after { width: 100%; }

.navbar-search {
  margin-left: auto; position: relative; display: flex; align-items: center;
}
.navbar-search input {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 999px; padding: 9px 38px 9px 16px; width: 220px;
  font-size: 13px; transition: width .3s ease, border-color .3s ease, background .3s ease;
}
.navbar-search input:focus {
  outline: none; width: 300px; border-color: var(--accent); background: var(--surface-2);
}
.icon-search { position: absolute; right: 12px; width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }

.navbar-user { display: flex; align-items: center; gap: 10px; }
.btn-login {
  background: var(--accent-gradient); color: #fff; border: none;
  padding: 9px 18px; border-radius: 999px; font-weight: 700; font-size: 13px;
  transition: transform .2s ease, box-shadow .2s ease;
}
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(255,61,104,.35); }

.user-chip {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 4px 12px 4px 4px; border-radius: 999px; border: 1px solid var(--border);
  transition: border-color .2s ease, background .2s ease;
}
.user-chip:hover { border-color: var(--accent); background: var(--surface); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.user-menu { position: relative; }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 10px); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  min-width: 170px; box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-8px); pointer-events: none; transition: all .2s ease;
}
.user-menu.open .user-dropdown { opacity: 1; transform: translateY(0); pointer-events: auto; }
.user-dropdown a, .user-dropdown button {
  display: block; width: 100%; text-align: left; padding: 12px 16px; background: none; border: none;
  color: var(--text); font-size: 13px; transition: background .15s ease;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--surface); }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: none; border-radius: 8px; padding: 12px 22px;
  font-weight: 700; font-size: 14px; transition: transform .18s ease, box-shadow .18s ease, background .2s ease;
}
.btn:active { transform: scale(.96); }
.btn-primary { background: #fff; color: #0a0a10; }
.btn-primary:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 10px 30px rgba(255,255,255,.15); }
.btn-ghost { background: rgba(255,255,255,.08); color: var(--text); border: 1px solid rgba(255,255,255,.16); }
.btn-ghost:hover { background: rgba(255,255,255,.16); transform: translateY(-2px); }
.btn-ghost.active { background: var(--accent-gradient); border-color: transparent; }
.btn-block { width: 100%; justify-content: center; }
.btn-back {
  background: none; border: none; color: var(--text-muted); font-size: 14px; font-weight: 600;
  margin: 20px 0 0 32px; transition: color .2s ease, transform .2s ease;
}
.btn-back:hover { color: var(--text); transform: translateX(-4px); }

/* =========================================================
   HERO
   ========================================================= */
.hero { position: relative; height: 78vh; min-height: 460px; overflow: hidden; }
.hero-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(0deg, var(--bg) 0%, rgba(10,10,16,.35) 55%, rgba(10,10,16,.15) 100%),
              linear-gradient(90deg, rgba(10,10,16,.85) 0%, rgba(10,10,16,.15) 65%);
}
.hero-content { position: absolute; left: 48px; bottom: 64px; max-width: 620px; }
.eyebrow {
  display: inline-block; text-transform: uppercase; letter-spacing: 2px; font-size: 12px;
  font-weight: 800; color: var(--accent); margin-bottom: 12px;
}
.hero-title {
  font-family: var(--font-display); font-size: clamp(38px, 6vw, 64px); line-height: 1;
  margin: 0 0 16px; letter-spacing: .5px;
}
.hero-desc { color: var(--text-muted); font-size: 15px; line-height: 1.6; margin-bottom: 24px; max-width: 520px; }
.hero-actions { display: flex; gap: 14px; }

/* =========================================================
   RAILS + CARDS
   ========================================================= */
.rail-section { padding: 40px 32px 8px; }
.rail-title, .section-subtitle {
  font-size: 20px; font-weight: 800; margin: 0 0 18px; letter-spacing: .3px;
}
.rail { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 14px; scroll-snap-type: x proximity; }
.rail::-webkit-scrollbar { height: 8px; }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 18px;
}

.card {
  position: relative; border-radius: var(--radius); overflow: hidden; cursor: pointer;
  background: var(--surface); aspect-ratio: 2/3; flex: 0 0 170px; scroll-snap-align: start;
  transition: transform .28s cubic-bezier(.2,.8,.2,1), box-shadow .28s ease;
  animation: card-in .5s ease both;
}
.grid .card { flex: none; }
@keyframes card-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.card:hover { transform: translateY(-8px) scale(1.045); box-shadow: var(--shadow-lg); z-index: 5; }
.card img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease, filter .4s ease; }
.card:hover img { transform: scale(1.08); }
.card-fallback {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  font-family: var(--font-display); font-size: 15px; text-align: center; padding: 14px; color: var(--text-muted);
}
.card-overlay {
  position: absolute; inset: 0; display: flex; align-items: flex-end; padding: 12px;
  background: linear-gradient(0deg, rgba(0,0,0,.85) 0%, transparent 55%);
  opacity: 0; transition: opacity .25s ease;
}
.card:hover .card-overlay { opacity: 1; }
.card-overlay span { font-size: 13px; font-weight: 700; }
.card-progress { position: absolute; left: 0; bottom: 0; height: 4px; background: rgba(255,255,255,.2); width: 100%; }
.card-progress-fill { height: 100%; background: var(--accent-gradient); }

.skeleton {
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* =========================================================
   ANIME PAGE
   ========================================================= */
.anime-banner { height: 320px; background: linear-gradient(135deg, var(--surface-2), var(--surface)); position: relative; }
.anime-banner-overlay { position: absolute; inset: 0; background: linear-gradient(0deg, var(--bg), transparent); }
.anime-header { display: flex; gap: 28px; padding: 0 40px; margin-top: -140px; position: relative; align-items: flex-end; }
.anime-cover {
  width: 220px; aspect-ratio: 2/3; object-fit: cover; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); border: 3px solid var(--bg); animation: slide-in-left .5s ease both;
}
@keyframes slide-in-left { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: translateX(0); } }
.anime-info { padding-bottom: 12px; animation: fade-in-up .5s .1s ease both; }
.anime-info h1 { font-family: var(--font-display); font-size: 40px; margin: 0 0 10px; }
.anime-tags { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.anime-tags span { background: var(--surface-2); border: 1px solid var(--border); padding: 4px 12px; border-radius: 999px; font-size: 12px; color: var(--text-muted); }
.anime-desc { color: var(--text-muted); max-width: 640px; line-height: 1.7; margin-bottom: 20px; }
.anime-actions { display: flex; gap: 14px; }

.episode-list { padding: 0 40px 60px; display: flex; flex-direction: column; gap: 10px; }
.episode-row {
  display: flex; align-items: center; gap: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px;
  transition: background .2s ease, transform .2s ease, border-color .2s ease;
  animation: fade-in-up .4s ease both;
}
.episode-row:hover { background: var(--surface-2); border-color: var(--accent); transform: translateX(6px); }
.episode-num {
  width: 42px; height: 42px; border-radius: 50%; background: var(--surface-2); display: flex;
  align-items: center; justify-content: center; font-weight: 800; flex-shrink: 0;
}
.episode-title { font-weight: 600; flex: 1; }
.episode-play {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent-gradient); display: flex;
  align-items: center; justify-content: center; color: #fff; flex-shrink: 0; transition: transform .2s ease;
}
.episode-row:hover .episode-play { transform: scale(1.15); }

/* =========================================================
   PLAYER PAGE
   ========================================================= */
.player-page { padding-bottom: 60px; }
.player-wrap { padding: 20px 32px; }
.player-video { width: 100%; max-height: 76vh; border-radius: var(--radius-lg); background: #000; box-shadow: var(--shadow-lg); }
.player-meta { padding: 0 32px 24px; }
.player-meta h1 { font-family: var(--font-display); font-size: 26px; margin: 4px 0 4px; }
.player-meta p { color: var(--text-muted); margin: 0; }
.player-page .episode-list { padding: 0 32px 40px; }

/* =========================================================
   PROFILE PAGE
   ========================================================= */
.profile-page, .catalog-page { padding: 48px 40px 80px; max-width: 1400px; margin: 0 auto; }
.page-title { font-family: var(--font-display); font-size: 34px; margin: 0 0 28px; }
.profile-header { display: flex; align-items: center; gap: 20px; margin-bottom: 40px; }
.profile-avatar {
  width: 84px; height: 84px; border-radius: 50%; background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 32px;
}
.muted { color: var(--text-muted); margin: 4px 0 0; }
.history-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 40px; }
.history-row {
  display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 16px; cursor: pointer; transition: transform .2s ease, border-color .2s ease;
}
.history-row:hover { transform: translateX(6px); border-color: var(--accent); }
.empty-state { color: var(--text-muted); padding: 20px 0; }

/* =========================================================
   MODAL / AUTH
   ========================================================= */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,4,8,.75); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px; width: 380px; position: relative; box-shadow: var(--shadow-lg);
  transform: scale(.92) translateY(10px); transition: transform .25s cubic-bezier(.2,.8,.2,1);
}
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }
.modal-close {
  position: absolute; top: 14px; right: 16px; background: none; border: none; color: var(--text-muted);
  font-size: 22px; line-height: 1; transition: color .2s ease, transform .2s ease;
}
.modal-close:hover { color: var(--text); transform: rotate(90deg); }

.auth-tabs { display: flex; gap: 4px; background: var(--surface-2); border-radius: 999px; padding: 4px; margin-bottom: 24px; }
.auth-tab {
  flex: 1; background: none; border: none; padding: 9px; border-radius: 999px; font-weight: 700;
  font-size: 13px; color: var(--text-muted); transition: all .2s ease;
}
.auth-tab.active { background: var(--accent-gradient); color: #fff; }

.auth-form { display: flex; flex-direction: column; gap: 16px; animation: fade-in-up .3s ease both; }
.auth-form label { font-size: 12px; color: var(--text-muted); display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.auth-form input {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 14px; border-radius: 8px; font-size: 14px; transition: border-color .2s ease, background .2s ease;
}
.auth-form input:focus { outline: none; border-color: var(--accent); background: #20202e; }
.form-error { color: var(--accent); font-size: 12px; min-height: 14px; margin: -6px 0 0; }

/* =========================================================
   TOASTS
   ========================================================= */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--surface-2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 14px 18px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-lg);
  animation: toast-in .3s ease both;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
.toast.leaving { animation: toast-out .25s ease both; }
@keyframes toast-out { to { opacity: 0; transform: translateX(30px); } }

/* =========================================================
   GENERIC ANIMATIONS
   ========================================================= */
.fade-in-up { animation: fade-in-up .5s ease both; }
@keyframes fade-in-up { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }

.spinner {
  width: 40px; height: 40px; border: 3px solid var(--surface-2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 60px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 860px) {
  .navbar-inner { flex-wrap: wrap; gap: 12px; padding: 12px 18px; }
  .nav-links { order: 3; width: 100%; justify-content: center; }
  .navbar-search input { width: 140px; }
  .navbar-search input:focus { width: 180px; }
  .hero { height: 60vh; }
  .hero-content { left: 20px; bottom: 32px; }
  .anime-header { flex-direction: column; align-items: flex-start; margin-top: -80px; padding: 0 20px; }
  .anime-cover { width: 150px; }
  .rail-section, .episode-list, .profile-page, .catalog-page { padding-left: 18px; padding-right: 18px; }
}
