.heritage-page {
  overflow-x: hidden;
}

.heritage-main {
  display: grid;
  gap: 0;
}

.heritage-reading-progress {
  position: fixed;
  top: var(--nav-height);
  right: 0;
  left: 0;
  z-index: 30;
  height: 2px;
  pointer-events: none;
}

.heritage-reading-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--color-terracotta);
  transform: scaleX(0);
  transform-origin: left center;
}

.heritage-sidenav .side-nav__link {
  display: grid;
  grid-template-columns: 1.65rem minmax(0, 1fr);
  align-items: flex-start;
}

.heritage-sidenav .side-nav__link::before {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.heritage-sidenav .side-nav__link > span,
.heritage-sidenav .side-nav__link > small {
  grid-column: 2;
}

.heritage-sidenav .side-nav__link small {
  display: block;
  margin-top: 0.18rem;
  color: var(--color-stone-dark);
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.35;
}

/* ── Hero ─────────────────────────────────────────────────────────────── */

.heritage-hero {
  padding: var(--space-editorial-hero-top) var(--space-editorial-section-x) var(--space-editorial-hero-bottom);
  max-width: 58rem;
}

.heritage-hero__eyebrow {
  display: inline-block;
  margin-bottom: var(--space-4);
  color: var(--color-terracotta);
  font-family: var(--font-label);
  font-size: var(--type-label-sm);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

/* Deliberately smaller than --type-editorial-hero. That token tops out at
   8.4rem, which suits a one-word page title like "ติดต่อเรา"; this headline is a
   full Thai clause and at 120px it broke into six lines 736px tall, pushing the
   opening paragraphs off the first screen. */
.heritage-hero__title {
  margin: 0 0 var(--space-6);
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 4.2vw, 3.5rem);
  font-weight: 700;
  line-height: 1.08;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.heritage-hero__lede {
  display: grid;
  gap: var(--space-4);
  max-width: 42rem;
  color: var(--color-stone-ink);
  line-height: 1.7;
}

.heritage-hero__lede p {
  margin: 0;
}

/* Three figures reading as one band. Terracotta is spent here and on the
   section kickers only — DESIGN.md keeps it as a marker, not decoration. */
.heritage-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0;
  margin: var(--space-12) 0 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.heritage-stat {
  padding: var(--space-6) var(--space-6) var(--space-6) 0;
}

.heritage-stat + .heritage-stat {
  padding-left: var(--space-6);
  border-left: 1px solid var(--color-border);
}

.heritage-stat__value {
  margin: 0 0 var(--space-2);
  color: var(--color-terracotta);
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1;
}

.heritage-stat__label {
  margin: 0;
  color: var(--color-stone-dark);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ── Sections ─────────────────────────────────────────────────────────── */

.heritage-section {
  padding: var(--space-editorial-section-y) 0;
}

/* Alternating tone gives the six sections rhythm without adding rules or
   shadows, which DESIGN.md reserves for interaction. */
.heritage-founder,
.heritage-timeline-section,
.heritage-present {
  background: var(--color-editorial-band);
}

.heritage-section-shell {
  display: grid;
  gap: var(--space-10);
}

.heritage-section-heading {
  max-width: 46rem;
}

.heritage-kicker {
  margin: 0 0 var(--space-3);
  color: var(--color-terracotta);
  font-family: var(--font-label);
  font-size: var(--type-label-sm);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.heritage-section-heading h2 {
  margin: 0;
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: var(--type-editorial-section);
  font-weight: 600;
  line-height: 1.1;
}

/* ── Text + figure pairs ──────────────────────────────────────────────── */

.heritage-split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: var(--space-12);
  align-items: start;
}

.heritage-split--reverse .heritage-prose {
  order: 2;
}

.heritage-prose {
  display: grid;
  gap: var(--space-4);
  max-width: 38rem;
  color: var(--color-stone-ink);
  line-height: 1.8;
  overflow-wrap: break-word;
  word-break: normal;
}

.heritage-prose p {
  margin: 0;
}

.heritage-prose__emphasis {
  padding-left: var(--space-5);
  border-left: 2px solid var(--color-terracotta);
  color: var(--color-ink);
  font-size: 1.05rem;
}

.heritage-prose__lede {
  color: var(--color-ink);
  font-size: 1.1rem;
  font-weight: 600;
}

.heritage-prose h3 {
  margin: var(--space-2) 0 0;
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: var(--type-editorial-card);
  font-weight: 600;
}

/* A section that reads as full-width prose (no paired figure), used where the
   supporting images run below the text rather than beside it. */
.heritage-prose--wide {
  max-width: 46rem;
}

.heritage-turning-point {
  display: grid;
  grid-template-columns: minmax(5.5rem, 0.22fr) minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
  max-width: 48rem;
  padding: var(--space-6) 0;
  border-top: 1px solid var(--color-terracotta);
  border-bottom: 1px solid var(--color-border);
}

.heritage-turning-point__year {
  color: var(--color-terracotta);
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1;
}

.heritage-turning-point strong {
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: 1.15rem;
}

.heritage-turning-point p {
  max-width: 62ch;
  margin: var(--space-2) 0 var(--space-3);
  color: var(--color-stone-ink);
  line-height: 1.7;
}

.heritage-turning-point a,
.heritage-editorial-link {
  color: var(--color-ink);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--color-terracotta);
  text-underline-offset: 0.2em;
}

/* Neutral markers only: terracotta is already spent on the kicker in this
   section, and DESIGN.md's accent budget caps how much of it a screen can carry. */
.heritage-list {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.heritage-list li {
  position: relative;
  padding-left: var(--space-5);
  color: var(--color-stone-ink);
  line-height: 1.7;
}

.heritage-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.75em;
  width: 0.45rem;
  height: 0.09rem;
  background: var(--color-stone-dark);
}

/* Reuses the placeholder's dashed-border language for provisional text, the
   same way the dashed placeholder frame marks provisional images. */
.heritage-verify-note {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  margin-top: var(--space-2);
  padding: var(--space-4);
  border: 1px dashed var(--color-border);
  background: var(--color-editorial-panel);
}

.heritage-verify-note__icon {
  flex-shrink: 0;
  color: var(--color-stone-dark);
  font-size: 1.1rem;
}

.heritage-verify-note p {
  margin: 0;
  color: var(--color-stone-ink);
  font-size: 0.85rem;
  line-height: 1.6;
}

.heritage-closing-line {
  max-width: 40rem;
  margin: var(--space-10) 0 0;
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
  font-weight: 600;
  line-height: 1.3;
}

/* ── Figures and dummy graphics ───────────────────────────────────────── */

.heritage-figure {
  margin: 0;
}

.heritage-figure--wide {
  margin-top: var(--space-4);
}

.heritage-figure--royal {
  margin-top: var(--space-6);
}

.heritage-figure-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-4);
}

.heritage-gallery-subheading {
  margin-top: var(--space-7);
  margin-bottom: var(--space-3);
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 700;
  color: var(--color-ink);
  border-bottom: 2px solid var(--color-border);
  padding-bottom: var(--space-2);
}

.heritage-figure figcaption {
  margin-top: var(--space-3);
  max-width: 72ch;
  color: var(--color-stone-dark);
  font-size: 0.875rem;
  line-height: 1.65;
  overflow-wrap: break-word;
  text-wrap: pretty;
}

.heritage-provenance {
  display: grid;
  grid-template-columns: minmax(7rem, max-content) minmax(0, 1fr);
  gap: var(--space-3);
  margin: var(--space-3) 0 0;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
  color: var(--color-stone-dark);
  font-size: 0.76rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}

.heritage-provenance strong {
  color: var(--color-ink);
  font-family: var(--font-label);
  letter-spacing: 0.04em;
}

.heritage-provenance--pending span {
  color: var(--color-stone-ink);
}

.heritage-evidence-note {
  max-width: 72ch;
  margin: 0;
  padding-top: var(--space-3);
  border-top: 1px dashed var(--color-border);
  color: var(--color-stone-dark);
  font-size: 0.78rem;
  line-height: 1.6;
}

.heritage-evidence-note strong {
  margin-right: var(--space-2);
  color: var(--color-ink);
}

/* Placeholder, not artwork. The dashed edge and the tag are there so nobody
   mistakes these for final images — they are meant to be swapped out. */
.heritage-placeholder {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px dashed var(--color-border);
  background: var(--color-editorial-panel);
}

.heritage-figure--portrait .heritage-placeholder {
  aspect-ratio: 4 / 5;
}

.heritage-figure--wide .heritage-placeholder {
  aspect-ratio: 12 / 5;
}

.heritage-figure--card .heritage-placeholder {
  aspect-ratio: 4 / 3;
}

.heritage-figure--royal .heritage-placeholder {
  aspect-ratio: 4 / 3;
}

.heritage-figure--khurusamanakarn .heritage-placeholder {
  aspect-ratio: 16 / 9;
}

.heritage-placeholder svg,
.heritage-placeholder img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.heritage-figure--royal img {
  object-fit: contain;
  background-color: var(--color-editorial-panel);
}

.heritage-figure--khurusamanakarn img {
  object-fit: cover;
  object-position: bottom center;
}

.heritage-placeholder:hover img {
  transform: scale(1.04);
}

.heritage-photo-frame {
  border-style: solid;
}

.heritage-placeholder__tag {
  position: absolute;
  left: 0;
  bottom: 0;
  padding: 0.4rem 0.7rem;
  background: var(--color-ink);
  color: var(--color-paper);
  font-family: var(--font-label);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.heritage-image-action {
  position: absolute;
  right: var(--space-3);
  top: var(--space-3);
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
  padding: 0.45rem 0.65rem;
  background: rgba(17, 18, 20, 0.9);
  color: var(--color-paper);
  font-family: var(--font-label);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.heritage-image-action .material-symbols-outlined {
  font-size: 1rem;
}

/* ── Timeline ─────────────────────────────────────────────────────────── */

.heritage-timeline {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--color-border);
}

.heritage-timeline__item {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: var(--space-6);
  align-items: baseline;
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--color-border);
}

.heritage-timeline__year {
  color: var(--color-ink);
  font-family: var(--font-label);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.heritage-timeline__event {
  margin: 0;
  color: var(--color-stone-ink);
  line-height: 1.7;
}

/* The two rows that carry the story: the founding year and where it stands
   now. Everything between them is context. */
.heritage-timeline__item.is-milestone .heritage-timeline__year,
.heritage-timeline__item.is-present .heritage-timeline__year {
  color: var(--color-terracotta);
}

.heritage-timeline__item.is-milestone .heritage-timeline__event,
.heritage-timeline__item.is-present .heritage-timeline__event {
  color: var(--color-ink);
  font-size: 1.05rem;
}

/* ── DNA cards ────────────────────────────────────────────────────────── */

/* 13rem, not 15rem: at 15rem the four cards land 3-up and leave one orphan on
   a second row, which reads as a mistake rather than a set of four. */
.heritage-dna-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--space-6);
}

.heritage-dna-card {
  display: grid;
  gap: var(--space-3);
  align-content: start;
  padding: var(--space-6);
  background: var(--color-paper);
  border: 1px solid var(--color-border);
}

.heritage-dna-card__icon {
  font-size: 1.6rem;
  color: var(--color-terracotta);
}

.heritage-dna-card h3 {
  margin: 0;
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: var(--type-editorial-card);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.heritage-dna-card p {
  margin: 0;
  color: var(--color-stone-ink);
  font-size: 0.92rem;
  line-height: 1.7;
}

/* ── CTA row ──────────────────────────────────────────────────────────── */

.heritage-cta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding-top: var(--space-4);
}

.heritage-cta__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.85rem 1.4rem;
  background: var(--color-paper);
  border: 1px solid var(--color-ink);
  color: var(--color-ink);
  font-family: var(--font-label);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.heritage-cta__link--primary {
  background: var(--color-ink);
  color: var(--color-paper);
}

.heritage-cta__link:hover {
  transform: translateY(-2px);
}

.heritage-cta__link:not(.heritage-cta__link--primary):hover {
  background: var(--color-ink);
  color: var(--color-paper);
}

.heritage-cta__link .material-symbols-outlined {
  font-size: 1.1rem;
}

.heritage-sources {
  display: grid;
  grid-template-columns: minmax(14rem, 0.65fr) minmax(0, 1.35fr);
  gap: var(--space-8);
  margin-top: var(--space-12);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
}

.heritage-sources h2 {
  margin: 0;
  color: var(--color-ink);
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  line-height: 1.15;
}

.heritage-sources ul {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding-left: 1.2rem;
  color: var(--color-stone-ink);
  line-height: 1.65;
}

.heritage-sources > p {
  grid-column: 2;
  margin: 0;
  color: var(--color-stone-dark);
  font-size: 0.85rem;
  line-height: 1.6;
}

.heritage-back-to-top {
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
  justify-self: start;
  color: var(--color-ink);
  font-family: var(--font-label);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.heritage-back-to-top:hover {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

.heritage-turning-point a:focus-visible,
.heritage-editorial-link:focus-visible,
.heritage-back-to-top:focus-visible {
  outline: 3px solid var(--color-ai);
  outline-offset: 0.25rem;
}

/* ── Narrow screens ───────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .heritage-split,
  .heritage-split--reverse {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-8);
  }

  /* Reset the reversed order so the prose still leads on a single column. */
  .heritage-split--reverse .heritage-prose {
    order: 0;
  }

  .heritage-timeline__item {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
  }

  .heritage-sources {
    grid-template-columns: minmax(0, 1fr);
  }

  .heritage-sources > p {
    grid-column: auto;
  }
}

@media (max-width: 600px) {
  .heritage-stats {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Stacked, the vertical divider between stats becomes a horizontal one. */
  .heritage-stat + .heritage-stat {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid var(--color-border);
  }

  .heritage-cta__link {
    width: 100%;
    justify-content: space-between;
  }

  .heritage-turning-point,
  .heritage-provenance {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── Interactive Micro-animations & Enhancements ─────────────────────── */

.heritage-placeholder {
  transition: border-color 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.heritage-placeholder:hover,
.heritage-placeholder:focus-visible {
  border-color: var(--color-terracotta);
  box-shadow: 0 16px 40px rgba(17, 18, 20, 0.08);
  outline: none;
}

.heritage-placeholder svg {
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.heritage-placeholder:hover svg {
  transform: scale(1.02);
}

.heritage-dna-card {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease;
}

.heritage-dna-card:hover {
  transform: translateY(-4px);
  border-color: var(--color-terracotta);
  box-shadow: 0 12px 30px rgba(168, 102, 63, 0.08);
}

.heritage-timeline__item {
  transition: background-color 0.2s ease, padding-left 0.2s ease;
}

.heritage-timeline__item:hover {
  background-color: var(--color-editorial-panel);
  padding-left: var(--space-3);
}

/* ── Scroll Reveal ────────────────────────────────────────────────────── */

html.has-heritage-reveal .heritage-reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

html.has-heritage-reveal .heritage-reveal.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ── Lightbox Modal ───────────────────────────────────────────────────── */

.heritage-lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.heritage-lightbox-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}

.heritage-lightbox-overlay {
  position: absolute;
  inset: 0;
  background: rgba(17, 18, 20, 0.75);
  backdrop-filter: blur(8px);
}

.heritage-lightbox-content {
  position: relative;
  z-index: 1;
  max-width: 52rem;
  width: 100%;
  max-height: 90vh;
  background: var(--color-paper);
  border: 1px solid var(--color-border);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}

.heritage-lightbox-modal.is-open .heritage-lightbox-content {
  transform: scale(1);
}

.heritage-lightbox-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  background: var(--color-editorial-panel);
  border: 1px solid var(--color-border);
  border-radius: var(--rounded-pill, 999px);
  color: var(--color-ink);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.heritage-lightbox-close:hover {
  background: var(--color-ink);
  color: var(--color-paper);
}

.heritage-lightbox-close:focus-visible,
.heritage-placeholder:focus-visible {
  outline: 3px solid var(--color-ai);
  outline-offset: 0.25rem;
}

.heritage-lightbox-body .heritage-placeholder {
  cursor: default;
}

.heritage-lightbox-body .heritage-placeholder:hover svg {
  transform: none;
}

.heritage-lightbox-caption {
  margin: 0;
  color: var(--color-stone-dark);
  font-size: 0.88rem;
  line-height: 1.5;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-3);
}

@media (prefers-reduced-motion: reduce) {
  html.has-heritage-reveal .heritage-reveal,
  html.has-heritage-reveal .heritage-reveal.is-revealed,
  .heritage-placeholder,
  .heritage-placeholder img,
  .heritage-dna-card,
  .heritage-timeline__item,
  .heritage-lightbox-modal,
  .heritage-lightbox-content {
    transition: none;
    transform: none;
  }
}

