/* Header: logo, menu and the day/night toggle. */

header { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 40px; height: var(--header-height); }
/* Once the page scrolls (app.js adds .is-stuck) a soft fade from the top keeps the header readable.
   The border-image outset reaches both screen edges without widening the page (ink overflow only). */
header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-image: var(--header-fade) fill 0 / 0 / 0 100vw;
  opacity: 0;
  transition: opacity .3s ease;
}
header.is-stuck::before { opacity: 1; }
header .brand { margin-right: auto; }
header img { display: block; width: 215px; height: auto; }

.logo-night { display: none; }
.night .logo-day { display: none; }
.night .logo-night { display: block; }

nav { display: flex; gap: 28px; font-size: var(--text-300); font-weight: var(--weight-bold); }
nav a { padding-block: 14px; transition: color .2s; }
nav a:hover { color: var(--color-accent); }

/* Adile Naşit tribute: a small portrait between the menu and the toggle */
.tribute { flex-shrink: 0; margin-inline: -12px; transition: transform .3s var(--ease-story); }
.tribute img { width: 44px; height: 44px; filter: drop-shadow(0 4px 8px var(--toon-shadow)); }
.tribute:hover { transform: translateY(-2px) rotate(-4deg); }

/* Burger menu (phones only): a glass round button beside the toggle and a small panel under the header */
.menu-toggle, .mobile-menu { display: none; }
.menu-toggle {
  flex-shrink: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: var(--color-ink);
}
.menu-toggle span { display: block; width: 16px; height: 2px; border-radius: 2px; background: currentColor; transition: transform .3s var(--ease-story), opacity .2s; }
.menu-toggle[aria-expanded=true] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.menu-toggle[aria-expanded=true] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded=true] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
.mobile-menu {
  position: absolute;
  top: calc(100% - 8px);
  left: var(--gutter);
  right: var(--gutter);
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius-box);
  background: var(--glass-solid);
  box-shadow: var(--glass-shadow);
  font-size: var(--text-350);
  animation: menu-in .3s var(--ease-story);
}
.mobile-menu a { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius-box); }
.mobile-menu a:hover { background: var(--color-soft); color: var(--color-accent); }
.mobile-menu img { width: 32px; height: 32px; margin-block: -6px; }

@keyframes menu-in { from { opacity: 0; transform: translateY(-8px); } }

/* Toggle: the knob and each icon share one two-column geometry at every width. */
.theme {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
  justify-content: space-between;
  width: 80px;
  height: 44px;
  padding: 4px;
  border-radius: 30px;
  color: var(--toggle-text);
  font-size: 21px;
}
.theme span { position: relative; z-index: 1; display: grid; place-items: center; width: 100%; height: 100%; }
.theme svg { display: block; width: 18px; height: 18px; }
.theme i {
  position: absolute;
  left: 4px;
  top: 50%;
  width: calc((100% - 8px) / 2);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--toggle-knob);
  box-shadow: var(--toggle-knob-shadow);
  transform: translateY(-50%);
  transition: transform .5s;
}
.night .theme i { transform: translate(100%, -50%); }

@media (max-width: 1000px) {
  header { gap: 25px; }
  nav { font-size: var(--text-200); }
}
@media (max-width: 700px) {
  header .brand img { width: 175px; }
  .tribute { display: none; }
  header { gap: 12px; }
  .menu-toggle { display: flex; }
  .mobile-menu:not([hidden]) { display: flex; }
  nav { display: none; }
  .theme { flex-shrink: 0; width: 72px; height: 42px; }
}

@media (max-width: 360px) {
  header .brand img { width: 150px; }
  .theme { width: 66px; height: 40px; }
  .menu-toggle { width: 40px; height: 40px; }
}

@media (forced-colors: active) {
  .theme { border: 1px solid ButtonText; }
}
