/* Coast 2 Coast Property Finance — base layer
 *
 * Direction: "Chart Room" (Refined Editorial x Coastal Premium).
 * Rules live in design-guide/current.md. Brand values come from tokens.css
 * (generated from design-guide/tokens.json). STRUCTURE lives here.
 * Framework classes only. Never inline styles, never a <style> tag.
 */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

:root {
  /* ── Type rhythm ───────────────────────────────────────────── */
  --lh-display: 1.08;
  --lh-heading: 1.18;
  --lh-snug: 1.34;
  --lh-body: 1.65;
  --tracking-display: -0.015em;
  --tracking-label: 0.18em;

  /* Fluid scale, ratio 1.25. H1 caps at 54.4px desktop, 33.6px mobile. */
  --fs-h1:    clamp(2.10rem, 1.35rem + 2.60vw, 3.40rem);
  --fs-h2:    clamp(1.65rem, 1.20rem + 1.55vw, 2.50rem);
  --fs-h3:    clamp(1.25rem, 1.08rem + 0.58vw, 1.55rem);
  --fs-lead:  clamp(1.10rem, 1.02rem + 0.30vw, 1.28rem);
  --fs-body:  clamp(1.00rem, 0.97rem + 0.12vw, 1.0625rem);
  --fs-small: 0.875rem;
  --fs-label: 0.6875rem;
  --fs-script: clamp(1.75rem, 1.30rem + 1.55vw, 2.60rem);

  /* ── Layout rhythm ─────────────────────────────────────────── */
  --container-pad: clamp(1.25rem, 5vw, 2.5rem);
  --prose-max: 64ch;
  --section-y: clamp(4.5rem, 3rem + 6vw, 8.5rem);
  --section-y-sm: clamp(3rem, 2rem + 4vw, 5rem);
  --stack: clamp(1.5rem, 1rem + 2vw, 2.25rem);
  --gutter: clamp(1.5rem, 1rem + 2.6vw, 3.25rem);

  /* ── Motion ────────────────────────────────────────────────── */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-ui: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 620ms;
  --dur-fast: 200ms;

  /* ── Elevation (one shadow on the whole site) ──────────────── */
  --shadow-card: 0 24px 60px -30px rgba(17, 74, 99, 0.35);

  --header-h: 74px;
  --topbar-h: 40px;
  --chrome-h: calc(var(--header-h) + var(--topbar-h));

  /* Third family. tokens.json has no slot for it, so it is declared here.
     Two instances on the whole page (design-guide/current.md §4). */
  --font-script: Sacramento, "Snell Roundhand", cursive;
}

/* ── Document ────────────────────────────────────────────────── */
body {
  margin: 0;
  background: var(--color-haze);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }

/* ── Headings ────────────────────────────────────────────────── */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 400;
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-display);
  color: var(--color-ocean);
  text-wrap: balance;
  margin: 0;
}
h1 { font-size: var(--fs-h1); line-height: var(--lh-display); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); letter-spacing: -0.008em; }

p { margin: 0 0 1.05em; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }

a { color: inherit; }

/* ── Layout primitives ───────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}
.container--narrow { max-width: 820px; }

/* Every anchor target has to clear the fixed chrome, or a nav click lands
   with the section heading hidden behind the header. */
[id] { scroll-margin-top: calc(var(--header-h) + 1rem); }
@media (min-width: 860px) { [id] { scroll-margin-top: calc(var(--chrome-h) + 1rem); } }

.section { padding-block: var(--section-y); position: relative; }
.section--tight { padding-block: var(--section-y-sm); }

.lede {
  font-size: var(--fs-lead);
  line-height: 1.55;
  color: var(--color-muted-ink);
  max-width: 56ch;
}

.prose { max-width: var(--prose-max); }
.prose p + p { margin-top: 0; }

/* Asymmetric editorial split: the page's default, not a centred column. */
.split {
  display: grid;
  gap: var(--gutter);
  align-items: start;
}
@media (min-width: 900px) {
  .split { grid-template-columns: 5fr 7fr; }
  .split--4-8 { grid-template-columns: 4fr 8fr; }
  .split--7-5 { grid-template-columns: 7fr 5fr; }
  .split--half { grid-template-columns: 1fr 1fr; }
}

/* ── The section opener: label + drawn rule ──────────────────
 * This is the site's ONE kicker system (design-guide §2). Permitted on
 * major section openers only. Never above a sub-heading, card or list item.
 */
.opener { margin-bottom: clamp(1.5rem, 1rem + 1.6vw, 2.5rem); }

.label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-coastline-ink);
  margin: 0 0 0.85rem;
}
.label::after {
  content: "";
  display: block;
  width: 44px;
  height: 1px;
  margin-top: 0.75rem;
  background: var(--color-sand);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 320ms var(--ease);
}
.label::after { transform: scaleX(1); }
.js .label::after { transform: scaleX(0); }
.js .is-revealed .label::after,
.js .reveal.in-view .label::after,
.js .reveal-rise.in-view .label::after { transform: scaleX(1); }

.on-dark .label { color: var(--color-sand); }
.on-dark .label::after { background: rgba(214, 194, 171, 0.55); }

/* ── Dark chapters ───────────────────────────────────────────── */
.on-dark {
  background: var(--color-ocean);
  color: var(--color-on-dark);
}
.on-dark h1, .on-dark h2, .on-dark h3, .on-dark h4 { color: var(--color-on-dark); }
.on-dark .lede { color: var(--color-on-dark-muted); }
.on-dark--deep { background: var(--color-ocean-deep); }

/* ── Reveal system ───────────────────────────────────────────
 * Signature entrance (design-guide §5): the rule draws, then the heading
 * rises, then content staggers. Fires once. Varied by role, never one
 * identical fade on every element.
 *
 * Everything below is scoped to `.js`, which an inline head script sets
 * before first paint. If the script never runs, or fails, the page renders
 * fully visible instead of leaving the copy and the CTA at opacity 0.
 */
.js .reveal,
.js .reveal-rise,
.js .reveal-left,
.js .reveal-right,
.js .reveal-mask {
  opacity: 0;
  transition:
    opacity var(--dur) var(--ease),
    transform var(--dur) var(--ease),
    clip-path var(--dur) var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
.js .reveal-rise  { transform: translateY(14px); }
.js .reveal-left  { transform: translateX(-22px); }
.js .reveal-right { transform: translateX(22px); }
.js .reveal-mask  { opacity: 0; }

.js .reveal.in-view,
.js .reveal-rise.in-view,
.js .reveal-left.in-view,
.js .reveal-right.in-view {
  opacity: 1;
  transform: none;
}
/* The wipe runs as an animation AFTER .in-view lands, never as a resting
   state: clip-path zeroes an element's intersection rectangle, so a
   clipped element can never trigger the observer that would unclip it.
   Six elements on this page were invisible in the browser because of it. */
.js .reveal-mask.in-view {
  opacity: 1;
  animation: c2c-wipe 720ms var(--ease) both;
  animation-delay: var(--reveal-delay, 0ms);
}
@keyframes c2c-wipe {
  from { clip-path: inset(0 0 100% 0); opacity: 0; }
  to   { clip-path: inset(0 0 0 0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .js .reveal, .js .reveal-rise, .js .reveal-left, .js .reveal-right, .js .reveal-mask {
    opacity: 1;
    transform: none;
    clip-path: none;
    transition: none;
  }
  .label::after { transform: scaleX(1); }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── Accessibility floor ─────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-ocean);
  outline-offset: 3px;
  border-radius: 2px;
}
.on-dark :focus-visible { outline-color: var(--color-sand); }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100%;
  z-index: 200;
  padding: 0.75rem 1.25rem;
  background: var(--color-ocean);
  color: var(--color-on-dark);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--dur-fast) var(--ease-ui);
}
.skip-link:focus { top: 1rem; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Editorial subheadline / pull quote ──────────────────────── */
.said {
  font-family: var(--font-heading);
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.25rem, 1.05rem + 0.85vw, 1.6rem);
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: var(--color-ocean);
  text-wrap: balance;
}

/* ── Script voice device: exactly two instances on the page ──── */
.script {
  font-family: var(--font-script);
  font-size: var(--fs-script);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: 0;
  color: var(--color-coastline-ink);
}
.on-dark .script { color: var(--color-sand); }
