/*
  Layout model: every Canva page is a 1366px-wide artboard. Elements carry their
  Canva geometry as unitless custom properties (--x, --y, --w, --h) and are
  scaled to the viewport with --u (one Canva pixel). Below 760px the artboard is
  dropped and elements flow in source order (see "Mobile" at the bottom).
*/

:root {
  --blue: #2974ba;
  --ink: #252e34;
  --card-fill: #edeced;
  --line: max(1px, calc(100vw / 1366));  /* hairline borders: 1 Canva px */
  --bg: #d6dfe1;          /* velvet's average tone, for solid panels (menu) */
  --link: var(--blue);
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

/* Velvet background (assets/velvet.webp): the photo plus its mirror image, so it
   repeats down the page without a seam. It scrolls with the page. */
body {
  margin: 0;
  background: var(--bg) url("../assets/velvet.webp") top center / 100% auto repeat-y;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }

/* Highlighter yellow behind hovered links and selected text. */
a:hover { background: #e5ef4b; }
::selection { background: #e5ef4b; color: var(--ink); }

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 20;
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--ink);
  border-radius: 999px;
}
.skip-link:focus { top: 12px; outline: none; }

/* ---------- Navigation ---------- */

.site-nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  container-type: inline-size;
  pointer-events: none;
}

.site-nav ul { margin: 0; padding: 0; list-style: none; }

#nav-list {
  --u: calc(100cqw / 1366);
  display: flex;
  justify-content: flex-end;
  gap: calc(28 * var(--u));
  padding: calc(14 * var(--u)) calc(24 * var(--u)) 0 0;
  pointer-events: auto;
}

.site-nav a,
.menu-btn {
  font: inherit;
  font-size: max(11px, calc(15 * var(--u)));
  color: var(--link);
  white-space: nowrap;
}

.menu-btn {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.menu-btn::after { content: " ▾"; font-size: 0.8em; }

/* Current page (and "projects" while on a project page) is underlined. */
.site-nav [aria-current] {
  text-decoration: underline;
  text-decoration-thickness: max(1px, calc(1.5 * var(--u)));
  text-underline-offset: 0.3em;
}

/* "projects" dropdown */
.has-menu { position: relative; }

.site-nav .submenu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: max-content;
  visibility: hidden;
  opacity: 0;
  transform: translateY(calc(-6 * var(--u)));
  transition: opacity 140ms ease-out, transform 140ms ease-out, visibility 0s 140ms;
  margin-top: calc(8 * var(--u));
  padding: calc(10 * var(--u)) calc(16 * var(--u));
  background: var(--bg);
  border: var(--line) solid var(--ink);
  border-radius: calc(16 * var(--u));
  text-align: right;
}

/* Invisible bridge so the menu stays open while the pointer moves down to it. */
.submenu::before { content: ""; position: absolute; inset: calc(-10 * var(--u)) 0 100% 0; }

.submenu a { display: block; line-height: 1.9; }

.has-menu:hover .submenu,
.has-menu:focus-within .submenu,
.has-menu.open .submenu {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition-delay: 0s;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .site-nav .submenu, .project-index a { transition: none; }
  html.reveal .el { opacity: 1; transform: none; transition: none; }
}

.nav-toggle { display: none; }

/* Light-gray list of projects fixed on the right of the projects page;
   the project in view is blue. */
.project-index {
  --u: calc(100vw / 1366);
  position: fixed;
  top: 50%;
  right: calc(18 * var(--u));
  z-index: 5;
  transform: translateY(-50%);
}

.project-index ul {
  display: flex;
  flex-direction: column;
  gap: calc(10 * var(--u));
  max-width: calc(112 * var(--u));
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: right;
}

.project-index a {
  display: block;
  font-size: max(11px, calc(13 * var(--u)));
  line-height: 1.25;
  color: #7b878d;
  transition: color 200ms ease-out;
}

.project-index a:hover { color: var(--ink); text-decoration: none; }
.project-index a[aria-current] { color: var(--link); }

/* Stitched project titles: cross-stitch cursive squares, built by tools/build_titles.py. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stitch-line {
  height: calc(var(--h) * var(--u));
  overflow: visible;
  fill: rgb(9, 112, 184);
}
.stitch-narrow { display: none; }

.reveal .el.stitch-line { opacity: 1; transform: none; }
/* Project names in the home page list keep the body text style. */
.quiet-link { color: inherit; }

/* Elements fade up as they scroll into view (class set in <head> so nothing flashes). */
.reveal .el {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 600ms ease-out, transform 600ms ease-out;
}

.reveal .el.in { opacity: 1; transform: none; }

/* ---------- Artboard ---------- */

.page {
  container-type: inline-size;
  scroll-margin-top: 0;
}

.board {
  --u: calc(100cqw / 1366);
  position: relative;
  width: 100%;
  height: calc(var(--h) * var(--u));
  overflow: hidden;
}

.el {
  position: absolute;
  left: calc(var(--x) * var(--u));
  top: calc(var(--y) * var(--u));
  width: calc(var(--w) * var(--u));
  margin: 0;
}

/* ---------- Text ---------- */

.t {
  font-size: calc(26.667 * var(--u));
  line-height: 1.18;
  white-space: pre-line;
  overflow-wrap: break-word;
}

.t em, .card em { font-style: italic; }

.display {
  font-size: calc(106.666 * var(--u));
  line-height: 0.83;
  letter-spacing: 0.045em;
  color: var(--blue);
  font-weight: normal;
}

.title {
  font-size: calc(26.667 * var(--u));
  line-height: 1.11;
  color: var(--blue);
  text-align: center;
  font-weight: normal;
}

/* Headings: box titles ("background:", "my impact:", "what i can do:" …) and the
   project titles under each cover. Century Schoolbook Bold where installed,
   otherwise C059 Bold, a free metric-compatible clone served with the site. */
@font-face {
  font-family: "Schoolbook";
  font-weight: 700;
  font-display: swap;
  src: local("Century Schoolbook Bold"), local("CenturySchoolbook-Bold"),
       url("../assets/fonts/C059-Bold.woff2") format("woff2");
}

.box-title,
.title,
.display,
.site-nav a,
.menu-btn {
  font-family: "Schoolbook", "Century Schoolbook", Georgia, serif;
  font-weight: 700;
}

.box-title { font-size: 1.05em; }

/* Projects page type, sized like Somi's case studies (px at a 1366-wide window):
   16 card text, 20 card labels / sublines / stat lines, 30 headings, 50 statements. */
.project .t, .project .card { font-size: calc(16 * var(--u)); line-height: 1.25; }
.project .box-title { font-size: 1.25em; }
.project .card p { margin: 0; }

/* Case-study patterns (after somi.framer.website):
   - .trio: three cards in a row, label centred over left-aligned text
   - .arrow: thin downward arrow from a problem to its insight
   - .kicker: small centred label above a statement; .pull: very large centred statement
   - .pull-note: centred lead-in line; .lede + .subline: left-aligned heading and its subline
   - .stat-line: the key line inside a card, a step larger than its text */
.trio .box-title { display: block; text-align: center; }

.arrow {
  height: calc(var(--h) * var(--u));
  color: var(--ink);
  overflow: visible;
}

.project .kicker, .project .pull-note, .project .subline {
  font-size: calc(20 * var(--u));
  font-weight: 300;
  white-space: normal;
}
.kicker, .pull-note { text-align: center; }

.project .pull {
  font-size: calc(50 * var(--u));
  line-height: 1.2;
  text-align: center;
  white-space: normal;
}

.project .lede { font-size: calc(30 * var(--u)); line-height: 1.2; white-space: normal; }

.stat-line { font-size: 1.25em; line-height: 1.2; }

/* A text card beside tall images keeps its text at the bottom, as on Somi's Instagram card. */
.card.beside { display: flex; align-items: flex-end; }

/* Glow highlights: the soft-light photo (assets/glow.webp) faded out radially behind
   key moments. Each .glow sits right before the element it highlights. */
.glow {
  height: calc(var(--h) * var(--u));
  z-index: -1;
  pointer-events: none;
  /* --fx/--fy pick which part of the photo shows (its colours vary top to bottom);
     --zoom enlarges it so one colour fills the glow. */
  background: url("../assets/glow.webp") var(--fx, 50%) var(--fy, 30%) / calc(var(--zoom, 1) * 100%) auto no-repeat;
  /* A soft, squarish fade: two long linear fades (across and down) multiplied
     together, then blurred, so there is no visible edge or oval. */
  --fade: transparent, rgba(0, 0, 0, 0.35) 18%, #000 42%, #000 58%, rgba(0, 0, 0, 0.35) 82%, transparent;
  -webkit-mask-image: linear-gradient(90deg, var(--fade)), linear-gradient(180deg, var(--fade));
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(90deg, var(--fade)), linear-gradient(180deg, var(--fade));
  mask-composite: intersect;
  filter: blur(calc(28 * var(--u)));
}

/* Arrow with a label set into its stem ("the execution"). */
.arrow.labeled {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: calc(var(--h) * var(--u));
}
.arrow.labeled .stem { flex: 1; width: calc(19 * var(--u)); overflow: visible; }
.arrow.labeled .label {
  padding: calc(10 * var(--u)) 0;
  font-size: calc(20 * var(--u));
  font-weight: 300;
  white-space: nowrap;
}
.arrow.labeled svg { width: calc(19 * var(--u)); height: calc(50 * var(--u)); overflow: visible; }

/* Slide carousels: a strip of small slides with one shown large in the middle.
   The strip slides so the active slide stays centred (--i, set by JS). */
.carousel {
  --big: calc(600 * var(--u));
  --small: calc(150 * var(--u));
  --gap: calc(14 * var(--u));
  height: calc(var(--h) * var(--u));
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.carousel .track {
  position: absolute;
  top: 0;
  left: 50%;
  height: calc(var(--big) * 9 / 16);
  display: flex;
  align-items: center;
  gap: var(--gap);
  transform: translateX(calc(-1 * (var(--i) * (var(--small) + var(--gap)) + var(--big) / 2)));
  transition: transform 600ms cubic-bezier(.2, .7, .2, 1);
}

.carousel .slide {
  position: relative;
  flex: none;
  width: var(--small);
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: #f2f2f2;
  cursor: pointer;
  transition: width 600ms cubic-bezier(.2, .7, .2, 1);
}
.carousel .slide[aria-current="true"] { width: var(--big); cursor: default; }
.carousel .slide img { width: 100%; height: 100%; object-fit: cover; display: block; }

.carousel .controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: calc(28 * var(--u));
  font-size: calc(16 * var(--u));
  font-variant-numeric: tabular-nums;
}
.carousel .controls button {
  padding: calc(8 * var(--u)) 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
}
.carousel .controls svg { display: block; width: calc(60 * var(--u)); height: calc(12 * var(--u)); overflow: visible; }
.carousel .controls button:hover { background: #e5ef4b; }

@media (prefers-reduced-motion: reduce) {
  .carousel .track, .carousel .slide { transition: none; }
}

/* Let the larger glows spill above and below their section instead of being cut
   off at its edge (sideways overflow stays clipped, so no horizontal scrolling). */
@supports (overflow: clip) {
  .board { overflow-x: clip; overflow-y: visible; }
}

/* Home: the cross-stitch flower in the bottom-left corner (squares match the titles'). */
.stamp { height: calc(var(--h) * var(--u)); }
.stamp img { display: block; width: 100%; height: 100%; }

/* Home: link to the projects page in the bottom-right corner. */
.next-page {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: calc(14 * var(--u));
  font-size: calc(26.667 * var(--u));
  color: var(--ink);
}
.next-page a { color: var(--ink); display: inline-flex; align-items: center; gap: calc(14 * var(--u)); padding: 0 calc(4 * var(--u)); }
.next-page svg { width: calc(60 * var(--u)); height: calc(12 * var(--u)); overflow: visible; }

/* Indented list inside a card. */
.indent { display: block; padding-left: 1.2em; }

/* Video in an image frame (minturn website screen recording). */
.img video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left center;  /* when cropped to match the card beside it, crop from the right */
}

/* "background" and "role" boxes, outlined like the cards below them. */
.box {
  height: calc(var(--h) * var(--u));
  padding: calc(32 * var(--u));
  border: var(--line) solid var(--ink);
  border-radius: calc(36 * var(--u));
}

.caption {
  color: var(--link);
  font-style: italic;
  text-align: center;
}

/* ---------- Images ---------- */

/* Frame = Canva rect; the <img> inside reproduces Canva's imageBox crop. */
.img {
  height: calc(var(--h) * var(--u));
  overflow: hidden;
  background: repeating-linear-gradient(45deg, #f2f2f2 0 10px, #e6e6e6 10px 20px);
}

.img img {
  position: absolute;
  display: block;
  max-width: none;
  left: calc(var(--ix, 0) / var(--w) * 100%);
  top: calc(var(--iy, 0) / var(--h) * 100%);
  width: calc(var(--iw, var(--w)) / var(--w) * 100%);
  height: calc(var(--ih, var(--h)) / var(--h) * 100%);
}

.img.hero-bg { background: none; }

/* Project-page images sit in rounded frames (36px, as in the Canva SVG exports)
   with the same hairline ink border as the other outlines. Cover images stay square. */
.project .img:not(.cover):not(.svg) { border-radius: calc(36 * var(--u)); }
.project .img:not(.cover):not(.svg)::after {
  content: "";
  position: absolute;
  inset: 0;
  border: var(--line) solid var(--ink);
  border-radius: inherit;
  pointer-events: none;
}

/* SVG exports from Canva already include their own crop, corners and stroke. */
.img.svg { background: none; border-radius: 0 !important; }

/* matmerize's SVG exports have no stroke of their own, so draw the ink rim here. */
#matmerize .img.svg::after {
  content: "";
  position: absolute;
  inset: 0;
  border: var(--line) solid var(--ink);
  border-radius: calc(36 * var(--u));
  pointer-events: none;
}

/* Rounded outline drawn around a group of images. */
.outline {
  height: calc(var(--h) * var(--u));
  border: var(--line) solid var(--ink);
  border-radius: calc(var(--r, 36) * var(--u));
  pointer-events: none;
}

/* ---------- Cards ---------- */

.card {
  height: calc(var(--h) * var(--u));
  padding: calc(32 * var(--u));
  border: var(--line) solid var(--ink);
  border-radius: calc(36 * var(--u));
  font-size: calc(26.667 * var(--u));
  line-height: 1;
  white-space: pre-line;
}


/* ---------- Mobile ---------- */

@media (max-width: 760px) {
  .site-nav { position: sticky; top: 0; background: rgba(214, 223, 225, 0.94); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); container-type: normal; }
  .nav-toggle {
    display: block;
    margin-left: auto;
    padding: 12px 16px;
    border: 0;
    background: none;
    color: var(--link);
    font: inherit;
    font-size: 15px;
    pointer-events: auto;
  }
  #nav-list {
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 0 16px 12px;
    text-align: right;
  }
  .site-nav.open #nav-list { display: flex; }
  .site-nav a, .menu-btn { font-size: 16px; line-height: 2.2; }
  .menu-btn::after { content: ""; }
  /* Inside the mobile menu the project list is always shown, indented under "projects". */
  .project-index, .glow { display: none; }
  .next-page { font-size: 17px; }
  .el.stamp { width: 95px; height: auto; aspect-ratio: 19 / 24; }
  .next-page svg { width: 44px; }
  /* Phones: one wrapped title, pulled up so it overlaps the bottom of the cover. */
  .stitch-wide { display: none; }
  .el.stitch-narrow {
    display: block;
    width: min(100%, calc(var(--w) * 0.75px));
    height: auto;
    margin-top: -28px;
    position: relative;
    z-index: 1;
  }
  .title.stitch { margin: 0; }
  section.project { scroll-margin-top: 48px; }

  .site-nav .submenu {
    position: static;
    visibility: visible;
    opacity: 1;
    transform: none;
    margin: 0;
    padding: 0 12px 0 0;
    border: 0;
  }
  .submenu a { line-height: 2; font-size: 15px; }

  .board {
    --u: 1px;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 24px 16px 56px;
    overflow: visible;
  }

  .el { position: relative; left: auto; top: auto; width: 100%; }

  .t, .card, .title { font-size: 17px; }
  .project .t, .project .card { font-size: 15px; }
  .project .kicker, .project .pull-note, .project .subline { font-size: 17px; }
  .project .lede { font-size: 22px; }
  .project .pull { font-size: 26px; }
  .el.arrow { width: 19px; height: 64px; align-self: center; }
  .el.arrow.labeled { width: auto; height: 130px; }
  .arrow.labeled .label { font-size: 17px; }
  .arrow.labeled svg { width: 19px; height: 40px; }
  .el.carousel { --big: 78vw; --small: 20vw; --gap: 8px; height: calc(78vw * 9 / 16 + 56px); }
  .carousel .controls { font-size: 15px; }
  .carousel .controls svg { width: 44px; height: 12px; }
  .display { font-size: 52px; }

  .img, .outline { height: auto; aspect-ratio: var(--w) / var(--h); }
  .project .img::after, .outline, .card, .box { border-width: 1px; }

  .card, .box { height: auto; padding: 22px; border-radius: 24px; }
  .card { line-height: 1.15; }

  .outline { display: none; }

  /* Rows of small images become a two-column grid. */
  .m-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .m-grid > .el { width: 100%; }

  .m-center { align-self: center; width: min(100%, 320px); }

  /* Home hero: signature stays full width, photo grid below it. */
  .page-hero .board { padding: 0 0 24px; gap: 0; }
  /* Crop the frame to the signature band (~215 Canva px tall) and keep the SVG's own aspect. */
  .page-hero .hero-bg { aspect-ratio: 1367.5 / 215; }
  .page-hero .hero-bg img { height: auto; top: calc(-20.8 / 215 * 100%); }
  .page-hero .m-grid { padding: 0 16px; }
}
