/* The shared site header (scripts/lib/site-header.mjs) and shared control proportions.
   Every surface loads this file, the Atlas included, so every rule is scoped to .wh or to a named control. */
:root {
  --wow-header-height: 4.75rem;
  --wow-gutter: clamp(1rem, 4vw, 4rem);
  --wow-ui-font: 'Josefin Sans', 'Avenir Next', 'Helvetica Neue', Arial, sans-serif;
  --wow-ui-size: .75rem;
  --wow-ui-ink: #4d0826;
  --wow-ui-paper: #f4eddf;
  --wow-ui-raised: #fbf7ef;
  --wow-ui-line: #c9b898;
  --wow-ui-muted: #6e5a4c;
  --wow-ui-focus: #850035;
}

.wh, .wh * { box-sizing: border-box; }
.wh {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 900;
  border-bottom: 1px solid var(--wow-ui-line); background: var(--wow-ui-paper); color: var(--wow-ui-ink);
  font: 500 var(--wow-ui-size)/1.4 var(--wow-ui-font);
}
.wh a { color: inherit; }
.wh :is(a, button, input):focus-visible { outline: 2px solid var(--wow-ui-focus); outline-offset: 3px; }
.wh__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wh__bar {
  display: flex; align-items: center; gap: clamp(1rem, 2.2vw, 2rem);
  min-height: var(--wow-header-height); padding: .5rem max(var(--wow-gutter), calc((100vw - 84rem) / 2));
}
.wh__brand { display: inline-flex; align-items: center; flex-shrink: 0; gap: .85rem; min-height: 44px; text-decoration: none; }
.wh__brand img { display: block; width: auto; height: 2.5rem; }
.wh__brand span { padding-left: .85rem; border-left: 1px solid var(--wow-ui-line); font-size: .625rem; letter-spacing: .15em; text-transform: uppercase; white-space: nowrap; }
.wh__menu { display: flex; flex: 1; align-items: center; outline: 0; gap: clamp(1rem, 2vw, 1.75rem); min-width: 0; }
.wh__toggle { display: none; }

/* Menu */
.wh__nav { order: 1; margin-right: auto; }
.wh__nav > ul { display: flex; align-items: center; gap: clamp(.7rem, 1.6vw, 1.6rem); margin: 0; padding: 0; list-style: none; }
.wh__item { position: relative; display: flex; align-items: center; }
.wh__link {
  display: inline-flex; align-items: center; min-height: 44px; padding: .35rem 0;
  letter-spacing: .12em; text-decoration: none; text-transform: uppercase; white-space: nowrap;
  border-bottom: 1px solid transparent;
}
.wh__link:hover { border-bottom-color: currentColor; }
.wh__item.is-current > .wh__link { border-bottom: 2px solid var(--wow-ui-focus); color: var(--wow-ui-focus); }
.wh__more {
  display: inline-grid; place-items: center; width: 1.5rem; min-height: 44px; margin-left: .1rem; padding: 0;
  border: 0; background: none; color: inherit; cursor: pointer;
}
.wh__more::before {
  content: ''; width: .75rem; height: .75rem; background: currentColor; transition: transform 160ms ease-out;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='black' stroke-width='1.3'/%3E%3C/svg%3E") center / contain no-repeat;
}
.wh__more[aria-expanded='true']::before { transform: rotate(180deg); }
.wh__panel {
  position: absolute; top: 100%; left: -1rem; display: none; min-width: 14rem; margin: 0; padding: .5rem 0; list-style: none;
  border: 1px solid var(--wow-ui-line); background: var(--wow-ui-raised); box-shadow: 0 16px 32px -18px rgb(36 0 20 / 45%);
}
.wh__panel a { display: block; padding: .6rem 1rem; font-size: .8rem; letter-spacing: .08em; text-decoration: none; text-transform: none; white-space: nowrap; }
.wh__panel a:hover { background: var(--wow-ui-paper); text-decoration: underline; text-underline-offset: .25em; }
.wh__more[aria-expanded='true'] + .wh__panel { display: block; }
@media (hover: hover) and (min-width: 64em) {
  .wh__item--panel:hover:not(.is-dismissed) > .wh__panel { display: block; }
}

/* Search and Find a wine */
.wh__search { position: relative; order: 2; display: flex; align-items: center; flex: 0 1 16rem; min-width: 9rem; }
.wh__search::before {
  content: ''; position: absolute; left: .7rem; width: 1rem; height: 1rem; background: var(--wow-ui-muted); pointer-events: none;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Ccircle cx='8.5' cy='8.5' r='5.5' fill='none' stroke='black' stroke-width='1.4'/%3E%3Cpath d='m13 13 4.5 4.5' fill='none' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E") center / contain no-repeat;
}
.wh__search input {
  width: 100%; min-height: 44px; padding: .5rem .8rem .5rem 2.2rem; border: 1px solid var(--wow-ui-line); border-radius: 0;
  background: var(--wow-ui-raised); color: var(--wow-ui-ink); font: 400 .95rem/1.2 Georgia, 'Times New Roman', serif;
  -webkit-appearance: none; appearance: none;
}
.wh__search input::placeholder { color: var(--wow-ui-muted); opacity: 1; }
.wh__search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.wh__find {
  order: 3; display: inline-flex; align-items: center; min-height: 44px; padding: .5rem 1rem; flex-shrink: 0;
  border: 1px solid var(--wow-ui-focus); color: var(--wow-ui-focus) !important; letter-spacing: .12em; text-decoration: none; text-transform: uppercase; white-space: nowrap;
}
.wh__find:hover, .wh__find[aria-current] { background: var(--wow-ui-focus); color: var(--wow-ui-paper) !important; }

.wh__results {
  position: absolute; top: calc(100% + .4rem); right: 0; width: min(26rem, calc(100vw - 2 * var(--wow-gutter))); max-height: min(70vh, 34rem); overflow-y: auto;
  padding: .4rem 0; border: 1px solid var(--wow-ui-line); background: var(--wow-ui-raised); box-shadow: 0 18px 36px -18px rgb(36 0 20 / 50%);
  font-family: Georgia, 'Times New Roman', serif; text-transform: none; letter-spacing: 0;
}
.wh__results[hidden] { display: none; }
.wh__group { padding: .3rem 0; }
.wh__group + .wh__group { border-top: 1px solid var(--wow-ui-line); }
.wh__group-title { margin: .3rem 1rem .2rem; color: var(--wow-ui-muted); font: 600 .66rem/1.3 var(--wow-ui-font); letter-spacing: .14em; text-transform: uppercase; }
.wh__result { display: flex; align-items: center; min-height: 44px; justify-content: space-between; gap: 1rem; padding: .5rem 1rem; text-decoration: none; }
.wh__result-title { min-width: 0; font-size: 1rem; overflow-wrap: anywhere; }
.wh__result-type { flex-shrink: 0; color: var(--wow-ui-muted); font: 500 .68rem/1.3 var(--wow-ui-font); letter-spacing: .08em; text-transform: uppercase; }
.wh__result:hover, .wh__result.is-active { background: var(--wow-ui-paper); }
.wh__result.is-active .wh__result-title { text-decoration: underline; text-underline-offset: .2em; }
.wh__all { display: block; margin-top: .2rem; padding: .7rem 1rem .5rem; border-top: 1px solid var(--wow-ui-line); color: var(--wow-ui-focus) !important; font-size: .92rem; }
.wh__note { margin: .6rem 1rem; font-size: .92rem; }

/* Narrow laptops: drop the brand line first */
@media (max-width: 77.5em) { .wh__brand span { display: none; } }

/* Phones and tablets: one Menu button opens search, the five subjects with their parts, and Find a wine */
@media (max-width: 63.9375em) {
  :root { --wow-header-height: 4.25rem; }
  .wh__brand img { height: 2.125rem; }
  .wh__toggle {
    display: inline-flex; align-items: center; gap: .6rem; min-width: 44px; min-height: 44px; margin-left: auto; padding: .4rem 0;
    border: 0; background: none; color: inherit; font: inherit; letter-spacing: .12em; text-transform: uppercase; cursor: pointer;
  }
  .wh__toggle::after {
    content: ''; width: 20px; height: 20px; background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M2 6h16M2 14h16' fill='none' stroke='black' stroke-width='1.2'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  .wh[data-open] .wh__toggle::after { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='m4 4 12 12M4 16 16 4' fill='none' stroke='black' stroke-width='1.2'/%3E%3C/svg%3E"); }
  .wh--js .wh__menu { display: none; }
  .wh--js[data-open] .wh__menu {
    position: absolute; top: 100%; left: 0; right: 0; display: flex; max-height: calc(100dvh - var(--wow-header-height)); overflow-y: auto;
    border-bottom: 1px solid var(--wow-ui-line); background: var(--wow-ui-paper); box-shadow: 0 16px 28px -16px rgb(36 0 20 / 35%);
  }
  .wh__menu { flex-direction: column; align-items: stretch; gap: 1rem; padding: 1rem var(--wow-gutter) 1.4rem; }
  .wh:not(.wh--js) .wh__bar { flex-wrap: wrap; }
  .wh:not(.wh--js) .wh__toggle { display: none; }
  .wh:not(.wh--js) .wh__menu { flex: 1 0 100%; padding-inline: 0; }
  .wh__search { order: 1; flex: none; min-width: 0; }
  /* Results lie over the menu links rather than pushing them down when the index arrives. */
  .wh__results { left: 0; right: 0; z-index: 1; width: auto; max-height: min(60dvh, 30rem); }
  .wh__nav { order: 2; margin: 0; }
  .wh__nav > ul { flex-direction: column; align-items: stretch; gap: 0; }
  .wh__item { flex-wrap: wrap; border-bottom: 1px solid var(--wow-ui-line); }
  .wh__link { flex: 1; min-height: 48px; font-size: .82rem; border-bottom: 0; }
  .wh__item.is-current > .wh__link { border-bottom: 0; }
  .wh__item.is-current > .wh__link::before { content: ''; width: .4rem; height: .4rem; margin-right: .6rem; border-radius: 50%; background: currentColor; }
  .wh__more { display: none; }
  .wh__panel { position: static; display: flex; flex: 1 0 100%; flex-wrap: wrap; gap: .1rem 1.2rem; min-width: 0; padding: 0 0 .8rem; border: 0; background: none; box-shadow: none; }
  .wh__panel a { padding: .35rem 0; font-size: .82rem; color: var(--wow-ui-muted); }
  .wh__find { order: 3; justify-content: center; }
}

/* Learn pages were laid out under a header fixed to the top of the window. */
.wh--fixed { position: fixed; top: 0; left: 0; right: 0; padding-top: env(safe-area-inset-top, 0px); }

/* Atlas: a slim floating bar over the map. The map keeps its own place search, so the header search stays out. */
.wh--atlas {
  position: fixed; z-index: 30; inset: max(.45rem, env(safe-area-inset-top)) .7rem auto;
  border: 1px solid rgb(154 110 10 / 28%); background: rgb(255 250 240 / 96%); box-shadow: 0 .5rem 2rem rgb(77 0 38 / 8%);
}
.wh--atlas .wh__bar { min-height: 3rem; padding: .2rem .7rem; }
.wh--atlas .wh__brand img { height: 1.85rem; }
.wh--atlas .wh__search { display: none; }
.wh--atlas :is(.wh__link, .wh__more, .wh__find) { min-height: 44px; }
.wh--atlas .wh__find { padding: .3rem .8rem; }
@media (max-width: 63.9375em) {
  .wh--atlas { inset: max(.35rem, env(safe-area-inset-top)) .4rem auto; }
  .wh--atlas .wh__brand img { height: 1.55rem; }
}

@media (prefers-reduced-motion: reduce) { .wh__more::before { transition: none; } }
@media (forced-colors: active) {
  .wh { border-color: CanvasText; }
  .wh__item.is-current > .wh__link { border-color: Highlight; }
}

/* Shared control proportions; each surface retains its light or dark colour roles. */
:is(.button, .btn, .identity-save, .library-finder__scope) { min-height: 44px; border-radius: 0; font-weight: 500; font-size: var(--wow-ui-size); line-height: 1.5; letter-spacing: .1em; }
:is(.hero-answer__field, .library-finder__field):focus-within { outline: 2px solid #850035; outline-offset: 3px; }
:is(.hero-answer__field, .library-finder__field) input { min-height: 54px; font-size: 1.125rem; caret-color: #850035; }
:is(.hero-answer__field, .library-finder__field) input::placeholder { color: #765e4e; opacity: 1; }
:is(.hero-answer__status, .library-finder__status) { font-size: .8rem; line-height: 1.5; }
