/*
 * Layout — page frame, container, header, navigation and footer.
 */
@layer layout {
  .page {
    min-height: 100vh;
    overflow-x: clip;
  }

  .container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding-inline: var(--gutter);
  }

  /* ---------- Header ---------- */
  .site-header {
    position: sticky;
    top: 0;
    z-index: 20;
  }

  .site-header__inner {
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
  }

  .site-nav {
    display: flex;
    gap: 30px;
    font-size: calc(16rem / 16);
    font-weight: 600;
  }

  .site-nav a {
    text-decoration: none;
  }

  .site-header__actions {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  /* Language switch: a small pill linking to the other language's page. */
  .lang-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    box-sizing: border-box;
    border: 1.5px solid var(--color-line);
    border-radius: var(--radius-pill);
    background: var(--color-white);
    font-size: calc(14rem / 16);
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--color-ink);
    text-decoration: none;
    transition: border-color 0.2s, color 0.2s;
  }

  .lang-switch:hover {
    border-color: var(--color-violet);
    color: var(--color-violet-strong);
  }

  @media (max-width: 900px) {
    .site-nav {
      display: none;
    }

    /* Phones: a compact switch, and room for it next to the button. */
    .site-header__inner {
      gap: 12px;
    }

    .site-header__actions {
      gap: 8px;
    }

    /* The wordmark alone carries the brand on phones, leaving room for the language switch. */
    .brand__robot {
      display: none;
    }

    .lang-switch {
      min-width: 40px;
      min-height: 40px;
      padding: 0 10px;
    }
  }

  /*
   * Static frosted background, so content never shows through the header when
   * the scroll effect below is unavailable or switched off (reduced motion or
   * the accessibility menu's "stop animations").
   */
  .site-header {
    background: rgba(250, 247, 240, 0.9);
    -webkit-backdrop-filter: blur(14px); /* iOS Safari before 18 */
    backdrop-filter: blur(14px);
    box-shadow: 0 1px 0 var(--color-line);
  }

  /* Where supported, the background fades in and the header shrinks as the page scrolls. */
  @supports (animation-timeline: scroll()) {
    .site-header {
      animation: header-solidify linear both;
      animation-timeline: scroll();
      animation-range: 0 160px;
    }

    .site-header__inner {
      animation: header-shrink linear both;
      animation-timeline: scroll();
      animation-range: 0 160px;
    }

    @keyframes header-solidify {
      from {
        background: rgba(250, 247, 240, 0);
      }

      to {
        background: rgba(250, 247, 240, 0.9);
        backdrop-filter: blur(14px);
        box-shadow: 0 1px 0 var(--color-line);
      }
    }

    @keyframes header-shrink {
      to {
        height: 68px;
      }
    }
  }

  /*
   * Reading progress: a violet bar on the header's bottom edge that fills as
   * the page scrolls, from the right since the page is RTL. ScrollProgress
   * (assets/js/components/scroll-progress.js) sets --scroll-progress, so the
   * bar works without scroll-timeline support. It tracks the visitor's own
   * scrolling like a scrollbar, so it stays on with motion reduced.
   */
  .site-header::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    bottom: -1px;
    height: 3px;
    background: linear-gradient(to left, var(--color-violet-soft), var(--color-violet));
    transform: scaleX(var(--scroll-progress, 0));
    transform-origin: right;
    pointer-events: none;
  }

  [dir="ltr"] .site-header::after {
    background: linear-gradient(to right, var(--color-violet-soft), var(--color-violet));
    transform-origin: left;
  }

  /* ---------- Footer ---------- */
  .site-footer {
    padding-block: 32px 104px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    font-size: calc(14rem / 16);
    color: var(--color-ink-muted);
  }

  .site-footer__brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  .site-footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
  }

  .site-footer__links a {
    text-decoration: none;
    color: var(--color-ink-muted);
  }
}
