/* ══════════════════════════════════════════════════════════════════════
   Шапка у верха страницы: десять видов.

   Файл общий для сайта и для админки: плитки выбора вида в разделе «Шапка»
   собраны из тех же классов и красятся этим же CSS, поэтому образец не может
   разойтись с сайтом. Вид — атрибут `data-header-style` на <html> (в плитке —
   на самой плитке); выравнивание, размер, показ адреса и подписи — тоже
   атрибуты. Селекторы поэтому по атрибуту на любом предке, а не по `:root`.

   Цвета — только из `palette.js` (`--hero-band*`): всё, что стоит на полосе,
   берёт пару от самой полосы. Новая пара «текст на цвете» — сначала в
   `palette.js` и в тест, потом сюда.

   Шапка лежит в потоке и уезжает со страницей. Нижние края (волна, дуга,
   зубцы) выходят за полосу на `--edge`, и вместо наползания на баннер
   полоса получает такой же нижний отступ: баннер и меню стоят на ровном
   отступе во всех видах.
   ══════════════════════════════════════════════════════════════════════ */

.hero {
  /* Множитель размера (компактная / обычная / крупная) и высота нижнего края. */
  --hs: 1;
  --edge: 0px;
  position: relative;
  z-index: 1;
  color: var(--hero-band-ink, #fff);
  /* Запасной цвет, пока скрипт не посчитал палитру: тёмная версия акцента.
     Едва заметный свет сверху даёт полосе глубину без «глянца». */
  background:
    linear-gradient(180deg, rgb(255 255 255 / 0.06), rgb(0 0 0 / 0.06)),
    var(--hero-band, color-mix(in srgb, var(--accent-strong) 78%, #000));
  padding: calc(env(safe-area-inset-top, 0px) + 12px * var(--hs)) 0 calc(20px * var(--hs));
  margin-bottom: var(--edge);
  border-radius: 0 0 28px 28px;
}
[data-header-size="compact"] .hero {
  --hs: 0.82;
}
[data-header-size="large"] .hero {
  --hs: 1.22;
}

.hero__inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, max-content);
  grid-template-areas:
    "brand tools"
    "pill sign"
    "nav nav";
  column-gap: 12px;
  align-items: center;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--page-gutter);
  transition:
    opacity var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out),
    visibility var(--dur-base);
}
.hero__brand {
  display: contents;
}
.hero .brand {
  grid-area: brand;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  justify-self: start;
  max-width: 100%;
  color: inherit;
  text-decoration: none;
}
.hero .brand__mark {
  scale: 1;
  display: grid;
  place-items: center;
}
.hero .brand__mark[data-logo="true"] .brand__logo,
:root[data-brand="both"] .hero .brand__mark[data-logo="true"] .brand__logo {
  height: calc(52px * var(--hs));
  max-width: 150px;
  width: auto;
}
.hero .brand__word,
:root[data-brand="both"] .hero .brand__word {
  position: static;
  min-width: 0;
  overflow: visible;
  white-space: normal;
  overflow-wrap: anywhere;
  text-overflow: clip;
  font-size: calc(clamp(1.55rem, 7.4vw, 2.1rem) * var(--hs) * var(--brand-fit, 1));
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.015em;
  text-indent: 0;
  text-transform: none;
}
.hero .brand__word::after {
  display: none;
}
.hero .brand:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
  border-radius: 6px;
}

/* Плашка с адресом: подложка — пара от полосы (`--hero-band-pill` / `--hero-band-ink`). */
.place-link--hero {
  grid-area: pill;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  max-width: 100%;
  gap: 6px;
  min-height: 38px;
  margin: calc(10px * var(--hs)) 0 0;
  padding: 0 10px 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--hero-band-pill, rgb(255 255 255 / 0.16));
  color: var(--hero-band-ink, #fff);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
}
.place-link--hero .place-link__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Мишень пальца 44px при видимой высоте 38. */
.place-link--hero::before {
  content: "";
  position: absolute;
  inset: -3px 0;
}
.place-link--hero .place-link__pin {
  flex: none;
  width: 16px;
  height: 16px;
}
.place-link--hero .place-link__go {
  flex: none;
  width: 16px;
  height: 16px;
  opacity: 0.8;
}
.place-link--hero:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.hero__tools {
  grid-area: tools;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
}
.search-toggle--hero {
  display: none;
}
.hero .lang-btn,
.hero .menu-btn,
.hero .round-btn {
  background: var(--hero-band-pill, rgb(255 255 255 / 0.16));
  color: var(--hero-band-ink, #fff);
}
.hero .lang-btn:focus-visible,
.hero .menu-btn:focus-visible,
.hero .round-btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Подпись — слова владельца из «О кафе». Шрифт по умолчанию объявлен в
   fonts.css с unicode-range и скачивается, только когда подпись показана. */
.hero__sign {
  grid-area: sign;
  justify-self: end;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  /* Подпись переносится на две строки, а не отнимает место у адреса. */
  max-width: 8.6em;
  margin: 8px 6px 0 0;
  font-family: var(--font-sign, "Marck Script", "Segoe Script", "Bradley Hand", cursive);
  font-size: calc(1.32rem * var(--hs) * var(--sign-fit, 1));
  font-weight: 400;
  line-height: 1.08;
  text-align: right;
  color: var(--hero-band-ink, #fff);
  font-synthesis: none;
  transform: rotate(-7deg);
  transform-origin: right center;
  overflow-wrap: anywhere;
}
.hero__sign[hidden] {
  display: none;
}
.hero__sign svg {
  flex: none;
  width: 16px;
  height: 16px;
  margin-bottom: 2px;
}

/* Разделы строкой в полосе — только где они помещаются (data-nav=auto) и
   есть место: от 1024px. Иначе работает лента под баннером. */
.hero__nav {
  grid-area: nav;
  display: none;
}

.hero__edge {
  display: none;
}

@media (max-width: 380px) {
  .hero__sign {
    font-size: calc(1.15rem * var(--hs) * var(--sign-fit, 1));
  }
}
@media (min-width: 640px) {
  .hero:not(.hero--tile) {
    padding-bottom: calc(24px * var(--hs));
  }
  .hero:not(.hero--tile) .hero__sign {
    font-size: calc(1.7rem * var(--hs) * var(--sign-fit, 1));
    margin-right: 16px;
  }
}
@media (min-width: 1024px) {
  .hero[data-nav="auto"] .search-toggle--hero {
    display: inline-grid;
  }
  .hero[data-nav="auto"] .hero__nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 24px;
    margin-top: 12px;
  }
  .hero__nav .site-nav__link {
    color: var(--hero-band-soft, rgb(255 255 255 / 0.8));
  }
  .hero__nav .site-nav__link::after {
    background: var(--hero-band-ink, #fff);
  }
  .hero__nav .site-nav__link:hover,
  .hero__nav .site-nav__link[aria-current="true"] {
    color: var(--hero-band-ink, #fff);
  }
  .hero:not(.hero--tile) {
    padding-top: calc(24px * var(--hs));
    padding-bottom: calc(28px * var(--hs));
    border-radius: 0 0 36px 36px;
  }
  .hero:not(.hero--tile) .brand__word,
  :root[data-brand="both"] .hero:not(.hero--tile) .brand__word {
    font-size: calc(2.4rem * var(--hs) * var(--brand-fit, 1));
  }
  .hero:not(.hero--tile) .hero__sign {
    font-size: calc(2rem * var(--hs) * var(--sign-fit, 1));
  }
}

/* ─── Шрифты названия и подписи ──────────────────────────────────────── */
/* Ключи в переменные превращает «Карта шрифтов» в fonts.css. Название меняется
   и в компактной плашке — шапка читается одной. Рукописным буквам разрядка и
   прописные не идут. */
:is(:root, .hdr-tile)[data-font-brand] :is(.hero, .site-header) .brand__word {
  font-family: var(--font-brand);
  font-synthesis-weight: none;
}
:is(:root, .hdr-tile)[data-font-brand] .site-header .brand__word {
  font-size: calc(1.05rem * var(--brand-fit, 1));
}
:is(:root, .hdr-tile)[data-font-brand] .hero .brand__word {
  font-size: calc(clamp(1.55rem, 7.4vw, 2.1rem) * var(--hs) * var(--brand-fit, 1));
}
@media (min-width: 1024px) {
  :root[data-font-brand] .hero:not(.hero--tile) .brand__word {
    font-size: calc(2.4rem * var(--hs) * var(--brand-fit, 1));
  }
}
:is(:root, .hdr-tile)[data-font-sign] .hero__sign {
  font-family: var(--font-sign);
  font-synthesis-weight: none;
}

/* ─── Показ адреса и подписи ─────────────────────────────────────────── */
[data-header-address="off"] .place-link--hero,
[data-header-sign="off"] .hero__sign {
  display: none;
}

/* ─── Выравнивание по центру (и вид «По центру» всегда) ──────────────── */
:is([data-header-style="center"], [data-header-align="center"]) .hero__inner {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "tools"
    "brand"
    "pill"
    "sign"
    "nav";
  justify-items: center;
  text-align: center;
}
:is([data-header-style="center"], [data-header-align="center"]) .hero__tools {
  justify-self: end;
  margin-bottom: -6px;
}
:is([data-header-style="center"], [data-header-align="center"]) .hero .brand {
  justify-self: center;
  flex-direction: column;
  gap: 8px;
  text-align: center;
}
:is([data-header-style="center"], [data-header-align="center"]) .place-link--hero {
  justify-self: center;
}
:is([data-header-style="center"], [data-header-align="center"]) .hero__sign {
  justify-self: center;
  max-width: 16em;
  margin: 12px 0 0;
  text-align: center;
  transform: rotate(-3deg);
  transform-origin: center;
}
:is([data-header-style="center"], [data-header-align="center"]) .hero__nav {
  justify-content: center;
}
/* Вид «По центру»: рамки-линии по бокам подписи и овальный низ. */
[data-header-style="center"] .hero {
  border-radius: 0 0 44px 44px / 0 0 30px 30px;
}
[data-header-style="center"] .hero__sign::before,
[data-header-style="center"] .hero__sign::after {
  content: "";
  flex: 0 0 22px;
  height: 1px;
  align-self: center;
  background: currentColor;
  opacity: 0.55;
}
[data-header-style="center"] .hero__sign svg {
  display: none;
}

/* ─── 2. Волна ───────────────────────────────────────────────────────── */
[data-header-style="wave"] .hero {
  --edge: calc(24px * var(--hs));
  background: var(--hero-band, color-mix(in srgb, var(--accent-strong) 78%, #000));
  border-radius: 0;
}
[data-header-style="wave"] .hero__edge {
  display: block;
  position: absolute;
  left: 0;
  top: calc(100% - 1px);
  width: 100%;
  height: calc(var(--edge) + 1px);
  fill: var(--hero-band, color-mix(in srgb, var(--accent-strong) 78%, #000));
  pointer-events: none;
}

/* ─── 3. Минимал ─────────────────────────────────────────────────────── */
[data-header-style="minimal"] .hero {
  background: none;
  border-radius: 0;
  padding-bottom: calc(14px * var(--hs));
  border-bottom: 1px solid var(--hero-band-line, currentColor);
}
[data-header-style="minimal"] .hero__inner::after {
  content: "";
  position: absolute;
  left: var(--page-gutter);
  bottom: calc(-14px * var(--hs) - 2px);
  width: 56px;
  height: 3px;
  border-radius: 3px;
  background: var(--hero-band-dot, var(--accent));
}
[data-header-style="minimal"][data-header-align="center"] .hero__inner::after {
  left: 50%;
  translate: -50% 0;
}
[data-header-style="minimal"] .place-link--hero,
[data-header-style="minimal"] .hero .lang-btn,
[data-header-style="minimal"] .hero .menu-btn,
[data-header-style="minimal"] .hero .round-btn {
  background: none;
  box-shadow: inset 0 0 0 1px var(--hero-band-line, currentColor);
}
[data-header-style="minimal"] .hero .brand__word,
:root[data-header-style="minimal"][data-brand="both"] .hero .brand__word {
  letter-spacing: -0.02em;
}
[data-header-style="minimal"] .hero__sign {
  transform: rotate(-4deg);
}

/* ─── 4. Карточка ────────────────────────────────────────────────────── */
[data-header-style="card"] .hero {
  width: calc(100% - 2 * var(--page-gutter));
  max-width: calc(var(--page-max) - 2 * var(--page-gutter));
  margin: calc(env(safe-area-inset-top, 0px) + 10px) auto 0;
  padding: calc(16px * var(--hs)) 0 calc(18px * var(--hs));
  border-radius: 28px;
  box-shadow:
    0 14px 30px -14px rgb(0 0 0 / 0.42),
    0 2px 6px rgb(0 0 0 / 0.12);
}
[data-header-style="card"] .hero__inner {
  padding: 0 18px;
}
[data-header-style="card"] .hero .brand__mark[data-logo="true"] .brand__logo {
  border-radius: 12px;
}

/* ─── 6. Арка ────────────────────────────────────────────────────────── */
[data-header-style="arch"] .hero {
  --edge: calc(30px * var(--hs));
  background: var(--hero-band, color-mix(in srgb, var(--accent-strong) 78%, #000));
  border-radius: 0;
  padding-bottom: calc(10px * var(--hs));
}
[data-header-style="arch"] .hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 1px);
  height: calc(var(--edge) + 1px);
  background: var(--hero-band, color-mix(in srgb, var(--accent-strong) 78%, #000));
  border-radius: 0 0 50% 50% / 0 0 100% 100%;
  pointer-events: none;
}

/* ─── 7. Градиент ────────────────────────────────────────────────────── */
[data-header-style="gradient"] .hero {
  background: linear-gradient(135deg, var(--hero-band, #333), var(--hero-band-2, var(--hero-band, #555)));
  border-radius: 0 0 36px 36px;
  overflow: clip;
}
/* Мягкие круги цвета плашки: пара «текст — плашка» уже проверена, поэтому
   читаемость они не ухудшают. */
[data-header-style="gradient"] .hero::before,
[data-header-style="gradient"] .hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  background: var(--hero-band-pill, rgb(255 255 255 / 0.14));
  opacity: 0.55;
  pointer-events: none;
}
[data-header-style="gradient"] .hero::before {
  width: 220px;
  height: 220px;
  right: -60px;
  top: -110px;
}
[data-header-style="gradient"] .hero::after {
  width: 130px;
  height: 130px;
  left: 38%;
  bottom: -90px;
  opacity: 0.35;
}

/* ─── 8. Узор ────────────────────────────────────────────────────────── */
[data-header-style="pattern"] .hero {
  background: var(--hero-band, color-mix(in srgb, var(--accent-strong) 78%, #000));
  border-radius: 0 0 32px 32px;
}
/* Точки цвета плашки (пара с текстом уже проверена) тают к правому краю. */
[data-header-style="pattern"] .hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background-image: radial-gradient(circle at 50% 50%, var(--hero-band-pill, rgb(255 255 255 / 0.18)) 1.7px, transparent 2.2px);
  background-size: 15px 15px;
  -webkit-mask-image: linear-gradient(105deg, #000 0%, rgb(0 0 0 / 0.25) 100%);
  mask-image: linear-gradient(105deg, #000 0%, rgb(0 0 0 / 0.25) 100%);
  pointer-events: none;
}

/* ─── 9. Стекло ──────────────────────────────────────────────────────── */
[data-header-style="glass"] .hero {
  background: none;
  border-radius: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 0 12px;
}
[data-header-style="glass"] .hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(closest-side at 16% 30%, color-mix(in srgb, var(--hero-blob-1, var(--accent)) 60%, transparent), transparent),
    radial-gradient(closest-side at 86% 78%, color-mix(in srgb, var(--hero-blob-2, var(--accent)) 50%, transparent), transparent);
  pointer-events: none;
}
[data-header-style="glass"] .hero__inner {
  width: calc(100% - 2 * var(--page-gutter) + 8px);
  max-width: calc(var(--page-max) - 2 * var(--page-gutter) + 8px);
  padding: calc(14px * var(--hs)) 18px calc(16px * var(--hs));
  border-radius: 28px;
  background: color-mix(in srgb, var(--hero-band, #888) 74%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--hero-band-ink, #fff) 16%, transparent),
    0 12px 28px -16px rgb(0 0 0 / 0.4);
}

/* ─── 10. Квитанция ──────────────────────────────────────────────────── */
[data-header-style="receipt"] .hero {
  --edge: calc(8px * var(--hs));
  background: var(--hero-band, color-mix(in srgb, var(--accent-strong) 78%, #000));
  border-radius: 0;
  padding-bottom: calc(30px * var(--hs));
}
/* Зубчатый край: маска из конусов даёт ряд треугольников остриём вниз. */
[data-header-style="receipt"] .hero::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% - 1px);
  height: calc(var(--edge) + 1px);
  background: var(--hero-band, color-mix(in srgb, var(--accent-strong) 78%, #000));
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(16px * var(--hs)) 100%;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / calc(16px * var(--hs)) 100%;
  pointer-events: none;
}
/* Пунктир над краем, как отрывная линия чека. */
[data-header-style="receipt"] .hero::before {
  content: "";
  position: absolute;
  left: var(--page-gutter);
  right: var(--page-gutter);
  bottom: calc(14px * var(--hs));
  border-top: 1px dashed var(--hero-band-line, currentColor);
  pointer-events: none;
}
[data-header-style="receipt"] .hero .brand__word {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
:root[data-header-style="receipt"]:is([data-font-brand="great-vibes"], [data-font-brand="pacifico"], [data-font-brand="lobster"], [data-font-brand="marck-script"]) .hero .brand__word {
  text-transform: none;
  letter-spacing: 0.02em;
}

/* ─── Шапка и плавающая плашка ───────────────────────────────────────── */
/* У видов, где фон лежит на самой полосе или прозрачен, при встающей плашке
   гаснет вся шапка, а не только её содержимое: пустая карточка или пятна под
   плашкой выглядели бы остатком. */
.site-header[data-stuck="true"] + .hero,
.site-header[data-search="open"] + .hero {
  transition: opacity var(--dur-base) var(--ease-out);
}
[data-header-style="card"] .site-header[data-stuck="true"] + .hero,
[data-header-style="minimal"] .site-header[data-stuck="true"] + .hero,
[data-header-style="glass"] .site-header[data-stuck="true"] + .hero,
[data-header-style="card"] .site-header[data-search="open"] + .hero,
[data-header-style="minimal"] .site-header[data-search="open"] + .hero,
[data-header-style="glass"] .site-header[data-search="open"] + .hero {
  opacity: 0;
}

/* ─── Плитка в админке (раздел «Шапка») ──────────────────────────────── */
/* Тот же `.hero`, нарисованный в ширине телефона. Размеры страницы заданы
   здесь, а не берутся от окна: на экране владельца плитка выглядит как на
   телефоне гостя, а не как на его компьютере. */
.hdr-tile {
  --page-gutter: 16px;
  --page-max: 400px;
  display: block;
  position: relative;
  overflow: hidden;
  height: calc(var(--hz, 0.4) * 300px);
  border-radius: 12px;
  background: var(--bg);
  color: var(--on-bg, var(--ink));
  font-family: var(--font-text, inherit);
  line-height: 1.3;
  text-align: left;
  pointer-events: none;
}
.hdr-tile__page {
  width: 400px;
  height: 300px;
  zoom: var(--hz, 0.4);
}
.hdr-tile__banner {
  display: grid;
  gap: 10px;
  align-content: end;
  height: 84px;
  margin: 16px 16px 0;
  padding: 14px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: 0 6px 12px -8px rgb(0 0 0 / 0.3);
}
.hdr-tile__banner span {
  display: block;
  height: 10px;
  width: 60%;
  border-radius: 6px;
  background: var(--ink-soft, #999);
  opacity: 0.35;
}
.hdr-tile__banner span + span {
  width: 36%;
}
.hero--tile .brand__word {
  font-family: var(--font-display, inherit);
}
.hero--tile .menu-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}
.hero--tile .menu-btn svg {
  width: 22px;
  height: 22px;
}
.hero--tile .lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px 0 12px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.hero--tile .lang-btn svg {
  width: 20px;
  height: 20px;
}
