/* ================================================================
   EUROSTIL DESIGN PROIECT — main.css
   Single source of truth for shared UI styles
   ================================================================ */

/* ── 1. GOOGLE FONTS (preload hint) ─────────────────────────── */
/* Loaded via <link> in HTML head for better performance */

/* ── 2. CUSTOM PROPERTIES ────────────────────────────────────── */
:root {
  /* Brand palette */
  --charcoal:       #3a4a48;
  --charcoal-light: #5a6a68;
  --charcoal-dark:  #2a3a38;
  --white:          #ffffff;
  --off-white:      #f8f7f5;
  --cream:          #f0eeea;
  --warm-gray:      #e5e2dc;
  --text-light:     #8a8a86;
  --accent:         #7a6a50;

  /* Typography */
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans:  'Karla', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Footer — intentionally NOT overridden in dark mode */
  --footer-bg:   #111414;
  --footer-text: rgba(255, 255, 255, 0.4);
  --footer-link: rgba(255, 255, 255, 0.6);
}

/* ── Dark mode overrides via data-theme on <html> ─────────── */
[data-theme="dark"] {
  --charcoal:       #e8e6e2;
  --charcoal-light: #b8b4ae;
  --charcoal-dark:  #f0eeea;   /* NOTE: only used for text, never for bg */
  --white:          #1a1e1d;
  --off-white:      #222726;
  --cream:          #2a2e2d;
  --warm-gray:      #3a3e3d;
  --text-light:     #8a8a86;
  --accent:         #b8a898;
  /* footer-bg stays #111414 — always dark */
}

/* ── 3. RESET ─────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  overflow-x: hidden;
}

body {
  font-family: var(--sans);
  color: var(--charcoal);
  background: var(--white);
  overflow-x: hidden;
}

/* ── 4. GRID BACKGROUND ──────────────────────────────────────── */
.grid-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.03;
  background-image:
    linear-gradient(var(--charcoal) 1px, transparent 1px),
    linear-gradient(90deg, var(--charcoal) 1px, transparent 1px);
  background-size: 80px 80px;
}
[data-theme="dark"] .grid-bg { opacity: 0.015; }

/* ── 5. PAGE LOADER ───────────────────────────────────────────── */
#page-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white);
  pointer-events: all;
  transition: opacity 0.5s ease;
}
#page-loader.exit {
  opacity: 0;
  pointer-events: none;
}
#page-loader .loader-logo {
  width: 52px;
  height: 52px;
  animation: logoPulse 1.6s ease-in-out infinite;
}
[data-theme="dark"] #page-loader .loader-logo {
  filter: brightness(0) invert(1);
}
@keyframes logoPulse {
  0%, 100% { opacity: 0.35; transform: scale(0.94); }
  50%       { opacity: 1;    transform: scale(1); }
}

/* ── 6. NAVIGATION — BASE ────────────────────────────────────── */
nav {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  z-index: 100;
  padding: 1.5rem 4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: transparent;
  transition: padding 0.4s ease, background 0.4s ease, backdrop-filter 0.4s ease;
}
nav.scrolled { padding: 1rem 4rem; }

.nav-logo {
  height: 44px;
  transition: height 0.4s ease, filter 0.4s ease, opacity 0.4s ease;
}
nav.scrolled .nav-logo { height: 38px; }

/* Dark mode: invert logo to white */
[data-theme="dark"] .nav-logo { filter: brightness(0) invert(1); }

.nav-links {
  display: flex;
  gap: 2.5rem;
  list-style: none;
  align-items: center;
}
.nav-links a {
  text-decoration: none;
  color: var(--charcoal);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 500;
  position: relative;
  transition: color 0.3s ease;
}
.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 0;
  width: 0; height: 1px;
  background: var(--charcoal);
  transition: width 0.3s ease;
}
.nav-links a:hover::after { width: 100%; }
.nav-links .nav-toggle-li { display: flex; align-items: center; }

/* ── 7. ADAPTIVE NAV — desktop only ─────────────────────────── */
/*
 * .on-dark  → nav sits over a dark section (index, servicii via JS observer)
 * .over-hero → nav sits over the dark project hero (proiect.html)
 * Both classes are DISABLED on mobile (overridden below in media query)
 */

@media (min-width: 769px) {
  /*
   * FIX: data-theme is on <html>, not <body>.
   *
   * TWO separate adaptive nav behaviors:
   *   nav.over-hero  → proiect.html hero photo (always dark image, always needs white nav)
   *   nav.on-dark    → JS observer: nav over a dark section (index portfolio, servicii process)
   *                    In dark mode these sections INVERT to light → nav needs dark text
   */

  /* over-hero: ALWAYS white regardless of theme (hero photo is dark in both themes) */
  nav.over-hero .nav-logo {
    filter: brightness(0) invert(1);
    opacity: 0.88;
  }
  nav.over-hero .nav-links a {
    color: rgba(255, 255, 255, 0.82);
  }
  nav.over-hero .nav-links a::after {
    background: rgba(255, 255, 255, 0.6);
  }
  nav.over-hero .theme-toggle {
    border: none;
  }
  nav.over-hero .theme-toggle svg {
    stroke: currentColor;
  }

  /* on-dark light mode: white nav over dark section */
  html:not([data-theme="dark"]) nav.on-dark .nav-logo {
    filter: brightness(0) invert(1);
    opacity: 0.88;
  }
  html:not([data-theme="dark"]) nav.on-dark .nav-links a {
    color: rgba(255, 255, 255, 0.82);
  }
  html:not([data-theme="dark"]) nav.on-dark .nav-links a::after {
    background: rgba(255, 255, 255, 0.6);
  }
  html:not([data-theme="dark"]) nav.on-dark .theme-toggle svg {
    stroke: rgba(255, 255, 255, 0.85);
  }

  /* on-dark dark mode: sections become light → nav needs dark text */
  [data-theme="dark"] nav.on-dark .nav-logo {
    filter: brightness(0);
    opacity: 1;
  }
  [data-theme="dark"] nav.on-dark .nav-links a {
    color: #1a1e1d;
  }
  [data-theme="dark"] nav.on-dark .nav-links a::after {
    background: #1a1e1d;
  }
  [data-theme="dark"] nav.on-dark .theme-toggle svg {
    stroke: #1a1e1d;
  }
}

/* ── 8. MOBILE NAV — static colors, bg on scroll ─────────── */
@media (max-width: 768px) {
  /* Frosted background after scroll — theme aware */
  nav.scrolled {
    background: rgba(248, 247, 245, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }
  [data-theme="dark"] nav.scrolled {
    background: rgba(26, 30, 29, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  /* DISABLE on-dark adaptive changes on mobile (only .on-dark, not .over-hero) */
  nav.on-dark .nav-logo {
    filter: none !important;
    opacity: 1 !important;
  }
  [data-theme="dark"] nav.on-dark .nav-logo {
    filter: brightness(0) invert(1) !important;
    opacity: 1 !important;
  }
  nav.on-dark .nav-links a    { color: var(--charcoal) !important; }
  nav.on-dark .theme-toggle   { border-color: var(--warm-gray) !important; }
  nav.on-dark .theme-toggle svg { stroke: var(--charcoal) !important; }

  /*
   * PROJECT PAGE — MOBILE over-hero:
   * .over-hero desktop rules (white nav) bleed into mobile because the media
   * query only gates the ON-DARK block above. We need to also neutralise
   * over-hero on mobile when scrolled. We do this via body.hero-over class:
   *   added by JS when nav has .over-hero AND NOT .scrolled
   *   removed by JS when nav gains .scrolled
   * This lets us target burger (which is outside <nav>) and nav simultaneously.
   */

  /* When entering the project page on mobile: white logo + white burger over dark hero */
  body.hero-over nav.over-hero .nav-logo {
    filter: brightness(0) invert(1) !important;
    opacity: 0.9 !important;
  }
  body.hero-over .burger span {
    background: rgba(255, 255, 255, 0.9) !important;
  }
  /* When burger is OPEN, overlay is white — X must be dark regardless of hero-over */
  body.hero-over .burger.open span {
    background: var(--charcoal) !important;
  }
  [data-theme="dark"] body.hero-over .burger.open span {
    background: #e8e6e2 !important;
  }
  /* After scroll: frosted bg visible, revert to theme-correct colors */
  body:not(.hero-over) nav.over-hero .nav-logo {
    filter: none !important;
    opacity: 1 !important;
  }
  [data-theme="dark"] body:not(.hero-over) nav.over-hero .nav-logo {
    filter: brightness(0) invert(1) !important;
    opacity: 1 !important;
  }
  body:not(.hero-over) .burger span {
    background: var(--charcoal) !important;
  }
  [data-theme="dark"] body:not(.hero-over) .burger span {
    background: #e8e6e2 !important;
  }
  nav.on-dark .burger span,
  nav.over-hero .burger span {
    background: var(--charcoal) !important;
  }
}

/* ── 9. BURGER ────────────────────────────────────────────────── */
.burger {
  display: none;
  cursor: pointer;
  width: 32px; height: 24px;
  position: fixed;
  top: 1.6rem; right: 4rem;
  z-index: 150;
}
.burger span {
  display: block;
  width: 100%; height: 2px;
  background: var(--charcoal);
  position: absolute; left: 0;
  transition: all 0.35s ease;
  transform-origin: center;
}
[data-theme="dark"] .burger span { background: #e8e6e2; }

.burger span:nth-child(1) { top: 0; }
.burger span:nth-child(2) { top: 11px; }
.burger span:nth-child(3) { top: 22px; }
.burger.open span:nth-child(1) { top: 11px;  transform: rotate(45deg); }
.burger.open span:nth-child(2) { opacity: 0;  transform: scaleX(0); }
.burger.open span:nth-child(3) { top: 11px;  transform: rotate(-45deg); }

/* ── 10. MOBILE OVERLAY ──────────────────────────────────────── */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--white);
  z-index: 120;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
}
.mobile-overlay.open { display: flex; }
.mobile-overlay a {
  text-decoration: none;
  color: var(--charcoal);
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 400;
  transition: color 0.3s;
}
.mobile-overlay a:hover { color: var(--charcoal-light); }
.overlay-top {
  position: absolute;
  top: 1.4rem; left: 2rem;
}
.overlay-logo { height: 34px; }
[data-theme="dark"] .overlay-logo { filter: brightness(0) invert(1); }

/* ── 11. THEME SWITCH (TOGGLE) ────────────────────────── */
.theme-switch {
  width: 44px;
  height: 22px;
  background: var(--warm-gray); /* Fundalul "pistei" */
  border-radius: 20px;
  border: none;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0 4px;
  transition: background 0.4s ease;
}

.switch-circle {
  width: 14px;
  height: 14px;
  background: var(--charcoal); /* Cercul care culisează */
  border-radius: 50%;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.4s ease;
}

/* Starea de Dark Mode (când [data-theme="dark"] este pe <html>) */
[data-theme="dark"] .theme-switch {
  background: #3a3e3d; /* O nuanță mai închisă pentru pistă în dark mode */
}

[data-theme="dark"] .switch-circle {
  transform: translateX(22px); /* Mută cercul la dreapta */
  background: #e8e6e2;
}

/* Ajustare pentru navigația pe fundal închis (on-dark) pe Desktop */
@media (min-width: 769px) {
  html:not([data-theme="dark"]) nav.on-dark .theme-switch {
    background: rgba(255, 255, 255, 0.2);
  }
  html:not([data-theme="dark"]) nav.on-dark .switch-circle {
    background: #ffffff;
  }
}

/* ── 12. FOOTER ───────────────────────────────────────────────── */
/*
 * Footer always uses --footer-bg (#111414) which is NOT overridden
 * in [data-theme="dark"], so it stays dark in both themes.
 */
footer {
  position: relative;
  z-index: 1;
  background: var(--footer-bg);
  color: var(--footer-text);
  padding: 3rem 4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}
footer a {
  color: var(--footer-link);
  text-decoration: none;
  transition: color 0.3s;
}
footer a:hover { color: #ffffff; }
.footer-links { display: flex; gap: 2rem; }

/* ── 13. SECTION BASE ────────────────────────────────────────── */
section { position: relative; z-index: 1; padding: 8rem 4rem; }
.section-label {
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 1.5rem;
  font-weight: 500;
}
.section-title {
  font-family: var(--serif);
  font-size: 3rem;
  font-weight: 300;
  line-height: 1.3;
  margin-bottom: 2rem;
}
.section-line {
  width: 40px; height: 1px;
  background: var(--charcoal);
  margin-bottom: 2rem;
}

/* ── 14. REVEAL ANIMATION ────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(40px);
  transition:
    opacity  0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal-delay-1 { transition-delay: 0.15s; }
.reveal-delay-2 { transition-delay: 0.30s; }
.reveal-delay-3 { transition-delay: 0.45s; }

/* ── 15. VIEW-ALL LINK ────────────────────────────────────────── */
/*
 * Base: designed for light backgrounds (services section etc.)
 * .portfolio overrides: white text/border on the charcoal dark background
 * IMPORTANT: hover does NOT change color to var(--charcoal) because on dark
 * backgrounds that would make text invisible (same color as background).
 */
.view-all-link {
  display: inline-block;
  margin-top: 3rem;
  color: var(--charcoal-light);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--warm-gray);
  padding-bottom: 4px;
  transition: color 0.3s, border-color 0.3s;
}
.view-all-link:hover {
  color: var(--charcoal);
  border-bottom-color: var(--charcoal);
}

/* Portfolio section: dark charcoal background in light mode, light bg in dark mode */
/* Light mode: white text on dark bg */
.portfolio .view-all-link {
  color: rgba(255, 255, 255, 0.65);
  border-bottom-color: rgba(255, 255, 255, 0.3);
}
.portfolio .view-all-link:hover {
  color: #ffffff;
  border-bottom-color: #ffffff;
}
/* Dark mode: portfolio bg becomes light (var(--charcoal) = #e8e6e2) → dark text */
[data-theme="dark"] .portfolio .view-all-link {
  color: var(--charcoal-light);
  border-bottom-color: var(--warm-gray);
}
[data-theme="dark"] .portfolio .view-all-link:hover {
  color: var(--charcoal);
  border-bottom-color: var(--charcoal);
}

/* ── 16. RESPONSIVE BASE ──────────────────────────────────────── */
@media (max-width: 1024px) {
  nav         { padding: 1.2rem 2rem; }
  nav.scrolled { padding: 1rem 2rem; }
  section     { padding: 5rem 2rem; }
  .section-title { font-size: 2.4rem; }
}
@media (max-width: 768px) {
  .nav-links { display: none; }
  .burger    { display: block; right: 2rem; }
}
@media (max-width: 640px) {
  nav                { padding: 1rem 1.5rem; }
  .burger            { right: 1.5rem; top: 1.2rem; }
  section            { padding: 4rem 1.5rem; }
  footer             { flex-direction: column; gap: 1.5rem; text-align: center; padding: 2rem 1.5rem; }
  .footer-links      { gap: 1.5rem; }
  #page-loader .loader-logo { width: 44px; height: 44px; }
}

/* Invertirea imaginilor din descriere doar în Dark Mode */
[data-theme="dark"] .project-description img {
  filter: invert(1) hue-rotate(180deg);
  opacity: 0.85; /* Opțional: le face puțin mai șlefuite pentru ochi pe fundal închis */
  mix-blend-mode: plus-lighter; /* Ajută la integrarea mai bună pe fundalul dark */
}