/* Shared header / mobile nav. Loaded on every page. */

html, body {
  height: auto !important;
  min-height: 100%;
  background: #FAF7E4;
  background: var(--paper);
  overscroll-behavior-y: none;
}
html {
  scroll-padding-top: calc(var(--chrome-h, 6.5rem) + .75rem);
}

#dc-root,
#dc-root > .sc-host {
  height: auto !important;
  min-height: 100%;
  min-height: 100dvh;
}

/* iPhone: do not scroll the document. Window scroll is what lets Safari
   paint page copy through the Dynamic Island. The shell is fixed and paper;
   only .sc-host scrolls, below the Island. */
html.chrome-ios,
html.chrome-ios body {
  height: 100% !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
  overflow: hidden !important;
  overscroll-behavior: none;
  background: #FAF7E4;
}
html.chrome-ios::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--sat, 59px);
  background: #FAF7E4;
  z-index: 2147483647;
  pointer-events: none;
}
html.chrome-ios::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 50vh;
  transform: translateY(-100%);
  background: #FAF7E4;
  z-index: 2147483647;
  pointer-events: none;
}
html.chrome-ios #dc-root {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  height: auto !important;
  min-height: 0 !important;
  padding-top: var(--sat, 59px);
  box-sizing: border-box;
  overflow: hidden;
  background: #FAF7E4;
}
html.chrome-ios #dc-root > .sc-host {
  height: 100% !important;
  min-height: 0 !important;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: none;
}

[data-hang] {
  top: calc(var(--chrome-h, 6.5rem) + 1rem) !important;
}

[data-chrome] {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
  padding-top: constant(safe-area-inset-top);
  padding-top: env(safe-area-inset-top, 0px);
}
html.chrome-ios [data-chrome] {
  padding-top: 0;
}

[data-chrome-bar] {
  box-sizing: border-box;
  max-width: 86rem;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: .85rem max(clamp(1.1rem, 4vw, 3.5rem), env(safe-area-inset-right, 0px)) .85rem max(clamp(1.1rem, 4vw, 3.5rem), env(safe-area-inset-left, 0px));
}

[data-chrome-brand] {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex: 0 0 auto;
  color: var(--ink);
}
[data-chrome-brand] img {
  width: 64px;
  height: 64px;
  display: block;
  flex: 0 0 auto;
}
[data-chrome-brand] span {
  font-family: var(--display);
  font-size: 1.95rem;
  letter-spacing: -.02em;
  line-height: 1;
}
[data-chrome-brand] span span {
  color: var(--brass-text);
}

[data-nav] {
  display: flex;
  align-items: center;
  gap: clamp(.85rem, 2.2vw, 1.9rem);
  margin-left: auto;
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted-l);
}
[data-nav] a {
  display: inline-flex;
  align-items: center;
  min-height: 2.2rem;
  transition: color .2s ease, background .2s ease;
}
[data-nav] a:hover {
  color: var(--ink);
}
[data-nav] a[aria-current="page"] {
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
  padding-bottom: 2px;
}
[data-nav] a[href^="https://t.me"] {
  border: 1px solid var(--ink);
  color: var(--ink);
  padding: .55rem 1rem;
  min-height: 0;
}
[data-nav] a[href^="https://t.me"]:hover {
  background: var(--ink);
  color: var(--paper);
}

[data-chrome-toggle] {
  display: none;
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0 .35rem;
  flex: 0 0 auto;
}
[data-chrome-toggle]:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

[data-chrome-icon] {
  position: relative;
  display: block;
  width: 16px;
  height: 9px;
}
[data-chrome-icon]::before,
[data-chrome-icon]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: currentColor;
  transition: transform .2s ease, top .2s ease, bottom .2s ease;
}
[data-chrome-icon]::before { top: 1px; }
[data-chrome-icon]::after { bottom: 1px; }
[data-chrome].is-open [data-chrome-icon]::before {
  top: 4px;
  transform: rotate(45deg);
}
[data-chrome].is-open [data-chrome-icon]::after {
  bottom: 4px;
  transform: rotate(-45deg);
}

html.chrome-nav-open {
  overflow: hidden;
}
html.chrome-ios.chrome-nav-open #dc-root > .sc-host {
  overflow: hidden;
}

@media (max-width: 720px) {
  [data-chrome-bar] {
    flex-wrap: wrap;
    gap: 0;
    padding-top: .45rem;
    padding-bottom: .45rem;
  }
  [data-chrome-brand] {
    gap: .6rem;
  }
  [data-chrome-brand] img {
    width: 56px;
    height: 56px;
  }
  [data-chrome-brand] span {
    font-size: 1.75rem;
  }
  [data-chrome-toggle] {
    display: inline-flex;
  }
  [data-nav] {
    display: none;
    flex: 1 0 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: .55rem 0 0;
    padding: .25rem 0 .35rem;
    border-top: 1px solid var(--ink);
    font-size: .78rem;
    letter-spacing: .16em;
    color: var(--ink);
  }
  [data-chrome].is-open [data-nav] {
    display: flex;
  }
  [data-nav] a {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 0 .1rem;
    color: var(--ink);
  }
  [data-nav] a[aria-current="page"] {
    border-bottom: 0;
    padding-bottom: 0;
    box-shadow: inset 2px 0 0 var(--ink);
    padding-left: .75rem;
  }
  [data-nav] a[href^="https://t.me"] {
    margin-top: .55rem;
    justify-content: center;
    padding: .85rem 1rem;
    min-height: 48px;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-chrome-icon]::before,
  [data-chrome-icon]::after,
  [data-nav] a {
    transition: none;
  }
}
