/* ==========================================================================
   Portfolio — stylesheet
   Everything you'd normally want to change lives in :root below.
   ========================================================================== */

:root {
  --paper:  #ffffff;   /* page background */
  --ink:    #111111;   /* text            */
  --muted:  #767676;   /* secondary text  */
  --line:   #e8e8e8;   /* hairlines       */
  --wash:   #f6f6f5;   /* image beds      */

  --sans: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI",
          Inter, Arial, sans-serif;

  --t-hero: clamp(2.75rem, 9vw, 6.5rem);
  --t-h2:   clamp(1.5rem, 3vw, 2.25rem);
  --t-h3:   1.125rem;
  --t-body: 1.0625rem;
  --t-small: 0.9375rem;

  --gutter: clamp(1.5rem, 6vw, 4rem);
  --maxw:   1200px;      /* content column   */
  --measure: 62ch;       /* reading width    */
  --gap:    clamp(4rem, 12vw, 10rem);   /* space between sections */

  --ease: cubic-bezier(.33, 1, .68, 1);
}

/* --- base ---------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

h1, h2, h3 { margin: 0; font-weight: 500; line-height: 1.1; letter-spacing: -0.025em; }
h1 { font-size: var(--t-hero); letter-spacing: -0.035em; }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); letter-spacing: -0.01em; }

p { margin: 0 0 1.4em; }
p:last-child { margin-bottom: 0; }

a { color: inherit; text-decoration: none; }

::selection { background: var(--ink); color: var(--paper); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* Back link — the only navigation on a case-study page. */
.back {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: var(--t-small);
  color: var(--muted);
  transition: color .25s;
}
.back:hover { color: var(--ink); }
.back .arrow { transition: transform .4s var(--ease); }
.back:hover .arrow { transform: translateX(-5px); }

/* --- layout -------------------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Every top-level block in <main> gets the same rhythm. Nothing else needed. */
main > * { margin-block: var(--gap); }
main > *:first-child { margin-top: clamp(3.5rem, 9vw, 7rem); }

.measure { max-width: var(--measure); }

[id] { scroll-margin-top: 2rem; }

.muted { color: var(--muted); }
.small { font-size: var(--t-small); }

/* Emphasis inside muted body copy: darken rather than embolden. */
.muted strong { color: var(--ink); font-weight: 400; }

/* The discipline line sitting under the name — the other half of the wordmark. */
.identity {
  margin: clamp(.75rem, 1.5vw, 1.25rem) 0 0;
  font-size: clamp(1rem, 1.8vw, 1.375rem);
  letter-spacing: -0.005em;
  color: var(--muted);
}

hr { height: 1px; border: 0; background: var(--line); margin: 0; }

/* --- scroll reveal ------------------------------------------------------- */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .7s var(--ease), transform .7s var(--ease);
  transition-delay: var(--delay, 0ms);
}
.js [data-reveal].is-in { opacity: 1; transform: none; }

/* --- images -------------------------------------------------------------- */

figure { margin: 0; }

.media {
  background: var(--wash);
  overflow: hidden;
}
.media img { width: 100%; height: 100%; object-fit: cover; }
.media--view { cursor: zoom-in; }

.r-1x1  { aspect-ratio: 1 / 1; }
.r-4x5  { aspect-ratio: 4 / 5; }
.r-4x3  { aspect-ratio: 4 / 3; }
.r-3x2  { aspect-ratio: 3 / 2; }
.r-16x9 { aspect-ratio: 16 / 9; }

figcaption {
  margin-top: .75rem;
  font-size: var(--t-small);
  color: var(--muted);
}

/* Bio text beside a portrait. Text gets the wider column; stacks on mobile,
   with the portrait first so it isn't stranded below four paragraphs. */
.bio {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
  margin-top: clamp(2.5rem, 5vw, 4rem);
}
@media (max-width: 760px) {
  .bio { grid-template-columns: 1fr; gap: 2.5rem; }
  .bio__portrait { order: -1; }
}

/* Two images side by side; stacks on small screens. */
.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1rem, 3vw, 2rem);
}
@media (max-width: 620px) { .pair { grid-template-columns: 1fr; } }

/* Stacked images inside one block */
.stack { display: grid; gap: clamp(1rem, 3vw, 2rem); }

/* --- work gallery -------------------------------------------------------- */

/* A twelve-column bed. Each tile sets its own span and vertical offset via the
   --c and --shift custom properties, inline in the HTML — so rearranging the
   collage means editing two numbers, not touching this file. */
.gallery {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(2rem, 4vw, 3.5rem) clamp(1rem, 2.5vw, 2.5rem);
  align-items: start;
}

.tile {
  display: block;
  grid-column: var(--c, auto / span 12);
  margin-top: var(--shift, 0);
}

/* Two per row on tablets, one on phones — offsets off, so nothing drifts. */
@media (max-width: 939px) {
  .tile { grid-column: auto / span 6; margin-top: 0; }
}
@media (max-width: 599px) {
  .tile { grid-column: auto / span 12; }
}

.tile__media {
  position: relative;
  background: var(--wash);
  overflow: hidden;
}
.tile__media img { width: 100%; height: 100%; object-fit: cover; }

/* Catalogue number, top-left of each tile */
.tile__no {
  position: absolute;
  top: .75rem; left: .75rem;
  z-index: 2;
  font-size: 0.75rem;
  letter-spacing: .08em;
  color: var(--muted);
  mix-blend-mode: multiply;
}

.tile__line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-top: .9rem;
  padding-bottom: .7rem;
  border-bottom: 1px solid var(--line);
}
.tile__line h3 { font-size: 1.0625rem; letter-spacing: -0.015em; }
.tile__line .arrow {
  color: var(--muted);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity .3s, transform .4s var(--ease);
}
.tile:hover .tile__line .arrow { opacity: 1; transform: none; }

.tile__meta {
  display: block;
  margin-top: .55rem;
  font-size: var(--t-small);
  color: var(--muted);
}

/* Ratios used by the collage. Mixing them is what stops it reading as a grid. */
.r-2x3 { aspect-ratio: 2 / 3; }
.r-3x4 { aspect-ratio: 3 / 4; }
.r-5x4 { aspect-ratio: 5 / 4; }

/* --- text blocks --------------------------------------------------------- */

.lead {
  font-size: clamp(1.125rem, 1.8vw, 1.375rem);
  line-height: 1.45;
  letter-spacing: -0.015em;
}

/* Label + value rows: project facts, specs, credits, archive, experience */
.rows { border-top: 1px solid var(--line); }
.rows > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: .25rem 2rem;
  padding-block: .9rem;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-small);
}
.rows dt, .rows b { color: var(--muted); font-weight: 400; margin: 0; }
.rows dd { margin: 0; }
@media (max-width: 560px) {
  .rows > div { grid-template-columns: 1fr; gap: .1rem; }
}

/* A run of short titled sections (research findings, process, FAQ) */
.notes { display: grid; gap: clamp(2rem, 4vw, 2.75rem); }
.notes h3 { margin-bottom: .5rem; }
.notes p { color: var(--muted); max-width: var(--measure); }

/* --- links & buttons ----------------------------------------------------- */

.link {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  padding-bottom: 1px;
  transition: background-size .35s var(--ease);
}
.link:hover { background-size: 0 1px; background-position: 100% 100%; }

.next {
  display: block;
  border-top: 1px solid var(--line);
  padding-top: clamp(2rem, 5vw, 3rem);
}
.next span { color: var(--muted); font-size: var(--t-small); }
.next h2 {
  margin-top: .5rem;
  transition: transform .5s var(--ease);
  display: inline-block;
}
.next:hover h2 { transform: translateX(8px); }

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

.footer {
  border-top: 1px solid var(--line);
  margin-top: var(--gap);
  padding-block: clamp(2.5rem, 5vw, 4rem);
  font-size: var(--t-small);
  color: var(--muted);
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
}
.footer a { transition: color .25s; }
.footer a:hover { color: var(--ink); }
.footer nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }

/* The footer is the contact section now, so the details lead. */
.footer__contact { display: grid; gap: .4rem; }
.footer__mail {
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  letter-spacing: -0.02em;
  color: var(--ink);
}
.footer__phone { font-size: var(--t-body); color: var(--ink); }
.footer__bottom {
  margin-top: clamp(2rem, 4vw, 3rem);
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
}

/* --- lightbox ------------------------------------------------------------ */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: var(--paper);
  display: grid;
  place-items: center;
  padding: clamp(1rem, 5vw, 3rem);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s, visibility .3s;
}
.lightbox.is-open { opacity: 1; visibility: visible; }
.lightbox img { max-width: 100%; max-height: 85svh; object-fit: contain; }
.lightbox__close {
  position: absolute;
  top: clamp(1rem, 3vw, 2rem);
  right: clamp(1rem, 3vw, 2rem);
  width: 40px; height: 40px;
  border: 0; border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 1.1rem;
  cursor: pointer;
}
.lightbox__close:hover { background: var(--wash); }

/* --- motion -------------------------------------------------------------- */

/* Headings that rise word by word. Add data-words to any heading. */
.js [data-words] .w { display: inline-block; overflow: hidden; vertical-align: top; }
.js [data-words] .w > span {
  display: inline-block;
  transform: translateY(105%);
  transition: transform .85s var(--ease);
  transition-delay: var(--delay, 0ms);
}
.js [data-words].is-in .w > span { transform: none; }

/* Images settle from a slight overscale as they come into view. */
.js [data-reveal] .media img,
.js [data-reveal] .tile__media img {
  transform: scale(1.06);
  transition: transform 1.4s var(--ease);
}
.js [data-reveal].is-in .media img,
.js [data-reveal].is-in .tile__media img { transform: none; }

/* Hover zoom. Selectors match the reveal rules' weight plus :hover so they win
   once the image has settled. */
.js [data-reveal].is-in.tile:hover .tile__media img,
.js [data-reveal].is-in .media--view:hover img { transform: scale(1.04); }

/* Lightbox image eases in. */
.lightbox img { transform: scale(.97); transition: transform .45s var(--ease); }
.lightbox.is-open img { transform: none; }

/* --- reduced motion & print ---------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    transition-duration: .001ms !important;
  }
  .js [data-reveal] { opacity: 1; transform: none; }
  .js [data-words] .w > span { transform: none; }
  .js [data-reveal] .media img,
  .js [data-reveal] .tile__media img { transform: none; }
}

@media print {
  .lightbox { display: none !important; }
  .js [data-reveal] { opacity: 1 !important; transform: none !important; }
}
