/* =========================================
   Base + stacking order
   ========================================= */
html, body { margin: 0; padding: 0; }
* { box-sizing: border-box; }

:root { --header-h: 50px; }

.site-header{
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 2000; /* below drawer/backdrop */
  height: var(--header-h);
}

/* 3-column header layout at all sizes */
.header-row{
  display: grid;
  grid-template-columns: 44px 1fr 44px; /* [menu] [title] [theme] */
  align-items: center;
  gap: 8px;
  padding: 2px 12px;
  height: var(--header-h);
}

/* Centered page title, consistent typography */
.site-title{
  display: block;
  margin: 0;
  padding: 0px 8px;
  text-align: center;
  font-family: 'Oswald', 'Oswald Narrow', 'Arial Narrow', Arial, sans-serif;
  font-weight: 600;
  font-size: 1.3rem;
  line-height: 1.25;
  color: var(--color-muted);
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Menu button */
.menu-btn{
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 10px;
  color: var(--color-text);
}
.menu-btn:hover{ background: rgba(0,0,0,0.06); }

/* =========================================
   Theme toggle (icon-only, mobile-safe)
   ========================================= */
.theme-toggle{
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 6px;
  border-radius: 10px;
  color: var(--color-muted);
  justify-self: end;
  width: 44px; height: 44px;
  display: grid; place-items: center;
}

.theme-toggle svg{
  width: 22px; height: 22px; display: block;
}

/* Visibility logic */
.theme-toggle .ico{ display: none; }

/* Fallback for first paint (before JS sets data-theme) */
.theme-toggle:not([data-theme]) .ico-sun{ display: block; }

/* Normal icon switching */
.theme-toggle[data-theme="light"]  .ico-sun{   display: block; }
.theme-toggle[data-theme="dark"]   .ico-moon{  display: block; }
.theme-toggle[data-theme="modern"] .ico-spark{ display: block; }

.theme-toggle:hover{ background: rgba(0,0,0,0.06); }
.theme-toggle:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }

/* =========================================
   Drawer (panel) — sits ABOVE everything
   ========================================= */
.nav-drawer{
  position: fixed;
  top: 0; bottom: 0;
  left: -320px;                   /* off-screen */
  width: 320px;
  background: var(--color-surface);
  transition: left .28s ease-in-out;
  z-index: 10001;                 /* higher than backdrop */
  overflow-y: auto;
  box-shadow: 2px 0 18px rgba(0,0,0,0.18);
  pointer-events: auto;           /* ensure clicks are accepted */
}
.nav-drawer.open{ left: 0; }
.nav-content{ padding: 20px; position: relative; }

/* Close button inside drawer */
.close-btn{
  position: absolute; top: 10px; right: 10px;
  background: none; border: none; font-size: 24px; cursor: pointer;
  width: 36px; height: 36px; line-height: 36px; text-align: center;
  border-radius: 8px; 
  color: var(--color-text);
}
.close-btn:hover{ background: rgba(0,0,0,0.06); }

/* Menu list */
.nav-list{ list-style: none; padding: 0; margin: 0; }
.nav-list li{ margin-bottom: 8px; }
.nav-list a{
  color: var(--color-text);
  text-decoration: none;
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
}
.nav-list a:hover{ background: var(--color-muted); }

/* =========================================
   Backdrop — real element, BELOW drawer
   ========================================= */
.nav-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;          /* disabled until shown */
  transition: opacity .28s ease;
  z-index: 10000;                /* below drawer (10001), above content/header */
}
.nav-backdrop.show{
  opacity: 1;
  pointer-events: auto;          /* captures click to close */
}

/* =========================================
   Small-screen refinements
   ========================================= */
@media (max-width: 768px){
  .nav-drawer{ width: 80vw; }
}

@media (max-width: 420px){
  .header-row{ padding: 8px 10px; gap: 6px; }
  .site-title{ font-size: 1.05rem; }
  .theme-toggle{ width: 40px; height: 40px; }
  .theme-toggle svg{ width: 20px; height: 20px; }
}
