/* ==========================================================================
   Mobile navigation  (active below 1200px – the desktop pill menu is untouched)
   Load AFTER css/style.css
   ========================================================================== */

:root {
  --nav-bar-h: 64px;
  /* height of the glass header pill on mobile   */
  --nav-gutter: 12px;
  /* distance of the pill from the screen edges  */
  --nav-ease: cubic-bezier(.22, 1, .36, 1);
  --nav-ink: var(--color-accent-dark, #123f3a);
  --nav-gold: var(--color-yellow-deep, #ebb447);
}

/* ---- Glass pill: the blur lives on a pseudo-element -----------------------
   `backdrop-filter` on .header-inner turned it into the containing block of
   every position:fixed child, so the old off-screen menu was sized/positioned
   relative to the 110px pill instead of the screen. Moving the glass to
   ::before fixes that for good.                                              */
header .header-inner {
  position: relative;
  isolation: isolate;
  background: none;
  border: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

header .header-inner::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--color-white-65);
  border: 1px solid rgba(255, 255, 255, .2);
  -webkit-backdrop-filter: blur(16px) saturate(125%);
  backdrop-filter: blur(16px) saturate(125%);
}

/* logo: a normal flex item instead of an absolutely-positioned hack */
.header-inner>div:first-child {
  flex: 0 0 auto;
  min-width: 0;
}

.header-inner>div:first-child>a {
  display: block;
  flex: none;
  min-width: 0;
}

.header-inner .logo {
  position: static;
  display: block;
  height: clamp(34px, 9vw, 50px);
  width: auto;
  margin: 0;
  transform: none;
}

.menu-items {
  flex: 0 0 auto;
  min-width: 0;
}

.site-nav {
  display: flex;
  align-items: center;
}

/* desktop: keep the logo exactly where the old absolute-position hack put it */
@media (min-width: 1201px) {
  .header-inner .logo {
    margin-left: 19px;
    transform: translateY(-2px);
  }
}

/* hidden on desktop */
.nav-toggle,
.mobile-nav {
  display: none;
}

@media (max-width: 1200px) {

  /* ---- header bar -------------------------------------------------------- */
  header .header-inner {
    height: var(--nav-bar-h);
    margin: var(--nav-gutter) auto;
    padding: 0 10px 0 clamp(14px, 4vw, 22px);
    width: calc(100% - 2 * var(--nav-gutter));
    flex-wrap: nowrap;
    gap: 12px;
  }

  header,
  .header {
    top: env(safe-area-inset-top, 0);
  }

  /* ---- toggle button ------------------------------------------------------ */
  .nav-toggle {
    position: relative;
    z-index: 3;
    /* stays above the open panel */
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--nav-ink);
    color: #fff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 14px rgba(18, 63, 58, .28);
    transition: background-color .35s var(--nav-ease), box-shadow .35s var(--nav-ease), transform .2s ease;
  }

  .nav-toggle:active {
    transform: scale(.94);
  }

  .nav-toggle:focus-visible {
    outline: 3px solid var(--nav-gold);
    outline-offset: 3px;
  }

  .nav-toggle__bars {
    position: relative;
    display: block;
    width: 20px;
    height: 14px;
  }

  .nav-toggle__bars i {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: transform .45s var(--nav-ease), opacity .25s ease, width .3s var(--nav-ease), background-color .3s ease;
  }

  .nav-toggle__bars i:nth-child(1) {
    top: 0;
  }

  .nav-toggle__bars i:nth-child(2) {
    top: 6px;
    width: 70%;
    left: 30%;
  }

  /* short middle bar */
  .nav-toggle__bars i:nth-child(3) {
    top: 12px;
  }

  .nav-open .nav-toggle {
    background: var(--nav-gold);
    color: var(--nav-ink);
    box-shadow: 0 4px 14px rgba(235, 180, 71, .45);
  }

  .nav-open .nav-toggle__bars i:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
  }

  .nav-open .nav-toggle__bars i:nth-child(2) {
    opacity: 0;
    transform: translateX(8px);
  }

  .nav-open .nav-toggle__bars i:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
  }

  /* desktop-only items */
  ul.hr,
  .lang-wrapper.desktop-lang-wrapper {
    display: none !important;
  }

  /* ---- menu container ------------------------------------------------------ */
  .mobile-nav {
    position: fixed;
    inset: 0;
    z-index: 2;
    display: block;
    text-align: left;
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0s linear .55s;
    /* hide only after the close animation */
  }

  .nav-open .mobile-nav {
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  .mobile-nav__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 38, 34, .45);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity .45s ease;
  }

  .nav-open .mobile-nav__backdrop {
    opacity: 1;
  }

  /* Light glass sheet – same material as the header pill.
     It grows out of the toggle button (circular reveal). */
  .mobile-nav__panel {
    position: absolute;
    inset: 0 0 0 auto;
    width: min(100%, 460px);
    display: flex;
    flex-direction: column;
    background:
      radial-gradient(120% 60% at 100% 0%, rgba(235, 180, 71, .22), transparent 60%),
      radial-gradient(90% 50% at 0% 100%, rgba(52, 247, 133, .12), transparent 60%),
      linear-gradient(180deg, #f6fbf8 0%, #e6f3ec 100%);
    box-shadow: -24px 0 60px rgba(10, 38, 34, .25);
    clip-path: circle(0px at calc(100% - 36px) 44px);
    transition: clip-path .6s var(--nav-ease);
  }

  .nav-open .mobile-nav__panel {
    clip-path: circle(160vmax at calc(100% - 36px) 44px);
  }

  .mobile-nav__scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 22px;
    /* clears the header bar: gutter + bar + breathing room */
    padding:
      calc(var(--nav-gutter) + var(--nav-bar-h) + 18px + env(safe-area-inset-top, 0)) clamp(18px, 5vw, 28px) calc(24px + env(safe-area-inset-bottom, 0));
  }

  /* ---- links ----------------------------------------------------------------- */
  .mobile-nav__list {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .mobile-nav__link {
    position: relative;
    display: flex;
    align-items: center;
    flex: none;
    min-width: 0;
    gap: 14px;
    min-height: 58px;
    padding: 0 16px;
    border-radius: 18px;
    color: var(--nav-ink);
    font-size: clamp(1.05rem, 4.6vw, 1.3rem);
    font-weight: 650;
    line-height: 1.2;
    letter-spacing: .01em;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .25s ease, color .25s ease, transform .25s var(--nav-ease);
  }

  .mobile-nav__index {
    flex: 0 0 1.9em;
    font-size: .68em;
    font-weight: 700;
    letter-spacing: .08em;
    color: rgba(18, 63, 58, .4);
    font-variant-numeric: tabular-nums;
    transition: color .25s ease;
  }

  .mobile-nav__label {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .mobile-nav__arrow {
    flex: none;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity .25s ease, transform .3s var(--nav-ease);
  }

  .mobile-nav__link:active {
    background: rgba(18, 63, 58, .08);
    transform: scale(.985);
  }

  .mobile-nav__link:focus-visible {
    outline: 3px solid var(--nav-gold);
    outline-offset: 2px;
  }

  @media (hover: hover) {
    .mobile-nav__link:hover {
      background: rgba(18, 63, 58, .07);
    }

    .mobile-nav__link:hover .mobile-nav__arrow {
      opacity: 1;
      transform: none;
    }
  }

  /* active page – same dark pill as the desktop menu, plus a gold marker */
  .mobile-nav__link.is-active {
    background: var(--nav-ink);
    color: #fff;
    box-shadow: 0 10px 24px rgba(18, 63, 58, .22);
  }

  .mobile-nav__link.is-active .mobile-nav__index {
    color: var(--nav-gold);
  }

  .mobile-nav__link.is-active .mobile-nav__arrow {
    opacity: 1;
    transform: none;
    color: var(--nav-gold);
  }

  .mobile-nav__link.is-active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 4px;
    height: 26px;
    border-radius: 0 4px 4px 0;
    background: var(--nav-gold);
    transform: translateY(-50%);
  }

  /* ---- language selector (segmented control, same slider idea as desktop) ---- */
  .mobile-nav__lang {
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-self: stretch;
    padding: 4px;
    border-radius: 999px;
    background: rgba(18, 63, 58, .08);
    border: 1px solid rgba(18, 63, 58, .1);
  }

  .mobile-nav__lang::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc((100% - 8px) / 3);
    border-radius: 999px;
    background: var(--nav-ink);
    box-shadow: 0 6px 14px rgba(18, 63, 58, .25);
    transform: translateX(0);
    transition: transform .4s var(--nav-ease);
  }

  .mobile-nav__lang[data-current-lang="en"]::before {
    transform: translateX(100%);
  }

  .mobile-nav__lang[data-current-lang="ru"]::before {
    transform: translateX(200%);
  }

  .mobile-nav__lang button {
    min-height: 46px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--nav-ink);
    font-size: 15px;
    font-weight: 750;
    letter-spacing: .08em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color .3s ease;
  }

  .mobile-nav__lang button.is-active {
    color: #fff;
  }

  .mobile-nav__lang button:focus-visible {
    outline: 3px solid var(--nav-gold);
    outline-offset: 1px;
  }

  /* ---- contact block --------------------------------------------------------- */
  .mobile-nav__info {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 16px;
    margin-top: auto;
    /* sticks to the bottom on tall screens */
    padding: 18px 4px 0;
    border-top: 1px solid rgba(18, 63, 58, .12);
    color: var(--nav-ink);
    text-align: left;
  }

  .mobile-nav__info-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
  }

  .mobile-nav__info h4 {
    margin: 0 0 4px;
    transform: none;
    color: rgba(18, 63, 58, .55);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
    line-height: 1.4;
    text-transform: uppercase;
  }

  .mobile-nav__info a,
  .mobile-nav__info span {
    display: inline-flex;
    flex: none;
    min-width: 0;
    min-height: 28px;
    align-items: center;
    color: var(--nav-ink);
    font-size: 14.5px;
    font-weight: 550;
    line-height: 1.3;
    white-space: nowrap;
  }

  .mobile-nav__info h4:hover {
    color: rgba(18, 63, 58, .55);
  }

  .mobile-nav__info a:focus-visible {
    outline: 2px solid var(--nav-gold);
    outline-offset: 3px;
    border-radius: 4px;
  }

  .mobile-nav__info .mobile-nav__social {
    grid-column: 1 / -1;
    justify-content: center;
    width: 46px;
    height: 46px;
    min-height: 0;
    border-radius: 50%;
    background: rgba(18, 63, 58, .08);
    transition: background-color .25s ease, color .25s ease, transform .25s var(--nav-ease);
  }

  .mobile-nav__social svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
  }

  .mobile-nav__social:active {
    transform: scale(.94);
  }

  @media (hover: hover) {
    .mobile-nav__social:hover {
      background: var(--nav-ink);
      color: #fff;
    }
  }

  /* ---- staggered entrance ------------------------------------------------------ */
  .mobile-nav__list li,
  .mobile-nav__lang,
  .mobile-nav__info {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .35s ease, transform .5s var(--nav-ease);
  }

  .nav-open .mobile-nav__list li,
  .nav-open .mobile-nav__lang,
  .nav-open .mobile-nav__info {
    opacity: 1;
    transform: none;
    transition-delay: calc(.12s + var(--i, 0) * .05s);
  }

  /* the stagger delay must not slow down the *closing* animation */
  .mobile-nav__list li,
  .mobile-nav__lang,
  .mobile-nav__info {
    transition-delay: 0s;
  }

  /* ---- scroll lock ---------------------------------------------------------------- */
  html.nav-open,
  html.nav-open body {
    overflow: hidden;
  }
}

/* narrow phones: let the panel cover the full width, tighten info block */
@media (max-width: 460px) {
  .mobile-nav__panel {
    width: 100%;
  }

  .mobile-nav__info {
    grid-template-columns: 1fr;
  }

  .mobile-nav__info .mobile-nav__social {
    justify-content: center;
  }
}

@media (max-width: 460px) and (min-width: 360px) {
  .mobile-nav__info {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-height: 560px) {
  .mobile-nav__link {
    min-height: 48px;
  }

  .mobile-nav__scroll {
    gap: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mobile-nav__panel {
    clip-path: none;
    opacity: 0;
    transition: opacity .2s ease;
  }

  .nav-open .mobile-nav__panel {
    clip-path: none;
    opacity: 1;
  }

  .mobile-nav__list li,
  .mobile-nav__lang,
  .mobile-nav__info,
  .nav-open .mobile-nav__list li,
  .nav-open .mobile-nav__lang,
  .nav-open .mobile-nav__info {
    transform: none;
    transition: opacity .2s ease;
  }

  .nav-toggle__bars i,
  .mobile-nav__link,
  .mobile-nav__arrow,
  .mobile-nav__lang::before {
    transition: none;
  }
}