/* ==========================================================================
   Portfolio — shared styles
   Edit the tokens in :root to restyle the whole site.
   ========================================================================== */

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --ink: #222222;
  --ink-soft: #3a3832;
  --ink-faint: #8a877c;
  --line: #e2ded4;
  --accent: #3d5afe;

  --font-heading: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-body: "Helvetica Neue", Helvetica, Arial, sans-serif;

  --max: 1200px;
  --text: 680px;
  --gutter: clamp(20px, 5vw, 56px);
  --radius: 14px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }

a { color: inherit; }

::selection { background: var(--ink); color: var(--bg); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 12px;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: 8px;
  z-index: 100;
}
.skip-link:focus { left: 12px; }

.container {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.logo {
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  gap: clamp(16px, 3vw, 32px);
  font-size: 15px;
}
.nav a {
  text-decoration: none;
  color: var(--ink-soft);
  transition: color 0.15s;
}
.nav a:hover { color: var(--ink); }

/* ---------- Typography helpers ---------- */

.eyebrow {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 0 0 16px;
}

/* All headings use the heading font */
h1, h2, h3, h4, h5, h6, .display { font-family: var(--font-heading); font-weight: 700; text-wrap: balance; }

.display {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(40px, 6.8vw, 88px);
  line-height: 1.02;
  letter-spacing: -0.04em;
  margin: 0;
}
.display em { font-style: normal; color: var(--ink-faint); }

.section-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  margin: 0;
}

.lead {
  font-size: clamp(18px, 2vw, 21px);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 620px;
}

/* ---------- Buttons / links ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: transform 0.15s, opacity 0.15s;
}
.btn:hover { transform: translateY(-1px); opacity: 0.9; }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.arrow-link {
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
}

/* ---------- Dark theme ----------
   The same tokens, inverted. Used for the landing intro's top-mask window;
   add class="theme-dark" to any section to make it dark. */

.theme-dark {
  --bg: #16150f;
  --surface: #23221c;
  --line: #34332b;
  --ink: #f6f4ef;
  --ink-soft: #b5b2a7;
  --ink-faint: #8f8c81;
  background: var(--bg);
  color: var(--ink);
}

/* ---------- Intro (landing) ----------
   Without JS: a full-screen logo + line, then the statement as its own screen.
   With JS (.is-masked, set in main.js): the screen pins while the statement layer,
   clipped to the logo's top bar, grows to fill the viewport. */

/* The logo and the window that grows out of its top bar share one colour */
.intro { --intro-color: #222222; }

.intro-pin { position: relative; }
.intro + .section { border-top: 0; } /* the dark-to-light edge already divides them */

.intro-content {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: clamp(20px, 3vh, 32px);
  min-height: 100vh;
  min-height: 100svh;
  padding: 0 var(--gutter);
  text-align: center;
}

.intro-logo {
  margin: 0;
  line-height: 0;
  color: var(--intro-color);
}
.intro-logo svg {
  display: block;
  width: clamp(180px, 22vw, 300px);
  height: auto;
}

.intro-text {
  margin: 0;
  max-width: 19em;
  font-size: clamp(18px, 1.7vw, 22px);
  font-weight: 400;
  line-height: 1.35;
}

/* Scroll hint: a mouse outline whose wheel dot keeps rolling down */
.scroll-hint {
  position: relative;
  display: block;
  width: 26px;
  height: 40px;
  margin-top: clamp(8px, 2vh, 24px);
  border: 2px solid var(--intro-color);
  border-radius: 13px;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.scroll-hint-dot {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--intro-color);
  animation: scroll-hint 1.8s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}
@keyframes scroll-hint {
  0%   { transform: translateY(0);    opacity: 0; }
  20%  { opacity: 1; }
  70%  { transform: translateY(14px); opacity: 0; }
  100% { transform: translateY(14px); opacity: 0; }
}
/* Gone as soon as you start scrolling */
.scroll-hint.is-hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  .scroll-hint-dot { animation: none; }
}

.intro .intro-mask {
  background: var(--intro-color);
}
.intro-mask {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 0 var(--gutter);
  text-align: center;
}

.intro-statement {
  margin: 0;
  max-width: 24em;
  font-size: clamp(22px, 2.4vw, 32px);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.intro-statement strong { font-weight: 700; }

/* Outlined pills under the statement */
.pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: clamp(32px, 5vh, 56px) 0 0;
  padding: 0;
  list-style: none;
}
.pills li {
  padding: 0.95em 1.6em;
  border: 1.5px solid currentColor;
  border-radius: 999px;
  font-family: var(--font-heading);
  font-size: clamp(12px, 1vw, 14px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* The scroll effect. --intro-scroll is how far you scroll while the window grows. */
.intro.is-masked {
  --intro-scroll: 90vh;
  height: calc(100vh + var(--intro-scroll));
  height: calc(100svh + var(--intro-scroll));
}
.intro.is-masked .intro-pin {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}
.intro.is-masked .intro-content { height: 100%; }
.intro.is-masked .intro-mask {
  position: absolute;
  inset: 0;
  min-height: 0;
  background: none; /* the scaled layer below paints the dark window */
  pointer-events: none;
}
/*
  The window: a full-screen dark layer that js/main.js scales down to the bar and back up.
  Scaling (unlike clipping) runs on the graphics card, so it stays smooth on phones.
*/
.intro-mask-bg { display: none; }
.intro.is-masked .intro-mask-bg {
  display: block;
  position: absolute;
  inset: 0;
  background: var(--intro-color);
  transform-origin: 0 0;
  will-change: transform;
}
/* The window takes over from the bar, so hide the original */
.intro.is-masked .top-mask { opacity: 0; }
/* Statement and pills sit above the window; the script fades and lifts them in */
.intro.is-masked .intro-statement,
.intro.is-masked .pills {
  position: relative;
  opacity: 0;
  will-change: opacity, transform;
  pointer-events: auto;
}

/*
  Scroll-driven version (Safari 26+, Chrome 115+). The browser ties these animations
  straight to the scroll position, so the window can't lag behind your finger.
  js/main.js only measures the bar and fills in --bar-* and --intro-top.
  Browsers without support (Firefox for now) use the script-driven version instead.
*/
@supports (animation-timeline: scroll()) {
  .intro.is-scroll-driven .intro-mask-bg,
  .intro.is-scroll-driven .intro-statement,
  .intro.is-scroll-driven .pills {
    animation-duration: 1ms; /* required by some engines; the timeline sets the real pace */
    animation-fill-mode: both;
    animation-timeline: scroll(root block);
    animation-range: var(--intro-top, 0px) calc(var(--intro-top, 0px) + var(--intro-scroll));
  }
  .intro.is-scroll-driven .intro-mask-bg {
    animation-name: intro-window;
    animation-timing-function: cubic-bezier(0.65, 0, 0.35, 1); /* ease in and out */
  }
  .intro.is-scroll-driven .intro-statement {
    animation-name: intro-rise;
    animation-timing-function: linear;
    --rise: 40px;
  }
  .intro.is-scroll-driven .pills {
    animation-name: intro-rise;
    animation-timing-function: linear;
    --rise: 70px; /* the pills trail the statement */
  }
}
@keyframes intro-window {
  from { transform: translate3d(var(--bar-x), var(--bar-y), 0) scale(var(--bar-sx), var(--bar-sy)); }
  to   { transform: translate3d(0, 0, 0) scale(1, 1); }
}
/* The statement waits until the window is mostly open, then fades and rises in */
@keyframes intro-rise {
  0%, 55% {
    opacity: 0;
    transform: translate3d(0, var(--rise), 0);
    animation-timing-function: cubic-bezier(0.33, 0, 0.2, 1);
  }
  100% { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* ---------- Sections ---------- */

.section {
  padding: clamp(64px, 10vh, 120px) 0;
  border-top: 1px solid var(--line);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 48px;
}
.section-head p { margin: 0; color: var(--ink-soft); max-width: 360px; }

/* ---------- Project cards ---------- */

.work-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: clamp(24px, 3vw, 40px);
}

.card {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card-media {
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--surface);
  transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.card-media img,
.card-media .ph { width: 100%; height: 100%; object-fit: cover; }

.card:hover .card-media { transform: scale(0.985); }

.card-body {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
}
.card-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.card-desc { margin: 0; color: var(--ink-soft); font-size: 16px; }
.card-meta {
  font-size: 14px;
  color: var(--ink-faint);
  white-space: nowrap;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding: 0;
  list-style: none;
}
.tags li {
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--ink-soft);
}

/* ---------- Image placeholders ----------
   Replace <div class="ph"> with <img src="..." alt="..."> when you have real images. */

.ph {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 200px;
  background:
    radial-gradient(120% 90% at 85% 10%, color-mix(in srgb, var(--accent) 55%, white) 0%, transparent 55%),
    radial-gradient(90% 80% at 10% 100%, color-mix(in srgb, var(--accent) 80%, black) 0%, transparent 60%),
    var(--accent);
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ph::after {
  content: "";
  position: absolute;
  inset: 12% 14%;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.35);
}
.ph span { position: relative; z-index: 1; }

/* ---------- About ---------- */

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: clamp(32px, 6vw, 96px);
}
.about-grid .lead { margin-top: 0; }

.columns {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 32px;
  margin-top: 48px;
}
.columns h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 12px;
}
.columns ul {
  list-style: none;
  padding: 0;
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
}
.columns li { padding: 4px 0; }

.experience {
  list-style: none;
  padding: 0;
  margin: 48px 0 0;
}
.experience li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
}
.experience strong { font-weight: 600; }
.experience span { color: var(--ink-soft); }
.experience time { color: var(--ink-faint); font-size: 15px; }

/* ---------- Contact / footer ---------- */

.contact {
  padding: clamp(80px, 14vh, 160px) 0;
  border-top: 1px solid var(--line);
}
.contact h2 a {
  overflow-wrap: break-word; /* never wider than the screen */
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 2px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.35s;
}
.contact h2 a:hover { background-size: 100% 2px; }

.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-top: 40px;
  padding: 0;
  list-style: none;
}

.site-footer {
  padding: 28px 0 40px;
  font-size: 14px;
  color: var(--ink-faint);
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ==========================================================================
   Case study pages
   ========================================================================== */

.back-link {
  display: inline-flex;
  gap: 6px;
  margin-top: 40px;
  font-size: 15px;
  color: var(--ink-soft);
  text-decoration: none;
}
.back-link:hover { color: var(--ink); }

.cs-hero { padding: 48px 0 56px; }
.cs-hero .display { font-size: clamp(40px, 6.5vw, 84px); max-width: 15ch; }
.cs-hero .lead { margin: 28px 0 0; }

.cs-meta {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin: 56px 0 0;
  padding: 28px 0 0;
  border-top: 1px solid var(--line);
}
.cs-meta dt {
  font-size: 13px;
  color: var(--ink-faint);
  margin-bottom: 6px;
}
.cs-meta dd { margin: 0; font-size: 16px; }

.cs-cover {
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16 / 9;
}
.cs-cover .ph,
.cs-cover img { width: 100%; height: 100%; object-fit: cover; }

/* Body layout: sticky table of contents + content */
.cs-body {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: clamp(32px, 6vw, 96px);
  padding: clamp(64px, 10vh, 112px) 0;
}

.toc {
  position: sticky;
  top: 100px;
  align-self: start;
  font-size: 14px;
}
.toc ol { list-style: none; padding: 0; margin: 0; }
.toc a {
  display: block;
  padding: 6px 0 6px 14px;
  color: var(--ink-faint);
  text-decoration: none;
  border-left: 1px solid var(--line);
  transition: color 0.15s, border-color 0.15s;
}
.toc a:hover,
.toc a.is-active { color: var(--ink); border-left-color: var(--ink); }

.cs-content { max-width: var(--text); }
.cs-content section + section { margin-top: clamp(64px, 9vh, 104px); }
.cs-content section { scroll-margin-top: 96px; }

.cs-content h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(28px, 3.2vw, 38px);
  line-height: 1.12;
  letter-spacing: -0.03em;
  margin: 0 0 20px;
}
.cs-content h3 {
  font-size: 18px;
  font-weight: 700;
  margin: 36px 0 8px;
}
.cs-content p { margin: 0 0 18px; color: var(--ink-soft); }
.cs-content strong { color: var(--ink); font-weight: 600; }
.cs-content ul,
.cs-content ol { color: var(--ink-soft); padding-left: 20px; }
.cs-content li { margin-bottom: 8px; }

/* Figures can break out wider than the text column */
.figure { margin: 40px 0; }
.figure .ph,
.figure img {
  border-radius: var(--radius);
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}
/* Real images keep their own shape */
.figure > img,
.figure > a > img { aspect-ratio: auto; height: auto; }
.figure > a { display: block; }
/* Screens on a white background: square corners, and the white blends into the page */
.figure img.is-plain { border-radius: 0; mix-blend-mode: multiply; }
.figure figcaption {
  font-size: 14px;
  color: var(--ink-faint);
  margin-top: 12px;
}
.figure-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.figure-row .ph,
.figure-row img { aspect-ratio: 4 / 5; }

.callout {
  margin: 32px 0;
  padding: 24px 28px;
  background: #222222;
  color: #fff;
  border-radius: var(--radius);
}
/* Paragraphs and bold text inside a callout stay white too */
.callout p,
.callout strong,
.cs-content .callout p,
.cs-content .callout strong { color: #fff; }
.callout p { margin: 0; }

/* Quote callout: larger Inter text wrapped in quote marks */
.callout.is-quote { padding: 32px 36px; }
.callout.is-quote p {
  font-family: var(--font-heading);
  font-size: clamp(20px, 2vw, 24px);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}
/* Big quote marks: the opening one sits above the text, the closing one trails the last word */
.callout.is-quote p::before {
  content: "\201C";
  display: block;
  height: 0.5em;
  margin-bottom: 0.15em;
  font-size: 3.6em;
  font-weight: 700;
  line-height: 0.9;
}
.callout.is-quote p::after {
  content: "\201D";
  margin-left: 0.05em;
  font-size: 1.8em;
  font-weight: 700;
  line-height: 0;
  vertical-align: -0.32em;
}

blockquote {
  margin: 40px 0;
  padding: 0;
  font-family: var(--font-body);
  font-size: clamp(22px, 2.6vw, 28px);
  line-height: 1.3;
  letter-spacing: -0.01em;
}
blockquote cite {
  display: block;
  margin-top: 14px;
  font-family: var(--font-body);
  font-size: 14px;
  font-style: normal;
  color: var(--ink-faint);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin: 32px 0;
}
.metric {
  padding: 24px;
  background: #222222;
  color: #fff;
  border-radius: var(--radius);
}
.metric strong {
  display: block;
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.04em;
  font-size: 44px;
  line-height: 1;
  color: #fff;
  margin-bottom: 8px;
}
.metric span { font-size: 15px; color: #fff; }

/* Next project */
.next-project {
  display: block;
  text-decoration: none;
  padding: clamp(64px, 12vh, 140px) 0;
  border-top: 1px solid var(--line);
}
.next-project .display {
  font-size: clamp(40px, 6.5vw, 84px);
  transition: color 0.2s;
}
.next-project:hover .display { color: var(--accent); }

/* ---------- Page transitions ----------
   Case studies slide in from the right over the page you came from ("open"),
   and slide back out to the right when you go back ("close").
   js/transitions.js picks the direction. Unsupported browsers switch instantly. */

@view-transition { navigation: auto; }

:root {
  --page-slide-duration: 0.55s;
  --page-slide-ease: cubic-bezier(0.22, 0.8, 0.24, 1);
}

::view-transition-old(root),
::view-transition-new(root) {
  mix-blend-mode: normal;
  animation-duration: var(--page-slide-duration);
  animation-timing-function: var(--page-slide-ease);
  animation-fill-mode: both;
}

/* Opening a case study: it slides in on top; the page behind drifts left and dims */
html:active-view-transition-type(open)::view-transition-old(root) { animation-name: page-behind-out; }
html:active-view-transition-type(open)::view-transition-new(root) {
  animation-name: page-slide-in;
  box-shadow: -24px 0 60px rgba(22, 21, 15, 0.18);
}

/* Going back: the case study slides out to the right, uncovering the page behind */
html:active-view-transition-type(close)::view-transition-old(root) {
  z-index: 1;
  animation-name: page-slide-out;
  box-shadow: -24px 0 60px rgba(22, 21, 15, 0.18);
}
html:active-view-transition-type(close)::view-transition-new(root) { animation-name: page-behind-in; }

@keyframes page-slide-in   { from { transform: translateX(100%); } to { transform: none; } }
@keyframes page-slide-out  { from { transform: none; } to { transform: translateX(100%); } }
@keyframes page-behind-out { from { transform: none; filter: none; } to { transform: translateX(-25%); filter: brightness(0.85); } }
@keyframes page-behind-in  { from { transform: translateX(-25%); filter: brightness(0.85); } to { transform: none; filter: none; } }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}

/* ---------- Motion ---------- */

/* Only hidden when JS is running, so content never disappears without it */
.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.js .reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .about-grid,
  .cs-body { grid-template-columns: 1fr; }
  .toc { display: none; }
  .cs-meta { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .work-grid { grid-template-columns: 1fr; }
  .section-head { flex-direction: column; align-items: start; }
  .card-body { flex-direction: column; gap: 4px; }
  .columns,
  .metrics,
  .figure-row { grid-template-columns: 1fr; }
  .experience li { grid-template-columns: 1fr; gap: 2px; }
  .nav a:not(:last-child) { display: none; }
  .pills { flex-direction: column; align-items: center; } /* intro pills stack on phones */
}
