/* Shared site UI (navigation, drawer, language dropdown)
 * Goal: consistent premium UX + better caching/SEO via shared assets.
 */

:root {
  --ui-overlay: rgba(17, 24, 39, 0.35);
  --ui-border: rgba(0, 0, 0, 0.08);
  --ui-card: rgba(17, 24, 39, 0.03);
  --ui-card-border: rgba(17, 24, 39, 0.06);
  --ui-accent: rgba(102, 126, 234, 0.12);
  --ui-accent-border: rgba(102, 126, 234, 0.18);
  --ui-drawer-width: min(420px, 92vw);
  --ui-top-offset: 72px;
}

/* Header: keep visible but compact */
header {
  position: sticky;
  top: 0;
  z-index: 2000;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
}

@media (max-width: 360px) {
  .header-content {
    flex-wrap: wrap;
  }
}

/* Hamburger button */
.nav-toggle {
  display: inline-flex;
  margin-left: auto;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 0; /* icon via ::before */
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-toggle:hover {
  transform: translateY(-1px);
  border-color: var(--ui-accent-border);
  background: var(--ui-accent);
}

.nav-toggle::before {
  content: "☰";
  font-size: 22px;
  line-height: 1;
  color: var(--text-dark, #2c3e50);
}

.nav-toggle.active::before {
  content: "✕";
}

/* Backdrop when drawer open */
body.menu-open {
  overflow: hidden;
}

body.menu-open::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--ui-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1998;
}

/* Default: keep nav visible on large screens? No - we use drawer everywhere to save space */
.main-nav {
  display: none !important;
}

/* Mobile drawer (top drop-down taking 50vh) */
@media (max-width: 820px) {
  .main-nav.is-open {
    display: flex !important;
    position: fixed;
    left: 0;
    right: 0;
    top: var(--ui-top-offset);
    height: 50vh;
    max-height: 50vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    flex-direction: column;
    flex-wrap: nowrap !important;
    overflow-x: hidden;
    align-items: stretch;
    gap: 8px;
    padding: 16px;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    border-bottom: 1px solid var(--ui-border);
    z-index: 1999;
  }

  .main-nav.is-open a {
    width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--ui-card);
    border: 1px solid var(--ui-card-border);
  }
}

/* Desktop drawer (right slide-in) */
@media (min-width: 821px) {
  .main-nav {
    display: flex !important;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--ui-drawer-width);
    height: 100vh;
    padding: 84px 16px 16px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: -18px 0 50px rgba(0, 0, 0, 0.16);
    border-left: 1px solid var(--ui-border);
    transform: translateX(110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 260ms ease, opacity 260ms ease;
    gap: 10px;
    align-items: stretch;
    flex-direction: column;
    flex-wrap: nowrap !important;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1999;
  }

  .main-nav.is-open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .main-nav::before {
    content: "Menu";
    position: fixed;
    top: 14px;
    right: 16px;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(44, 62, 80, 0.7);
    padding: 10px 12px;
    border-radius: 999px;
    background: rgba(102, 126, 234, 0.10);
    border: 1px solid var(--ui-accent-border);
    z-index: 2001;
  }

  .main-nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--ui-card);
    border: 1px solid var(--ui-card-border);
    transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .main-nav a::after {
    content: "→";
    color: rgba(44, 62, 80, 0.35);
    font-weight: 700;
  }

  .main-nav a:hover {
    background: rgba(102, 126, 234, 0.10);
    border-color: var(--ui-accent-border);
    transform: translateX(-2px);
  }

  .main-nav a.is-current {
    background: rgba(102, 126, 234, 0.14);
    border-color: rgba(102, 126, 234, 0.28);
  }
}

/* Language dropdown (mobile fixed, desktop absolute) */
.language-selector {
  position: relative;
  z-index: 3004;
}

.lang-dropdown {
  display: none;
  z-index: 3005;
}

.lang-dropdown.active {
  display: block;
}

@media (max-width: 820px) {
  .lang-dropdown {
    position: fixed;
    left: 16px;
    right: 16px;
    top: var(--ui-top-offset);
    max-height: calc(50vh - 24px);
    overflow-y: auto;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
  }
}

@media (min-width: 821px) {
  .lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    min-width: 220px;
    max-height: 60vh;
    overflow-y: auto;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
  }
}

/* Focus styles (keyboard) */
.nav-toggle:focus-visible,
.main-nav a:focus-visible,
.lang-btn:focus-visible,
.lang-dropdown a:focus-visible {
  outline: 2px solid rgba(102, 126, 234, 0.65);
  outline-offset: 2px;
  border-radius: 10px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }

  .main-nav,
  body.menu-open::before,
  .nav-toggle {
    transition: none !important;
  }
}

