/* ==========================================================================
   TeaHouse Fansub - Core Design System & Global Styles
   Inspired by REVIVE, LazySano & Bruuhim with a cozy Matcha & Obsidian theme
   ========================================================================== */

:root {
  /* Color Tokens */
  --bg-darkest: #070a0d;
  --bg-base: #0b0f14;
  --bg-surface: #111720;
  --bg-surface-elevated: #16202c;
  --bg-card: rgba(18, 26, 36, 0.75);
  --bg-card-solid: #131c26;
  --bg-glass: rgba(13, 19, 26, 0.82);
  --bg-glass-input: rgba(10, 15, 22, 0.7);

  /* Brand Accents (Matcha Green & Warm Amber Tea) */
  --tea-green: #10b981;
  --tea-green-light: #34d399;
  --tea-green-dark: #059669;
  --tea-green-glow: rgba(16, 185, 129, 0.28);
  --tea-green-subtle: rgba(16, 185, 129, 0.12);

  --tea-amber: #f59e0b;
  --tea-amber-light: #fbbf24;
  --tea-amber-glow: rgba(245, 158, 11, 0.25);
  --tea-amber-subtle: rgba(245, 158, 11, 0.12);

  --tea-crimson: #f43f5e;
  --tea-blue: #38bdf8;
  --tea-purple: #a855f7;

  /* Typography Colors */
  --text-pure: #ffffff;
  --text-main: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --text-faint: #4b5563;

  /* Borders & Shadows */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.18);
  --border-matcha: rgba(16, 185, 129, 0.35);
  --border-amber: rgba(245, 158, 11, 0.35);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.7);
  --shadow-glow-matcha: 0 0 25px rgba(16, 185, 129, 0.35);
  --shadow-glow-amber: 0 0 25px rgba(245, 158, 11, 0.3);

  /* Layout & Radii */
  --container-max: 1380px;
  --header-height: 76px;
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.18s ease;
  --transition-smooth: 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  --transition-bounce: 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Reset & Box Sizing */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  direction: rtl;
  text-align: right;
  background-color: var(--bg-darkest);
  color: var(--text-main);
  font-family: 'Readex Pro', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  background: 
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(16, 185, 129, 0.08), transparent 70%),
    radial-gradient(circle at 10% 40%, rgba(245, 158, 11, 0.04), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.05), transparent 45%),
    var(--bg-darkest);
  display: flex;
  flex-direction: column;
}

/* Custom Japanese Tea Vapor Particle Canvas / Ambient Glow */
#ambient-vapor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.65;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-darkest);
}
::-webkit-scrollbar-thumb {
  background: #1f2b37;
  border-radius: 4px;
  border: 2px solid var(--bg-darkest);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--tea-green-dark);
}

/* Typography Enhancements */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Cairo', 'Readex Pro', sans-serif;
  font-weight: 800;
  color: var(--text-pure);
  line-height: 1.3;
}

a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition-fast);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
  border: none;
  outline: none;
  background: transparent;
  color: inherit;
}

button {
  cursor: pointer;
}

/* Restore visible keyboard focus (global outline reset above removes it) */
:focus-visible {
  outline: 2px solid var(--tea-green-light);
  outline-offset: 2px;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Layout Utilities */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 24px;
  padding-right: 24px;
  position: relative;
  z-index: 2;
}

.main-content {
  flex: 1;
  padding-top: calc(var(--header-height) + 16px);
  padding-bottom: 80px;
  position: relative;
  z-index: 2;
}

/* Navigation Header */
.site-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  height: var(--header-height);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 100;
  transition: var(--transition-smooth);
}

.site-header.scrolled {
  background: rgba(7, 10, 13, 0.94);
  border-bottom-color: rgba(16, 185, 129, 0.15);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* Brand Logo */
.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-symbol {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(245, 158, 11, 0.15));
  border: 1px solid var(--border-matcha);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 12px rgba(16, 185, 129, 0.2);
  transition: var(--transition-bounce);
}

.brand-logo:hover .logo-symbol {
  transform: rotate(-6deg) scale(1.06);
  border-color: var(--tea-green);
  box-shadow: var(--shadow-glow-matcha);
}

.logo-symbol svg {
  width: 26px;
  height: 26px;
  color: var(--tea-green-light);
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.6));
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-family: 'Outfit', 'Cairo', sans-serif;
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  background: linear-gradient(120deg, #ffffff 40%, var(--tea-green-light) 90%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logo-tag {
  font-size: 0.68rem;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* Nav Links */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}

.nav-item {
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--transition-fast);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--text-pure);
  background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
  color: var(--tea-green-light);
  background: var(--tea-green-subtle);
  border-color: var(--border-matcha);
}

.nav-link svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

/* Dropdown Menu (الأعمال) */
.nav-dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  min-width: 220px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px;
  list-style: none;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(24px);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: var(--transition-smooth);
  z-index: 120;
}

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-main);
  transition: var(--transition-fast);
}

.dropdown-item a:hover {
  background: var(--tea-green-subtle);
  color: var(--tea-green-light);
  transform: translateX(-4px);
}

.dropdown-badge {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

/* Header Action Buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Search Trigger Bar in Header */
.quick-search-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-size: 0.88rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.quick-search-trigger:hover {
  border-color: var(--tea-green);
  color: var(--text-main);
  background: rgba(16, 185, 129, 0.05);
}

.quick-search-kbd {
  font-family: 'Outfit', sans-serif;
  font-size: 0.72rem;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

/* Mobile Toggle */
.mobile-toggle-btn {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  align-items: center;
  justify-content: center;
  color: var(--text-main);
}

/* Site Footer */
.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 18px 0;
  position: relative;
  z-index: 2;
}


/* Badges & Tags */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-bd {
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: #eff6ff;
  border: 1px solid rgba(147, 197, 253, 0.3);
}

.badge-web {
  background: linear-gradient(135deg, #065f46, #10b981);
  color: #ecfdf5;
  border: 1px solid rgba(110, 231, 183, 0.3);
}

.badge-dvd {
  background: linear-gradient(135deg, #78350f, #d97706);
  color: #fffbeb;
  border: 1px solid rgba(252, 211, 77, 0.3);
}

.badge-ova {
  background: linear-gradient(135deg, #581c87, #9333ea);
  color: #faf5ff;
  border: 1px solid rgba(216, 180, 254, 0.3);
}

.badge-movie {
  background: linear-gradient(135deg, #831843, #ec4899);
  color: #fdf2f8;
  border: 1px solid rgba(244, 114, 182, 0.3);
}

.badge-ongoing {
  background: rgba(16, 185, 129, 0.15);
  color: var(--tea-green-light);
  border: 1px solid var(--border-matcha);
}

.badge-completed {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-new {
  background: #f43f5e;
  color: #ffffff;
  animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.5);
  }
  50% {
    box-shadow: 0 0 12px 4px rgba(244, 63, 94, 0.25);
  }
}

/* Back to Top Button */
.back-to-top-btn {
  position: fixed;
  bottom: 30px;
  left: 30px;
  width: 46px;
  height: 46px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-matcha);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tea-green-light);
  box-shadow: var(--shadow-md), 0 0 15px rgba(16, 185, 129, 0.2);
  cursor: pointer;
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.back-to-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top-btn:hover {
  background: var(--tea-green-dark);
  color: #fff;
  border-color: var(--tea-green-light);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg), var(--shadow-glow-matcha);
}

@media (max-width: 768px) {
  .back-to-top-btn {
    bottom: 80px;
    left: 20px;
    width: 42px;
    height: 42px;
  }
}
