/* Chrome: the header, the menu, and the footer that every page shares.
 *
 * How the menu degrades, so it can never become a dead end:
 *   no script at all     hover or keyboard focus opens a panel; on a phone the whole menu is a list
 *   script running       nav.js controls panels with the .is-open class (html has .js)
 *   script failed        boot.js adds .nav-failed after 4 seconds and we fall back to the no-script look
 * "enhanced" below means html.js:not(.nav-failed).
 */

.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  view-transition-name: site-header;
}

.site-header__bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--header-h);
}

/* ---------------------------------------------------------------- brand */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--target);
  margin-right: auto;
  color: var(--ink);
  text-decoration: none;
}
.brand:hover { color: var(--ink); }
.brand__mark { flex: none; width: 32px; height: 32px; }
/* TWO TONES, AND ITS OWN PAIR OF THEM. The mark has exactly one colour and one tone of glass, and
   they live in --mark-ground and --mark-glass rather than in --accent, so the mark can be recoloured
   without dragging every button and link on the site along with it. The dark pair is lighter, not
   inverted: the tile has to stay visible against the dark header. */
.brand__tile { fill: var(--mark-ground); }
.brand__glass { fill: var(--mark-glass); }
.brand__text { display: flex; align-items: baseline; gap: 6px; line-height: 1; }
.brand__name { font-size: 1.1875rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; white-space: nowrap; }
.brand__sub { display: none; font-size: 0.9375rem; font-weight: 500; color: var(--muted); }
@media (min-width: 420px) { .brand__sub { display: inline; } }

/* ---------------------------------------------------------------- shared nav bits */
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-link {
  color: var(--ink);
  font-weight: 500;
  text-decoration: none;
}
.nav-link:hover { color: var(--accent); }
.nav-link[aria-current="page"],
.nav-link[aria-current="true"] { color: var(--accent); }

.nav-caret {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.nav-caret:hover { color: var(--accent); }
.nav-caret .icon { transition: transform var(--t-fast) var(--ease); }
.nav-item.is-open > .nav-split > .nav-caret .icon { transform: rotate(180deg); }

.nav-panel:focus { outline: none; }

.header-cta { white-space: nowrap; padding: 0 14px; min-height: var(--target); font-size: 0.9375rem; }

.nav-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: var(--target);
  min-height: var(--target);
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.nav-toggle:hover { border-color: var(--accent); color: var(--accent); }
.nav-toggle__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (min-width: 440px) {
  .nav-toggle__label { position: static; width: auto; height: auto; overflow: visible; clip-path: none; }
}
.icon--menu .icon__cross { display: none; }
.site-header.is-sheet-open .icon--menu .icon__bars { display: none; }
.site-header.is-sheet-open .icon--menu .icon__cross { display: inline; }

/* ---------------------------------------------------------------- menu rows (shared look) */
.mega__title { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; margin-bottom: var(--s-2); }
.mega__title a { color: var(--muted); text-decoration: none; }
.mega__title a:hover { color: var(--accent); }
.mega__list, .menu-list { list-style: none; margin: 0; padding: 0; }
.mega__item, .menu-item {
  display: block;
  padding: 8px 10px;
  margin-inline: -10px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
}
.mega__item:hover, .menu-item:hover { background: var(--accent-soft); color: var(--ink); }
.mega__short, .menu-item__short { display: block; margin-top: 2px; font-size: 0.8125rem; line-height: 1.35; color: var(--muted); }
.mega__foot, .menu-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  margin-top: var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--line);
  max-width: none;
}
.mega__all { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; text-decoration: none; min-height: 32px; }
.mega__legend { font-size: 0.8125rem; color: var(--muted); }

/* ---------------------------------------------------------------- the grouped menus (one shape for all)
   Icon in its own column, name and one line beside it, so every item in every column starts on the
   same left edge whether or not its name wraps. */
.mega__item { display: flex; align-items: flex-start; gap: 10px; }
.mega__item > .icon--product, .mega__noicon { flex: none; width: 20px; height: 20px; margin-top: 1px; color: var(--muted); transition: color 0.15s ease; }
.mega__item:hover > .icon--product, .mega__item:focus-visible > .icon--product { color: var(--accent); }
.mega__text { min-width: 0; }
.mega__name { display: block; }
.mega-intro__title { font-weight: 600; font-size: 1.0625rem; margin: 0 0 var(--s-2); }
.mega-intro .mega__all { display: flex; }
.mega-intro__lead { margin: 0 0 var(--s-3); color: var(--ink-2); font-size: 0.875rem; line-height: 1.45; max-width: 40ch; }

/* ================================================================= PHONE and TABLET: the sheet */
@media (max-width: 1079.98px) {
  .primary-nav { order: 5; }

  /* Enhanced: the nav is a full-screen sheet that the hamburger opens. */
  html.js:not(.nav-failed) .primary-nav { display: none; }
  html.js:not(.nav-failed) .site-header.is-sheet-open .primary-nav {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--bg);
    padding: 4px var(--gutter) 40px;
  }
  html.nav-locked { overflow: hidden; }

  /* Not enhanced: show the nav as a plain list under the bar, and no hamburger. */
  html:not(.js) .nav-toggle, html.nav-failed .nav-toggle { display: none; }
  html:not(.js) .site-header__bar, html.nav-failed .site-header__bar { flex-wrap: wrap; }
  html:not(.js) .primary-nav, html.nav-failed .primary-nav { flex: 1 0 100%; padding-bottom: var(--s-4); }
  html:not(.js) .site-header, html.nav-failed .site-header { position: static; }

  .nav-item { border-bottom: 1px solid var(--line); }
  .nav-split { display: flex; align-items: stretch; }
  .nav-link { flex: 1; display: flex; align-items: center; min-height: 52px; font-size: 1.0625rem; }
  .nav-caret { width: 52px; min-height: 52px; }
  .nav-item--login .nav-link { color: var(--accent); }

  .nav-panel { display: none; padding: 0 0 var(--s-4); }
  .nav-item.is-open > .nav-panel { display: block; }
  /* Without a working script the phone menu is just the top-level links. Products is a real link to a
     page that lists every product, so nothing is out of reach. */
  html:not(.js) .nav-panel, html.nav-failed .nav-panel { display: none; }
  html:not(.js) .nav-caret, html.nav-failed .nav-caret { display: none; }

  .mega { display: block; }
  .mega__group { margin-top: var(--s-4); }
  .mega__item, .menu-item { padding: 10px 10px; min-height: var(--target); }
  .mega-intro { padding-top: var(--s-2); }
  .mega-intro__title { display: none; }
  .mega__legend { display: none; }
}

/* A phone: keep the lists short enough to scan. Name on the left, nothing else. */
@media (max-width: 559.98px) {
  .mega__short { display: none; }
  .mega-intro__lead { display: none; }
}

/* ================================================================= DESKTOP: bar with panels */
@media (min-width: 1080px) {
  /* THE BAR IS WIDER THAN THE PAGE, ON PURPOSE.
     Everything below used to be an argument about a few pixels: gaps cut to 12, link padding cut to
     8, the words "Ask Buan" dropped, the button hidden outright in one band. All of it because the
     bar inherited .wrap - the measure that keeps a PARAGRAPH readable at 1120px. A header is not
     prose. It is the frame around the page, and on a wide screen it can use the screen.
     Raising its own --wrap to 1280 re-uses .wrap's formula and changes nothing below 1328px, where
     the bar is narrower than that anyway: the brand sits at the left edge of a wider bar, Book a
     demo and Ask Buan at the right edge of one, and the room that appears between them goes back
     into the gaps and the links. The content underneath keeps the 1120 measure it needs. */
  /* Grows with the screen rather than stepping at a second breakpoint: the menu's breakpoint is
     1080 and only 1080, in the css, the markup and the script alike, and a header that wants more
     air on a big monitor is not a reason to have two. 20px at 1080, 28px by 1330, where the wider
     bar above has stopped being capped by the screen. */
  .site-header__bar {
    --wrap: 1280px;
    align-items: stretch;
    gap: clamp(20px, calc(20px + (100vw - 1080px) * 0.032), 28px);
  }
  .brand { align-self: center; margin-right: 0; }
  .nav-toggle { display: none; }
  .header-cta { align-self: center; }

  .primary-nav { flex: 1; display: flex; min-width: 0; }
  .nav-list { display: flex; align-items: stretch; width: 100%; }
  .nav-item { display: flex; align-items: stretch; position: relative; }
  .nav-item--mega { position: static; }
  .nav-split { display: flex; align-items: stretch; }
  /* 8 at the widths where the bar really is tight, 12 once it is not. The seven links do not
     shrink, so between 1080 and the point where the wider bar above starts to bite they still need
     every pixel; past that there is room to let them breathe again, which is the difference between
     a row of tabs and a row of words jammed together. */
  .nav-link {
    display: flex;
    align-items: center;
    padding: 0 clamp(8px, calc(8px + (100vw - 1080px) * 0.016), 12px);
    white-space: nowrap;
    font-size: 0.9375rem;
    position: relative;
  }
  .nav-item--has-panel > .nav-split > .nav-link { padding-right: 2px; }
  .nav-caret { width: 30px; }
  .nav-item--login { margin-left: auto; }
  .nav-link[aria-current="page"]::after,
  .nav-link[aria-current="true"]::after {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 14px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
  }
  .nav-item--has-panel > .nav-split > .nav-link[aria-current]::after { right: 2px; }

  .nav-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 2;
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 0;
    box-shadow: var(--shadow);
  }
  .nav-panel--list { min-width: 320px; padding: 8px 14px 12px; border-radius: 0 0 var(--radius) var(--radius); }
  .nav-item:nth-last-child(-n + 3) > .nav-panel--list { left: auto; right: 0; }
  .nav-panel--mega {
    left: 0;
    right: 0;
    border-inline: 0;
    max-height: calc(100vh - var(--header-h));
    overflow-y: auto;
  }
  /* The panel uses the header bar's wider measure, so its left edge lines up with the logo. */
  .mega-wrap { --wrap: 1280px; display: grid; grid-template-columns: 1fr; gap: var(--s-4) 40px; padding-top: var(--s-5); padding-bottom: var(--s-5); }
  .mega { display: grid; gap: var(--s-4) 24px; align-items: start; }
  .mega--cols-1 { grid-template-columns: minmax(0, 1fr); }
  .mega--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mega--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mega--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .mega--cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .mega__title { padding-bottom: var(--s-2); border-bottom: 1px solid var(--line); }
  /* The headings share one row, so a heading that wraps to two lines moves every underline down
     together instead of leaving its own column out of step. */
  .mega { grid-template-rows: auto auto; row-gap: 0; }
  .mega__group { display: grid; grid-row: span 2; grid-template-rows: subgrid; }
  .mega__title { display: flex; align-items: flex-end; margin-bottom: var(--s-2); }
  /* Narrow desktop: the intro is one line across the top, so five columns keep their width. */
  .mega-intro { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 20px; }
  .mega-intro__title, .mega-intro__lead { margin: 0; max-width: none; }
  .mega-intro .mega__all { margin-left: auto; }

  /* Enhanced: shown when nav.js says so. */
  html.js:not(.nav-failed) .nav-item.is-open > .nav-panel { display: block; }

  /* Not enhanced: hover or keyboard focus inside the item shows the panel. */
  html:not(.js) .nav-item:hover > .nav-panel,
  html:not(.js) .nav-item:focus-within > .nav-panel,
  html.nav-failed .nav-item:hover > .nav-panel,
  html.nav-failed .nav-item:focus-within > .nav-panel { display: block; }
  html:not(.js) .nav-caret, html.nav-failed .nav-caret { pointer-events: none; }
}

/* ---------------------------------------------------------------- footer */
.site-footer {
  margin-top: var(--s-8);
  padding-block: var(--s-7) var(--s-6);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.footer__cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-6) var(--s-5);
}
@media (min-width: 720px) { .footer__cols { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .footer__cols { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.footer__title {
  margin-bottom: var(--s-2);
  font-size: var(--fs--1);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.footer__col ul { list-style: none; margin: 0; padding: 0; }
.footer__col a {
  display: block;
  padding: 7px 0;
  color: var(--ink);
  text-decoration: none;
  font-size: var(--fs-0);
}
.footer__col a:hover { color: var(--accent); text-decoration: underline; }
.footer__col a[aria-current="page"] { color: var(--accent); font-weight: 600; }

.footer__legal {
  display: grid;
  gap: var(--s-2);
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
  color: var(--muted);
  /* The registered-company lines are a legal requirement rather than something to read: small, like the
     small print it is, so it does not compete with the links above it. */
  font-size: var(--fs--1);
}
.footer__line { max-width: 80ch; }
.footer__line a { color: var(--ink); }
.footer__tools { margin-top: var(--s-2); }

.pause-motion {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--target);
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-0);
  font-weight: 600;
  cursor: pointer;
}
.pause-motion:hover { border-color: var(--accent); color: var(--accent); }
.pause-motion .icon--play { display: none; }
.pause-motion[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.pause-motion[aria-pressed="true"] .icon--pause { display: none; }
.pause-motion[aria-pressed="true"] .icon--play { display: inline; }
.pause-motion[aria-pressed="true"] span::after { content: ": on"; }

/* ---------------------------------------------------------------- Ask Buan
   A round button in the bottom-right corner that opens a small chat window above it (the founder's
   call, after Guesty's assistant). It never opens itself. The affordance is a link to the contact form
   until js/ask-panel.js makes it a button, so nothing here is hidden on the strength of scripts running. */
.ask-trigger {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 18px 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.ask-trigger:hover { background: var(--accent-hover); color: var(--accent-ink); }
.ask-trigger[aria-expanded="true"] { filter: brightness(0.92); }
.ask-trigger .icon--ask { flex: none; }
.ask-trigger__label { white-space: nowrap; }

.ask {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  z-index: 61;
  width: min(380px, calc(100vw - 32px));
  max-height: min(600px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.ask[hidden] { display: none; }
.ask__inner { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.ask__top {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 12px 12px 12px 18px;
  background: var(--accent);
  color: var(--accent-ink);
}
.ask__title { margin: 0; font-size: 1.0625rem; color: inherit; }
.ask__close {
  appearance: none;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--target);
  min-height: var(--target);
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.ask__close:hover { background: var(--accent-hover); }
.ask__log {
  flex: 1;
  min-height: 140px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  background: var(--surface-2);
}
.ask__msg { max-width: 88%; padding: 10px 12px; border-radius: 14px; font-size: 0.9375rem; line-height: 1.45; }
.ask__msg--bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.ask__msg--you { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.ask__msg p { margin: 0; }
.ask__msg .ask__what { color: var(--ink-2); font-size: 0.9375rem; }
.ask__from { margin-top: 6px !important; color: var(--muted); font-size: 0.8125rem; }
.ask__chips { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.ask__chips[hidden] { display: none; }
.ask__chip {
  appearance: none;
  padding: 8px 12px;
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.ask__chip:hover { background: var(--accent-soft); }
.ask__status { margin: 0; padding: 0 16px; min-height: 0; color: var(--muted); font-size: 0.8125rem; }
.ask__status:not(:empty) { padding-top: 8px; }
.ask__status--bad { color: var(--built-fg); }
.ask__form { display: grid; gap: 6px; padding: 12px 16px 0; border-top: 1px solid var(--line); }
.ask__row { display: flex; gap: 8px; }
.ask__input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.ask__send { flex: 0 0 auto; }
.ask__hint, .ask__foot { margin: 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.4; }
.ask__foot { padding: 6px 16px 14px; }
.ask__input:focus-visible, .ask__close:focus-visible, .ask-trigger:focus-visible, .ask__chip:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ask__hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* A phone: the window is the width of the screen less the gutters, and the button keeps to its corner. */
@media (max-width: 559.98px) {
  .ask { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); max-height: calc(100vh - 100px); }
  .ask-trigger { min-height: 48px; padding: 0 16px 0 12px; }
}

/* A wide panel: the intro becomes its own column on the left, beside the groups. A container query
   on the panel, not a second screen breakpoint - the menu has exactly one of those (1080). */
.nav-panel--mega { container-type: inline-size; }
@container (min-width: 1340px) {
  .mega-wrap { grid-template-columns: 220px minmax(0, 1fr); }
  .mega-intro { display: block; padding-right: 24px; border-right: 1px solid var(--line); }
  .mega-intro__title { margin-bottom: var(--s-2); }
  .mega-intro__lead { margin-bottom: var(--s-3); }
  .mega-intro .mega__all { margin-left: 0; }
}

/* Language picker (header). One language today; built to list more. */
.lang-picker { position: relative; }
.lang-picker__btn { list-style: none; display: inline-flex; align-items: center; gap: 6px; min-height: var(--target); padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 0.875rem; letter-spacing: 0.04em; cursor: pointer; }
.lang-picker__btn::-webkit-details-marker { display: none; }
.lang-picker__btn:hover, .lang-picker[open] .lang-picker__btn { border-color: var(--accent); color: var(--accent); }
.lang-picker__icon { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.lang-picker__menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 180px; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12); }
.lang-picker__menu a { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-weight: 600; }
.lang-picker__menu a:hover { background: var(--accent-soft); }
.lang-picker__menu a[aria-current="true"] { color: var(--accent); }
.lang-picker__code { color: var(--muted); font-weight: 600; font-size: 0.8125rem; }
