/* ============================================================
   NAV — Desktop sticky bar + mobile full-screen overlay
   ============================================================ */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  width: 100%;
}

/* Nav spans the full viewport width with fixed gutters.
   Independent of the .page-wrap used for content below. */
.nav__inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 40px;
  padding-right: 40px;
  height: 60px;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .nav__inner {
    padding-left: 20px;
    padding-right: 20px;
  }
}

.nav__logo {
  font-size: 14px;
  letter-spacing: 0.05em;
}

.nav__list {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.nav__link {
  font-size: 14px;
  letter-spacing: 0.05em;
  transition: opacity 0.15s ease;
}

.nav__link:hover {
  opacity: 0.6;
}

/* ----------------------------------------------------------
   Essays dropdown — desktop
   ---------------------------------------------------------- */
.nav__item--has-sub {
  position: relative;
}

.nav__sub {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}

.nav__item--has-sub:hover .nav__sub,
.nav__item--has-sub:focus-within .nav__sub {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav__sub li + li {
  margin-top: 8px;
}

.nav__sub a {
  display: block;
  font-size: 14px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.nav__sub a:hover {
  opacity: 0.6;
}

/* ----------------------------------------------------------
   Hamburger — hidden on desktop
   ---------------------------------------------------------- */
.nav__toggle {
  display: none;
  width: 28px;
  height: 28px;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  gap: 5px;
}

.nav__toggle span {
  display: block;
  width: 22px;
  height: 1px;
  background: var(--fg);
}

/* ----------------------------------------------------------
   Mobile overlay — full-screen, X top right, B.G.A centered
   ~40% down the screen, links centered below.
   ---------------------------------------------------------- */
.nav__overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  display: none;
  overflow-y: auto;
}

.nav__overlay.is-open {
  display: block;
}

.nav__close {
  position: absolute;
  top: 0;
  right: 0;
  padding: 20px;
  font-size: 16px;
  line-height: 1;
}

.nav__overlay-content {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  padding-left: 20px;
  padding-right: 20px;
  text-align: center;
  box-sizing: border-box;
}

.nav__overlay-logo {
  display: block;
  margin-bottom: var(--space-md);
  font-size: 52px;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.nav__overlay-list {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: center;
}

.nav__overlay-list > li > a,
.nav__overlay-list > li > button {
  display: inline-block;
  font-size: 16px;
  line-height: 3;
  letter-spacing: 0.02em;
}

.nav__overlay-sub-toggle {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: center;
}

/* Default expanded state — vertical sub-list (home + bio pages). */
.nav__overlay-sub {
  list-style: none;
  margin: 0;
  padding: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.nav__overlay-item--open .nav__overlay-sub {
  display: flex;
}

.nav__overlay-sub a {
  display: inline-block;
  font-size: 14px;
  line-height: 2.4;
  letter-spacing: 0.02em;
}

/* Essay-page variant — Brad Gooch Essay | Essays | Salman Rushdie Essay
   shown on one centered row, with Essays in italic. */
.nav__overlay-sub--inline {
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.nav__overlay-item--open .nav__overlay-sub--inline {
  display: flex;
}

.nav__overlay-sub--inline .nav__overlay-sub-current {
  font-style: italic;
  font-size: 14px;
  line-height: 2.4;
}

/* ----------------------------------------------------------
   Mobile breakpoint
   ---------------------------------------------------------- */
@media (max-width: 768px) {
  .nav__list {
    display: none;
  }

  .nav__toggle {
    display: flex;
  }
}

/* Lock body scroll when overlay open */
body.no-scroll {
  overflow: hidden;
}

/* When overlay is open, hide the hamburger so only the X is visible. */
body.no-scroll .nav__toggle {
  display: none;
}
