/* Site header: masthead, primary nav with dropdowns, search, mobile drawer. */

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-rule);
  transition: box-shadow var(--t-base) var(--ease);
}

/* Shadow only appears once the page has actually scrolled. */
.site-header.is-stuck {
  box-shadow: var(--shadow-sm);
}

.header-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  height: var(--header-h);
}

/* Masthead ----------------------------------------------------------------- */

.brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  font-family: var(--f-serif);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--c-ink);
  white-space: nowrap;
}

/* Soft taupe ink-wash disc behind the brush mark, echoing the logo's circle. */
.brand::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 50%;
  width: 54px;
  height: 54px;
  transform: translateY(-53%);
  border-radius: 50%;
  background: radial-gradient(circle at 42% 42%,
              rgba(201, 187, 164, 0.62), rgba(201, 187, 164, 0.26) 58%, transparent 72%);
  z-index: 0;
  pointer-events: none;
}

.brand:hover {
  color: var(--c-ink);
}

.brand-mark {
  position: relative;
  z-index: 1;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  object-fit: contain;
}

.brand-word {
  position: relative;
  z-index: 1;
  font-family: var(--f-display);
  font-weight: 500;
  letter-spacing: 0.16em;
}

/* Primary nav -------------------------------------------------------------- */

.nav-primary {
  margin-left: auto;
}

.nav-list {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-item {
  position: relative;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 0;
  font-size: var(--fs-small);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #4d4d4d;
  background: none;
  border: 0;
  font-family: var(--f-sans);
  cursor: pointer;
  white-space: nowrap;
}

/* Underline grows from the left on hover and stays for the active section. */
.nav-link::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2px;
  background: var(--c-accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-base) var(--ease);
}

.nav-item:hover > .nav-link::after,
.nav-item.is-open > .nav-link::after,
.nav-item.is-active > .nav-link::after {
  transform: scaleX(1);
}

.nav-link:hover,
.nav-item.is-active > .nav-link {
  color: var(--c-accent);
}

.nav-link.is-highlight {
  color: var(--c-accent);
}

.caret {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--t-fast) var(--ease);
}

.nav-item.is-open .caret {
  transform: rotate(-135deg) translateY(-2px);
}

/* Dropdown ----------------------------------------------------------------- */

.dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  z-index: var(--z-dropdown);
  min-width: 220px;
  padding: var(--sp-3) 0;
  margin: 0;
  list-style: none;
  background: var(--c-surface);
  border: 1px solid var(--c-rule);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 8px);
  transition: opacity var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease),
              visibility var(--t-fast);
}

/* Two columns once the list is long (the Categories menu). */
.dropdown.dropdown-wide {
  min-width: 440px;
  columns: 2;
  column-gap: 0;
}

.nav-item.is-open .dropdown {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.dropdown a {
  display: block;
  padding: 8px 20px;
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--c-body);
  break-inside: avoid;
}

.dropdown a:hover {
  background: var(--c-surface-sunk);
  color: var(--c-accent);
}

/* Popular dropdown — thumbnail list of most-read articles. */
.dropdown.dropdown-popular {
  min-width: 340px;
  padding: var(--sp-3);
}

.dropdown-popular a {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 2px;
}

.dropdown-popular img {
  width: 72px;
  height: 48px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--c-surface-sunk);
}

.dropdown-popular .pd-cat {
  display: block;
  font-size: var(--fs-eyebrow);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-accent);
  margin-bottom: 2px;
}

.dropdown-popular .pd-title {
  display: block;
  font-size: var(--fs-small);
  font-weight: 700;
  line-height: 1.3;
  color: var(--c-ink);
}

.dropdown-popular a:hover .pd-title {
  color: var(--c-accent);
}

.dropdown .dropdown-all a,
.dropdown .dropdown-all {
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: var(--fs-meta);
  color: var(--c-accent);
}

/* Separator between the extra categories and the About links in More Topics. */
.dropdown-sep {
  height: 1px;
  margin: var(--sp-2) 20px;
  background: var(--c-rule);
  break-inside: avoid;
}

/* Search — wide inline box with a leading icon, mirroring the reference. */
.nav-search {
  position: relative;
  flex-shrink: 1;
  min-width: 0;
  margin-left: var(--sp-4);
}

.nav-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  color: var(--c-faint);
  pointer-events: none;
}

.nav-search-input {
  width: 260px;
  max-width: 30vw;
  padding: 9px 14px 9px 34px;
  border: 1px solid var(--c-rule);
  border-radius: 2px;
  font-family: var(--f-sans);
  font-size: var(--fs-small);
  color: var(--c-body);
  background: var(--c-surface-alt);
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}

.nav-search-input:focus {
  outline: none;
  background: var(--c-surface);
  border-color: var(--c-ink);
}

/* Membership — red call-to-action at the far right. */
.nav-membership {
  flex-shrink: 0;
  margin-left: var(--sp-4);
  font-family: var(--f-sans);
  font-size: var(--fs-small);
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--c-accent);
  white-space: nowrap;
}

.nav-membership:hover {
  color: var(--c-accent-dark);
}

/* Burger ------------------------------------------------------------------- */

.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  margin-left: auto;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.burger span {
  display: block;
  width: 22px;
  height: 2px;
  margin: 0 auto;
  background: var(--c-ink);
  transition: transform var(--t-base) var(--ease),
              opacity var(--t-fast) var(--ease);
}

.burger.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.burger.is-open span:nth-child(2) {
  opacity: 0;
}

.burger.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Drawer ------------------------------------------------------------------- */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-drawer);
  width: min(400px, 88vw);
  padding: var(--sp-5) 0 var(--sp-8);
  background: var(--c-surface);
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateX(100%);
  transition: transform var(--t-base) var(--ease);
  visibility: hidden;
}

.drawer.is-open {
  transform: translateX(0);
  visibility: visible;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: rgba(9, 9, 9, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base) var(--ease), visibility var(--t-base);
}

.drawer-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.drawer-search {
  padding: 0 var(--sp-5) var(--sp-5);
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--c-rule);
}

.drawer-search form {
  display: flex;
  gap: var(--sp-2);
}

.drawer-search .input {
  flex: 1;
}

.drawer-nav {
  margin: 0;
  padding: 0;
  list-style: none;
}

.drawer-nav > li {
  border-bottom: 1px solid var(--c-rule-soft);
}

.drawer-nav > li > a,
.drawer-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px var(--sp-5);
  font-family: var(--f-sans);
  font-size: var(--fs-body);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-ink);
  background: none;
  border: 0;
  cursor: pointer;
  text-align: left;
}

.drawer-toggle .caret {
  transition: transform var(--t-base) var(--ease);
}

.drawer-toggle[aria-expanded="true"] .caret {
  transform: rotate(-135deg) translateY(-2px);
}

/* Accordion panel: animated by max-height so it can be driven purely by a class. */
.drawer-panel {
  max-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--c-surface-alt);
  transition: max-height var(--t-base) var(--ease);
}

.drawer-panel.is-open {
  max-height: 640px;
}

.drawer-panel a {
  display: block;
  padding: 11px var(--sp-5) 11px var(--sp-7);
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--c-body);
}

.drawer-panel a:hover {
  color: var(--c-accent);
}

.drawer-social {
  display: flex;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-6) var(--sp-5) 0;
}

.drawer-social a {
  color: var(--c-muted);
}

.drawer-social a:hover {
  color: var(--c-accent);
}

/* Responsive --------------------------------------------------------------- */

/* Tighten spacing before the layout is forced into the drawer. */
@media (max-width: 1280px) {
  .nav-list {
    gap: var(--sp-4);
  }

  .nav-search-input {
    width: 190px;
  }
}

/* Nav is too wide to fit below this; swap to the drawer. */
@media (max-width: 1100px) {
  .nav-primary,
  .nav-search,
  .nav-membership {
    display: none;
  }

  .burger {
    display: flex;
  }
}

@media (min-width: 1025px) {
  .drawer,
  .drawer-overlay {
    display: none;
  }
}
