/* ==========================================================================
   Dragonfall — shared header + navigation.
   Loaded on EVERY page, before theme.css. theme.css then re-skins it (glass
   bar, ember accents, drawer tint), so this file only owns structure and
   behaviour: where things sit, how big they are, and how the mobile drawer
   opens. Keep colours as tokens with fallbacks so the page still renders if
   theme.css or the page's own stylesheet is missing.
   ========================================================================== */

.wrap{
  width:100%;
  max-width:1080px;
  margin:0 auto;
  padding:0 1.25rem;
}

/* ---------- Bar ---------- */
header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:.75rem;
  padding:1.25rem 0;
  position:relative;
  z-index:100;
}
header > *:not(.nav):not(.nav-overlay){min-width:0}

.logo{
  /* Fluid: at 264px the wordmark plus the two 44px buttons do not fit at the
     full size, and `nowrap` used to paint the overflow over the language
     button. Scaling with the viewport keeps it readable on phones without
     ever clipping or overlapping. */
  font:700 clamp(.95rem, 4.2vw, 1.35rem) var(--pixel, Georgia, serif);
  text-decoration:none;
  letter-spacing:.02em;
  white-space:nowrap;
  /* keeps the dragon glyph on the same baseline as the wordmark */
  display:inline-flex;
  align-items:center;
  gap:.35rem;
  min-width:0;
}
.logo b{color:var(--ember, #ff6b4a);font-weight:700}

/* ---------- Desktop nav ---------- */
.nav{
  display:flex;
  gap:1.5rem;
  font:600 .95rem var(--ui, system-ui, sans-serif);
}
.nav a{
  color:var(--muted, #cdb8aa);
  text-decoration:none;
  white-space:nowrap;
  position:relative;
  padding:.15rem 0;
  /* comfortable hit area without moving the visual baseline */
  display:inline-flex;
  align-items:center;
  min-height:36px;
}
.nav a:hover,
.nav a[aria-current="page"]{color:var(--text, #f6ece4)}
.nav a[aria-current="page"]::after{
  content:"";
  position:absolute;
  left:0;
  bottom:.1rem;
  width:100%;
  height:2px;
  background:var(--teal, #ffc766);
}

/* ---------- Language toggle ---------- */
.lang{
  flex:none;
  min-width:44px;
  min-height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:rgba(255,255,255,.06);
  border:1px solid var(--line, rgba(255,170,100,.22));
  color:var(--muted, #cdb8aa);
  font:600 .875rem var(--ui, system-ui, sans-serif);
  border-radius:6px;
  cursor:pointer;
  transition:background .15s, color .15s, border-color .15s;
}
.lang:hover{color:var(--text, #f6ece4);border-color:var(--muted, #cdb8aa);background:rgba(255,255,255,.1)}

/* ---------- Hamburger ---------- */
.menu-toggle{
  display:none;
  flex:none;
  align-items:center;
  justify-content:center;
  width:44px;
  height:44px;
  padding:0;
  background:rgba(255,255,255,.06);
  border:1px solid var(--line, rgba(255,170,100,.22));
  border-radius:6px;
  color:var(--text, #f6ece4);
  cursor:pointer;
  transition:border-color .2s ease, background .2s ease;
}
.menu-toggle:hover{border-color:var(--muted, #cdb8aa)}
.menu-toggle svg{width:22px;height:22px;display:block}
.menu-toggle .close-icon{display:none}
.menu-toggle[aria-expanded="true"] .menu-icon{display:none}
.menu-toggle[aria-expanded="true"] .close-icon{display:block}

/* ---------- Backdrop behind the drawer ---------- */
.nav-overlay{
  display:none;
  position:fixed;
  inset:0;
  background:rgba(10,16,32,.85);
  -webkit-backdrop-filter:blur(4px);
  backdrop-filter:blur(4px);
  z-index:98;
  opacity:0;
  transition:opacity .3s ease;
}
.nav-overlay.is-open{opacity:1}

/* ---------- Mobile: drawer ---------- */
@media(max-width:768px){
  header{padding:1rem 0}

  .menu-toggle{display:flex}

  /* logo left; language button and hamburger grouped on the right */
  .lang{margin-left:auto}

  .nav-overlay{display:block;pointer-events:none}
  .nav-overlay.is-open{pointer-events:auto}

  .nav{
    position:fixed;
    top:0;
    right:0;
    bottom:0;
    width:min(320px,86vw);
    display:flex;
    flex-direction:column;
    gap:0;
    padding:calc(4.5rem + env(safe-area-inset-top, 0px)) 1.5rem calc(2rem + env(safe-area-inset-bottom, 0px));
    background:rgba(17,26,46,.92);
    border-left:1px solid var(--line, rgba(255,170,100,.22));
    z-index:99;
    transform:translateX(100%);
    transition:transform .3s cubic-bezier(.4,0,.2,1);
    overflow-y:auto;
    -webkit-backdrop-filter:blur(16px) saturate(1.3);
    backdrop-filter:blur(16px) saturate(1.3);
    overscroll-behavior:contain;
  }
  .nav.open{transform:translateX(0)}

  .nav a{
    display:flex;
    align-items:center;
    min-height:52px;
    padding:.9rem .25rem;
    font-size:1.05rem;
    border-bottom:1px solid var(--line, rgba(255,170,100,.22));
    color:var(--muted, #cdb8aa);
  }
  .nav a:last-child{border-bottom:none}
  /* the underline marker belongs to the desktop bar only */
  .nav a[aria-current="page"]{color:var(--text, #f6ece4)}
  .nav a[aria-current="page"]::after{display:none}
}

/* Desktop: make sure nothing from the mobile block can leak in. */
@media(min-width:769px){
  .menu-toggle{display:none}
  .nav-overlay{display:none !important}
}

/* No layout animation for people who asked for less motion. */
@media(prefers-reduced-motion:reduce){
  .nav,
  .nav-overlay{transition:none}
}

/* Drawer open: stop the page behind it from scrolling. */
html.nav-open,
body.nav-open{overflow:hidden}
