/* ============================================================
 * history.css — Corporate History page
 *
 * Sections in top-to-bottom order:
 *   .ch-hero          Editorial hero + language switcher slot
 *   .ch-metrics       4-up counter bar (years / companies / hubs / continents)
 *   .ch-map           SVG Brazil silhouette + 3 production hubs
 *   .ch-groups        5 group-company cards (color-tracked by segment)
 *   .ch-timeline      Dual-track filter + vertical zig-zag milestone rail
 *   .ch-certs         ANVISA / CODAM / ZFM certification grid
 *   .ch-gallery       image_slot placeholders for photos to be added later
 *   .ch-downloads     PDF download row
 *   .ch-cta           3-way call-to-action
 *
 * Track color system (used across companies + timeline + filter):
 *   --track-plastics : charcoal / navy — industrial trust
 *   --track-beauty   : pink / rose     — DSMADE brand continuity
 *   --track-both     : neutral gold    — cross-track milestones
 * ========================================================== */

:root {
  --ch-bg:          #ffffff;
  --ch-ink:         #0b0b0d;
  --ch-ink-soft:    #4a4a4d;
  --ch-ink-mute:    #8b8680;
  --ch-hairline:    rgba(11, 11, 13, 0.10);
  --ch-hairline-2:  rgba(11, 11, 13, 0.06);

  --track-plastics: #1f2a3a;    /* deep navy */
  --track-beauty:   #d13a6b;    /* DSMADE rose */
  --track-both:     #8a6f2b;    /* muted gold */

  --ch-radius:      6px;
  --ch-radius-lg:   14px;
  --ch-shadow:      0 1px 3px rgba(11,11,13,0.06), 0 8px 24px rgba(11,11,13,0.04);

  --ch-serif:       "Playfair Display", "Times New Roman", serif;
  --ch-sans:        "Inter", system-ui, -apple-system, sans-serif;
  --ch-mono:        "JetBrains Mono", ui-monospace, monospace;
}

/* ── Page shell ───────────────────────────────────────── */

/* main.css sets `html, body { background: #18161D !important; }` for the
   homepage's dark liquid canvas. History page needs the opposite — a
   warm off-white editorial surface — so we override with equal
   specificity + !important to win the cascade. */
html, body.ch-body {
  background: var(--ch-bg) !important;
  color: var(--ch-ink);
  font-family: var(--ch-sans);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

.ch-wrap { max-width: 1240px; margin: 0 auto; padding: 0 clamp(20px, 5vw, 64px); }

/* ── HERO ─────────────────────────────────────────────── */

.ch-hero {
  padding: clamp(120px, 18vh, 200px) 0 clamp(60px, 10vh, 100px);
  border-bottom: 1px solid var(--ch-hairline);
  position: relative;
}
.ch-hero__crumb {
  font-family: var(--ch-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ch-ink-mute);
  margin: 0 0 32px;
  display: inline-flex; align-items: center; gap: 12px;
}
.ch-hero__crumb a { color: inherit; text-decoration: none; opacity: .7; }
.ch-hero__crumb a:hover { opacity: 1; }
.ch-hero__crumb__sep { opacity: .4; }

.ch-hero__title {
  font-family: var(--ch-serif);
  font-weight: 800;
  font-size: clamp(56px, 9vw, 128px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin: 0;
  text-wrap: balance;
  max-width: 14ch;
}
.ch-hero__title em {
  font-style: normal;
  font-weight: 800;
}
.ch-hero__lede {
  font-family: var(--ch-sans);
  font-size: clamp(18px, 1.6vw, 22px);
  line-height: 1.55;
  color: var(--ch-ink-soft);
  margin: 40px 0 0;
  max-width: 62ch;
  text-wrap: pretty;
}
.ch-hero__since {
  position: absolute;
  top: clamp(120px, 18vh, 200px);
  right: clamp(20px, 5vw, 64px);
  font-family: var(--ch-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--ch-ink-mute);
  letter-spacing: 0.1em;
}
.ch-hero__since strong {
  display: block;
  font-family: var(--ch-serif);
  font-weight: 800;
  font-size: clamp(24px, 2.4vw, 32px);
  color: var(--ch-ink);
  letter-spacing: -0.01em;
  margin-top: 4px;
}

@media (max-width: 720px) {
  .ch-hero__since { position: static; margin: 24px 0 -12px; }
}

/* ── METRICS BAR ──────────────────────────────────────── */

.ch-metrics {
  border-bottom: 1px solid var(--ch-hairline);
  padding: clamp(40px, 6vh, 64px) 0;
}
.ch-metrics__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(20px, 3vw, 48px);
}
@media (max-width: 720px) {
  .ch-metrics__grid { grid-template-columns: repeat(2, 1fr); gap: 32px 24px; }
}
.ch-metric__num {
  font-family: var(--ch-serif);
  font-weight: 800;
  font-size: clamp(44px, 5.5vw, 76px);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ch-ink);
  margin: 0;
}
.ch-metric__num small {
  font-size: 0.55em;
  font-weight: 700;
  color: var(--ch-ink-mute);
  margin-left: 4px;
  letter-spacing: 0;
}
.ch-metric__label {
  font-family: var(--ch-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ch-ink-mute);
  margin: 12px 0 0;
}

/* ── SECTION HEADER SHARED ────────────────────────────── */

.ch-section {
  padding: clamp(80px, 12vh, 140px) 0;
  border-bottom: 1px solid var(--ch-hairline);
}
.ch-section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: clamp(48px, 6vw, 80px);
  flex-wrap: wrap;
}
.ch-section__eyebrow {
  font-family: var(--ch-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ch-ink-mute);
  margin: 0 0 16px;
}
.ch-section__title {
  font-family: var(--ch-serif);
  font-weight: 800;
  font-size: clamp(36px, 4.5vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
  max-width: 20ch;
}
.ch-section__title em { font-style: normal; }
.ch-section__intro {
  font-family: var(--ch-sans);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ch-ink-soft);
  max-width: 46ch;
  text-wrap: pretty;
  margin: 0;
}

/* ── MAP ──────────────────────────────────────────────── */

.ch-map__stage {
  position: relative;
  background: #f6f4ef;
  border-radius: var(--ch-radius-lg);
  padding: clamp(32px, 5vw, 64px);
  overflow: hidden;
}
.ch-map__svg {
  width: 100%;
  height: auto;
  max-height: 620px;
  display: block;
}
.ch-map__svg .country {
  fill: #ffffff;
  stroke: rgba(11,11,13,0.15);
  stroke-width: 1;
}
.ch-map__svg .link {
  stroke: var(--track-plastics);
  stroke-width: 1.5;
  fill: none;
  stroke-dasharray: 4 6;
  opacity: .35;
}
.ch-map__svg .link.animated {
  stroke-dashoffset: 0;
  animation: chLinkFlow 3s linear infinite;
}
@keyframes chLinkFlow {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -100; }
}
.ch-map__svg .hub circle.outer {
  fill: var(--track-plastics);
  opacity: .12;
  transition: opacity .25s ease, r .25s ease;
}
.ch-map__svg .hub circle.inner {
  fill: var(--track-plastics);
  transition: r .25s ease;
}
.ch-map__svg .hub:hover circle.outer,
.ch-map__svg .hub.is-active circle.outer { opacity: .28; }
.ch-map__svg .hub text.city {
  font-family: var(--ch-sans);
  font-size: 13px;
  font-weight: 700;
  fill: var(--ch-ink);
  letter-spacing: 0.02em;
}
.ch-map__svg .hub text.role {
  font-family: var(--ch-mono);
  font-size: 10px;
  fill: var(--ch-ink-mute);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ch-map__legend {
  display: flex;
  gap: 32px;
  margin-top: 32px;
  flex-wrap: wrap;
  font-family: var(--ch-sans);
  font-size: 13px;
  color: var(--ch-ink-soft);
}
.ch-map__legend b { color: var(--ch-ink); font-weight: 700; margin-right: 8px; letter-spacing: .04em; }

/* ── GROUP COMPANIES ──────────────────────────────────── */

.ch-groups__grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 20px;
}
.ch-groups__card {
  grid-column: span 2;
  background: #fff;
  border: 1px solid var(--ch-hairline);
  border-radius: var(--ch-radius-lg);
  padding: 32px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform .3s cubic-bezier(.22,.61,.36,1), box-shadow .3s ease, border-color .3s ease;
  position: relative;
  overflow: hidden;
}
/* 5 cards in a 6-col grid: cols 1-2, 3-4, 5-6 (row 1) and 2-3, 4-5 (row 2 centered) */
.ch-groups__card:nth-child(4) { grid-column: 2 / span 2; }
.ch-groups__card:nth-child(5) { grid-column: 4 / span 2; }

@media (max-width: 960px) {
  .ch-groups__grid { grid-template-columns: repeat(2, 1fr); }
  .ch-groups__card,
  .ch-groups__card:nth-child(4),
  .ch-groups__card:nth-child(5) { grid-column: auto; }
}
@media (max-width: 560px) {
  .ch-groups__grid { grid-template-columns: 1fr; }
}

.ch-groups__card:hover {
  transform: translateY(-2px);
  box-shadow: var(--ch-shadow);
  border-color: rgba(11,11,13,0.20);
}
.ch-groups__card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--card-track, var(--ch-ink));
}
.ch-groups__card[data-track="plastics"] { --card-track: var(--track-plastics); }
.ch-groups__card[data-track="beauty"]   { --card-track: var(--track-beauty); }
.ch-groups__card[data-track="both"]     { --card-track: var(--track-both); }

.ch-groups__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--ch-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--card-track) 10%, transparent);
  color: var(--card-track);
  align-self: flex-start;
}
.ch-groups__name {
  font-family: var(--ch-serif);
  font-weight: 800;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--ch-ink);
}
.ch-groups__meta {
  font-family: var(--ch-mono);
  font-size: 11px;
  color: var(--ch-ink-mute);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
}
.ch-groups__desc {
  font-family: var(--ch-sans);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ch-ink-soft);
  margin: 4px 0 0;
  text-wrap: pretty;
}

/* ── TIMELINE ─────────────────────────────────────────── */

.ch-tl__filter {
  /* Center the pill group horizontally so it sits on the same
     vertical axis as the timeline rail (which is at 50%). */
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 5px;
  background: rgba(11,11,13,0.05);
  border-radius: 999px;
  margin: 0 auto clamp(48px, 6vw, 72px);
  width: fit-content;
}
@media (max-width: 900px) {
  /* On mobile the rail moves to left:20px, so the filter should
     match — flush-left rather than centered. */
  .ch-tl__filter { margin-left: 0; margin-right: auto; }
}
.ch-tl__filter button {
  border: 0;
  background: transparent;
  font-family: var(--ch-sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ch-ink-soft);
  transition: background .2s ease, color .2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ch-tl__filter button:hover:not(.is-active) { color: var(--ch-ink); }
.ch-tl__filter button.is-active { background: var(--ch-ink); color: #fff; }
.ch-tl__filter button[data-track="plastics"].is-active { background: var(--track-plastics); }
.ch-tl__filter button[data-track="beauty"].is-active   { background: var(--track-beauty); }
.ch-tl__filter .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; opacity: .6;
}
.ch-tl__filter button[data-track="plastics"] .dot { background: var(--track-plastics); opacity: 1; }
.ch-tl__filter button[data-track="beauty"] .dot   { background: var(--track-beauty);   opacity: 1; }

/* Sticky year indicator (top of viewport during timeline scroll) */
.ch-tl__sticky {
  position: sticky;
  top: 80px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  border: 1px solid var(--ch-hairline);
  border-radius: 999px;
  font-family: var(--ch-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--ch-ink-mute);
  margin-bottom: 24px;
  transition: opacity .3s ease, transform .3s ease;
  opacity: 0;
  transform: translateY(-4px);
}
.ch-tl__sticky.is-visible { opacity: 1; transform: translateY(0); }
.ch-tl__sticky strong {
  font-family: var(--ch-serif);
  font-weight: 800;
  font-size: 18px;
  color: var(--ch-ink);
  letter-spacing: 0;
}

/* Rail — vertical line down the middle (or left on mobile) */
.ch-tl__rail {
  position: relative;
  padding: 40px 0;
}
.ch-tl__rail::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    var(--ch-hairline) 60px,
    var(--ch-hairline) calc(100% - 60px),
    transparent 100%
  );
  transform: translateX(-0.5px);
}
@media (max-width: 900px) {
  /* Rail (vertical hairline) runs down the screen centre on
     mobile now, matching the centred card + dot layout below.
     Previously it hugged the left at 20px which paired with a
     left-anchored card — that layout has changed. */
  .ch-tl__rail::before { left: 50%; }
}

.ch-tl__item {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  gap: 0;
  align-items: center;
  padding: 32px 0;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .6s cubic-bezier(.22,.61,.36,1), transform .6s cubic-bezier(.22,.61,.36,1);
}
.ch-tl__item.is-visible { opacity: 1; transform: none; }
.ch-tl__item.is-hidden {
  display: none;                     /* filtered out */
}

/* Both columns now use left-aligned text for consistent
   readability. The odd (left) card previously mirrored to
   text-align: right + align-items: flex-end + meta justify
   flex-end — that produced the "text pushed to the right"
   effect the user flagged. Column position + padding-right
   are preserved so the left/right rhythm of the timeline
   stays intact; only the text INSIDE the card is left-aligned. */
.ch-tl__item:nth-child(odd)  .ch-tl__card { grid-column: 1; text-align: left; padding-right: 40px; align-items: flex-start; }
.ch-tl__item:nth-child(even) .ch-tl__card { grid-column: 3; text-align: left; padding-left: 40px;  align-items: flex-start; }
.ch-tl__item:nth-child(odd)  .ch-tl__meta { justify-content: flex-start; }

@media (max-width: 900px) {
  /* Mobile layout ─────────────────────────────────────────────
     Was: left rail (20px) + right column with card padded in
     24px from the rail. Result: card hugged the right edge of
     the screen while the rail sat far left — no visual balance.
     Now: rail runs down the SCREEN CENTER; dot sits on the
     rail; card sits BELOW the dot, horizontally centred with
     even side gutters. Reads as a proper vertical timeline. */
  .ch-tl__item {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 24px 20px;               /* even side gutter around card */
    justify-items: center;            /* dot + card share centre axis */
  }
  .ch-tl__item .ch-tl__card,
  .ch-tl__item:nth-child(odd)  .ch-tl__card,
  .ch-tl__item:nth-child(even) .ch-tl__card {
    grid-column: 1;
    grid-row: 2;                      /* card sits below the dot */
    text-align: left;
    padding: 22px 24px;               /* re-assert generous internal padding */
    align-items: flex-start;
    width: 100%;
    max-width: 360px;                 /* keeps card readable on wide phones */
    margin: 14px 0 0;                 /* space between dot and card */
  }
  .ch-tl__item .ch-tl__meta,
  .ch-tl__item:nth-child(odd)  .ch-tl__meta { justify-content: flex-start; }
  .ch-tl__dot {
    grid-column: 1;
    grid-row: 1;                      /* dot above the card */
    justify-self: center;
    /* Clear the desktop absolute-position override that pinned
       the dot to the left rail. */
    left: auto !important;
    position: relative;
  }
}

.ch-tl__dot {
  grid-column: 2;
  justify-self: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--dot-track, var(--ch-ink));
  position: relative;
  z-index: 2;
  transition: transform .3s ease, background .3s ease;
}
.ch-tl__item[data-track="plastics"] { --dot-track: var(--track-plastics); }
.ch-tl__item[data-track="beauty"]   { --dot-track: var(--track-beauty); }
.ch-tl__item[data-track="both"]     { --dot-track: var(--track-both); }

.ch-tl__item.is-pivot .ch-tl__dot {
  width: 22px; height: 22px;
  background: var(--dot-track);
  box-shadow: 0 0 0 6px color-mix(in oklab, var(--dot-track) 15%, transparent);
}

.ch-tl__card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  cursor: default;
  /* Subtle backing so the text stays legible against the ghost
     backdrop photos, without covering the photos themselves.
     Padding widened (was 14px 18px — text was hugging the border
     visibly on mobile) so type has breathing room on all sides. */
  padding: 22px 26px;
  border-radius: 14px;
  background: rgba(246, 244, 239, 0.75);
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow:
    0 1px 2px rgba(20, 15, 8, 0.04),
    0 8px 20px -12px rgba(20, 15, 8, 0.12);
  backdrop-filter: blur(6px) saturate(1.05);
  -webkit-backdrop-filter: blur(6px) saturate(1.05);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}
.ch-tl__item.is-pivot .ch-tl__card:hover {
  background: rgba(246, 244, 239, 0.88);
  box-shadow:
    0 1px 2px rgba(20, 15, 8, 0.06),
    0 12px 28px -12px rgba(20, 15, 8, 0.18);
}
.ch-tl__item.is-pivot .ch-tl__card { cursor: pointer; }

.ch-tl__year {
  font-family: var(--ch-serif);
  font-weight: 800;
  font-size: clamp(32px, 3.5vw, 48px);
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ch-ink);
  margin: 0;
}
.ch-tl__meta {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.ch-tl__badge {
  font-family: var(--ch-sans);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--dot-track, var(--ch-ink));
  background: color-mix(in oklab, var(--dot-track, var(--ch-ink)) 10%, transparent);
}
.ch-tl__badge--pivot {
  background: var(--dot-track, var(--ch-ink));
  color: #fff;
}
.ch-tl__subtitle {
  font-family: var(--ch-sans);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ch-ink);
  margin: 0;
  letter-spacing: -0.005em;
}
.ch-tl__body {
  font-family: var(--ch-sans);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ch-ink-soft);
  margin: 0;
  max-width: 42ch;
  text-wrap: pretty;
}
/* margin-left: auto on the odd .ch-tl__body was pushing the 42ch
   paragraph to the right edge of the card container, pairing with
   text-align: right for a right-aligned block. Now that the card
   is left-aligned, leave margin-left at its default (0) so the
   paragraph starts flush with the card's left edge. */

.ch-tl__more {
  font-family: var(--ch-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dot-track, var(--ch-ink));
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ch-tl__more::after {
  content: "→";
  transition: transform .2s ease;
}
.ch-tl__more:hover::after { transform: translateX(4px); }
/* .ch-tl__more align-self flex-end removed — the "Read more"
   button (currently display:none anyway) would have sat on the
   right; now it defaults to flex-start with the rest of the
   card content. */

/* Inline pivot story — always expanded, sits below the card's
   summary paragraph. Replaces the old "Read the pivot story"
   modal flow so users see the full story without clicking. */
.ch-tl__pivot-inline {
  max-width: 42ch;
  width: 100%;
  margin-top: 12px;
}
/* pivot-inline margin-left: auto removed for the same reason —
   the block now flush-aligns to the card's left edge, matching
   the parent card's align-items: flex-start. */
.ch-tl__pivot-inner {
  padding-top: 16px;
  border-top: 1px solid var(--ch-hairline);
}
.ch-tl__pivot-eyebrow {
  font-family: var(--ch-sans);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dot-track, var(--ch-ink-mute));
  margin: 0 0 10px;
}
.ch-tl__pivot-inner p {
  font-family: var(--ch-sans);
  font-size: 14px;
  line-height: 1.7;
  color: var(--ch-ink-soft);
  margin: 0 0 0.9em;
  text-wrap: pretty;
}
.ch-tl__pivot-inner p:last-child { margin-bottom: 0; }
/* Left-side (odd) pivot cards previously mirrored their body text
   to `text-align: right` for symmetry with the right column. In
   practice that hurt readability — the ragged left edge broke the
   reading rhythm. Both sides now read left-aligned like a normal
   paragraph; the card's grid position still keeps the visual
   left/right rhythm intact. */

/* Old "Read the pivot story" button — hidden because the story
   is now always visible inline. */
.ch-tl__more { display: none; }

/* ── Footer override ────────────────────────────────────────
   main.css sets .footer { background: transparent !important }
   which works on the dark homepage but disappears on this
   white-background page. Give the footer its own dark surface
   here so the hairline + white text render against a real bg. */
.footer.footer--compact {
  background: #0a0a0a !important;
}

/* ── Floating "Back to top" FAB ─────────────────────────────
   Fixed bottom-right dark rounded button. Fades in once the
   user has scrolled past 300px; smooth-scrolls to top on click.
   Uses the same visual language as press/terms.html so returning
   users see a consistent affordance across the site. */
.fab-top {
  position: fixed;
  right: clamp(16px, 2vw, 24px);
  bottom: clamp(16px, 2vw, 24px);
  z-index: 60;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: #0a0a0a;
  color: #f5f2ee;
  cursor: pointer;
  box-shadow:
    0 8px 24px -8px rgba(0, 0, 0, 0.45),
    0 2px 6px -2px rgba(0, 0, 0, 0.30);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease,
    background 0.20s ease,
    border-color 0.20s ease;
}
.fab-top.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.fab-top:hover {
  background: #1a1a1a;
  border-color: rgba(255, 255, 255, 0.28);
}
.fab-top:hover svg { transform: translateY(-2px); }
.fab-top svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  transition: transform 0.25s ease;
}
.fab-top__label {
  font-family: var(--ch-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1;
  color: rgba(245, 242, 238, 0.88);
}
@media (max-width: 640px) {
  .fab-top { width: 48px; height: 48px; border-radius: 14px; }
  .fab-top svg { width: 14px; height: 14px; }
  .fab-top__label { font-size: 9px; }
}

@media (max-width: 900px) {
  .ch-tl__item:nth-child(odd) .ch-tl__body,
  .ch-tl__item:nth-child(odd) .ch-tl__more { margin-left: 0; align-self: flex-start; }
  .ch-tl__item:nth-child(odd) .ch-tl__pivot-inline { margin-left: 0; }
  .ch-tl__item:nth-child(odd) .ch-tl__pivot-inner { text-align: left; }
}

/* Modal for pivot deep-dives */
.ch-modal {
  position: fixed;
  inset: 0;
  background: rgba(11,11,13,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity .25s ease;
}
.ch-modal.is-open { display: flex; opacity: 1; }
.ch-modal__panel {
  background: #fff;
  border-radius: var(--ch-radius-lg);
  padding: clamp(32px, 5vw, 56px);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform .25s ease;
  position: relative;
}
.ch-modal.is-open .ch-modal__panel { transform: none; }
.ch-modal__close {
  position: absolute;
  top: 20px; right: 20px;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--ch-hairline);
  background: #fff;
  cursor: pointer;
  font-size: 18px;
  color: var(--ch-ink-mute);
  line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .2s ease, color .2s ease;
}
.ch-modal__close:hover { background: var(--ch-ink); color: #fff; border-color: var(--ch-ink); }
.ch-modal__eyebrow {
  font-family: var(--ch-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ch-ink-mute);
  text-transform: uppercase;
  margin: 0 0 12px;
}
.ch-modal__year {
  font-family: var(--ch-serif);
  font-weight: 800;
  font-size: 56px;
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}
.ch-modal__title {
  font-family: var(--ch-sans);
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 20px;
  color: var(--ch-ink);
}
.ch-modal__body {
  font-family: var(--ch-sans);
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--ch-ink-soft);
  text-wrap: pretty;
}
.ch-modal__body p + p { margin-top: 1em; }

/* ── CERTIFICATIONS ───────────────────────────────────── */

.ch-certs__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 720px) { .ch-certs__grid { grid-template-columns: 1fr; } }

.ch-certs__card {
  background: #fff;
  border: 1px solid var(--ch-hairline);
  border-radius: var(--ch-radius-lg);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ch-certs__code {
  font-family: var(--ch-serif);
  font-weight: 800;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ch-ink);
  margin: 0;
}
.ch-certs__code small {
  display: block;
  font-family: var(--ch-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--ch-ink-mute);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 6px;
}
.ch-certs__desc {
  font-family: var(--ch-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ch-ink-soft);
  margin: 0;
  text-wrap: pretty;
}

/* ── GALLERY (image_slot placeholders) ────────────────── */

.ch-gallery__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  grid-template-rows: 260px 260px;
  gap: 16px;
}
.ch-gallery__slot { border-radius: var(--ch-radius-lg); overflow: hidden; }
.ch-gallery__slot:nth-child(1) { grid-column: 1; grid-row: 1 / span 2; }
.ch-gallery__slot:nth-child(2) { grid-column: 2; grid-row: 1; }
.ch-gallery__slot:nth-child(3) { grid-column: 3; grid-row: 1; }
.ch-gallery__slot:nth-child(4) { grid-column: 2 / span 2; grid-row: 2; }
@media (max-width: 720px) {
  .ch-gallery__grid { grid-template-columns: 1fr; grid-template-rows: repeat(4, 220px); }
  .ch-gallery__slot { grid-column: 1 !important; grid-row: auto !important; }
}

/* ── DOWNLOADS ────────────────────────────────────────── */

.ch-dl__row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 720px) { .ch-dl__row { grid-template-columns: 1fr; } }
.ch-dl__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px;
  background: #fff;
  border: 1px solid var(--ch-hairline);
  border-radius: var(--ch-radius-lg);
  text-decoration: none;
  color: var(--ch-ink);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.ch-dl__item:hover {
  transform: translateY(-1px);
  box-shadow: var(--ch-shadow);
  border-color: rgba(11,11,13,0.18);
}
.ch-dl__label {
  font-family: var(--ch-sans);
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}
.ch-dl__meta {
  font-family: var(--ch-mono);
  font-size: 11px;
  color: var(--ch-ink-mute);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 4px 0 0;
}
.ch-dl__icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--ch-ink);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

/* ── CTA ──────────────────────────────────────────────── */

.ch-cta {
  padding: clamp(80px, 12vh, 140px) 0;
  background: var(--ch-ink);
  color: #fff;
  border-bottom: 0;
}
.ch-cta .ch-section__title { color: #fff; max-width: 24ch; }
.ch-cta .ch-section__eyebrow { color: rgba(255,255,255,0.6); }
.ch-cta .ch-section__intro { color: rgba(255,255,255,0.7); }

.ch-cta__row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 48px;
}
@media (max-width: 720px) { .ch-cta__row { grid-template-columns: 1fr; } }

.ch-cta__card {
  padding: 32px 28px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--ch-radius-lg);
  color: #fff;
  text-decoration: none;
  transition: background .2s ease, border-color .2s ease, transform .2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ch-cta__card:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.35);
  transform: translateY(-2px);
}
.ch-cta__card__label {
  font-family: var(--ch-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin: 0;
}
.ch-cta__card__title {
  font-family: var(--ch-serif);
  font-weight: 800;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 4px 0 6px;
}
.ch-cta__card__desc {
  font-family: var(--ch-sans);
  font-size: 13.5px;
  line-height: 1.5;
  color: rgba(255,255,255,0.65);
  margin: 0;
  text-wrap: pretty;
}
.ch-cta__card__arrow {
  margin-top: 12px;
  font-family: var(--ch-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ch-cta__card__arrow::after { content: "→"; transition: transform .2s ease; }
.ch-cta__card:hover .ch-cta__card__arrow::after { transform: translateX(4px); }

/* Cta footer bottom-border adjustment (dark section on light bg) */
.ch-cta { border-bottom-color: transparent; }


/* ============================================================
 * CINEMATIC BANNER  (.ch-cine)
 * ------------------------------------------------------------
 * Grand, letterbox-wide opener for the history page. Different
 * from the brands/cinema-banner (which is a 100vh fixed-attach
 * parallax): this is a proportional wide banner that mirrors
 * the composition the client showed in the reference — extra
 * wide, low height, editorial lockup bottom-left.
 *
 * Layout is aspect-ratio driven, which auto-scales cleanly on
 * every viewport. Ratios chosen per breakpoint:
 *   • desktop  21 / 9   (cinemascope)
 *   • tablet   16 / 9
 *   • phone    4  / 5   (upright — keeps the type readable)
 * Min-height guard prevents it from collapsing when a very
 * short viewport uses the widest aspect ratio.
 * ========================================================== */
.ch-cine {
  position: relative;
  width: 100%;
  aspect-ratio: 21 / 9;
  min-height: 420px;
  max-height: 82vh;
  overflow: hidden;
  background: #0a0a0f;
  isolation: isolate;   /* keep the scrim's blend contained */
}

/* Media layer — background-image (no <img>) so the crop stays
   art-directed without a separate srcset chain. Slow ken-burns
   drift for weight; disabled under prefers-reduced-motion. */
.ch-cine__media {
  position: absolute;
  inset: 0;
  background-image: url("../assets/history-pelourinho.jpg");
  background-size: cover;
  background-position: center 45%;
  background-repeat: no-repeat;
  transform: scale(1.06);
  animation: chCineDrift 22s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes chCineDrift {
  0%   { transform: scale(1.06) translate3d(-1.2%, 0.4%, 0); }
  100% { transform: scale(1.10) translate3d( 1.4%,-0.6%, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .ch-cine__media { animation: none; transform: none; }
}

/* Scrim — protects the lockup contrast without deadening the
   image. Vertical gradient weighted to the lower-left, plus a
   subtle top vignette so the fixed nav pill sits cleanly. */
.ch-cine__scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg,
      rgba(0,0,0,0.55) 0%,
      rgba(0,0,0,0.15) 20%,
      rgba(0,0,0,0.00) 45%,
      rgba(0,0,0,0.35) 78%,
      rgba(0,0,0,0.72) 100%),
    linear-gradient(90deg,
      rgba(0,0,0,0.35) 0%,
      rgba(0,0,0,0.00) 55%);
  pointer-events: none;
}

/* Lockup — bottom-left aligned editorial stack. Padding uses
   the same wrap padding as the rest of the page for alignment. */
.ch-cine__lockup {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: clamp(28px, 5vw, 72px) clamp(20px, 5vw, 64px);
  max-width: 1240px;
  margin: 0 auto;
  color: #fff;
}
.ch-cine__crumb {
  font-family: var(--ch-sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.75);
  margin: 0 0 clamp(18px, 2vw, 28px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.ch-cine__crumb a {
  color: inherit;
  text-decoration: none;
  opacity: 0.78;
  transition: opacity .18s ease;
}
.ch-cine__crumb a:hover { opacity: 1; }
.ch-cine__crumb__sep { opacity: 0.45; }
.ch-cine__eyebrow {
  font-family: var(--ch-sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.85);
  margin: 0 0 clamp(14px, 1.4vw, 20px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.ch-cine__eyebrow::before {
  content: "";
  display: inline-block;
  width: 36px; height: 1px;
  background: rgba(255,255,255,0.65);
}
.ch-cine__title {
  font-family: var(--ch-serif);
  font-weight: 800;
  font-size: clamp(40px, 6.6vw, 108px);
  line-height: 0.98;
  letter-spacing: -0.025em;
  color: #fff;
  margin: 0;
  max-width: 16ch;
  text-wrap: balance;
  text-shadow: 0 2px 24px rgba(0,0,0,0.35);
}
.ch-cine__title em {
  font-style: normal;
  font-weight: 800;
  color: #fff;
}

/* ── Responsive aspect-ratio steps ─────────────────────────
   Wide cinemascope on desktop; shorter+taller on tablet;
   near-square/portrait on phone so the wide crop doesn't
   swallow the whole screen and type stays legible. */
@media (max-width: 1100px) {
  .ch-cine { aspect-ratio: 16 / 9; min-height: 380px; }
}
@media (max-width: 700px) {
  .ch-cine {
    aspect-ratio: 4 / 5;
    min-height: 520px;
    max-height: none;
  }
  .ch-cine__media {
    background-position: 62% center;   /* keep the machinery in frame on portrait */
  }
  .ch-cine__scrim {
    background:
      linear-gradient(180deg,
        rgba(0,0,0,0.50) 0%,
        rgba(0,0,0,0.10) 25%,
        rgba(0,0,0,0.00) 50%,
        rgba(0,0,0,0.55) 82%,
        rgba(0,0,0,0.85) 100%);
  }
  .ch-cine__title { max-width: 14ch; }
}

/* Section that follows the banner shouldn't butt right against
   it — the old .ch-hero used to provide that top padding. Give
   the timeline section that spacing back. */
.ch-cine + .ch-section { padding-top: clamp(64px, 8vw, 112px); }

/* The timeline is now the LAST section on the page before the
   shared site footer (Certifications / Gallery / Downloads / CTA
   were removed 2026-08-12). Add generous breathing room below
   the final milestone so the dark footer doesn't slam into it. */
.ch-tl__rail { padding-bottom: clamp(48px, 8vw, 120px); }


/* ═══════════════════════════════════════════════════════════
   Ghost backdrop — three era photos live in a fixed layer
   BEHIND the timeline text. Fades between them based on
   which year band the reader is currently in.
   Text stays fully readable: layers are low-opacity and
   heavily masked at the edges + a page-tint overlay on top.
   ═══════════════════════════════════════════════════════════ */
.ch-tl-bg {
  position: fixed;
  inset: 0;
  z-index: 0;                    /* behind body content but above body bg */
  pointer-events: none;
  overflow: hidden;
  /* Whole backdrop only becomes visible while the timeline is
     being read — activated / deactivated by history.js as the
     .ch-tl__rail enters and leaves the viewport. */
  opacity: 0;
  transition: opacity 0.8s ease-out;
}
.ch-tl-bg.is-active { opacity: 1; }

.ch-tl-bg__layer {
  position: absolute;
  inset: -6% -3%;                /* overshoot so slow drift doesn't reveal edges */
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  /* Slight saturation boost so the photo carries through the
     legibility mask on top of it, without any blur that would
     mush the details. */
  filter: saturate(1.05) brightness(0.98);
  transition: opacity 1.6s ease-in-out;
  will-change: opacity, transform;
  animation: chTlBgDrift 40s ease-in-out infinite alternate;
}
@keyframes chTlBgDrift {
  0%   { transform: scale(1.02) translate(0, 0); }
  100% { transform: scale(1.08) translate(-1.5%, -0.8%); }
}

/* Show ONE layer at a time, chosen by [data-era] on the parent.
   0 = none · 1 = Foundation (skyline) · 2 = Expansion (flag) · 3 = Consumer (fans) */
.ch-tl-bg[data-era="1"] .ch-tl-bg__layer--1,
.ch-tl-bg[data-era="2"] .ch-tl-bg__layer--2,
.ch-tl-bg[data-era="3"] .ch-tl-bg__layer--3 {
  opacity: 0.55;      /* higher so photos actually read; mask below keeps text safe */
}

/* Legibility mask — lighter fades so more of the photo shows,
   but still enough page-tint wash to keep timeline copy solid. */
.ch-tl-bg__mask {
  position: absolute;
  inset: 0;
  background:
    /* Softer top + bottom fade so photo is visible through the
       middle band instead of only peeking */
    linear-gradient(180deg,
      var(--ch-page-bg, #f6f4ef) 0%,
      rgba(246, 244, 239, 0.15) 15%,
      rgba(246, 244, 239, 0) 40%,
      rgba(246, 244, 239, 0) 60%,
      rgba(246, 244, 239, 0.3) 90%,
      var(--ch-page-bg, #f6f4ef) 100%),
    /* Very light L↔R feather */
    linear-gradient(90deg,
      rgba(246, 244, 239, 0.2) 0%,
      rgba(246, 244, 239, 0) 20%,
      rgba(246, 244, 239, 0) 80%,
      rgba(246, 244, 239, 0.2) 100%);
}

/* Anything above this backdrop must sit above z-index:0 so text
   floats on top. The timeline rail already has its own stacking
   from position:relative, but be explicit so future changes to
   history.css don't accidentally send text underneath. */
.ch-section,
.ch-cine,
.ch-wrap,
.ch-tl__rail {
  position: relative;
  z-index: 1;
}

/* Reduced motion — no drift, faster / instant crossfade */
@media (prefers-reduced-motion: reduce) {
  .ch-tl-bg,
  .ch-tl-bg__layer { transition: opacity 0.3s ease-out; animation: none; }
}


/* ═══════════════════════════════════════════════════════════
   Icon-only Back-to-home button.
   On the history page it lives INSIDE the timeline rail's own
   bottom padding (no dedicated band). .ch-tl__back centres the
   button in that existing breathing room.
   ═══════════════════════════════════════════════════════════ */
.ch-tl__back {
  /* Centre the icon-only home button horizontally on the timeline's
     vertical rail. The button lives inside .ch-tl__rail, whose
     ::before draws the hairline down the middle at left:50%. We
     centre the button on that same axis so it visually caps the
     end of the timeline line. */
  position: relative;
  z-index: 1;
  margin-top: clamp(16px, 3vw, 32px);
  /* Slide the button DOWN visually without adding page height.
     Using `top` (not transform) so the .au-back-btn:hover
     transform:translateY(-2px) lift animation doesn't fight
     with the offset and cause the button to jitter on hover. */
  top: clamp(60px, 8vw, 120px);
}
/* Selector doubled up (.au-back-btn.ch-tl__back) so this beats the
   .au-back-btn { display: inline-flex } rule that comes after and
   would otherwise re-collapse the button back to inline flow (which
   left-aligned it against the rail's content-edge). Forcing block
   flex lets the auto margins actually centre the fixed-width button. */
.au-back-btn.ch-tl__back {
  display: flex;
  margin-left: auto;
  margin-right: auto;
}
.au-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid #0a0a0a;
  border-radius: 999px;
  background: #ffffff;
  color: #0a0a0a;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
    color 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.au-back-btn:hover {
  background: #0a0a0a;
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.35);
}
.au-back-btn:hover .au-back-btn__arrow {
  transform: translateX(-3px);
}
.au-back-btn:focus-visible {
  outline: 2px solid #0a0a0a;
  outline-offset: 4px;
}
.au-back-btn:active { transform: translateY(0); }
.au-back-btn__arrow {
  width: 18px;
  height: 18px;
  transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
