/* Latin variable fonts from Google Fonts, served locally with the site. */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("/assets/fonts/space-grotesk-latin-variable.woff2") format("woff2");
}

@font-face {
  font-family: "DM Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/dm-sans-latin-variable.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --font-heading: "Space Grotesk", system-ui, sans-serif;
  --font-body: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --color-paper: #faf9f6;
  --color-background: #292827;
  --color-footer: #eae7e1;
  --color-ink: #242322;
  --color-muted: #65615d;
  --color-accent: #a71b56;
  --color-rule: #dedad4;
  --surface-radius: 4px;
  --surface-edge: linear-gradient(
    to bottom left,
    rgb(255 255 255 / 100%),
    rgb(255 255 255 / 95%) 30%,
    rgb(255 255 255 / 55%) 55%,
    rgb(52 42 30 / 4%) 75%,
    rgb(52 42 30 / 18%)
  );
  --content-width: 64rem;
  --prose-width: 62ch;
  --gutter: clamp(1.25rem, calc(0.45rem + 4vw), 3rem);
  --surface-margin: clamp(0.5rem, calc(4.5vw - 0.4rem), 2.5rem);
  --paper-texture: url("/assets/paper-grain.svg");
  --section-space: clamp(3rem, 7vw, 6rem);
  --header-padding: clamp(1.5rem, calc(1.25rem + 1.25vw), 2rem);
  /* Reach the viewport edges on small screens, tapering to a 2% overhang. */
  --header-expanded-width: clamp(102%, calc(100% + 4rem - 8vw), 100vw);
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html {
  overflow-x: clip;
  scroll-snap-type: y mandatory;
  scroll-padding-block-start: var(--snap-header-height, calc(var(--header-padding) * 2 + 2.75rem + 1rem));
  background: var(--paper-texture) repeat, var(--color-background);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-optical-sizing: auto;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}
html[data-scroll-snap="off"] { scroll-snap-type: none; }
body {
  inline-size: min(72rem, calc(100% - var(--surface-margin) * 2));
  margin: var(--surface-margin) auto 0;
  isolation: isolate;
  font-size: 1rem;
}
img { display: block; max-inline-size: 100%; block-size: auto; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-heading); text-wrap: balance; }
h1, h2 {
  max-inline-size: 14ch;
  font-size: clamp(2.5rem, 1.5rem + 4vw, 5rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.06;
}
h3 { font-size: 1.125rem; line-height: 1.35; letter-spacing: -0.02em; }
p { overflow-wrap: break-word; }
a { color: inherit; text-decoration-thickness: 0.075em; text-underline-offset: 0.22em; }
a:hover { color: var(--color-accent); }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 5px; }
::selection { background: #f0c8da; color: var(--color-ink); }
[hidden] { display: none !important; }
.container { inline-size: min(var(--content-width), calc(100% - var(--gutter) * 2)); margin-inline: auto; }

/* Keep the existing sticky header and independently expanding paper surface. */
.site-header { position: sticky; inset-block-start: 0; z-index: 5; padding-block: var(--header-padding); }
.site-header-inner { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem 1.5rem; }
.site-header::before {
  content: ""; position: absolute; z-index: -1; inset-block: 0; inset-inline-start: 50%;
  inline-size: 100%; transform: translateX(-50%); pointer-events: none;
  background: var(--paper-texture) repeat, var(--color-paper); border-radius: var(--surface-radius);
}
.site-header::after { opacity: 0; }
.site-header::before, .site-header::after {
  --header-bottom-radius: clamp(0px, calc((100vw - 100%) / 2), var(--surface-radius));
  border-bottom-left-radius: var(--header-bottom-radius);
  border-bottom-right-radius: var(--header-bottom-radius);
}
@supports (animation-timeline: scroll()) and (animation-range: 0px 1px) {
  .site-header::before, .site-header::after {
    animation: header-elevation linear both, header-corners linear both;
    animation-timeline: scroll(root block), scroll(root block);
    animation-range: var(--surface-margin) calc(var(--surface-margin) + 3rem), 0px var(--surface-margin);
  }
  .site-header::after { animation-name: header-emboss, header-corners; }
}
@keyframes header-corners {
  from { border-top-left-radius: var(--surface-radius); border-top-right-radius: var(--surface-radius); }
  to { border-top-left-radius: 0; border-top-right-radius: 0; }
}
@keyframes header-elevation {
  from { inline-size: 100%; box-shadow: 0 2px 4px rgb(52 42 30 / 0%), 0 12px 24px -12px rgb(52 42 30 / 0%); }
  to { inline-size: var(--header-expanded-width); box-shadow: 0 2px 4px rgb(52 42 30 / 3%), 0 12px 24px -12px rgb(52 42 30 / 10%); }
}
@keyframes header-emboss {
  from { inline-size: 100%; opacity: 0; }
  to { inline-size: var(--header-expanded-width); opacity: 1; }
}
.identity { display: inline-flex; align-items: center; gap: 0.75rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
nav { display: flex; gap: clamp(0.75rem, 2vw, 1.5rem); }
nav a { display: inline-flex; align-items: center; min-block-size: 2.75rem; text-decoration: none; }
nav a[aria-current] { color: var(--active-accent, var(--color-accent)); }
.site-header nav { gap: clamp(0.75rem, 2vw, 1.5rem); }

/* Equal framing above/below each card preserves the header/footer reveal.
   Long copy scrolls within the available card space. */
.card-deck { position: relative; }
.page-surface > main.intro { padding-block: var(--section-space); }
.card-deck:focus-visible { outline-offset: -4px; }
.scene-card {
  --ribbon-size: clamp(6rem, min(48vw, calc((100svh - var(--snap-header-height, 8rem) * 2) * 0.4)), 11rem);
  --section-accent: #9b184b;
  --ribbon-start: #cf0e66;
  --ribbon-end: #ff9c06;
  --color-accent: var(--section-accent);
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-content: stretch;
  align-items: center;
  gap: 1.5rem;
  min-inline-size: 0;
  block-size: calc(100svh - var(--snap-header-height, 8rem) * 2);
  min-block-size: 12rem;
  inline-size: min(var(--content-width), calc(100% - var(--gutter) * 2));
  margin-inline: auto;
  padding-block: clamp(1rem, 2.5vw, 2.5rem);
  scroll-snap-align: start;
}
.scene-card > .card-copy > :is(h1, h2) { color: var(--color-ink); }
#about { --section-accent: #116a66; --ribbon-start: #158e83; --ribbon-end: #8accb9; }
#work { --section-accent: #234d96; --ribbon-start: #355fc1; --ribbon-end: #a0b9ef; }
#contact { --section-accent: #683e85; --ribbon-start: #9261b7; --ribbon-end: #d4b2e2; }
.scene-card:first-child { scroll-margin-block-start: calc(var(--surface-margin) + 1.5rem); }
.page-surface {
  position: relative; z-index: 1;
  min-block-size: calc(100svh - var(--surface-margin));
  background: var(--paper-texture) repeat, var(--color-paper);
  border-radius: var(--surface-radius);
  box-shadow: 0 1px 2px rgb(52 42 30 / 5%), 0 8px 24px rgb(52 42 30 / 4%), 0 24px 64px rgb(52 42 30 / 3%);
}
.page-surface::after, .site-header::after {
  content: ""; position: absolute; z-index: 1; inset-block: 0; inset-inline-start: 50%;
  inline-size: 100%; transform: translateX(-50%); padding: 1px; border-radius: var(--surface-radius);
  background: var(--surface-edge);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude; pointer-events: none;
}
.site-header::after {
  border-bottom-left-radius: var(--header-bottom-radius);
  border-bottom-right-radius: var(--header-bottom-radius);
}
.card-copy { position: relative; z-index: 3; min-inline-size: 0; min-block-size: 0; max-block-size: 100%; max-inline-size: 39rem; overflow-y: auto; scrollbar-width: thin; padding-inline-end: 0.75rem; }
.eyebrow { margin-block-end: 1.5rem; color: var(--color-muted); font-size: 0.8125rem; }
.lead { max-inline-size: 36ch; margin-block-start: 1.75rem; color: var(--color-muted); font-size: clamp(1.125rem, 1rem + 0.6vw, 1.5rem); line-height: 1.5; text-wrap: pretty; }
.text-link { display: inline-block; margin-block-start: 2rem; font-size: 0.9375rem; }
.prose { max-inline-size: var(--prose-width); margin-block-start: 1.5rem; }
.prose > * + * { margin-block-start: 1.25em; }
.scene-card.home-projects > .card-copy { grid-column: 1 / -1; max-inline-size: none; padding-inline-end: 0; }
.home-projects h2 { max-inline-size: none; }
.home-projects .eyebrow { margin-block-end: 1rem; }
.home-project-list {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(0.875rem, 3vw, 2rem); padding: 0;
  margin: clamp(1rem, 3vw, 2.25rem) 0 0; list-style: none;
}
.home-project-link { display: block; text-decoration: none; }
.home-project-link:focus-visible { outline-offset: -2px; }
.home-project-link img { inline-size: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--surface-radius); }
.home-project-link h3 { margin-block-start: 0.75rem; font-size: clamp(1.125rem, 1rem + 1vw, 1.55rem); }
.home-project-list p { max-inline-size: 44ch; margin-block-start: 0.35rem; color: var(--color-muted); font-size: clamp(0.875rem, 0.82rem + 0.2vw, 1rem); line-height: 1.5; }
.home-projects .text-link { margin-block-start: clamp(1rem, 2vw, 1.75rem); }

/* The intro anchors the monogram. Later curves follow their card headings. */
.ribbon-stage {
  position: relative;
  grid-row: 2;
  display: grid;
  place-items: center;
  inline-size: var(--ribbon-size);
  aspect-ratio: 1;
  block-size: auto;
  min-block-size: 0;
  min-inline-size: 0;
  margin: 0 auto;
  pointer-events: none;
}
.ribbon-stage img { inline-size: 100%; block-size: 100%; object-fit: contain; }
.intro { grid-template-rows: minmax(0, 1fr) auto; }
.ribbon-fallback { position: absolute; inset-inline-end: calc(var(--gutter) * -1); inset-block-start: calc(50% - var(--ribbon-size) / 2 - 3rem); inline-size: min(72rem, calc(100vw - var(--surface-margin) * 2)); block-size: 10rem; overflow: visible; pointer-events: none; }
.ribbon-color-start { stop-color: var(--ribbon-start); }
.ribbon-color-end { stop-color: var(--ribbon-end); }
.ribbon-active :is(.ribbon-stage img, .ribbon-fallback) { visibility: hidden; }
@media (prefers-reduced-motion: no-preference) {
  [data-ribbon-startup="pending"] :is(.ribbon-stage img, .ribbon-fallback) { visibility: hidden; }
}
.ribbon-layer { position: fixed; inset: 0; z-index: 2; pointer-events: none; }

/* Temporary authoring guides; the toggle changes no layout or GL geometry. */
[data-ribbon-debug="true"] .ribbon-stage {
  z-index: 1;
  outline: 1px dashed #087f83;
  background: linear-gradient(90deg, #087f830c 1px, transparent 1px), linear-gradient(#087f830c 1px, transparent 1px);
  background-size: 10% 10%;
}
[data-ribbon-debug="true"] .ribbon-stage::before {
  content: attr(data-ribbon-label) " · " attr(data-ribbon-layout);
  position: absolute; inset-block-end: calc(100% + 5px); inset-inline-start: 0;
  color: #086b6f; font: 11px/1.4 var(--font-body); white-space: nowrap;
}
[data-ribbon-debug="true"] .ribbon-stage::after {
  content: ""; position: absolute; inset: 50% auto auto 50%;
  inline-size: 6px; block-size: 6px; border-radius: 50%; transform: translate(-50%, -50%);
  background: #087f83; box-shadow: 0 0 0 2px var(--color-paper);
}
.ribbon-route-debug { display: none; position: fixed; inset: 0; inline-size: 100%; block-size: 100%; z-index: 4; pointer-events: none; overflow: hidden; }
[data-ribbon-debug="true"] .ribbon-route-debug { display: block; }
.route-guide { fill: none; stroke: #087f83; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.9; }
.route-guide-connector, .route-guide-entrance { stroke: #8d55c4; stroke-dasharray: 5 5; opacity: 0.7; }
.ribbon-debug-toggle {
  position: fixed; z-index: 6; inset-block-end: 0.75rem; inset-inline-start: 50%; transform: translateX(-50%);
  padding: 0.4rem 0.75rem; border: 1px solid var(--color-rule); border-radius: 1rem;
  background: var(--color-paper); color: #086b6f; font: 12px/1.4 var(--font-body);
  box-shadow: 0 2px 8px #342a1e12; cursor: pointer;
}

.footer-snap { block-size: 1px; margin-block-end: -1px; scroll-snap-align: start; }
.site-footer {
  position: sticky; inset-block-end: 0; z-index: 0;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.25rem 1.5rem;
  block-size: var(--snap-header-height, 8rem); min-block-size: 0; padding-block: 1rem;
  color: var(--color-footer); font-size: 0.875rem;
}
.site-footer:focus-within { position: relative; }
.site-footer a:hover { color: #fff; }
.site-footer :focus-visible { outline-color: var(--color-footer); }
.footer-links { display: flex; flex-wrap: wrap; gap: 0 clamp(0.5rem, 1.25vw, 1rem); }

@media (min-width: 40rem) { body { font-size: 1.125rem; } }
@media (min-width: 48rem) {
  .scene-card { grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .scene-card .card-copy { grid-column: 1; grid-row: 1; }
  .scene-card { --ribbon-size: clamp(6rem, min(22vw, calc((100svh - var(--snap-header-height, 8rem) * 2) * 0.5)), 17rem); }
  .intro .ribbon-stage { grid-column: 2; grid-row: 1; }
}
@media (prefers-reduced-motion: reduce) {
  :root { --header-expanded-width: 100%; }
  *, *::before, *::after { transition: none !important; }
}
