/* Site header, nav, theme toggle, mobile menu, preloader, sticky book btn. */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  padding-block: 22px;
  transition: padding var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease);
  border-bottom: 1px solid transparent;
}
.site-header.scrolled {
  padding-block: 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; }

.brand { font-family: var(--font-display); font-size: 1.55rem; font-weight: 400; letter-spacing: 0.02em; color: var(--text); transition: color var(--dur-fast) var(--ease); }
.brand .dot { color: var(--accent); }

.nav { display: flex; align-items: center; gap: 36px; }
.nav-links { display: flex; gap: 30px; }
.nav-links a {
  position: relative;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-2);
  padding-block: 4px;
  transition: color var(--dur-fast) var(--ease);
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; bottom: 0;
  width: 0; height: 1px;
  background: var(--accent);
  transition: width var(--dur-fast) var(--ease);
}
.nav-links a:hover, .nav-links a.is-active { color: var(--text); }
.nav-links a.is-active::after, .nav-links a:hover::after { width: 100%; }

/* Two Book buttons exist: the one inside .nav is for the mobile menu, the one
   in .header-actions is the desktop CTA. Hide the nav's on desktop. */
@media (min-width: 901px) { .nav > .btn { display: none; } }

/* --- Header option A: white over the hero at the top, themed once scrolled --- */
@media (min-width: 901px) {
  .site-header:not(.scrolled) .nav-links a { color: rgba(255, 255, 255, 0.8); }
  .site-header:not(.scrolled) .nav-links a:hover,
  .site-header:not(.scrolled) .nav-links a.is-active { color: #fff; }
}
.site-header:not(.scrolled) .brand { color: #fff; }
.site-header:not(.scrolled) .theme-toggle { color: rgba(255, 255, 255, 0.85); border-color: rgba(255, 255, 255, 0.4); }
.site-header:not(.scrolled) .nav-toggle span { background: #fff; }

.header-actions { display: flex; align-items: center; gap: 18px; }

.theme-toggle {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  color: var(--text-2);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle .icon-sun, .theme-toggle .icon-moon { width: 17px; height: 17px; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }

.nav-toggle { display: none; width: 40px; height: 40px; flex-direction: column; justify-content: center; gap: 5px; }
.nav-toggle span { display: block; height: 1.5px; width: 22px; margin-inline: auto; background: var(--text); transition: transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease); }

@media (max-width: 900px) {
  .header-actions .btn { display: none; }
  .nav-toggle { display: flex; }
  .nav {
    position: fixed;
    inset: 0;
    height: 100vh;
    height: 100dvh;          /* covers the full screen even as the mobile bars show/hide */
    flex-direction: column;
    justify-content: center;
    gap: 28px;
    background: var(--bg);
    overscroll-behavior: contain;
    transform: translateX(100%);
    transition: transform var(--dur) var(--ease);
  }
  body.menu-open .nav { transform: none; }
  /* Lock the page behind the menu so a fast scroll can't reveal it. */
  body.menu-open { overflow: hidden; }
  body.menu-open .book-fab { display: none; }
  /* The scrolled header's backdrop-filter would otherwise trap the fixed
     nav panel inside the header box — neutralise it while the menu is open. */
  body.menu-open .site-header {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: transparent;
    border-bottom-color: transparent;
  }
  body.menu-open .nav-toggle span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
  body.menu-open .nav-toggle span:nth-child(2) { opacity: 0; }
  body.menu-open .nav-toggle span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }
  .nav-links { flex-direction: column; text-align: center; gap: 22px; }
  .nav-links a { font-size: 1rem; }
  .nav .btn { display: inline-flex; }
}

/* Floating book button on mobile. */
.book-fab {
  position: fixed;
  right: 18px; bottom: 18px;
  z-index: 90;
  display: none;
  box-shadow: var(--shadow);
}
@media (max-width: 900px) { .book-fab { display: inline-flex; } }

/* Preloader. */
.preloader {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  background: var(--bg);
  transition: opacity 0.6s var(--ease), visibility 0.6s var(--ease);
}
.preloader.loaded { opacity: 0; visibility: hidden; }
.preloader .mark {
  font-family: var(--font-display);
  font-size: 2.4rem; font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--text);
  opacity: 0;
  animation: markIn 1.1s var(--ease) forwards;
}
.preloader .mark .dot { color: var(--accent); }
@keyframes markIn { 0% { opacity: 0; letter-spacing: 0.4em; } 60% { opacity: 1; } 100% { opacity: 1; letter-spacing: 0.05em; } }

/* --- Cart icon colour over the hero (matches the theme toggle) --- */
.site-header:not(.scrolled) .cart-toggle { color: rgba(255, 255, 255, 0.85); }
.site-header:not(.scrolled) .cart-toggle:hover { color: #fff; }

/* --- Header option B: solid/themed from the top (pages without a dark hero) --- */
@media (min-width: 901px) {
  .site-header.is-solid:not(.scrolled) .nav-links a { color: var(--text-2); }
  .site-header.is-solid:not(.scrolled) .nav-links a:hover,
  .site-header.is-solid:not(.scrolled) .nav-links a.is-active { color: var(--text); }
}
.site-header.is-solid:not(.scrolled) .brand { color: var(--text); }
.site-header.is-solid:not(.scrolled) .theme-toggle { color: var(--text-2); border-color: var(--line-2); }
.site-header.is-solid:not(.scrolled) .cart-toggle { color: var(--text-2); }
.site-header.is-solid:not(.scrolled) .cart-toggle:hover,
.site-header.is-solid:not(.scrolled) .theme-toggle:hover { color: var(--accent); }
.site-header.is-solid:not(.scrolled) .nav-toggle span { background: var(--text); }
