/* ──────────────────────────────────────────
   HEADER
   The header is a single element that lives at three sizes:
     1. tall           — top of the page, no scroll yet            (var(--header-h))
     2. shrunk         — after scrolling past hero                 (var(--header-h-shrunk))
     3. mega           — burger clicked, expands to full viewport  (100vh)

   Visual continuity: the mega-open state reuses the *shrunk* (frosted) look —
   the top bar simply stays at its scrolled-state height and the lower portion
   fills the rest of the screen with the mega-menu content.

   Markup:
     <header class="header">
       <div class="header-bar"> ← the original top-bar row
         ...nav, logo-slot, lang, burger
       </div>
       <div class="mega"> ← the panel that lives below; only visible when open
         ...
       </div>
     </header>
─────────────────────────────────────────── */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow: hidden;           /* clips .mega while header is collapsed */
  border-bottom: 1px solid transparent;
  transition:
    height 0.62s var(--ease-out-quint),
    background-color 0.5s var(--ease-out-quint),
    backdrop-filter 0.5s var(--ease-out-quint),
    border-color 0.5s var(--ease-out-quint);
}
.header.scrolled {
  height: var(--header-h-shrunk);
  background: rgba(19, 19, 19, 0.55);
  backdrop-filter: blur(18px) saturate(1.1);
  -webkit-backdrop-filter: blur(18px) saturate(1.1);
  border-bottom: 1px solid var(--light-ghost);
}

/* Menu-open: header grows to full viewport, frosted look stays.
   JS adds `.scrolled` if it wasn't already there (matches user's spec:
   "if not scrolled, force scrolled when opening"), so the bg/blur
   below is guaranteed via the .scrolled rule above. */
body.menu-open .header {
  height: 100vh;
}

/* ──────────────────────────────────────────
   TOP BAR — the original horizontal row (unchanged behavior)
─────────────────────────────────────────── */
.header-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 48px;
  height: var(--header-h);
  transition: height 0.5s var(--ease-out-quint);
}
.header.scrolled .header-bar {
  height: var(--header-h-shrunk);
}

/* ── Header sides ─────────────────────────── */
.header-side {
  display: flex;
  align-items: center;
  gap: 36px;
  flex: 1;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.9s var(--ease-out-quint) 1.6s, transform 0.9s var(--ease-out-quint) 1.6s;
}
.header-side.right { justify-content: flex-end; gap: 24px; }
body.loaded .header-side { opacity: 1; transform: translateY(0); }

/* ── WhatsApp contact (left side of top bar) ── */
.header-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--light);
  text-decoration: none;
  padding: 4px 0;
  transition: color 0.4s ease;
}
.header-whatsapp:hover { color: var(--light-dim); }
.header-whatsapp svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.4s var(--ease-out-quint);
}
.header-whatsapp:hover svg { transform: scale(1.1); }

/* ── Logo slot (placeholder, real logo is fixed) ──── */
.logo-slot {
  width: var(--logo-size);
  height: var(--logo-size);
  flex-shrink: 0;
  transition: width 0.5s var(--ease-out-quint), height 0.5s var(--ease-out-quint);
}
.header.scrolled .logo-slot {
  width: var(--logo-size-shrunk);
  height: var(--logo-size-shrunk);
}

/* ── Fixed logo — animates from screen-center to header-center ──── */
.logo {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 180px;
  height: 180px;
  transform: translate(-50%, -50%);
  z-index: 150;
  transition:
    top 1.4s var(--ease-out-quint) 0.9s,
    width 1.4s var(--ease-out-quint) 0.9s,
    height 1.4s var(--ease-out-quint) 0.9s,
    opacity 0.8s ease 0.2s;
  opacity: 0;
  pointer-events: none;
  /* The logo is also an <a href="index.html"> — kill default link chrome */
  text-decoration: none;
  color: inherit;
  display: block;
}
/* Clickable only once docked into the header (intro animation is over) */
body.docked .logo {
  pointer-events: auto;
  cursor: pointer;
}
body.loaded .logo { opacity: 1; }
body.docked .logo {
  top: calc(var(--header-h) / 2);
  width: var(--logo-size);
  height: var(--logo-size);
  transition:
    top 0.5s var(--ease-out-quint),
    width 0.5s var(--ease-out-quint),
    height 0.5s var(--ease-out-quint);
}
body.docked.scrolled-state .logo {
  top: calc(var(--header-h-shrunk) / 2);
  width: var(--logo-size-shrunk);
  height: var(--logo-size-shrunk);
}
.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 24px rgba(0, 0, 0, 0.4));
}

/* ── Language switcher ────────────────────── */
.lang-switcher {
  position: relative;
  display: flex;
  align-items: center;
}
.lang-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid transparent;
  color: var(--light);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 2px;
  transition: border-color 0.4s ease, background-color 0.4s ease;
}
.lang-trigger:hover { border-color: var(--light-faint); }
.lang-trigger .chev {
  width: 10px;
  height: 10px;
  transition: transform 0.4s var(--ease-out-quint);
  display: inline-block;
}
.lang-switcher.open .lang-trigger { border-color: var(--light-faint); background: rgba(196, 186, 176, 0.04); }
.lang-switcher.open .chev { transform: rotate(180deg); }

.lang-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 110px;
  background: rgba(19, 19, 19, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--light-faint);
  border-radius: 2px;
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.4s var(--ease-out-quint);
}
.lang-switcher.open .lang-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.lang-option {
  display: block;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  color: var(--light);
  font-family: var(--serif);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
  border-radius: 2px;
  transition: background-color 0.3s ease, padding-left 0.3s ease;
}
.lang-option:hover {
  background: rgba(196, 186, 176, 0.08);
  padding-left: 18px;
}

/* ── Burger menu ──────────────────────────── */
.burger {
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  position: relative;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.burger-inner {
  width: 30px;
  height: 14px;
  position: relative;
}
.burger-inner span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: var(--light);
  border-radius: 2px;
  transition: transform 0.5s var(--ease-out-quint), top 0.3s var(--ease-out-quint), opacity 0.3s ease;
}
.burger-inner span:nth-child(1) { top: 0; }
.burger-inner span:nth-child(2) { top: 12px; }
.burger:hover .burger-inner span:nth-child(1) { transform: translateX(-2px); }
.burger:hover .burger-inner span:nth-child(2) { transform: translateX(2px); }
.burger.active .burger-inner span:nth-child(1) {
  top: 6px;
  transform: rotate(45deg);
}
.burger.active .burger-inner span:nth-child(2) {
  top: 6px;
  transform: rotate(-45deg);
}

/* ──────────────────────────────────────────
   MEGA MENU
   Lives inside <header>. Hidden by default; fades in 300ms after the header
   has begun expanding so the panel feels "filled in", not "popped open".
─────────────────────────────────────────── */
.mega {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}
body.menu-open .mega {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.5s ease 0.28s, visibility 0s linear 0.28s;
}

.mega-inner {
  flex: 1 1 auto;
  width: 100%;
  max-width: 1700px;
  margin: 0 auto;
  padding: clamp(32px, 5vh, 72px) 80px clamp(24px, 4vh, 48px);
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.1fr);
  gap: clamp(40px, 6vw, 96px);
  align-items: center;
  min-height: 0;          /* lets the inner grid shrink within flex parent */
}

/* ──────────────────────────────────────────
   LEFT · live preview pane
   The image swaps on link hover (JS). Cross-fade is a CSS opacity transition.
─────────────────────────────────────────── */
.mega-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;             /* taller — portrait, anchors the menu visually */
  max-height: 74vh;
  border-radius: 18px;
  overflow: hidden;
  margin: 0;
  background: var(--dark-deep);
  box-shadow:
    0 30px 60px -25px rgba(0, 0, 0, 0.6),
    0 0 0 1px var(--light-ghost);
}
.mega-preview-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transform: scale(1.045);
  transition:
    opacity 0.55s var(--ease-out-quint),
    transform 0.9s var(--ease-out-quint);
}
.mega-preview-img.is-active {
  opacity: 1;
  transform: scale(1);
}
/* ──────────────────────────────────────────
   RIGHT · numbered nav rows
─────────────────────────────────────────── */
.mega-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}
.mega-nav li {
  border-top: 1px solid var(--light-ghost);
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.4s var(--ease-out-quint),
    transform 0.4s var(--ease-out-quint);
}
.mega-nav li:last-child { border-bottom: 1px solid var(--light-ghost); }
body.menu-open .mega-nav li { opacity: 1; transform: translateY(0); }
body.menu-open .mega-nav li:nth-child(1) { transition-delay: 0.36s; }
body.menu-open .mega-nav li:nth-child(2) { transition-delay: 0.40s; }
body.menu-open .mega-nav li:nth-child(3) { transition-delay: 0.44s; }
body.menu-open .mega-nav li:nth-child(4) { transition-delay: 0.48s; }
body.menu-open .mega-nav li:nth-child(5) { transition-delay: 0.52s; }
body.menu-open .mega-nav li:nth-child(6) { transition-delay: 0.56s; }

.mega-link {
  display: grid;
  grid-template-columns: 56px 1fr 32px;
  align-items: center;
  gap: 24px;
  padding: clamp(18px, 2.4vh, 28px) 8px;
  text-decoration: none;
  color: var(--light);
  font-family: var(--serif);
  transition:
    padding-left 0.55s var(--ease-out-quint),
    opacity 0.35s ease,
    color 0.4s ease;
}
.mega-link:hover { padding-left: 22px; }

.mega-index {
  font-size: 11px;
  letter-spacing: 0.3em;
  color: var(--light-dim);
  font-feature-settings: 'tnum' 1;
  transition: color 0.4s ease;
}
.mega-link:hover .mega-index { color: var(--light); }

.mega-label {
  font-size: clamp(26px, 3vw, 42px);
  font-weight: 400;
  letter-spacing: 0.005em;
  line-height: 1;
}

.mega-arrow {
  width: 22px;
  height: 22px;
  opacity: 0;
  transform: translateX(-14px);
  transition:
    opacity 0.4s ease,
    transform 0.5s var(--ease-out-quint);
  justify-self: end;
}
.mega-link:hover .mega-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* Focus follows the eye: when any link is hovered, dim the others.
   Uses :has() — supported in modern browsers (Chrome/Safari/Firefox 121+).
   The "restore opacity on the hovered one" rule has to match the same
   :has() context, otherwise the dim rule outranks it on specificity
   (because :has(.mega-link:hover) carries the specificity of its argument). */
.mega-nav:has(.mega-link:hover) .mega-link        { opacity: 0.38; }
.mega-nav:has(.mega-link:hover) .mega-link:hover  { opacity: 1; }

/* ──────────────────────────────────────────
   BOTTOM STRIP — contact + social
─────────────────────────────────────────── */
.mega-strip {
  flex: 0 0 auto;
  width: 100%;
  max-width: 1700px;
  margin: 0 auto;
  padding: 24px 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid var(--light-ghost);
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--light-dim);
}
.mega-contact {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.mega-contact a {
  color: var(--light-dim);
  text-decoration: none;
  transition: color 0.3s ease;
}
.mega-contact a:hover { color: var(--light); }
.mega-contact .dot { color: var(--light-faint); }

.mega-social {
  display: flex;
  align-items: center;
  gap: 18px;
}
.mega-social a {
  color: var(--light-dim);
  text-decoration: none;
  transition: color 0.3s ease;
}
.mega-social a:hover { color: var(--light); }

/* ──────────────────────────────────────────
   MOTION FALLBACK
─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .header,
  .header-bar,
  .mega,
  .mega-nav li,
  .mega-preview-img,
  .mega-link,
  .mega-arrow {
    transition-duration: 0.001s !important;
    transition-delay: 0s !important;
  }
}

/* ──────────────────────────────────────────
   RESPONSIVE
─────────────────────────────────────────── */
@media (max-width: 1000px) {
  .mega-inner {
    grid-template-columns: 1fr;
    gap: 28px;
    padding: 32px 32px 0;
    align-items: start;
  }
  .mega-preview {
    aspect-ratio: 16 / 9;
    max-height: 32vh;
  }
  .mega-link {
    grid-template-columns: 40px 1fr 22px;
    gap: 16px;
    padding: 18px 4px;
  }
  .mega-label { font-size: 24px; }
  .mega-strip {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 20px 32px;
  }
}

@media (max-width: 600px) {
  .mega-inner { padding: 24px 20px 0; }
  .mega-preview { display: none; }   /* small screens: skip the preview, just list */
  .mega-link { padding: 16px 4px; }
  .mega-label { font-size: 22px; }
  .mega-strip { padding: 16px 20px; }
}

/* ──────────────────────────────────────────
   RESPONSIVE — mobile top-bar
   These rules used to live in responsive.css but they're shared by every
   page that has a header, so they belong here.
─────────────────────────────────────────── */
@media (max-width: 900px) {
  .header-bar { padding: 0 20px; }
  .header-side { gap: 16px; }
  .lang-trigger { font-size: 11px; padding: 6px 10px; }
  .header-whatsapp { font-size: 12px; gap: 8px; }
  .header-whatsapp svg { width: 16px; height: 16px; }
}
@media (max-width: 480px) {
  /* On very small screens, hide the number text — icon only */
  .header-whatsapp span { display: none; }
}
