/* Header language picker, mobile navigation drawer, and EN/JA typography overrides. */
.site-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
  row-gap: 8px;
}

.site-header .site-nav {
  justify-content: flex-end;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}

.header-actions .header-github,
.language-switch,
.nav-drawer-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  border: 1.5px solid #d4bce7;
  border-radius: 14px;
  background: #f5eefb;
  color: #321d42;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  list-style: none;
  transition: background 0.16s, border-color 0.16s;
}

.header-actions .header-github svg,
.language-switch svg,
.nav-drawer-toggle svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.language-switch svg,
.nav-drawer-toggle svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-actions .header-github svg {
  fill: currentColor;
  stroke: none;
}

.header-actions .header-github:hover,
.language-switch:hover,
.nav-drawer-toggle:hover {
  background: #fff0a8;
  border-color: #d6b94c;
}

.language-switch::-webkit-details-marker,
.nav-drawer-toggle::-webkit-details-marker {
  display: none;
}

.language-switch:focus-visible,
.nav-drawer-toggle:focus-visible,
.header-actions .header-github:focus-visible {
  outline: 3px solid #6f4e94;
  outline-offset: 3px;
}

.language-picker,
.nav-drawer {
  position: relative;
  flex: none;
}

.language-chevron {
  font-size: 13px;
  line-height: 1;
}

.language-options,
.nav-drawer-panel {
  position: absolute;
  z-index: 60;
  right: 0;
  top: calc(100% + 8px);
  min-width: 176px;
  padding: 8px;
  background: #fffdf8;
  border: 1.5px solid #d4bce7;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(45, 24, 62, 0.16);
}

.language-option,
.nav-drawer-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #271331;
  white-space: nowrap;
  text-decoration: none;
}

.language-option:hover,
.language-option:focus-visible,
.nav-drawer-link:hover,
.nav-drawer-link:focus-visible {
  background: #fff0a8;
}

.language-option[aria-current="page"] {
  background: #efe4fa;
}

.nav-drawer {
  display: none;
}

.nav-drawer-panel {
  min-width: min(240px, calc(100vw - 24px));
  display: grid;
  gap: 2px;
}

.nav-drawer-github {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed #d8c8e6;
  justify-content: flex-start;
  gap: 10px;
}

.nav-drawer-github svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  stroke: none;
}

.nav-drawer-github span:last-child {
  margin-left: auto;
}

/* Desktop & tablet header layouts controlled by fitHeader() */
.site-header[data-layout="single"] {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.site-header[data-layout="single"] .brand {
  grid-column: 1;
  grid-row: 1;
}

.site-header[data-layout="single"] .site-nav {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  width: auto;
}

.site-header[data-layout="single"] .header-actions {
  grid-column: 3;
  grid-row: 1;
}

.site-header[data-layout="stacked"] {
  grid-template-columns: minmax(0, 1fr) auto;
}

.site-header[data-layout="stacked"] .brand {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
}

.site-header[data-layout="stacked"] .header-actions {
  grid-column: 2;
  grid-row: 1;
}

.site-header[data-layout="stacked"] .site-nav {
  grid-column: 1 / -1;
  grid-row: 2;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 6px;
  width: 100%;
  padding-top: 4px;
  border-top: 1px dashed #e7dccd;
}

@media (min-width: 768px) and (max-width: 1480px) {
  .site-header .site-nav > a {
    padding: 8px 9px;
    font-size: 13.5px;
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .site-header {
    width: calc(100% - 24px);
    padding: 10px 14px;
  }

  .site-header[data-layout="stacked"] .site-nav {
    flex-wrap: nowrap;
    gap: 2px 3px;
  }

  .site-header[data-layout="stacked"] .site-nav > a {
    padding: 8px 5px;
    font-size: 12.5px;
  }
}

/* Mobile single-row 56px header: Brand + Language + Drawer (zero brand/action collision at 320px+). */
@media (max-width: 767px) {
  .site-header {
    grid-template-columns: minmax(0, 1fr) auto;
    width: calc(100% - 20px);
    min-height: 56px;
    padding: 6px 10px;
    column-gap: 8px;
    border-radius: 18px;
  }

  .site-header .site-nav,
  .header-actions .header-github {
    display: none;
  }

  .nav-drawer {
    display: block;
  }

  .site-header .brand {
    font-size: 16.5px;
    gap: 7px;
    letter-spacing: -0.03em;
    min-width: 0;
  }

  .site-header .brand img {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  .header-actions {
    gap: 6px;
  }

  .language-switch,
  .nav-drawer-toggle {
    min-height: 44px;
    padding: 0 10px;
    font-size: 13px;
    border-radius: 12px;
  }
}

@media (max-width: 440px) {
  .site-header {
    width: calc(100% - 16px);
    padding: 6px 8px;
    column-gap: 6px;
  }

  .site-header .brand {
    font-size: 15px;
    gap: 6px;
    letter-spacing: -0.04em;
  }

  .site-header .brand img {
    width: 26px;
    height: 26px;
    border-radius: 8px;
  }

  .language-switch {
    padding: 0 8px;
    font-size: 12.5px;
    gap: 4px;
  }

  .language-switch svg {
    width: 15px;
    height: 15px;
  }

  .nav-drawer-toggle {
    width: 44px;
    min-width: 44px;
    padding: 0;
  }

  .nav-drawer-toggle > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

@media (max-width: 365px) {
  .site-header .brand {
    font-size: 13.5px;
    gap: 5px;
  }

  .site-header .brand img {
    width: 24px;
    height: 24px;
  }

  .language-switch {
    padding: 0 6px;
    font-size: 11.5px;
    gap: 3px;
  }

  .language-chevron {
    display: none;
  }
}

/* Localized hero display typography and language notes. */
.en-heading {
  font-size: clamp(46px, 5.8vw, 96px);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 1.02;
  margin: 0 0 18px;
  color: #2f173d;
}

.ja-heading {
  font-size: clamp(32px, 5vw, 76px);
  font-weight: 900;
  line-height: 1.25;
  letter-spacing: -0.03em;
  margin: 0 0 16px;
  color: #2f173d;
}

.localized-heading em {
  font-style: normal;
  text-decoration: underline;
  text-decoration-color: #ffe44d;
  text-underline-offset: 10px;
  text-decoration-thickness: 6px;
}

.language-note {
  font-size: 13.5px;
  line-height: 1.65;
  max-width: 460px;
  color: var(--muted, #5d4d68);
  margin: 0 0 12px;
}

html[lang="en"] .showcase-copy h2 {
  font-size: clamp(28px, 3.2vw, 48px);
  line-height: 1.18;
}

html[lang="en"] .web-entry {
  font-size: 19px;
}

html[lang="en"] .sound-play {
  white-space: normal;
}

html[lang="en"] .next-sounds .sound-play {
  font-size: 12.5px;
  line-height: 1.35;
  min-height: 54px;
}

html[lang="en"] :is(
  .release-body p,
  .release-body li,
  .upcoming-copy p,
  .faq-list details p,
  .speech-bubble p,
  .lab-card > p,
  .lab-recipe p,
  .reconstruction-example > p,
  .next-comparison-heading p
) {
  text-align: left;
}

@media (max-width: 899px) {
  .en-heading {
    font-size: clamp(48px, 12vw, 78px);
    text-align: center;
  }

  .ja-heading {
    font-size: clamp(36px, 10.5vw, 68px);
    text-align: center;
  }

  .language-note {
    margin: 0 auto 14px;
    text-align: center;
  }
}

/* Japanese uses one consistent Japanese sans stack everywhere (including pseudo-elements). */
html[lang="ja"] {
  --ja-font: 'Yu Gothic UI', 'Yu Gothic', Meiryo, 'Hiragino Kaku Gothic ProN', sans-serif;
  font-family: var(--ja-font);
}

html[lang="ja"] :is(
  h1, h2, h3, h4, h5, h6, p, a, span, small, strong, em, b,
  summary, label, li, figcaption, cite, th, td, time, output,
  button, input, textarea, select
),
html[lang="ja"] ::before,
html[lang="ja"] ::after {
  font-family: var(--ja-font) !important;
}

html[lang="ja"] code,
html[lang="ja"] code * {
  font-family: Consolas, ui-monospace, monospace !important;
}

html[lang="ja"] .intervals span {
  font-family: PTB-IPA, Georgia, serif !important;
}

html[lang="ja"] .showcase-copy h2 {
  font-size: clamp(28px, 3vw, 46px);
  line-height: 1.4;
}

html[lang="ja"] .sound-play {
  white-space: normal;
  line-height: 1.45;
}
