/* layout.css — container, section rhythm, section headers, site header. */

.container {
  width: min(100% - (var(--gutter) * 2), var(--container));
  margin-inline: auto;
}

/* ---- Section rhythm ---- */
.section {
  padding-block: clamp(48px, 7vw, 100px);
}
.section--mist {
  background: var(--color-blue-mist);
}

/* ---- Full-bleed background layer ----
   Add <div class="bg-layer" aria-hidden="true"></div> as the first child of any
   .hero or .section--image. The image comes from --bg-image (set per container);
   until an image exists it falls back to the placeholder wash. */
.section--image {
  position: relative;
  isolation: isolate;
}
.section--image {
  --bg-image: var(--img-band, none);
}
.section--image > .container {
  position: relative;
  z-index: 1;
}
.bg-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: var(--bg-image, none), var(--bg-placeholder);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.bg-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg-scrim);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 32px;
  margin-bottom: clamp(24px, 4vw, 44px);
}
.section-head__text {
  max-width: 46ch;
}
.eyebrow {
  display: block;
  font-family: var(--font-en);
  font-size: var(--step--1);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-primary);
}
:root[data-lang="my"] .eyebrow {
  font-family: var(--font-mm);
  letter-spacing: 0.02em;
  text-transform: none;
  font-size: 0.9rem;
}
.section-head h2 {
  font-size: var(--step-3);
  margin-top: 10px;
}

/* ---- Site header ----
   Two-tone green: dark on the brand row, mid green on the full-bleed nav row. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-primary-deep);
  color: #fff;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.12);
}
.site-header :focus-visible {
  outline-color: #fff;
}
/* Desktop: two rows — brand + language on top, the nav bar below. */
.site-header .container {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 20px;
}

.brand {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
  padding-block: 20px;
  text-decoration: none;
  color: #fff;
  transition: padding-block var(--dur) var(--ease-out);
}
.brand:hover {
  text-decoration: none;
  color: #fff;
}
.brand__mark {
  width: 64px;
  height: 64px;
  flex: none;
  border-radius: 10px;
  /* background: #fff; */
  padding: 4px;
  object-fit: contain;
  transition:
    width var(--dur) var(--ease-out),
    height var(--dur) var(--ease-out);
}
.brand__name {
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  transition: font-size var(--dur) var(--ease-out);
}
.brand__name b {
  display: block;
  font-weight: 800;
}
:root[data-lang="my"] .brand__name b {
  font-family: var(--font-mm);
  font-weight: 700;
  font-size: 18px;
  transition: font-size var(--dur) var(--ease-out);
}

/* Condensed header after scrolling past the top. */
html.is-scrolled .brand {
  padding-block: 11px;
}
html.is-scrolled .brand__mark {
  width: 40px;
  height: 40px;
  padding: 3px;
}
html.is-scrolled .brand__name {
  font-size: 14.5px;
}
:root[data-lang="my"].is-scrolled .brand__name b {
  font-size: 13.5px;
}
html.is-scrolled .primary-nav a {
  padding-top: 10px;
  padding-bottom: 10px;
}
@media (prefers-reduced-motion: reduce) {
  .brand,
  .brand__mark,
  .brand__name,
  .brand__name b,
  .primary-nav a {
    transition: none;
  }
}
.brand__name span {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-mm);
  font-weight: 400;
  font-size: 12.5px;
  line-height: 1.3;
  letter-spacing: 0;
  color: rgba(255, 255, 255, 0.72);
}

.primary-nav {
  grid-area: 2 / 1 / 3 / -1;
  position: relative;
}
.primary-nav::before {
  content: "";
  position: absolute;
  inset: 0 calc(50% - 50vw);
  z-index: -1;
  background: var(--header-nav);
}
.primary-nav > ul {
  list-style: none;
  display: flex;
  gap: 2px;
  padding: 0;
  margin: 0 -24px;
}
.primary-nav a {
  display: block;
  padding: 14px 24px;
  border-radius: var(--radius-xs);
  font-family: var(--font-en);
  font-size: 15px;
  transition: padding var(--dur) var(--ease-out);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  white-space: nowrap;
}
:root[data-lang="my"] .primary-nav a {
  font-family: var(--font-mm);
}
.primary-nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  text-decoration: none;
}
.primary-nav a[aria-current="page"] {
  color: #fff;
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  box-shadow: inset 0 -2px 0 #fff;
}
/* Menu items with a mega dropdown (About / Updates). */
.primary-nav .has-dropdown {
  position: static;
}
.primary-nav .has-dropdown > a {
  display: flex;
  align-items: center;
  gap: 5px;
}
.nav-caret {
  width: 13px;
  height: 13px;
  flex: none;
  margin-top: 1px;
  opacity: 0.8;
  transition: transform var(--dur) var(--ease-out);
}
.primary-nav .has-dropdown > a[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.primary-nav .has-dropdown > a[aria-expanded="true"] .nav-caret {
  transform: rotate(180deg);
  opacity: 1;
}

/* Full-bleed mega panel that drops from below the nav row. */
.mega {
  position: absolute;
  top: 100%;
  left: 50%;
  width: 100vw;
  transform: translateX(-50%) translateY(-6px);
  z-index: 90;
  background: var(--color-primary-deep);
  color: #fff;
  box-shadow: 0 26px 44px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.18s var(--ease-out),
    transform 0.18s var(--ease-out),
    visibility 0s 0.18s;
}
.mega.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition-delay: 0s;
}
.mega :focus-visible {
  outline-color: #fff;
}
.mega__inner {
  width: min(100% - (var(--gutter) * 2), var(--container));
  margin-inline: auto;
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(28px, 4vw, 48px) clamp(40px, 9vw, 130px);
  padding-block: clamp(30px, 4vw, 48px) clamp(30px, 4vw, 52px);
}
.mega__intro {
  flex: 1 1 16rem;
  max-width: 22rem;
}
.mega .mega__title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-en);
  font-weight: 800;
  font-size: var(--step-3);
  line-height: 1.15;
  color: #fff;
  text-decoration: none;
}
:root[data-lang="my"] .mega .mega__title {
  font-family: var(--font-mm);
}
.mega__title svg {
  width: 22px;
  height: 22px;
  flex: none;
}
.mega .mega__title:hover span {
  text-decoration: underline;
  text-underline-offset: 4px;
}
.mega__intro p {
  margin: 14px 0 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.72);
}
:root[data-lang="my"] .mega__intro p {
  font-family: var(--font-mm);
  line-height: 1.75;
}
.mega__links {
  flex: 0 1 auto;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.mega .mega__links a {
  display: inline-block;
  padding: 11px 0;
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}
:root[data-lang="my"] .mega .mega__links a {
  font-family: var(--font-mm);
}
.mega .mega__links a:hover {
  text-decoration-thickness: 2px;
}
.mega__close {
  position: absolute;
  top: clamp(20px, 3vw, 30px);
  right: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: var(--font-en);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}
:root[data-lang="my"] .mega__close {
  font-family: var(--font-mm);
  letter-spacing: 0.02em;
  text-transform: none;
  font-size: 13px;
}
.mega__close svg {
  width: 20px;
  height: 20px;
  flex: none;
}
.mega__close:hover {
  color: #fff;
}
@media (prefers-reduced-motion: reduce) {
  .mega {
    transition: none;
  }
}

.lang-toggle {
  grid-area: 1 / 2;
  display: inline-flex;
  flex: none;
  justify-self: end;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.08);
}
.lang-toggle button {
  min-height: 26px;
  padding: 3px 11px;
  font-family: var(--font-en);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition:
    background var(--dur),
    color var(--dur);
}
.lang-toggle button:hover:not([aria-pressed="true"]) {
  color: #fff;
}
.lang-toggle button[aria-pressed="true"] {
  background: #fff;
  color: var(--color-primary-deep);
}

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}
.nav-toggle svg {
  width: 22px;
  height: 22px;
}

@media (max-width: 1080px) {
  .site-header .container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
  }
  .lang-toggle {
    order: 2;
    margin-left: auto;
    justify-self: auto;
  }

  /* No JavaScript: keep the full nav visible, wrapped onto its own row. */
  .primary-nav {
    order: 4;
    width: 100%;
    margin: 0 0 6px;
  }
  .primary-nav > ul {
    margin: 0;
    flex-wrap: wrap;
  }
  .primary-nav a[aria-current="page"] {
    box-shadow: none;
    text-decoration: underline;
  }

  /* With JavaScript: collapse the nav into a toggle-driven panel. */
  html.js .site-header .container {
    flex-wrap: nowrap;
  }
  html.js .lang-toggle {
    margin-left: auto;
  }
  html.js .primary-nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    width: auto;
    margin: 0;
    order: 0;
    background: var(--header-nav);
    box-shadow: 0 16px 30px rgba(0, 0, 0, 0.22);
    opacity: 0;
    transform: translateY(-8px);
    pointer-events: none;
    transition:
      opacity 0.18s var(--ease-out),
      transform 0.18s var(--ease-out);
    max-height: calc(100dvh - var(--header-h));
    overflow: auto;
  }
  html.js .primary-nav.is-open {
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }
  html.js .primary-nav > ul {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    padding: 8px var(--gutter) 20px;
  }
  html.js .primary-nav a {
    padding: 14px 6px;
    font-size: 16px;
    border-radius: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  }
  html.js .primary-nav .has-dropdown > a {
    justify-content: space-between;
  }
  .nav-caret {
    width: 15px;
    height: 15px;
  }
  html.js .nav-toggle {
    display: inline-flex;
    margin-left: 4px;
  }

  /* Mega panel becomes an inline accordion inside the mobile menu. */
  html.js .mega {
    position: static;
    width: auto;
    transform: none;
    box-shadow: none;
    opacity: 1;
    visibility: hidden;
    height: 0;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.18);
    transition: none;
  }
  html.js .mega.is-open {
    visibility: visible;
    height: auto;
  }
  html.js .mega__inner {
    display: block;
    width: auto;
    padding: 6px var(--gutter) 14px;
  }
  html.js .mega__title {
    font-size: 17px;
  }
  html.js .mega__intro p {
    margin: 6px 0 10px;
  }
  html.js .mega__links a {
    display: block;
    padding: 10px 0;
    font-size: 15px;
  }
  html.js .mega__close {
    display: none;
  }
}

@media (max-width: 520px) {
  .site-header .container {
    gap: 10px;
  }
  /* Emblem-only in the bar; the full name sits in the hero just below. */
  .brand__name {
    display: none;
  }
  .lang-toggle button {
    padding: 3px 10px;
    font-size: 11.5px;
    min-height: 26px;
  }
  html.js .nav-toggle {
    width: 40px;
    height: 40px;
  }
}
