/* ==========================================================================
   Sohbah Retreats — top bar
   Desktop: the tile star travels beneath the link for the section you're in.
   Scrolling down tucks the bar away; scrolling up brings it straight back.
   Phones: a full-screen forest sheet with large serif links.
   ========================================================================== */

/* ---------- Tuck away on scroll down, return on scroll up ----------
   Doubled class beats every older header rule (some were overriding the
   transform transition on the homepage, which made the bar snap). */
html body .header.header {
  transition:
    transform 460ms cubic-bezier(.16, 1, .3, 1),
    background-color 240ms ease, border-color 240ms ease, color 240ms ease;
  will-change: transform;
}
html body .header.header.nav-tucked {
  transform: translate3d(0, -100%, 0);
  transition:
    transform 360ms cubic-bezier(.4, 0, .6, 1),
    background-color 240ms ease, border-color 240ms ease, color 240ms ease;
}
html body .header.header.nav-tucked:focus-within { transform: none; }
/* a live blur has to be recomputed every frame while the bar moves; near-solid paper reads the same */
html body .header.header.scrolled {
  -webkit-backdrop-filter: none;
          backdrop-filter: none;
  background: rgba(246, 243, 234, .97);
}

/* ---------- Desktop: travelling star ---------- */
@media (min-width: 761px) {
  html body .header nav#nav { position: relative; }
  /* the star replaces the hover underline */
  html body .header nav#nav a::after { display: none; }
  html body .header nav#nav a { transition: color 200ms ease, opacity 200ms ease; }
  html body .header.scrolled nav#nav a[aria-current="true"],
  html body .header.scrolled nav#nav a:hover { color: var(--r-ink, #233023); }
  html body .header:not(.scrolled) nav#nav a[aria-current="true"] { color: #fff; }

  .nav-star {
    position: absolute;
    left: 0; bottom: -14px;
    width: 9px; height: 9px;
    margin-left: -4.5px;
    pointer-events: none;
    opacity: 0;
    background: var(--r-accent, #9c4a31);
    -webkit-mask: var(--r-star) center / contain no-repeat;
            mask: var(--r-star) center / contain no-repeat;
    transform: translate3d(var(--x, 0px), 0, 0) rotate(var(--turn, 0deg)) scale(.4);
    transition:
      transform 700ms cubic-bezier(.22, 1, .36, 1),
      opacity 300ms ease,
      background-color 240ms ease;
  }
  .nav-star.is-on {
    opacity: 1;
    transform: translate3d(var(--x, 0px), 0, 0) rotate(var(--turn, 0deg)) scale(1);
  }
  html body .header:not(.scrolled) .nav-star { background: #e9c9a0; }
  .nav-contact { display: none; }
}

/* ---------- Phones: full-screen sheet ---------- */
@media (max-width: 760px) {
  /* a blurred or transformed bar would trap the fixed sheet inside it */
  html body .header:has(nav#nav.open) {
    -webkit-backdrop-filter: none !important;
            backdrop-filter: none !important;
    background: transparent !important;
    border-color: transparent !important;
    mix-blend-mode: normal !important;
    transform: none !important;
    will-change: auto !important;
  }
  html body .header:has(nav#nav.open) .logo img { filter: brightness(0) invert(1); }
  html body .header:has(nav#nav.open) .menu span { background: #f6f3ea !important; }

  html body .header nav#nav {
    display: flex !important;
    position: fixed;
    inset: 0;
    z-index: -1;
    height: 100vh; height: 100dvh;
    margin: 0;
    padding: 108px 24px max(32px, env(safe-area-inset-bottom));
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    overflow-y: auto;
    background: #1f2a1f !important;
    border: 0;
    counter-reset: navitem;
    visibility: hidden;
    opacity: 0;
    transition: opacity 380ms cubic-bezier(.22, 1, .36, 1), visibility 0s linear 380ms;
  }
  html body .header nav#nav.open {
    visibility: visible;
    opacity: 1;
    transition: opacity 380ms cubic-bezier(.22, 1, .36, 1), visibility 0s;
  }

  html body .header nav#nav > a {
    display: flex;
    align-items: baseline;
    gap: 16px;
    min-height: 0;
    padding: 18px 0;
    border-bottom: 1px solid rgba(246, 243, 234, .12);
    font-family: var(--r-serif, Georgia, serif);
    font-size: clamp(26px, 7.8vw, 36px);
    line-height: 1.1;
    font-weight: 350;
    letter-spacing: -.02em;
    color: #f6f3ea !important;
    counter-increment: navitem;
    opacity: 0;
    transform: translate3d(0, 28px, 0);
    transition: opacity 500ms cubic-bezier(.22, 1, .36, 1), transform 700ms cubic-bezier(.22, 1, .36, 1);
  }
  html body .header nav#nav > a:first-of-type { border-top: 1px solid rgba(246, 243, 234, .12); }
  html body .header nav#nav > a::before {
    content: '0' counter(navitem);
    flex: none;
    width: 24px;
    font-family: var(--r-sans, sans-serif);
    font-size: 12px;
    letter-spacing: .02em;
    font-variant-numeric: tabular-nums;
    color: rgba(246, 243, 234, .5);
    transform: translateY(-.9em);
  }
  html body .header nav#nav > a::after {
    content: '↗';
    display: block !important;
    position: static;
    margin-left: auto;
    width: auto; height: auto;
    background: none;
    opacity: .45;
    font-family: var(--r-sans, sans-serif);
    font-size: 18px;
    transform: none;
  }
  html body .header nav#nav > a[aria-current="true"]::before { color: #e9c9a0; }

  html body .header nav#nav.open > a { opacity: 1; transform: none; }
  html body .header nav#nav.open > a:nth-of-type(1) { transition-delay: 90ms; }
  html body .header nav#nav.open > a:nth-of-type(2) { transition-delay: 150ms; }
  html body .header nav#nav.open > a:nth-of-type(3) { transition-delay: 210ms; }
  html body .header nav#nav.open > a:nth-of-type(4) { transition-delay: 270ms; }

  .nav-contact {
    display: grid;
    gap: 8px;
    margin-top: auto;
    padding-top: 40px;
    opacity: 0;
    transform: translate3d(0, 16px, 0);
    transition: opacity 500ms ease, transform 700ms cubic-bezier(.22, 1, .36, 1);
  }
  html body .header nav#nav.open .nav-contact { opacity: 1; transform: none; transition-delay: 360ms; }
  .nav-contact p { margin: 0 0 8px; font-size: 13px; color: rgba(246, 243, 234, .55); }
  html body .header nav#nav .nav-contact a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-family: var(--r-sans, sans-serif);
    font-size: 16px;
    color: #f6f3ea !important;
    text-decoration: underline;
    text-decoration-color: rgba(246, 243, 234, .3);
    text-underline-offset: 5px;
  }

  /* hamburger lines morph smoothly into a cross */
  html body .header .menu { position: relative; z-index: 1; min-width: 44px; min-height: 44px; }
  html body .header .menu span { transition: transform 420ms cubic-bezier(.22, 1, .36, 1), background-color 240ms ease; }
}

html.nav-locked, html.nav-locked body { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  html body .header, .nav-star, html body .header nav#nav, html body .header nav#nav > a, .nav-contact { transition: none !important; }
}

/* ---------- Logo: gold leaf catching the light on hover ----------
   A warm band sweeps across the letters only (the wordmark itself is the mask),
   and the mark lifts a hair. Replays on every hover and on keyboard focus. */
html body .header .logo { position: relative; isolation: isolate; }
html body .header .logo img { transition: transform 600ms cubic-bezier(.22, 1, .36, 1); }
html body .header .logo::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(105deg,
    transparent 0%, transparent 40%,
    rgba(214, 170, 100, .0) 42%,
    rgba(214, 170, 100, .95) 48%,
    rgba(250, 232, 196, 1) 50%,
    rgba(214, 170, 100, .95) 52%,
    rgba(214, 170, 100, 0) 58%,
    transparent 60%, transparent 100%);
  background-size: 300% 100%;
  background-position: 100% 0;
  -webkit-mask: url('/assets/sohbah-wordmark-2026.png') center / contain no-repeat;
          mask: url('/assets/sohbah-wordmark-2026.png') center / contain no-repeat;
  opacity: 0;
}
@media (hover: hover) {
  html body .header .logo:hover { mix-blend-mode: normal; }
  html body .header .logo:hover img { transform: translate3d(0, -1px, 0); }
  html body .header .logo:hover::after { animation: logo-sheen 700ms cubic-bezier(.4, 0, .2, 1) both; }
}
html body .header .logo:focus-visible::after { animation: logo-sheen 700ms cubic-bezier(.4, 0, .2, 1) both; }
html body .header .logo:active img { transform: scale(.98); transition-duration: 120ms; }
/* Over the hero the wordmark is white, so the light needs a deeper, wider gold to read */
html body .header:not(.scrolled) .logo::after,
html body.journey-page .header:not(.scrolled) .logo::after {
  background: linear-gradient(105deg,
    transparent 0%, transparent 34%,
    rgba(201, 138, 52, 0) 36%,
    rgba(201, 138, 52, 1) 44%,
    rgba(226, 168, 82, 1) 50%,
    rgba(201, 138, 52, 1) 56%,
    rgba(201, 138, 52, 0) 64%,
    transparent 66%, transparent 100%);
  background-size: 300% 100%;
}
/* Over the hero the whole bar uses a screen blend, which bleaches any colour toward white.
   While the logo is hovered or focused the bar blends normally, so the gold reads at full strength
   (white text looks identical either way). */
html body .header:not(.scrolled):has(.logo:hover),
html body .header:not(.scrolled):has(.logo:focus-visible),
html body .header:not(.scrolled) .logo:hover,
html body .header:not(.scrolled) .logo:focus-visible { mix-blend-mode: normal !important; }
@keyframes logo-sheen {
  0%   { background-position: 100% 0; opacity: 1; }
  85%  { opacity: 1; }
  100% { background-position: 0% 0; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  html body .header .logo::after { display: none; }
  html body .header .logo:hover img { transform: none; }
}
