/* ============================================================
   GLOBAL THEME SYSTEM LAYER
   Loaded on frontend + auth pages AFTER main.css / auth.css and
   the dynamic theme variables (theme-styles component).
   Handles:
     - smooth scrolling (with reduced-motion respect)
     - dark / light mode (data-theme-mode on <html>)
     - logo alignment fixes
     - per-theme structural tweaks (data-theme on <html>)
   ============================================================ */

/* ---------- Smooth scroll (global) ---------- */
html {
  scroll-behavior: smooth;
}

/* ---------- Dark mode: override the theme tokens ---------- */
html[data-theme-mode="dark"] {
  --background-color: #0E141C;
  --default-color: #CBD5E1;
  --heading-color: #E7EDF4;
  --accent-color: var(--site-primary, #0EA5FF);
  --surface-color: #151D27;
  --contrast-color: #FFFFFF;
  --site-background: #0E141C;
  --site-surface: #151D27;
  --site-text: #CBD5E1;
  --site-heading: #E7EDF4;
  --site-muted: #8B98A8;
  --site-border: #232D3A;
  --nav-mobile-background-color: #10161E;
  --nav-dropdown-background-color: #151D27;
  --nav-dropdown-color: #CBD5E1;
  --footer-bg-custom: #090E14;
}

html[data-theme-mode="dark"] body,
html[data-theme-mode="dark"] .site-theme-bg {
  color: var(--default-color, #CBD5E1);
}

/* ---------- 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;
    scroll-behavior: auto !important;
  }
}

/* ---------- Dark / light toggle button ---------- */
.theme-toggle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--site-border, #E9EEF3);
  background: var(--site-surface, #F5F7FA);
  color: var(--site-text, #1A1F25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease;
  line-height: 1;
  padding: 0;
}

.theme-toggle-btn:hover {
  background: var(--site-primary, #0EA5FF);
  color: var(--site-contrast, #FFFFFF);
  transform: translateY(-2px);
}

/* ---------- Logo alignment ---------- */
.header .logo,
header .logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  line-height: 1;
  text-decoration: none;
  flex-shrink: 0;
}

.header .logo img,
header .logo img {
  max-height: 42px;
  width: auto;
  height: auto;
  display: block;
  object-fit: contain;
}

.header .logo .sitename,
header .logo h1.sitename {
  margin: 0;
  line-height: 1;
  font-size: 1.5rem;
  font-weight: 700;
}

@media (max-width: 576px) {
  .header .logo img,
  header .logo img {
    max-height: 36px;
  }

  .header .logo .sitename,
  header .logo h1.sitename {
    font-size: 1.3rem;
  }
}

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--site-primary, #0EA5FF);
  color: var(--site-contrast, #FFFFFF);
  font-size: 1.15rem;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 900;
  box-shadow: 0 12px 28px rgba(12, 15, 18, 0.25);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.back-to-top.show {
  display: inline-flex;
}

.back-to-top:hover {
  transform: translateY(-3px);
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: none; }
}

/* ---------- Per-theme structural tweaks ---------- */

/* Modern Developer: subtle code-grid backdrop on hero + sections */
html[data-theme="modern-developer"] body {
  background-image: radial-gradient(rgba(37, 99, 235, 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
}

html[data-theme="modern-developer"] .hero,
html[data-theme="modern-developer"] #hero {
  background:
    linear-gradient(160deg, rgba(11, 17, 32, 0.55), rgba(11, 17, 32, 0.25)),
    radial-gradient(700px 400px at 85% 20%, rgba(37, 99, 235, 0.25), transparent 60%);
}

/* Ultra Modern: glass cards + gradient hero text */
html[data-theme="ultra-modern"] .card,
html[data-theme="ultra-modern"] .portfolio-item,
html[data-theme="ultra-modern"] .service-card,
html[data-theme="ultra-modern"] .testimonial-item {
  border: 1px solid rgba(124, 58, 237, 0.14);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

html[data-theme="ultra-modern"] .hero h1,
html[data-theme="ultra-modern"] #hero h1,
html[data-theme="ultra-modern"] .section-title h2 {
  background: linear-gradient(120deg, #7C3AED, #EC4899);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #7C3AED;
}

/* Minimal Professional: hairline borders, no hover lift */
html[data-theme="minimal-professional"] .portfolio-item,
html[data-theme="minimal-professional"] .service-card {
  border: 1px solid #E5E7EB;
  box-shadow: none !important;
  border-radius: 2px;
}

/* Creative Designer: playful accent borders on hover */
html[data-theme="creative-designer"] .portfolio-item:hover,
html[data-theme="creative-designer"] .service-card:hover {
  border-color: #FF4D8D;
  transform: translateY(-6px) rotate(-0.5deg);
}

/* Photographer: full-bleed images, no border, generous spacing */
html[data-theme="photographer"] .portfolio-item,
html[data-theme="photographer"] .service-card,
html[data-theme="photographer"] .card {
  border: 0;
  border-radius: 0;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

html[data-theme="photographer"] .portfolio-item img,
html[data-theme="photographer"] .service-card img {
  border-radius: 0;
}

/* Software Engineer: terminal-style cards */
html[data-theme="software-engineer"] .portfolio-item,
html[data-theme="software-engineer"] .service-card {
  border: 1px solid #1B2A31;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.06);
  background: #0E171B;
}

html[data-theme="software-engineer"] .portfolio-item::before,
html[data-theme="software-engineer"] .service-card::before {
  content: "";
  display: block;
  height: 26px;
  margin-bottom: 10px;
  border-bottom: 1px solid #1B2A31;
  background:
    radial-gradient(circle at 12px 50%, #F87171 4px, transparent 5px),
    radial-gradient(circle at 26px 50%, #FBBF24 4px, transparent 5px),
    radial-gradient(circle at 40px 50%, #34D399 4px, transparent 5px);
}

/* Agency: strong drop shadows + indigo glow */
html[data-theme="agency"] .portfolio-item,
html[data-theme="agency"] .service-card {
  box-shadow: 0 24px 60px rgba(79, 70, 229, 0.14);
}

html[data-theme="agency"] .hero,
html[data-theme="agency"] #hero {
  background: radial-gradient(800px 460px at 80% 10%, rgba(79, 70, 229, 0.18), transparent 60%);
}

/* Artist / Creative: flowing section separators + expressive headings */
html[data-theme="artist-creative"] .section-title h2,
html[data-theme="artist-creative"] .hero h1,
html[data-theme="artist-creative"] #hero h1 {
  font-family: "Playfair Display", Georgia, serif;
  font-style: italic;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Premium Executive: serif headings, thin gold rule, subtle motion */
html[data-theme="premium-executive"] h1,
html[data-theme="premium-executive"] h2,
html[data-theme="premium-executive"] h3,
html[data-theme="premium-executive"] .section-title h2 {
  font-family: "Playfair Display", Georgia, serif;
  letter-spacing: 0.01em;
  color: #1C1917;
}

html[data-theme="premium-executive"] .section-title::after {
  background: #A67C2E;
  height: 1px;
  width: 70px;
}

/* Freelancer: vibrant CTA cards */
html[data-theme="freelancer"] .cta,
html[data-theme="freelancer"] .hero {
  background: linear-gradient(135deg, #0F172A, #10B981);
}
