/* Shared foundation for every page: tokens, base, type scale, layout rhythm, media
   surfaces, reveal motion, back/next links and the footer. Loaded before each page's
   own <style>, so a page only defines what is unique to it. The header capsule lives
   in css/header.css. */

/* ============ TOKENS ============ */
:root {
  /* canvas */
  --bg: #ffffff;
  --bg-sage: #e7ebe6;
  --bg-sand: #ede9d0;
  --bg-deep: #e3dcc0;
  --card: #fcfcfa;

  /* ink */
  --ink: #0A3323;
  --ink-2: #2d3828;
  --body: #3a4835;
  --muted: #6b7860;
  --label: #7a8770;

  /* accents */
  --teal: #105666;
  --sage: #839958;
  --clay: #D4714A;

  /* lines */
  --line: rgba(10,51,35,.12);
  --line-soft: rgba(10,51,35,.07);
  --line-card: rgba(10,51,35,.09);

  /* type */
  --font-serif: 'Newsreader', Georgia, serif;
  --font-display: 'Sora', 'Inter Tight', system-ui, sans-serif;
  --font-sans: 'Hanken Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --fs-h1: clamp(40px, 6vw, 72px);
  --fs-h2: clamp(28px, 3.6vw, 44px);
  --fs-h3: 22px;
  --fs-lead: clamp(17px, 1.7vw, 20px);
  --fs-body: 16px;
  --fs-label: 12px;
  --fs-caption: 12px;

  /* layout */
  /* one edge for all text and media: 6vw from each side of the window, 20px on phones */
  --gutter: 6vw;
  --section-y: clamp(64px, 8vw, 104px);
  --block-gap: clamp(32px, 4vw, 48px);
  --col-gap: clamp(38.4px, 6vw, 76.8px);
  --card-pad: 28px;
  --header-clear: 72px;

  /* surfaces */
  --r-sm: 10px;
  --r-card: 14px;
  --r-media: 16px;
  --r-box: 20px;
  --shadow-media: 0 24px 56px -28px rgba(10,51,35,.36);
  --shadow-media-lg: 0 36px 80px -40px rgba(10,51,35,.46);
  --shadow-box: 0 26px 60px -34px rgba(10,51,35,.15);
  --shadow-lift: 0 18px 40px -22px rgba(10,51,35,.28);
  --image-outline: oklch(0 0 0 / .1);

  /* motion */
  --ease: cubic-bezier(.22,.61,.36,1);
}

/* ============ BASE ============ */
*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: clip; scroll-behavior: smooth; scroll-padding-top: 88px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
::selection { background: #ddd9b0; color: var(--ink); }
a { -webkit-tap-highlight-color: transparent; }
img, video { max-width: 100%; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* ============ LAYOUT ============ */
.wrap, .rp-wrap { margin: 0; padding-left: var(--gutter); padding-right: var(--gutter); }
.pad, .section { padding-top: var(--section-y); padding-bottom: var(--section-y); }
.section + .section { border-top: 1px solid var(--line-soft); }
.bg-sage { background: var(--bg-sage); }
.bg-deep { background: var(--bg-deep); }
.prose { max-width: 66ch; }

/* back link rows above the hero and above the footer */
.back-row { padding-top: var(--header-clear); }
.back-row--end { padding-top: 0; padding-bottom: 40px; }

/* ============ TYPE ============ */
h1 {
  font-family: var(--font-display); font-weight: 400;
  font-size: var(--fs-h1); line-height: 1.04; letter-spacing: -.04em;
  margin: 0 0 24px; max-width: 20ch; text-wrap: balance;
}
h2 {
  font-family: var(--font-display); font-weight: 300;
  font-size: var(--fs-h2); line-height: 1.1; letter-spacing: -.035em;
  margin: 0 0 20px; color: inherit; text-wrap: balance;
}
h3 {
  font-family: var(--font-display); font-weight: 400;
  font-size: var(--fs-h3); line-height: 1.3; letter-spacing: -.02em;
  margin: 0 0 12px; color: var(--ink);
}
.eyebrow {
  font-family: var(--font-mono); font-size: var(--fs-label); font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--teal); margin-bottom: 20px;
}
.eyebrow--warm { color: var(--clay); }
.section-label {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--label); margin-bottom: 16px;
}
.lead { font-size: var(--fs-lead); line-height: 1.6; color: var(--ink-2); max-width: 58ch; margin: 0; text-wrap: pretty; }
.body-lg, .body-text, .body-sm { font-size: var(--fs-body); line-height: 1.7; color: var(--body); text-wrap: pretty; }
.body-text { max-width: 66ch; }
.body-sm { line-height: 1.6; }
.body-lg strong, .body-text strong { font-weight: 600; color: var(--ink); }
.body-lg strong.accent { color: var(--teal); }
.body-text + .body-text { margin-top: 16px; }
.img-caption {
  font-family: var(--font-mono); font-size: var(--fs-caption); line-height: 1.55;
  letter-spacing: .02em; color: var(--label); margin: 12px 0 0; text-wrap: pretty;
}
.img-caption--center { text-align: center; }

/* ============ CASE STUDY HERO ============ */
.hero { position: relative; padding: clamp(40px, 6vw, 72px) 0 var(--block-gap); }
.meta, .meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 24px 32px; padding: 28px 0; margin: 40px 0 0;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.meta-lbl {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: .1em; text-transform: uppercase; color: var(--label); margin-bottom: 8px;
}
.meta-val { font-size: 15px; line-height: 1.5; color: var(--ink); }

/* ============ MEDIA SURFACES ============ */
.cs-img, .media {
  display: block; width: 100%; height: auto;
  border-radius: var(--r-media); box-shadow: var(--shadow-media);
  outline: 1px solid var(--image-outline); outline-offset: -1px;
}
.cs-img--hero { box-shadow: var(--shadow-media-lg); margin: 0; }
.cs-img--sm, .cs-img--flat { box-shadow: 0 16px 40px -22px rgba(10,51,35,.3); }

/* framed product image: a tinted panel around a screenshot (from the Scenario Catalog page) */
.showcase {
  position: relative; margin-top: var(--block-gap);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: clamp(26px, 5vw, 56px); border-radius: var(--r-box);
  background: rgba(236,230,212,.7); border: 1px solid rgba(10,51,35,.06);
  box-shadow: var(--shadow-box);
}
.showcase img { display: block; width: 66.666%; height: auto; border-radius: var(--r-sm); }
.showcase--sage { background: rgba(215,221,211,.7); }
/* a screen recording inside the frame, with its play/pause pill underneath */
.vid-box { position: relative; display: flex; flex-direction: column; align-items: center; width: 100%; }
.vid-box .vid-wrap { position: relative; width: 66.666%; line-height: 0; border-radius: var(--r-sm); overflow: hidden; box-shadow: 0 14px 30px -16px rgba(10,51,35,.28); }
.vid-box .vid-wrap video { display: block; width: 100%; height: auto; }
.vid-box > .vid-ctrl {
  position: static; display: flex; justify-content: center; padding: 16px 0 0; background: none;
  opacity: 0; transition: opacity .25s;
}
.vid-box:hover > .vid-ctrl, .vid-box:focus-within > .vid-ctrl { opacity: 1; }
@media (hover: none) { .vid-box > .vid-ctrl { opacity: 1; } }
.vid-box .vid-btn {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; color: var(--ink);
  padding: 7px 18px; border-radius: 20px; cursor: pointer;
  background: rgba(10,51,35,.06); border: 1px solid rgba(10,51,35,.14);
  -webkit-backdrop-filter: none; backdrop-filter: none; transition: background-color .2s;
}
@media (hover: hover) { .vid-box .vid-btn:hover { background: rgba(10,51,35,.12); } }
@media (max-width: 640px) { .showcase img, .vid-box .vid-wrap { width: 80%; } }

/* masking tape label pinned to a media corner ("Pending Patent", etc.) */
.tape-tag {
  position: absolute; top: -16px; left: 28px; z-index: 2;
  display: inline-block; padding: 7px 14px; border-radius: 3px;
  background: var(--bg-sage); color: var(--teal);
  border: 1px solid rgba(16,86,102,.12);
  font-family: var(--font-mono); font-size: 10px; font-weight: 500;
  letter-spacing: .13em; text-transform: uppercase;
  box-shadow: 2px 4px 14px rgba(16,86,102,.18), 0 1px 3px rgba(0,0,0,.1);
  transform: rotate(-3deg); transform-origin: top left; pointer-events: none;
}
.tape-tag__tape {
  position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  display: block; width: 32px; height: 13px; border-radius: 2px;
  background: rgba(16,86,102,.1);
}

/* lift on hover, only where a real pointer can hover */
.img-hover, .cs-img { transition: transform .45s var(--ease), box-shadow .45s var(--ease); }
@media (hover: hover) {
  .img-hover:hover { transform: translateY(-4px); }
  .cs-img:hover { transform: translateY(-4px); box-shadow: var(--shadow-media-lg); }
}

/* ============ BUTTONS (page level; the header scopes its own) ============ */
.rp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-sans); font-size: 14px; font-weight: 500; line-height: 1;
  color: var(--ink-2); text-decoration: none;
  height: 40px; padding: 0 18px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.6);
  border: 1px solid rgba(10,51,35,.08);
  box-shadow: 0 4px 14px -7px rgba(10,51,35,.22);
  transition-property: transform, background-color, box-shadow, color, filter;
  transition-duration: .25s; transition-timing-function: var(--ease);
}
.rp-btn--warm { background: linear-gradient(135deg, var(--teal), var(--sage)); color: #fff; border-color: transparent; }
.rp-ext { font-size: 13px; display: inline-block; transition: transform .28s var(--ease); }
.rp-btn:active { transform: scale(.96); transition-duration: .15s; transition-timing-function: ease-out; }
@media (hover: hover) {
  .rp-btn:hover { transform: translateY(-2px); background: #fff; color: var(--ink); box-shadow: 0 14px 28px -10px rgba(10,51,35,.32); }
  .rp-btn--warm:hover { background: linear-gradient(135deg, var(--teal), var(--sage)); color: #fff; filter: brightness(1.08); }
  .rp-btn:hover .rp-ext { transform: translate(3px,-3px); }
}

/* ============ BACK / NEXT ============ */
.back {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: var(--fs-label); letter-spacing: .06em;
  color: var(--teal); text-decoration: none;
  border-bottom: 1px solid rgba(16,86,102,.3); padding-bottom: 3px;
  transition: border-color .25s;
}
.back:hover { border-bottom-color: rgba(16,86,102,.9); }
.back__arrow, .next-link__arrow { display: inline-block; transition: transform .3s var(--ease); }
.back:hover .back__arrow { transform: translateX(-4px); }

.next-project { text-align: center; padding: clamp(56px, 7vw, 88px) 0; margin-top: var(--section-y); border-top: 1px solid var(--line-soft); }
.next-label {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  letter-spacing: .14em; text-transform: uppercase; color: var(--label); margin-bottom: 16px;
}
.next-link {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-size: clamp(22px, 3vw, 32px); font-weight: 400;
  letter-spacing: -.03em; color: var(--ink); text-decoration: none; text-wrap: balance;
  border-bottom: 2px solid rgba(16,86,102,.3); padding-bottom: 4px;
  transition: border-color .25s, color .25s;
}
.next-link:hover { color: var(--teal); border-bottom-color: var(--teal); }
.next-link:hover .next-link__arrow { transform: translateX(5px); }

/* ============ FOOTER ============ */
.rp-footer { width: 100%; background: var(--bg-sand); border-top: 1px solid var(--line-soft); padding: 40px 0; }
.rp-footer__inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px; }
.rp-footer__name {
  font-family: var(--font-display); font-weight: 400; font-size: 18px; letter-spacing: -.02em;
  color: #3d4d38; text-decoration: none; transition: color .25s;
}
.rp-footer__name:hover { color: var(--teal); }
.rp-footer__nav { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.rp-fbtn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 500; color: var(--ink-2); text-decoration: none;
  height: 40px; padding: 0 18px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.6); border: 1px solid rgba(10,51,35,.08);
  transition-property: transform, background-color, box-shadow;
  transition-duration: .25s; transition-timing-function: var(--ease);
}
.rp-fbtn:active { transform: scale(.96); transition-duration: .15s; transition-timing-function: ease-out; }
@media (hover: hover) {
  .rp-fbtn:hover { transform: translateY(-2px); background: #fff; box-shadow: 0 12px 24px -12px rgba(10,51,35,.3); }
}

/* reading progress (filled by js/header.js) */
#rp-prog {
  position: fixed; top: 0; left: 0; z-index: 200;
  height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--teal) 0%, var(--sage) 60%, var(--clay) 100%);
  pointer-events: none;
}

/* ============ REVEAL ============
   Pages use one of three hooks; all share one motion: a 16px rise and fade.
   .rv / .rv2 / .rv3 run once on load, 100ms apart. The rest wait for
   IntersectionObserver to add .is-visible / .is-in / .visible.
   Under reduced motion everything only fades. */
@keyframes revealUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes revealFade { from { opacity: 0; } to { opacity: 1; } }
.rv, .rv2, .rv3 { animation: revealUp .8s var(--ease) both; }
.rv2 { animation-delay: .1s; }
.rv3 { animation-delay: .2s; }

.reveal, [data-reveal], .reveal-group > *, [data-reveal-group] > * {
  opacity: 0; transform: translateY(16px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
}
.reveal.is-visible, .reveal.is-in, [data-reveal].visible,
.reveal-group.is-visible > *, [data-reveal-group].visible > * { opacity: 1; transform: none; }
.reveal-group.is-visible > :nth-child(2), [data-reveal-group].visible > :nth-child(2) { transition-delay: .1s; }
.reveal-group.is-visible > :nth-child(3), [data-reveal-group].visible > :nth-child(3) { transition-delay: .2s; }
.reveal-group.is-visible > :nth-child(4), [data-reveal-group].visible > :nth-child(4) { transition-delay: .3s; }
.reveal-group.is-visible > :nth-child(n+5), [data-reveal-group].visible > :nth-child(n+5) { transition-delay: .4s; }

@media (prefers-reduced-motion: reduce) {
  .rv, .rv2, .rv3 { animation-name: revealFade; }
  .reveal, [data-reveal], .reveal-group > *, [data-reveal-group] > * { transform: none; transition: opacity .4s ease-out; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 640px) {
  :root { --gutter: 20px; --header-clear: 64px; }
  .meta, .meta-grid { grid-template-columns: 1fr 1fr; gap: 16px; }
  .rp-footer { padding: 32px 0; }
  .rp-footer__inner { flex-direction: column; align-items: flex-start; gap: 16px; }
  .rp-footer__nav { justify-content: flex-start; gap: 8px; }
  .rp-fbtn { height: 36px; padding: 0 14px; font-size: 13px; }
}
