/* =============================================================
   SKInnocence Clinic — shared menu (hamburger + full-screen overlay)
   Progressive enhancement: desktop nav stays as-is.
   Below 1080px the desktop nav-links are forcibly hidden and the
   hamburger trigger appears. Tapping it slides down a full-screen
   overlay with the site nav rendered as a serif menu (Apple style).
   ============================================================= */

.menu-trigger {
  display: none;
  position: relative;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  color: var(--fg);
  -webkit-tap-highlight-color: transparent;
  border-radius: 999px;
  transition: background 0.18s;
}
.menu-trigger:hover { background: var(--rule-soft); }
.menu-trigger:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 2px;
}
.menu-trigger span {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--fg);
  border-radius: 1px;
  transition: transform 0.32s cubic-bezier(.2,.7,.2,1), opacity 0.18s;
  transform-origin: center;
}
.menu-trigger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}
.menu-trigger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.menu-trigger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

/* Show hamburger / hide desktop nav links uniformly across the site.
   1080px catches the widest breakpoint any page uses; below this we
   universally collapse into the overlay. */
@media (max-width: 1080px) {
  .menu-trigger { display: flex; }
  header.nav .nav-links { display: none !important; }
}

/* ============================================================
   FULL-SCREEN OVERLAY
   ============================================================ */
.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 24px var(--gutter) 32px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition:
    opacity 0.32s cubic-bezier(.2,.7,.2,1),
    transform 0.4s cubic-bezier(.2,.7,.2,1);
}
.menu-overlay.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.menu-overlay-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}
.menu-brand {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 20px;
  font-weight: 500;
  font-style: italic;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}
.menu-brand b { font-style: normal; font-weight: 600; }

.menu-close {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.menu-close:hover { background: var(--rule-soft); }
.menu-close:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 2px;
}
.menu-close svg { display: block; }

.menu-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding-top: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.menu-list a {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: baseline;
  gap: 16px;
  padding: 22px 4px 22px 0;
  border-top: 1px solid var(--rule);
  color: var(--fg);
  text-decoration: none;
  font-family: 'EB Garamond', Georgia, serif;
  transition: padding-left 0.18s ease;
  /* Each item fades up with a stagger when the overlay opens */
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease, padding-left 0.18s ease;
}
.menu-overlay.open .menu-list a {
  opacity: 1;
  transform: none;
}
.menu-overlay.open .menu-list a:nth-child(1) { transition-delay: 0.08s; }
.menu-overlay.open .menu-list a:nth-child(2) { transition-delay: 0.13s; }
.menu-overlay.open .menu-list a:nth-child(3) { transition-delay: 0.18s; }
.menu-overlay.open .menu-list a:nth-child(4) { transition-delay: 0.23s; }
.menu-overlay.open .menu-list a:nth-child(5) { transition-delay: 0.28s; }
.menu-overlay.open .menu-list a:nth-child(6) { transition-delay: 0.33s; }
.menu-overlay.open .menu-list a:nth-child(7) { transition-delay: 0.38s; }
.menu-overlay.open .menu-list a:nth-child(8) { transition-delay: 0.43s; }
.menu-list a:hover { padding-left: 8px; }
.menu-list a:last-child { border-bottom: 1px solid var(--rule); }
.menu-list a:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: -2px;
}

.menu-list a .ix {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--fg-muted);
  font-weight: 400;
  padding-top: 8px;
}
.menu-list a .nm {
  font-weight: 500;
  font-size: clamp(28px, 7vw, 56px);
  line-height: 1.0;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.menu-list a .ar {
  font-family: 'Geist', system-ui, sans-serif;
  font-size: 14px;
  color: var(--fg-muted);
  align-self: center;
  transition: transform 0.2s ease;
}
.menu-list a:hover .ar { transform: translateX(4px); color: var(--fg); }

.menu-list a.active .nm {
  font-style: italic;
}
.menu-list a.active::before {
  content: '';
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--fg);
  border-radius: 999px;
  margin-left: -16px;
  margin-top: 24px;
}

.menu-foot {
  padding-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.menu-foot a {
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.menu-foot a:hover { color: var(--fg); }
.menu-foot .sp { flex: 1; }

/* Lock the page when the menu is open */
body.menu-open { overflow: hidden; }

/* ============================================================
   PICTURE — make <picture> transparent so existing `img` rules apply
   ============================================================ */
picture { display: contents; }

/* ============================================================
   READING PROGRESS BAR — thin line under nav, scrolls with page
   ============================================================ */
.read-progress {
  position: fixed;
  top: 64px; /* matches nav height */
  left: 0;
  right: 0;
  height: 2px;
  z-index: 59;
  background: transparent;
  pointer-events: none;
}
.read-progress::after {
  content: '';
  display: block;
  height: 100%;
  width: var(--rp, 0%);
  background: var(--fg);
  transform-origin: left center;
  transition: width 0.06s linear;
}

/* ============================================================
   BACK TO TOP — quiet floating dot, appears after scroll
   ============================================================ */
.to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 58;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--rule);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  color: var(--fg);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(.2,.7,.2,1), background 0.18s;
}
.to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.to-top:hover { background: var(--bg); }
.to-top:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 4px;
}
.to-top svg { display: block; }

@media (prefers-reduced-motion: reduce) {
  .read-progress::after { transition: none; }
  .to-top { transition: none; }
}

/* ============================================================
   VIEW TRANSITIONS API — smooth crossfade between pages
   Chromium-only today; ignored elsewhere. The brand wordmark and
   nav are flagged with view-transition-name so they animate as a
   single element rather than crossfade twice.
   ============================================================ */
@view-transition { navigation: auto; }
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.28s;
  animation-timing-function: cubic-bezier(.2,.7,.2,1);
}
header.nav { view-transition-name: site-nav; }
header.nav .brand { view-transition-name: site-brand; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ============================================================
   DESKTOP NAV — Apple-strict polish (focus + active state)
   Scoped to header.nav so it does not affect any other nav.
   ============================================================ */
header.nav .nav-links a:not(.nav-cta) {
  position: relative;
  padding: 6px 2px;
}
header.nav .nav-links a:not(.nav-cta):focus-visible,
header.nav .nav-links a.nav-cta:focus-visible,
header.nav .brand:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 4px;
  border-radius: 2px;
}
header.nav .nav-links a:not(.nav-cta).active {
  color: var(--fg);
  font-weight: 500;
}
header.nav .nav-links a:not(.nav-cta).active::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -6px;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--fg);
  border-radius: 999px;
}

@media (prefers-reduced-motion: reduce) {
  .menu-overlay, .menu-trigger span, .menu-list a, .menu-list a .ar {
    transition: none !important;
  }
  .menu-overlay.open .menu-list a { transition-delay: 0s !important; }
}
