/* ==========================================================================
   Tours Bénies — header, entry gate, page transitions
   Modelled on thebloombarr.com. See REFERENCE-thebloombarr.md.
   ========================================================================== */

/* --- Header ---------------------------------------------------------------
   Reference structure: centred logo, links either side, utility at the right.
   Reference type: lowercase, ~12–14px, tracking ~0.03em, weight 400.
   -------------------------------------------------------------------------- */
.tb-header {
  position: fixed; inset-block-start: 0; inset-inline: 0;
  z-index: var(--tb-z-nav);
  height: var(--tb-header-h);
  display: flex; align-items: center;
  background: transparent;
  transition: background-color var(--tb-dur-fast) var(--tb-ease),
              box-shadow var(--tb-dur-fast) var(--tb-ease),
              height var(--tb-dur-fast) var(--tb-ease);
}
/* Reference behaviour: background-color 0.3s on scroll, nothing more. */
.tb-header.is-stuck {
  height: 68px;
  background: color-mix(in srgb, var(--tb-surface) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: 0 1px 0 var(--tb-rule);
}

.tb-header__grid {
  width: 100%; max-width: var(--tb-max);
  margin-inline: auto; padding-inline: var(--tb-gutter);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--tb-space-3);
}

.tb-nav { display: flex; align-items: center; gap: clamp(1rem, .4rem + 1.6vw, 2.25rem); }
.tb-nav--end { justify-content: flex-end; }

/* Nav link: reference sizing, with a gold rule that draws in from the left. */
.tb-nav__link {
  position: relative;
  font-size: .8125rem;              /* 13px — reference band is 12–14px */
  font-weight: 500;
  letter-spacing: .03em;
  color: var(--tb-ink);
  padding-block: .5rem;
  white-space: nowrap;
  transition: color var(--tb-dur-fast) var(--tb-ease);
}
/* Over a dark hero the nav must invert; once stuck it sits on the page
   surface again and reverts. The class goes on the header itself. */
.tb-header--over-hero:not(.is-stuck) :is(.tb-nav__link, .tb-iconbtn) { color: var(--tb-cream); }
.tb-header--over-hero:not(.is-stuck) .tb-brand__word b:last-child { color: var(--tb-cream); }
.tb-header--over-hero:not(.is-stuck) .tb-brand__word b:first-child { color: var(--tb-gold-300); }
.tb-header--over-hero:not(.is-stuck) :is(.tb-nav__link, .tb-iconbtn):hover { color: var(--tb-gold-300); }
/* The rule is drawn at full width and scaled from 0, rather than animating
   `width` — width is a layout property, so it cannot be composited and forces
   a layout pass on every frame of the hover. scaleX runs on the compositor
   and is visually identical at 1px tall. */
.tb-nav__link::after {
  content: "";
  position: absolute; inset-inline-start: 0; inset-block-end: .25rem;
  height: 1px; width: 100%;
  background: var(--tb-gold-500);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--tb-dur-fast) var(--tb-ease);
}
.tb-nav__link:hover { color: var(--tb-gold-700); }
.tb-nav__link:hover::after,
.tb-nav__link[aria-current="page"]::after { transform: scaleX(1); }
.tb-nav__link[aria-current="page"] { color: var(--tb-gold-700); }

/* Centred lockup.

   The client's primary logo is a near-square stack — the tower rises well
   above the words — so at header height the wordmark inside it would render
   around 8px and be unreadable. This uses the real tower mark as the symbol
   with the wordmark as live text beside it, which is exactly the horizontal
   "secondary logo" the brand guide supplies for this situation. The full
   stacked lockup is used at full size in the footer. */
.tb-brand { display: flex; align-items: center; gap: .625rem; }
.tb-brand__img { height: 38px; width: auto; flex: none; }
.tb-header.is-stuck .tb-brand__img { height: 32px; }

/* Cream mark on any dark surface — over the hero, or in the dark theme. */
.tb-brand__img--dark { display: none; }
:is(.tb-header--over-hero:not(.is-stuck), [data-theme="dark"]) .tb-brand__img--light { display: none; }
:is(.tb-header--over-hero:not(.is-stuck), [data-theme="dark"]) .tb-brand__img--dark  { display: block; }
.tb-brand__word {
  display: flex; align-items: baseline; gap: .3em;
  font-size: clamp(.9375rem, .85rem + .35vw, 1.125rem);
  letter-spacing: var(--tb-track-wordmark);
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
}
/* The wordmark's own two-tone split: TOURS light, BÉNIES weighted. */
.tb-brand__word b:first-child { font-weight: 300; color: var(--tb-gold-700); }
.tb-brand__word b:last-child  { font-weight: 700; color: var(--tb-forest-700); }
[data-theme="dark"] .tb-brand__word b:last-child { color: var(--tb-cream); }

/* Utility cluster */
.tb-util { display: flex; align-items: center; gap: .75rem; }
.tb-iconbtn {
  display: grid; place-items: center;
  width: 44px; height: 44px;          /* touch target floor */
  border: 1px solid transparent; border-radius: var(--tb-radius-sm);
  background: none; cursor: pointer; color: var(--tb-ink);
  transition: color var(--tb-dur-fast) var(--tb-ease),
              border-color var(--tb-dur-fast) var(--tb-ease);
}
.tb-iconbtn:hover { color: var(--tb-gold-700); border-color: var(--tb-rule); }
.tb-iconbtn svg { width: 19px; height: 19px; }

/* The sun/moon swap inside the theme toggle */
.tb-iconbtn .tb-icon-moon { display: none; }
[data-theme="dark"] .tb-iconbtn .tb-icon-moon { display: block; }
[data-theme="dark"] .tb-iconbtn .tb-icon-sun  { display: none; }

.tb-header__cta { padding: .75rem 1.375rem; min-height: 44px; font-size: .75rem; }

/* --- Mobile ---------------------------------------------------------------- */
.tb-burger { display: none; }

@media (max-width: 979px) {
  /* The start nav is hidden here, so the grid holds two items, not three. The
     desktop three-track template kept an empty third column plus its gap,
     which pushed the burger 4px off a 390px screen. */
  .tb-header__grid { grid-template-columns: minmax(0, 1fr) auto; gap: var(--tb-space-2); }
  .tb-nav--start, .tb-nav--end .tb-nav__link { display: none; }
  /* Book stays in the header on phones — it's the one action that matters. */
  .tb-header__cta { padding: .5rem .875rem; font-size: .6875rem; letter-spacing: .12em; }
  .tb-burger { display: grid; }
  .tb-brand { justify-content: flex-start; min-width: 0; }
}
@media (max-width: 480px) {
  .tb-header__grid { gap: .75rem; }
  .tb-util { gap: .25rem; }
  .tb-brand__word { font-size: .875rem; letter-spacing: .14em; }
}
/* Below 370px there is no comfortable room for all three; Book is still item 05 in the menu. */
@media (max-width: 369px) {
  .tb-header__cta { display: none; }
}

/* Full-screen overlay menu */
.tb-menu {
  position: fixed; inset: 0; z-index: var(--tb-z-overlay);
  background: var(--tb-surface-dark);
  color: var(--tb-cream);
  display: grid; align-content: center;
  padding: var(--tb-space-7) var(--tb-gutter) var(--tb-space-5);
  visibility: hidden; opacity: 0;
  transition: opacity var(--tb-dur-base) var(--tb-ease),
              visibility 0s linear var(--tb-dur-base);
}
.tb-menu.is-open { visibility: visible; opacity: 1; transition-delay: 0s; }

.tb-menu__list { display: grid; gap: .25rem; max-width: var(--tb-max); margin-inline: auto; width: 100%; }
.tb-menu__link {
  font-family: var(--tb-font-display);
  font-size: clamp(1.75rem, 1.2rem + 3.6vw, 3rem);
  color: var(--tb-cream);
  padding-block: .35em;
  border-bottom: 1px solid var(--tb-rule-dark);
  display: flex; align-items: baseline; gap: 1rem;
  opacity: 0; transform: translateY(18px);
  transition: opacity var(--tb-dur-base) var(--tb-ease),
              transform var(--tb-dur-base) var(--tb-ease),
              color var(--tb-dur-fast) var(--tb-ease);
}
.tb-menu.is-open .tb-menu__link { opacity: 1; transform: none; }
.tb-menu__link:hover { color: var(--tb-gold-300); }
.tb-menu__link i {
  font-style: normal; font-family: var(--tb-font-body);
  font-size: .6875rem; letter-spacing: var(--tb-track-eyebrow);
  color: var(--tb-gold-300); opacity: .8;
}
.tb-menu__close { position: absolute; top: 1.25rem; right: var(--tb-gutter); color: var(--tb-cream); }

/* --- Entry gate -----------------------------------------------------------
   The reference site's signature moment: a "choose your experience" light /
   dark chooser over a blurred backdrop, before the site is revealed.

   Two deliberate departures, both flagged for client sign-off:
     1. It is SKIPPABLE — Esc, backdrop click, and a visible skip control.
     2. It shows ONCE, then remembers the choice in localStorage.
   A hard interstitial on every visit taxes both conversion and SEO on a site
   whose entire job is collecting booking enquiries. Set TB.gate = false in
   main.js to remove it altogether.
   -------------------------------------------------------------------------- */
.tb-gate {
  position: fixed; inset: 0; z-index: var(--tb-z-curtain);
  display: grid; place-items: center;
  padding: var(--tb-gutter);
  background: rgba(18, 32, 15, .55);
  backdrop-filter: blur(22px) saturate(1.1);
  -webkit-backdrop-filter: blur(22px) saturate(1.1);
  opacity: 0; visibility: hidden;
  transition: opacity var(--tb-dur-gate) var(--tb-ease),
              visibility 0s linear var(--tb-dur-gate);
}
.tb-gate.is-open { opacity: 1; visibility: visible; transition-delay: 0s; }

.tb-gate__card {
  width: min(460px, 100%);
  background: var(--tb-surface);
  border-radius: var(--tb-radius-lg);
  box-shadow: var(--tb-shadow-lg);
  padding: clamp(2rem, 1.4rem + 2.4vw, 3rem);
  text-align: center;
  transform: translateY(16px) scale(.985);
  opacity: 0;
  transition: transform var(--tb-dur-gate) var(--tb-ease),
              opacity var(--tb-dur-gate) var(--tb-ease);
}
.tb-gate.is-open .tb-gate__card { transform: none; opacity: 1; }

.tb-gate__title { font-size: var(--tb-size-h2); }
.tb-gate__sub {
  font-size: var(--tb-size-small); color: var(--tb-ink-soft);
  margin-top: .5rem;
}
.tb-gate__mark { width: 42px; height: auto; margin: var(--tb-space-4) auto var(--tb-space-2); }
.tb-gate__state {
  font-size: var(--tb-size-small); letter-spacing: .12em;
  text-transform: lowercase; color: var(--tb-ink);
  margin-bottom: var(--tb-space-3);
}

/* Switch */
.tb-switch {
  display: inline-flex; align-items: center; gap: .625rem;
  background: var(--tb-blush-100);
  border: 1px solid var(--tb-rule);
  border-radius: 999px;
  padding: .3125rem;
  cursor: pointer;
  min-height: 44px;
}
.tb-switch__dot {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--tb-surface-raised);
  box-shadow: var(--tb-shadow-sm);
  transition: transform var(--tb-dur-base) var(--tb-ease),
              background var(--tb-dur-base) var(--tb-ease);
}
.tb-switch[aria-checked="true"] .tb-switch__dot {
  transform: translateX(58px);
  background: var(--tb-gold-500);
}
.tb-switch__label {
  font-size: var(--tb-size-micro); letter-spacing: .1em;
  color: var(--tb-ink-soft); padding-right: .875rem;
}

.tb-gate__actions { display: grid; gap: .75rem; justify-items: center; margin-top: var(--tb-space-4); }
.tb-gate__skip {
  font-size: var(--tb-size-micro); letter-spacing: .08em;
  color: var(--tb-ink-faint); text-decoration: underline;
  text-underline-offset: 3px; background: none; border: 0; cursor: pointer;
  padding: .5rem;
}
.tb-gate__skip:hover { color: var(--tb-ink); }

/* --- Page transitions -----------------------------------------------------
   The reference has none — navigation is a plain full page load. This uses
   the native View Transitions API: a real cross-fade between documents, no
   library, no page-weight cost, and browsers without support simply navigate
   normally. Strictly an enhancement.
   -------------------------------------------------------------------------- */
@view-transition { navigation: auto; }

::view-transition-old(root) {
  animation: tb-fade-out var(--tb-dur-page) var(--tb-ease) both;
}
::view-transition-new(root) {
  animation: tb-fade-in var(--tb-dur-page) var(--tb-ease) both;
}
@keyframes tb-fade-out { to { opacity: 0; transform: translateY(-8px); } }
@keyframes tb-fade-in  { from { opacity: 0; transform: translateY(10px); } }

/* The header must not cross-fade with the body, or it visibly flickers. */
.tb-header { view-transition-name: tb-header; }
::view-transition-old(tb-header),
::view-transition-new(tb-header) { animation: none; mix-blend-mode: normal; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
