/* ==========================================================================
   System
   - One container (.wrap), one row shape (.row: label column + content column).
   - Two alignment lines: the page margin (section titles, hero) and the
     content line (everything inside a row).
   - Four type sizes: display, section title, item title, lede. Body and
     small sit underneath.
   ========================================================================== */

:root {
  --paper: #fafaf8;
  --ink: #16181d;
  --muted: #5c6170;
  --rule: #dcdde1;
  --blue: #2b50d8;
  --night: #0f1d45;
  --night-ink: #e9ecf7;
  --night-muted: #a9b3d6;

  --serif: "Newsreader", Georgia, serif;
  --sans: "Hanken Grotesk", system-ui, sans-serif;

  --t-display: clamp(2.5rem, 6.2vw, 5.75rem);
  --t-section: clamp(2.25rem, 4.4vw, 3.75rem);
  --t-item: clamp(1.75rem, 2.6vw, 2.375rem);
  --t-lede: clamp(1.3rem, 1.8vw, 1.6rem);
  --t-body: 1.1875rem;
  --t-small: 0.9375rem;

  --gutter: clamp(16px, 5vw, 64px);
  --max: 1240px;
  --label-col: minmax(0, 3fr);
  --content-col: minmax(0, 9fr);
  --col-gap: clamp(24px, 4vw, 64px);
  --measure: 36rem;

  --space-section: clamp(80px, 12vh, 144px);
  --space-row: clamp(56px, 8vh, 96px);
  --space-block: 32px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--t-body);
  line-height: 1.65;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip {
  position: absolute; left: var(--gutter); top: -40px;
  font-family: var(--sans); font-size: var(--t-small);
  background: var(--ink); color: var(--paper); padding: 6px 12px;
}
.skip:focus { top: 12px; }

/* Container */
.wrap { width: 100%; max-width: calc(var(--max) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }

/* Header */
.site-header {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-top: 28px; padding-bottom: 28px;
  font-family: var(--sans); font-size: var(--t-small);
}
.brand { color: var(--ink); text-decoration: none; font-weight: 600; }
.site-header nav { display: flex; gap: 24px; }
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--ink); }

/* Hero: the one loud moment */
.hero { padding-top: clamp(48px, 10vh, 120px); padding-bottom: var(--space-section); }
.titles {
  margin: 0;
  display: flex; flex-direction: column; align-items: flex-start;
  font-weight: 400;
  font-size: clamp(1.9rem, 7.4vw, 6.25rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
}
.title { position: relative; display: inline-block; max-width: 100%; }
.title.was { color: var(--muted); opacity: 0.55; }
.title.was::after {
  content: "";
  position: absolute; left: -0.04em; right: -0.04em; top: 54%;
  height: max(2px, 0.055em);
  background: var(--blue);
  transform-origin: left center;
}
.title.now { font-weight: 500; color: var(--ink); margin-top: 0.08em; }
.hero-lede { max-width: 30rem; margin: 40px 0 0; font-size: var(--t-lede); line-height: 1.5; }

@media (prefers-reduced-motion: no-preference) {
  .title.was { animation: settle 0.5s ease-out both; animation-delay: calc(0.35s + var(--i) * 0.42s); }
  .title.was::after { animation: strike 0.42s cubic-bezier(.6,0,.2,1) both; animation-delay: calc(0.35s + var(--i) * 0.42s); }
  .title.now { animation: arrive 0.7s ease-out both; animation-delay: calc(0.35s + var(--i) * 0.42s); }
  .hero-lede { animation: arrive 0.7s ease-out both; animation-delay: 2.1s; }
  @keyframes strike { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  @keyframes settle { from { color: var(--ink); opacity: 1; } to { color: var(--muted); opacity: 0.55; } }
  @keyframes arrive { from { opacity: 0; transform: translateY(0.25em); } to { opacity: 1; transform: none; } }
}

/* Sections */
.section { border-top: 1px solid var(--rule); padding-top: var(--space-section); }
.section-title {
  margin: 0 0 var(--space-row);
  max-width: 20ch;
  font-size: var(--t-section);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.025em;
}

/* Dark title bands: the section title sits in a full-bleed night band,
   the rows below start without a rule so the band does the separating. */
.section-band { border-top: none; padding-top: 0; }
.band { background: var(--night); color: var(--night-ink); padding: var(--space-row) 0; }
.band .section-title { margin: 0; }
.section-band > .wrap > .row:first-child { border-top: none; }
.section-band > .wrap > .cards { padding-top: var(--space-row); }

/* The row: label column + content column */
.row {
  display: grid;
  grid-template-columns: var(--label-col) var(--content-col);
  column-gap: var(--col-gap);
  padding: var(--space-row) 0;
  border-top: 1px solid var(--rule);
}
.row-flush { border-top: none; padding-top: 0; }
.wrap.row { padding-left: var(--gutter); padding-right: var(--gutter); }
.row-label { align-self: start; position: sticky; top: 24px; }
.row-content { min-width: 0; }

.year {
  margin: 0 0 8px;
  font-size: clamp(2.5rem, 4vw, 3.5rem);
  font-weight: 300;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--blue);
}
.label { margin: 0; font-family: var(--sans); font-size: var(--t-small); line-height: 1.45; color: var(--muted); }
.label + .label { margin-top: 8px; }
.label-strong { color: var(--blue); font-weight: 600; }

.item-title {
  margin: 0 0 20px;
  font-size: var(--t-item);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.015em;
}
.lede { margin: 0 0 24px; max-width: 34rem; font-size: var(--t-lede); line-height: 1.45; }
.prose { max-width: var(--measure); }
.prose p { margin: 0 0 1.1em; }
.prose p:last-child { margin-bottom: 0; }
.note { margin: 24px 0 0; max-width: var(--measure); font-size: 1rem; color: var(--muted); }

/* Term/definition pairs, two up */
.pairs {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--col-gap);
  margin: var(--space-block) 0 0;
}
.pairs > div { padding: 20px 0; border-top: 1px solid var(--rule); }
.pairs dt { margin: 0 0 6px; font-family: var(--sans); font-weight: 600; font-size: 1rem; }
.pairs dd { margin: 0; font-size: 1.05rem; line-height: 1.55; }
.terms dd { color: var(--muted); }
.pairs-flush { margin-top: 0; }
.pairs-flush > div:first-child, .pairs-flush > div:nth-child(2) { border-top: none; padding-top: 0; }
.prose-after { margin-top: var(--space-block); }

/* Grid of smaller projects, two up */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px var(--col-gap); margin-top: 8px; }
.grid article { border-top: 1px solid var(--rule); padding-top: 20px; }
.grid h4 { margin: 0 0 10px; font-size: 1.35rem; font-weight: 600; line-height: 1.25; }
.grid p { margin: 0; font-size: 1.05rem; line-height: 1.6; }

/* Personal photos: a fixed mosaic inside the content column */
.gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, clamp(150px, 15vw, 210px));
  grid-template-areas:
    "kiko alps alps tati"
    "kiko camp camp tati"
    "golf group group trout";
  gap: 12px;
  margin-top: 40px;
}
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 6px; background: var(--rule); }
.g-kiko { grid-area: kiko; object-position: 30% 60%; }
.g-alps { grid-area: alps; object-position: 50% 40%; }
.g-camp { grid-area: camp; object-position: 50% 55%; }
.g-trout { grid-area: trout; object-position: 50% 45%; }
.g-tati { grid-area: tati; object-position: 50% 35%; }
.g-golf { grid-area: golf; object-position: 50% 70%; }
.g-group { grid-area: group; object-position: 50% 45%; }

/* Inline terms that open an explainer popup */
.term {
  font: inherit; color: inherit; background: none; border: none; padding: 0; margin: 0;
  cursor: pointer;
  text-decoration: underline dotted var(--blue);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}
.term:hover { color: var(--blue); text-decoration-style: solid; }
.label .term { color: var(--muted); }
.label .term:hover { color: var(--blue); }

.popup {
  width: min(44rem, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 40px clamp(20px, 4vw, 48px) 48px;
  border: none; border-radius: 10px;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 24px 64px rgba(15, 29, 69, 0.28);
}
.popup::backdrop { background: rgba(15, 29, 69, 0.55); }
.popup-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.popup-title { margin: 0; font-size: var(--t-item); font-weight: 500; line-height: 1.12; letter-spacing: -0.015em; }
.popup-close {
  flex-shrink: 0; width: 36px; height: 36px; margin: -4px -8px 0 0;
  border: none; border-radius: 50%; background: none; color: var(--muted);
  font-size: 1.75rem; line-height: 1; cursor: pointer;
}
.popup-close:hover { background: var(--rule); color: var(--ink); }
.popup-sub { margin: var(--space-block) 0 0; font-family: var(--sans); font-size: 1rem; font-weight: 600; }
.popup-sub + .prose { margin-top: 12px; }
.popup .pairs { margin-top: 8px; }
@media (prefers-reduced-motion: no-preference) {
  .popup[open] { animation: arrive 0.25s ease-out; }
}

/* Media inside a row: same left edge, capped width */
.row-content .demo { margin: var(--space-block) 0; max-width: 820px; }
.market { margin: var(--space-block) 0; max-width: 640px; color: var(--blue); }
.market svg { width: 100%; height: auto; display: block; }
.market .node { fill: #fff; stroke: var(--ink); stroke-width: 1.5; }
.market .node-title { font-family: var(--serif); font-size: 24px; fill: var(--ink); }
.market .node-sub { font-family: var(--sans); font-size: 15px; fill: var(--muted); }
.market .flow { stroke: currentColor; stroke-width: 2; }
.market .flow-label { font-family: var(--sans); font-size: 15px; fill: var(--ink); }

/* Closing and footer */
.closing { padding-bottom: var(--space-section); }
.closing .section-title { font-size: var(--t-display); max-width: 18ch; margin-bottom: 40px; }
.site-footer { border-top: 1px solid var(--rule); }
.site-footer .row { padding-top: var(--space-row); padding-bottom: 40px; }
.contact-links { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 0; font-size: var(--t-lede); }
.fineprint { margin: 56px 0 0; font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }

/* Small screens: the label column stacks above the content */
@media (max-width: 860px) {
  .row { grid-template-columns: minmax(0, 1fr); }
  .row-label { position: static; margin-bottom: 20px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; }
  .row-label:empty { display: none; }
  .year { margin: 0; font-size: 2.5rem; }
  .label + .label { margin-top: 0; }
  .pairs, .grid { grid-template-columns: minmax(0, 1fr); }
  .pairs-flush > div:nth-child(2) { border-top: 1px solid var(--rule); padding-top: 20px; }
  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: 260px 180px 200px 260px 200px;
    grid-template-areas: "kiko tati" "alps alps" "camp camp" "golf trout" "group group";
  }
}
@media (max-width: 560px) {
  body { font-size: 1.0625rem; }
  .site-header nav { gap: 16px; }
}

/* ==========================================================================
   Projects: card grid on the home page, one page per project
   ========================================================================== */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: clamp(20px, 3vw, 40px);
  padding-bottom: var(--space-section);
}
.card {
  display: flex; flex-direction: column;
  color: inherit; text-decoration: none;
  background: #fff;
  border: 1px solid var(--rule); border-radius: 12px; overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card:hover, .card:focus-visible { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(15, 29, 69, 0.12); border-color: transparent; }
.card-visual { aspect-ratio: 16 / 10; background: var(--night); }
.card-visual img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 20px 22px 24px; display: flex; flex-direction: column; flex: 1; }
.card-title { margin: 0 0 8px; font-size: 1.5rem; font-weight: 500; line-height: 1.15; letter-spacing: -0.015em; }
.card-text { margin: 0; font-size: 1.0625rem; line-height: 1.5; color: var(--muted); }
.card-more { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--rule); font-family: var(--sans); font-size: var(--t-small); font-weight: 500; color: var(--blue); margin-top: auto; }
.card-more::after { content: " \2192"; }

/* Placeholder motifs: night background, blue-tinted geometry. Swap for an <img> when screenshots exist. */
.motif-spark  { background: radial-gradient(circle at 50% 50%, rgba(43,80,216,0.9) 0 6%, transparent 6.5%), radial-gradient(circle at 50% 50%, transparent 0 18%, rgba(169,179,214,0.25) 18.5% 19.5%, transparent 20%), radial-gradient(circle at 50% 50%, transparent 0 30%, rgba(169,179,214,0.18) 30.5% 31.5%, transparent 32%), var(--night); }
.motif-flow   { background: linear-gradient(90deg, transparent 0 22%, rgba(169,179,214,0.5) 22% 24%, transparent 24% 76%, rgba(169,179,214,0.5) 76% 78%, transparent 78%), repeating-linear-gradient(0deg, transparent 0 22px, rgba(43,80,216,0.55) 22px 24px), var(--night); background-size: 100% 100%, 100% 72px; background-position: 0 0, 0 50%; background-repeat: no-repeat, repeat-x; }
.motif-grid   { background: repeating-linear-gradient(0deg, rgba(169,179,214,0.22) 0 1px, transparent 1px 28px), repeating-linear-gradient(90deg, rgba(169,179,214,0.22) 0 1px, transparent 1px 28px), linear-gradient(135deg, rgba(43,80,216,0.55), transparent 60%), var(--night); }
.motif-lines  { background: repeating-linear-gradient(0deg, transparent 0 18px, rgba(169,179,214,0.35) 18px 19px), linear-gradient(90deg, rgba(43,80,216,0.6) 0 30%, transparent 30%), var(--night); background-size: 60% 100%, 100% 100%, 100% 100%; background-position: 20% 0, 0 0, 0 0; background-repeat: no-repeat; }
.motif-blocks { background: linear-gradient(rgba(43,80,216,0.75), rgba(43,80,216,0.75)) 12% 20% / 30% 22% no-repeat, linear-gradient(rgba(169,179,214,0.35), rgba(169,179,214,0.35)) 12% 60% / 55% 10% no-repeat, linear-gradient(rgba(169,179,214,0.35), rgba(169,179,214,0.35)) 12% 80% / 76% 10% no-repeat, var(--night); }
.motif-bars   { background: linear-gradient(rgba(43,80,216,0.8), rgba(43,80,216,0.8)) 18% 100% / 9% 45% no-repeat, linear-gradient(rgba(43,80,216,0.8), rgba(43,80,216,0.8)) 34% 100% / 9% 70% no-repeat, linear-gradient(rgba(43,80,216,0.8), rgba(43,80,216,0.8)) 50% 100% / 9% 30% no-repeat, linear-gradient(rgba(43,80,216,0.8), rgba(43,80,216,0.8)) 66% 100% / 9% 80% no-repeat, linear-gradient(rgba(43,80,216,0.8), rgba(43,80,216,0.8)) 82% 100% / 9% 55% no-repeat, var(--night); }
.motif-dots   { background: radial-gradient(circle, rgba(169,179,214,0.55) 0 2px, transparent 2.5px) 0 0 / 22px 22px, linear-gradient(160deg, rgba(43,80,216,0.5), transparent 55%), var(--night); }
.motif-rings  { background: radial-gradient(circle at 70% 50%, transparent 0 12%, rgba(43,80,216,0.8) 12.5% 15%, transparent 15.5% 24%, rgba(169,179,214,0.35) 24.5% 26%, transparent 26.5% 36%, rgba(169,179,214,0.2) 36.5% 37.5%, transparent 38%), var(--night); }

/* Project page */
.project-hero { padding-top: clamp(32px, 6vh, 72px); padding-bottom: var(--space-row); }
.crumb { margin: 0 0 20px; font-family: var(--sans); font-size: var(--t-small); color: var(--muted); }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); }
.crumb span { margin: 0 8px; }
.project-title {
  margin: 0 0 20px; max-width: 16ch;
  font-size: var(--t-section); font-weight: 400; line-height: 1.05; letter-spacing: -0.025em;
}
.project-hero .lede { max-width: 40rem; }
.project-meta { display: flex; flex-wrap: wrap; gap: 12px 48px; margin: 0; }
.project-meta div { margin: 0; }
.project-meta dt { margin: 0 0 2px; font-family: var(--sans); font-size: var(--t-small); font-weight: 600; color: var(--blue); }
.project-meta dd { margin: 0; font-family: var(--sans); font-size: var(--t-small); color: var(--muted); }
.project-visual { margin: 0 auto; }
.project-visual > .demo, .project-visual > .market { margin: 0; max-width: 100%; }
.project-visual-placeholder { aspect-ratio: 16 / 7; border-radius: 12px; }
.project-visual-caption { margin: 12px 0 0; font-family: var(--sans); font-size: var(--t-small); color: var(--muted); }
.project-body { margin-top: var(--space-row); }
.project-body .row:first-child { border-top: none; padding-top: 0; }
.project-nav { display: grid; grid-template-columns: 1fr 1fr; gap: var(--col-gap); padding-top: var(--space-row); padding-bottom: var(--space-section); }
.project-nav-link { display: flex; flex-direction: column; gap: 6px; color: inherit; text-decoration: none; padding-top: 20px; border-top: 1px solid var(--rule); }
.project-nav-link.is-next { text-align: right; }
.project-nav-title { font-size: 1.35rem; line-height: 1.2; }
.project-nav-link:hover .project-nav-title { color: var(--blue); }

@media (max-width: 720px) {
  .project-nav { grid-template-columns: 1fr; }
  .project-nav-link.is-next { text-align: left; }
}

/* ---- Project pages: real screens, embeds, galleries ---- */
.project-visual .shot { display: block; }
.shot-hero { display: block; width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 12px; background: #fff; }
.demo-intro { margin: 0 0 12px; font-family: var(--sans); font-size: 0.95rem; color: var(--muted); }
.embed { border: 1px solid var(--rule); border-radius: 12px; overflow: hidden; background: #f8fafc; }
.embed iframe { display: block; width: 100%; height: 780px; border: 0; }
.embed-fallback { display: none; }
.embed-fallback img { display: block; width: 100%; height: auto; }
.embed-note { display: flex; justify-content: space-between; gap: 12px; margin: 10px 0 0; font-family: var(--sans); font-size: 0.85rem; color: var(--muted); }
@media (max-width: 820px) { .embed iframe { display: none; } .embed-fallback { display: block; } }

.shots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px var(--col-gap); margin: 0; padding: 0; list-style: none; }
.shot { color: inherit; text-decoration: none; }
.shot figure { margin: 0; }
.shots img { display: block; width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 10px; background: #fff; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.shot:hover img, .shot:focus-visible img { border-color: var(--blue); box-shadow: 0 10px 30px rgba(15, 29, 69, 0.12); }
.shot figcaption { margin: 10px 0 0; font-family: var(--sans); font-size: var(--t-small); line-height: 1.45; color: var(--muted); }
@media (max-width: 640px) { .shots { grid-template-columns: 1fr; } }

dialog.lightbox { border: 0; border-radius: 12px; padding: 0; max-width: min(96vw, 1400px); max-height: 94vh; background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,0.35); }
dialog.lightbox::backdrop { background: rgba(15, 24, 45, 0.7); }
dialog.lightbox img { display: block; max-width: 100%; max-height: calc(94vh - 56px); width: auto; height: auto; margin: 0 auto; }
.lightbox-cap { margin: 0; padding: 12px 16px; font-family: var(--sans); font-size: var(--t-small); color: var(--muted); }
.lightbox-close { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: rgba(15, 24, 45, 0.75); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.lightbox-close:hover { background: var(--blue); }
