/**
 * Portfolio theme system — Light (default) / Dark + global 3D layer
 */

/* ------------------------------------------------------------------ */
/* Theme toggle                                                        */
/* ------------------------------------------------------------------ */
.theme-toggle {
  --toggle-w: 52px;
  --toggle-h: 28px;
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 9999;
  width: var(--toggle-w);
  height: var(--toggle-h);
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 999px;
}

.theme-toggle-track {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-color), var(--default-color) 8%);
  border: 1px solid color-mix(in srgb, var(--default-color), transparent 82%);
  box-shadow: 0 2px 12px color-mix(in srgb, var(--default-color), transparent 88%);
  transition: background 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
  position: relative;
}

.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(var(--toggle-h) - 6px);
  height: calc(var(--toggle-h) - 6px);
  border-radius: 50%;
  background: linear-gradient(145deg, #ffffff, #e8eef8);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  transition: transform 0.4s cubic-bezier(0.34, 1.2, 0.64, 1), background 0.35s ease;
}

.theme-toggle.is-dark .theme-toggle-thumb {
  transform: translateX(calc(var(--toggle-w) - var(--toggle-h)));
  background: linear-gradient(145deg, #1e293b, #0f172a);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.theme-toggle.is-dark .theme-toggle-track {
  background: rgba(15, 25, 45, 0.85);
  border-color: rgba(56, 189, 248, 0.25);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.12);
}

.theme-toggle-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.theme-toggle-icon-light {
  left: 8px;
  color: #f59e0b;
  opacity: 1;
}

.theme-toggle-icon-dark {
  right: 7px;
  color: #38bdf8;
  opacity: 0.45;
}

.theme-toggle.is-dark .theme-toggle-icon-light {
  opacity: 0.35;
}

.theme-toggle.is-dark .theme-toggle-icon-dark {
  opacity: 1;
}

@media (max-width: 576px) {
  .theme-toggle {
    top: 14px;
    left: 14px;
    --toggle-w: 48px;
    --toggle-h: 26px;
  }
}

/* Language switcher — sits next to theme toggle */
.lang-switcher {
  position: fixed;
  top: 18px;
  left: 82px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-color), var(--default-color) 8%);
  border: 1px solid color-mix(in srgb, var(--default-color), transparent 82%);
  box-shadow: 0 2px 12px color-mix(in srgb, var(--default-color), transparent 88%);
  backdrop-filter: blur(8px);
}

.lang-switcher-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: color-mix(in srgb, var(--default-color), transparent 25%);
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
  padding: 0.42rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease;
}

.lang-switcher-btn:hover {
  color: var(--default-color);
  background: color-mix(in srgb, var(--default-color), transparent 92%);
}

.lang-switcher-btn.is-active {
  color: #fff;
  background: var(--accent-color, #0d6efd);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent-color, #0d6efd), transparent 55%);
}

html[data-theme="dark"] .lang-switcher {
  background: rgba(15, 25, 45, 0.85);
  border-color: rgba(56, 189, 248, 0.25);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.12);
}

html[data-theme="dark"] .lang-switcher-btn {
  color: rgba(226, 232, 240, 0.65);
}

html[data-theme="dark"] .lang-switcher-btn.is-active {
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: #fff;
}

@media (max-width: 576px) {
  .lang-switcher {
    top: 14px;
    left: 72px;
    padding: 2px;
  }
  .lang-switcher-btn {
    padding: 0.36rem 0.45rem;
    font-size: 0.62rem;
  }
}

/* ------------------------------------------------------------------ */
/* Global 3D background layer (dark mode only)                        */
/* ------------------------------------------------------------------ */
.global-3d-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.8s ease;
}

html[data-theme="dark"] .global-3d-background.is-active {
  opacity: 1;
}

.global-3d-background canvas {
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.global-3d-background canvas.model-ready {
  opacity: 1;
}

/* Dark mode atmosphere: deep cosmic cyan / navy gradient */
.global-3d-atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 65% 45%, rgba(56, 189, 248, 0.18) 0%, transparent 65%),
    radial-gradient(ellipse 100% 80% at 50% 100%, rgba(6, 92, 194, 0.25) 0%, transparent 60%),
    linear-gradient(180deg, rgba(7, 11, 20, 0.15) 0%, rgba(7, 11, 20, 0.55) 100%);
}

.main {
  position: relative;
  z-index: 1;
}

/* ------------------------------------------------------------------ */
/* Dark theme tokens                                                   */
/* ------------------------------------------------------------------ */
html[data-theme="dark"] {
  color-scheme: dark;

  --background-color: #070b14;
  --default-color: #b8c9e0;
  --heading-color: #eef4ff;
  --accent-color: #38bdf8;
  --surface-color: rgba(13, 22, 38, 0.88);
  --contrast-color: #ffffff;

  --nav-color: #94a3b8;
  --nav-hover-color: #38bdf8;
  --nav-mobile-background-color: rgba(8, 13, 24, 0.97);
  --nav-dropdown-background-color: rgba(12, 22, 40, 0.95);
  --nav-dropdown-color: #94a3b8;
  --nav-dropdown-hover-color: #ffffff;

  --theme-border: rgba(56, 189, 248, 0.12);
  --theme-border-strong: rgba(56, 189, 248, 0.22);
  --theme-glass: rgba(10, 18, 32, 0.78);
  --theme-input-bg: rgba(8, 14, 26, 0.9);
  --theme-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] body {
  background-color: transparent;
}

html[data-theme="dark"] .section {
  background-color: transparent;
}

html[data-theme="dark"] .light-background {
  --background-color: rgba(8, 13, 22, 0.72);
  --surface-color: rgba(13, 22, 38, 0.88);
}

html[data-theme="dark"] .page-title.light-background {
  background: rgba(8, 13, 22, 0.78);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Header */
html[data-theme="dark"] .header {
  --background-color: rgba(7, 11, 20, 0.55);
}

html[data-theme="dark"] body.scrolled .header {
  --background-color: rgba(7, 11, 20, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .mobile-nav-toggle {
  color: var(--nav-hover-color);
}

/* Footer */
html[data-theme="dark"] .footer {
  background: rgba(5, 9, 18, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--theme-border);
}

/* Hero */
html[data-theme="dark"] .hero::before {
  opacity: 0;
}

html[data-theme="dark"] .hero .lead {
  color: color-mix(in srgb, var(--default-color), transparent 8%);
}

/* Cards & surfaces */
html[data-theme="dark"] .skill-card,
html[data-theme="dark"] .service-item,
html[data-theme="dark"] .experience-card,
html[data-theme="dark"] .education-content,
html[data-theme="dark"] .portfolio-entry,
html[data-theme="dark"] .testimonial-item,
html[data-theme="dark"] .critic-review,
html[data-theme="dark"] .faq-item,
html[data-theme="dark"] .info-box,
html[data-theme="dark"] .contact-form,
html[data-theme="dark"] .floating-card,
html[data-theme="dark"] .feature-item,
html[data-theme="dark"] .service-sidebar .service-menu,
html[data-theme="dark"] .portfolio-details-content,
html[data-theme="dark"] .skills-summary {
  background: var(--theme-glass) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--theme-border);
  box-shadow: var(--theme-shadow);
}

html[data-theme="dark"] .hero .floating-card {
  background: rgba(13, 22, 38, 0.75);
}

html[data-theme="dark"] .hero .hero-actions .btn.btn-outline {
  border-color: var(--theme-border-strong);
  color: var(--heading-color);
}

html[data-theme="dark"] .hero .hero-actions .btn.btn-outline:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--accent-color);
  color: var(--accent-color);
}

html[data-theme="dark"] .hero .social-links a {
  background: rgba(13, 22, 38, 0.8);
  border: 1px solid var(--theme-border);
}

/* Forms */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .php-email-form input,
html[data-theme="dark"] .php-email-form textarea {
  background-color: var(--theme-input-bg);
  border-color: var(--theme-border);
  color: var(--heading-color);
}

html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .php-email-form input:focus,
html[data-theme="dark"] .php-email-form textarea:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] .php-email-form input::placeholder,
html[data-theme="dark"] .php-email-form textarea::placeholder {
  color: color-mix(in srgb, var(--default-color), transparent 40%);
}

/* Progress bars */
html[data-theme="dark"] .progress {
  background-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .progress-bar {
  background-color: var(--accent-color);
}

/* Portfolio filters */
html[data-theme="dark"] .portfolio-filters li {
  background: var(--theme-glass);
  border: 1px solid var(--theme-border);
  color: var(--default-color);
}

html[data-theme="dark"] .portfolio-filters li.filter-active {
  background: color-mix(in srgb, var(--accent-color), transparent 75%);
  border-color: var(--accent-color);
  color: var(--heading-color);
}

/* Breadcrumbs */
html[data-theme="dark"] .breadcrumbs a {
  color: var(--accent-color);
}

html[data-theme="dark"] .breadcrumbs .current {
  color: var(--default-color);
}

/* Scroll top */
html[data-theme="dark"] .scroll-top {
  background: rgba(13, 22, 38, 0.9);
  border: 1px solid var(--theme-border);
}

/* Section title underline accents */
html[data-theme="dark"] .section-title h2::after {
  background: linear-gradient(90deg, var(--accent-color), transparent);
}

/* Swiper pagination */
html[data-theme="dark"] .swiper-pagination-bullet {
  background: rgba(255, 255, 255, 0.35);
}

html[data-theme="dark"] .swiper-pagination-bullet-active {
  background: var(--accent-color);
}

/* Readability veil over 3D when earth is active */
html[data-theme="dark"] .main,
html[data-theme="dark"] .footer {
  position: relative;
  z-index: 1;
}

html[data-theme="dark"] .global-3d-background.is-active ~ .main::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(7, 11, 20, 0.1) 0%,
    rgba(7, 11, 20, 0.25) 50%,
    rgba(7, 11, 20, 0.45) 100%
  );
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle-thumb,
  .theme-toggle-track,
  .global-3d-background {
    transition: none !important;
  }
}
