/* ==========================================================================
   APPROACH PAGE · Part One: Our philosophies
   --------------------------------------------------------------------------
   One illustration in three states, with the text on the left and the art on
   the right (stacked on small screens). scripts/philosophy.js drives the
   tabs, the directed transition videos and the text choreography.
   ========================================================================== */

:root {
  /* ONE ivory for the page, the art container, all six videos and all three stills.
     Every media file's background was normalised to the ivory H.264 can carry
     exactly; measured in Chrome over every frame of all six videos (1440, 1920,
     retina, 390) it renders as 254.96 · 244.02 · 238.06, i.e. #FFF4EE.
     (Tools: tools/normalize_bg.py; docs/APPROACH-PHILOSOPHIES.md.)
     Previously #FEF3EE, which encoded video cannot hit exactly. */
  --phil-ivory: #FFF4EE;
  /* The one canvas for the upper Approach page: root, main, philosophies and the
     development forms all paint this, so there is no seam between them. */
  --approach-canvas: var(--phil-ivory);
  --phil-ink: var(--c-ink);
  --phil-soft: #4F474C;            /* 8.3:1 on --phil-ivory */
  --phil-faint: #6E6469;           /* 5.3:1, labels and numerals only */
  --phil-rule: rgb(20 18 21 / 0.16);
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.page-approach main { background: var(--approach-canvas); }
/* the scrollbar gutter shows the root background: make it the page ivory here */
html:has(body.page-approach) { background: var(--approach-canvas); }
.nowrap { white-space: nowrap; }

/* ---------- Section ------------------------------------------------------ */
.phil {
  background: var(--approach-canvas);
  color: var(--phil-ink);
  /* bottom kept short: the development forms continue on the same canvas below */
  padding-block: clamp(2.5rem, 1rem + 5vw, 6.5rem) 0;
}
.phil :focus-visible { outline: 2px solid var(--light-focus); outline-offset: 4px; }

.phil__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-inline: var(--gutter);
  display: grid;
  /* Desktop: text left, art right. The art takes the larger share and is
     capped so the whole 4:3 composition fits comfortably on screen. */
  grid-template-columns: minmax(19rem, 5fr) minmax(0, 7fr);
  grid-template-areas:
    ".     art"
    "head  art"
    "tabs  art"
    "panel art"
    ".     art";
  grid-template-rows: 1fr auto auto auto 1fr;
  column-gap: clamp(2.5rem, 1rem + 4.5vw, 7rem);
  align-items: start;
}
.phil__head  { grid-area: head; }
.phil__tabs  { grid-area: tabs; }
.phil__panels { grid-area: panel; }
.phil__art   { grid-area: art; }

/* ---------- Headings ---------------------------------------------------- */
.phil__page {
  margin: 0 0 0.9rem;
  font-family: var(--font-sans);
  font-size: var(--fs-eyebrow);
  font-weight: 500;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--phil-faint);
}
.phil__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--fs-h3);
  line-height: 1.2;
  color: var(--phil-soft);
}

/* ---------- Selectors: a restrained numbered index ---------------------- */
.phil__tabs {
  position: relative;
  display: flex;
  gap: clamp(1.25rem, 0.5rem + 1.6vw, 2.25rem);
  margin: clamp(1.75rem, 1rem + 1.6vw, 2.75rem) 0 clamp(2rem, 1rem + 2.2vw, 3.25rem);
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--phil-rule);
}
.phil__tab {
  display: inline-flex;
  align-items: baseline;
  gap: 0.55em;
  min-height: 2.75rem;
  margin: 0;
  padding: 0.35rem 0;
  border: 0;
  background: none;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  letter-spacing: 0.01em;
  color: var(--phil-soft);
  cursor: pointer;
  transition: color 280ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.phil__tab-num {
  font-size: 0.75em;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: var(--phil-faint);
  transition: color 280ms var(--ease-out);
}
.phil__tab[aria-selected="true"] { color: var(--phil-ink); }
.phil__tab[aria-selected="true"] .phil__tab-num { color: var(--c-orange); }
@media (hover: hover) and (pointer: fine) {
  .phil__tab:hover { color: var(--phil-ink); }
}
.phil__tab:active { transform: scale(0.98); }
.phil__tab:focus-visible { outline-offset: 2px; border-radius: 2px; }

/* The selected tab is marked by a short ink thread on the rule (the orange
   numeral carries the colour). It glides between tabs. */
.phil__thread {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: var(--thread-w, 0px);
  background: var(--phil-ink);
  transform: translateX(var(--thread-x, 0px));
  transition: transform 640ms var(--ease-in-out), width 640ms var(--ease-in-out);
}

/* ---------- Text panels -------------------------------------------------- */
/* All three panels share one grid cell, so the column never changes height
   as the text changes (the longest paragraph sets it). */
.phil__panels { display: grid; }
.phil__panel {
  grid-area: 1 / 1;
  max-width: 34rem;
}
.phil__panel:not(.is-active):not(.is-leaving) { visibility: hidden; }
.phil__panel:focus-visible { outline-offset: 8px; border-radius: 2px; }
.phil__num {
  margin: 0 0 0.7rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  color: var(--phil-faint);
}
.phil__heading {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2rem, 1.3rem + 2vw, 3.25rem);
  line-height: 1.06;
  letter-spacing: -0.012em;
  text-wrap: balance;
}
.phil__sub {
  margin: 0.75rem 0 0;
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.1875rem, 1.05rem + 0.45vw, 1.4375rem);
  line-height: 1.3;
  color: var(--phil-soft);
}
.phil__body {
  margin: clamp(1.25rem, 0.9rem + 1vw, 1.75rem) 0 0;
  /* 18 px at 1440, ≈19 px at 1920, 20 px max; the column width is unchanged */
  font-size: clamp(var(--fs-lede), 0.9rem + 0.25vw, 1.25rem);
  line-height: 1.65;
  color: var(--phil-soft);
  text-wrap: pretty;
}

/* ---------- Artwork ------------------------------------------------------ */
.phil__art {
  position: relative;
  margin: 0;
  width: 100%;
  /* keep the full 4:3 composition on screen beside the text */
  max-width: calc((100svh - var(--header-h) - 3rem) * 4 / 3);
  justify-self: end;
  aspect-ratio: 4 / 3;
  background: var(--phil-ivory);
  overflow: hidden;
  /* The backgrounds now match exactly (see --phil-ivory). This 3 px hairline is only a
     safety margin for sub-level rounding; lines touching the edge stay intact. */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 3px, #000 calc(100% - 3px), transparent),
                      linear-gradient(to bottom, transparent, #000 3px, #000 calc(100% - 3px), transparent);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(to right, transparent, #000 3px, #000 calc(100% - 3px), transparent),
                      linear-gradient(to bottom, transparent, #000 3px, #000 calc(100% - 3px), transparent);
          mask-composite: intersect;
}
.phil__still,
.phil__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}
.phil__still { opacity: 0; }
.phil__still.is-shown { opacity: 1; }
/* Static switching (reduced motion, Still mode, or a video that cannot load) */
.phil__still.is-fading { transition: opacity 420ms var(--ease-quiet); }
.phil__video { opacity: 0; visibility: hidden; }
.phil__video.is-shown { opacity: 1; visibility: visible; }
/* nearly imperceptible handoffs between near-identical frames */
.phil__video.is-in  { transition: opacity 140ms linear, visibility 0s; }
.phil__video.is-out { transition: opacity 200ms linear, visibility 0s 200ms; }

/* ---------- Tablet ------------------------------------------------------- */
@media (max-width: 1100px) {
  .phil__inner { grid-template-columns: minmax(17rem, 1fr) minmax(0, 1.25fr); column-gap: clamp(2rem, 4vw, 3rem); }
}

/* ---------- Stacked (portrait tablets and phones) ----------------------- */
@media (max-width: 860px) {
  .phil__inner {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "head" "art" "tabs" "panel";
    grid-template-rows: none;
  }
  .phil__head { margin-bottom: clamp(1.5rem, 4vw, 2.25rem); }
  .phil__art {
    max-width: none;
    justify-self: stretch;
    /* bleed to the screen edges on phones; the art has its own margin */
    width: calc(100% + 2 * var(--gutter));
    margin-inline: calc(-1 * var(--gutter));
  }
  /* art, tabs and text read as one unit on small screens */
  .phil__tabs { margin-top: clamp(0.75rem, 3vw, 1.5rem); margin-bottom: clamp(1.25rem, 4vw, 2rem); }
  .phil__panel { max-width: 40rem; }
}
@media (max-width: 560px) {
  .phil__tabs { gap: 0; justify-content: space-between; }
  .phil__tab {
    flex: 1 1 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    font-size: 0.9375rem;
  }
  .phil__tab-num { font-size: 0.75rem; }
}

/* ---------- Reduced motion ---------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .phil__thread, .phil__tab, .phil__tab-num { transition: none; }
}

/* ---------- Review switch (footer) -------------------------------------- */
.page-approach .layout-switch button[aria-pressed="true"] {
  color: var(--dark-text);
  text-decoration: underline;
  text-underline-offset: 0.25em;
}
