/* ==========================================================================
   Capitan Gamenet — Design System Base
   ========================================================================== */

:root,
[data-theme="light"] {
  /* Colors — Light (default) */
  --color-primary: #6366F1;
  --color-primary-dark: #4F46E5;
  --color-secondary: #64748B;
  --color-blue: #0EA5E9;
  --color-bg: #F8FAFC;
  --color-white: #FFFFFF;
  --color-gray-soft: rgba(99, 102, 241, 0.08);
  --color-border: rgba(15, 23, 42, 0.1);
  --color-success: #16A34A;
  --color-error: #DC2626;
  --color-warning: #D97706;
  --color-text: #0F172A;
  --color-text-muted: #64748B;
  --color-accent: #DC2626;
  --color-accent-dark: #B91C1C;
  --color-accent-glow: rgba(220, 38, 38, 0.22);
  --color-indigo-glow: rgba(99, 102, 241, 0.22);

  /* Surfaces */
  --surface-glass: rgba(255, 255, 255, 0.92);
  --surface-border: rgba(99, 102, 241, 0.12);
  --gradient-primary: linear-gradient(135deg, #6366F1 0%, #DC2626 55%, #F97316 100%);
  --gradient-cta: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
  --gradient-bg:
    radial-gradient(ellipse 90% 60% at 15% -5%, rgba(99, 102, 241, 0.08), transparent 55%),
    radial-gradient(ellipse 70% 50% at 95% 5%, rgba(220, 38, 38, 0.05), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(99, 102, 241, 0.04), transparent 60%),
    linear-gradient(180deg, #F8FAFC 0%, #F1F5F9 45%, #F8FAFC 100%);

  /* Shadows */
  --shadow-soft: 0 14px 44px rgba(15, 23, 42, 0.07);
  --shadow-card: 0 12px 36px rgba(99, 102, 241, 0.12);
  --shadow-glow: 0 10px 36px var(--color-indigo-glow);

  /* Glass */
  --glass-bg: rgba(255, 255, 255, 0.92);
  --glass-blur: blur(16px);
}

[data-theme="dark"] {
  /* Colors — Dark Cinema */
  --color-primary: #818CF8;
  --color-primary-dark: #6366F1;
  --color-secondary: #334155;
  --color-blue: #38BDF8;
  --color-bg: #0B1220;
  --color-white: #1A2332;
  --color-gray-soft: rgba(99, 102, 241, 0.12);
  --color-border: rgba(148, 163, 184, 0.14);
  --color-success: #22C55E;
  --color-error: #F87171;
  --color-warning: #FBBF24;
  --color-text: #F1F5F9;
  --color-text-muted: #94A3B8;
  --color-accent: #DC2626;
  --color-accent-dark: #B91C1C;
  --color-accent-glow: rgba(220, 38, 38, 0.35);
  --color-indigo-glow: rgba(99, 102, 241, 0.35);

  --surface-glass: rgba(26, 35, 50, 0.72);
  --surface-border: rgba(99, 102, 241, 0.18);
  --gradient-bg:
    radial-gradient(ellipse 90% 60% at 15% -5%, rgba(99, 102, 241, 0.22), transparent 55%),
    radial-gradient(ellipse 70% 50% at 95% 5%, rgba(220, 38, 38, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(99, 102, 241, 0.08), transparent 60%),
    linear-gradient(180deg, #0B1220 0%, #0F172A 45%, #0B1220 100%);

  --shadow-soft: 0 12px 40px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 8px 32px rgba(99, 102, 241, 0.15);
  --shadow-glow: 0 8px 32px var(--color-indigo-glow);
  --glass-bg: rgba(11, 18, 32, 0.82);
}

:root {
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 999px;

  /* Spacing (8px grid) */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;
  --space-10: 80px;
  --space-12: 96px;

  /* Layout */
  --container-max: 1200px;
  --header-height: 64px;
  --topbar-height: 52px;
  --tabbar-height: 60px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --content-padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom) + var(--space-2));

  /* Typography — Yekan */
  --font-body: 'Yekan', Tahoma, system-ui, sans-serif;
  --font-display: 'Yekan', Tahoma, system-ui, sans-serif;
  --font-family: var(--font-body);
  --font-size-body: 15px;
  --font-size-sm: 13px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-h1: clamp(26px, 3.5vw, 34px);
  --font-size-h2: clamp(22px, 2.8vw, 28px);
  --font-size-h3: clamp(18px, 2.2vw, 22px);
  --line-height: 1.75;
  --line-height-tight: 1.25;

  /* Transitions — soft easing (overridden further in performance.css) */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: 160ms var(--ease-soft);
  --transition-base: 280ms var(--ease-out);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  line-height: var(--line-height);
  color: var(--color-text);
  background: var(--gradient-bg);
  direction: rtl;
  text-align: right;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--safe-top);
}

/* Keep body visible — soft enter handled in performance.css */
body.page-loading,
body.page-ready {
  opacity: 1;
}

img, svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-dark);
}

ul, ol {
  list-style: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Typography */
h1, h2, h3, h4, h5, h6,
.font-display {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--line-height-tight);
  color: var(--color-text);
  letter-spacing: 0.015em;
}

.font-body {
  font-family: var(--font-body);
}

h1 { font-size: var(--font-size-h1); }
h2 { font-size: var(--font-size-h2); }
h3 { font-size: var(--font-size-h3); }

p, li, label, input, select, textarea, .text-body {
  font-size: var(--font-size-body);
}

.text-muted { color: var(--color-text-muted); }
.text-accent { color: var(--color-primary); }
.text-center { text-align: center; }
.text-sm { font-size: var(--font-size-sm); }
.text-md { font-size: var(--font-size-md); }

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-2);
}

@media (min-width: 768px) {
  .container {
    padding-inline: var(--space-3);
  }
}

/* Main content area */
.app-main {
  min-height: calc(100dvh - var(--header-height));
  padding-bottom: var(--content-padding-bottom);
}

@media (min-width: 768px) {
  :root {
    --content-padding-bottom: var(--space-6);
  }

  .app-main {
    min-height: calc(100dvh - var(--header-height) - 200px);
    padding-bottom: var(--space-6);
  }
}

/* Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hide-mobile { display: none !important; }
.hide-desktop { display: block !important; }

@media (min-width: 768px) {
  .hide-mobile { display: block !important; }
  .hide-desktop { display: none !important; }
}

/* Grid */
.grid {
  display: grid;
  gap: var(--space-2);
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 767px) {
  .grid--3, .grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Section */
.section {
  padding-block: clamp(20px, 3vw, 32px);
}

.section__header {
  margin-bottom: var(--space-3);
}

.section__header--row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.section__heading {
  min-width: 0;
}

.section__title {
  position: relative;
  padding-inline-end: var(--space-2);
  font-family: var(--font-display);
  font-size: var(--font-size-h2);
  line-height: 1.25;
}

.section__title::before {
  content: '';
  position: absolute;
  inset-inline-end: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 70%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
}

.section__subtitle {
  margin: 8px 0 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
