/* =========================================================================
   FRANK DE MOL — PORTFOLIO STYLES
   Sections (search for the ==== headers):
     1. Design tokens (colours, fonts)  ← change the look of the whole site here
     2. Base
     3. Shared header / footer
     4. Stop-motion helper
     5. Index (exhibition building)
     6. Landing (the table)
     7. About + contact
     8. Portfolio (filters, projects, studies, lightbox)
     9. Project case-study page
    10. Fade overlay
   ========================================================================= */


/* ==== 1. DESIGN TOKENS ================================================== */
/* Fonts: stored in the "fonts" folder of this site (not loaded from Google), so no visitor
   data goes to Google. Both fonts are free to use (SIL Open Font License, see fonts/LICENSE-*). */
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: block; /* text waits (invisibly) for the right font, never shows a stand-in font first */
  src: url("fonts/ibm-plex-mono-400.woff2") format("woff2");
}

@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 500;
  font-display: block; /* text waits (invisibly) for the right font, never shows a stand-in font first */
  src: url("fonts/ibm-plex-mono-500.woff2") format("woff2");
}

@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  font-display: block; /* text waits (invisibly) for the right font, never shows a stand-in font first */
  src: url("fonts/instrument-serif-400.woff2") format("woff2");
}

:root {
  /* EDIT: colours. Mint + brown are sampled from the hand-written notes. */
  --paper: #f9f7f3;          /* Main page background (warm off-white). */
  --paper-deep: #efebe5;     /* Slightly darker paper for image boxes. */
  --bar: rgba(249, 247, 243, 0.92); /* Top bar, name card and portfolio filter bar (= --paper, slightly see-through). */
  --ink: #1f1a17;            /* Main text colour. */
  --ink-soft: #6a625c;       /* Secondary text. */
  --mint: #a9dcc4;           /* Note paper green. */
  --mint-light: #d9f0e4;     /* Light note green for highlights. */
  --marker: #5b2c1e;         /* Brown marker ink from the notes. */

  /* EDIT: fonts. The files are in the "fonts" folder (see @font-face above). */
  --font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif; /* Big titles. */
  --font-mono: 'IBM Plex Mono', 'Courier New', Courier, monospace;      /* Labels, body, UI. */

  --gutter: clamp(16px, 4vw, 56px); /* Side padding used on every page. */
  --header-h: 60px;                 /* Height of the sticky top bar. */

  /* EDIT: length of the fade between ALL pages (out + in). scripts/shared.js reads this too. */
  --page-fade: 0.22s;
}


/* ==== 2. BASE =========================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth; /* Smooth jump to #contact etc. */
  scroll-padding-top: calc(var(--header-h) + 16px); /* Anchors land below the sticky top bar. */
  background-color: #ffffff; /* What you see for a split second between two pages. */
}

body {
  background-color: var(--paper);
  /* Page transition: every page fades in; scripts/shared.js adds .is-leaving to fade out. */
  animation: page-in var(--page-fade) ease-out both;
  transition: opacity var(--page-fade) ease-in;
  isolation: isolate; /* Keeps the fixed table photos (z-index below 0) in front of the body colour. */
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: clip; /* No sideways scrolling; "clip" keeps position: sticky working. */
  min-height: 100vh;
}

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

a {
  color: inherit;
}

:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: 4px;
}

body.is-leaving {
  animation: none;
  opacity: 0;
}

@keyframes page-in {
  from { opacity: 0; }
}

/* The fade-in waits (page stays invisible) until the fonts are loaded and, on the portfolio,
   the tab and scroll position are set. Then it plays as usual. See scripts/early.js. */
html.fonts-pending body,
html.portfolio-pending body {
  animation-play-state: paused;
}

/* Make the hidden attribute always win, even over display: grid/flex (used by the filters). */
[hidden] {
  display: none !important;
}

/* Text that screen readers read but nobody sees. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Small uppercase label used above headings. */
.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}


/* ==== 3. SHARED HEADER / FOOTER ========================================= */
/* Sticky top bar on every inner page. Semi-solid paper so it stays readable over images. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--header-h);
  padding: 0 var(--gutter);
  background-color: var(--bar); /* EDIT: change --bar at the top of this file. */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 rgba(31, 26, 23, 0.08);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-brand {
  font-weight: 500;
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: clamp(14px, 3vw, 32px);
}

.site-nav a {
  text-decoration: none;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  border-bottom-color: var(--marker); /* Marker-brown underline for the current page. */
}

/* Text on the textured bottom bar sits on small slips of paper, so it stays readable
   on the busy texture: cream paper + dark ink. Hover = marker brown. */
.site-footer > * {
  display: inline-block;
  padding: 5px 10px 4px;
  background-color: var(--paper);
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 1px 3px rgba(31, 26, 23, 0.3);
  transition: background-color 0.15s, color 0.15s;
}

/* "Privacy" sits right next to "2026 Frank de Mol" (the empty space goes after it). */
.site-footer .footer-privacy {
  margin-right: auto;
}

.site-footer a:hover {
  background-color: var(--marker);
  color: var(--paper);
}

/* Bottom bar: the texture with its torn top edge. The see-through top part of the image
   gives the ragged edge; the text slips sit on the solid bottom part. */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 72px var(--gutter) 22px;
  background: url("Images/web/bar-bottom.webp") left bottom / auto 100% repeat-x;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}


/* Your name on a paper card: identical on the table page and the portfolio page,
   at the same spot, so going from one to the other feels like one continuous page. */
:root {
  --name-card-top: clamp(20px, 2.6vw, 38px); /* EDIT: space between the top bar and the name card (portfolio + table page). */
}

.name-card {
  display: inline-block;
  justify-self: start;
  padding: 14px 26px 10px;
  background-color: var(--bar);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(3rem, 7vw, 6rem); /* EDIT: size of your name. */
  line-height: 0.95;
}


/* ==== 4. STOP-MOTION HELPER =============================================
   Markup:  <span class="sm" data-stopmotion="hover|loop" data-speed="160">
              <img class="sm-frame is-active" …> <img class="sm-frame" …> …
            </span>
   The first frame sets the size; the others are stacked exactly on top.
   scripts/shared.js switches .is-active to play the animation.          */
.sm {
  position: relative;
  display: block;
}

.sm-frame {
  width: 100%;
  height: auto;
  visibility: hidden;
}

.sm-frame:not(:first-child) {
  position: absolute;
  inset: 0;
  height: 100%;
}

.sm-frame.is-active {
  visibility: visible;
}


/* ==== 5. INDEX (EXHIBITION BUILDING) ==================================== */
body#home {
  background-color: #ffffff;
}

/* Quick links top-right for visitors who want to skip straight to the work. */
.home-header {
  position: absolute;
  z-index: 5;
  top: 0;
  right: 0;
  padding: 24px var(--gutter);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.home-skip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px clamp(30px, 4vw, 30px); /* EDIT: space between the two links. */
}

.home-header a {
  text-decoration: none;
  border-bottom: 1px solid rgba(31, 26, 23, 0.25);
}

.home-header a:hover {
  border-bottom-color: var(--ink);
}

.exhibition-display {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh; /* Visible phone height, ignoring the address bar. */
  min-height: 520px;
  overflow: hidden;
}

/*
  THE STAGE TECHNIQUE
  The stage has exactly the drawing's aspect ratio (2632 x 951) and is sized like
  object-fit: cover for an area 100% wide and --stage-height tall, anchored bottom-center.
  Anything inside it positioned with % (the door hotspot) stays glued to the drawing
  at every screen size. Reuse this for any scene with clickable/animated parts.
*/
.ex-stage {
  --ratio: calc(2632 / 951);  /* Width ÷ height of the exhibition drawings. */
  --stage-height: 80vh;       /* EDIT: how much of the screen height the building takes. */
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: max(100%, var(--stage-height) * var(--ratio));
  aspect-ratio: 2632 / 951;
}

.ex-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  pointer-events: none;
}

.ex-frame.active {
  display: block;
}

.ex-door {
  position: absolute;
  /* Measured on the drawing: the door opening spans 38.5–59% across and 45–85% down. */
  left: 38.5%;
  top: 45%;
  width: 20.5%;
  height: 40%;
  z-index: 2;
  cursor: pointer;
}


/* ==== 6. LANDING (THE TABLE) ============================================ */
body#landing {
  background-color: #a9a39e; /* Close to the table colour, shown while the photo loads. */
}

/* The table photo, fixed behind everything. */
.table-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* White see-through layer over the table (same idea as the contact block). */
.table-light {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-color: rgba(255, 255, 255, 0.568); /* EDIT: last number = how white the layer is. */
}

/*
  Table layout (big screens), like a photo of a table with things put down by hand:
     [Frank de Mol]      [Portfolio]   [ceramics]   [textiles]
     [About & contact]                 [experiments]
                   [photography]  [digital]          [prints]
  The name card and About & contact sit in the normal flow (top left, exactly where the
  name card sits on the portfolio page). The other objects are placed one by one with
  --x / --y / --w in landing.html.
*/
.table-surface {
  /* One "unit" of object size: about 1% of the screen width (a bit more on laptops), but
     smaller on short/wide screens so the whole table always fits on one screen.
     EDIT: 42 = how many units fit in the height. */
  --u: min(calc(0.7vw + 6px), calc((100svh - var(--header-h)) / 42));
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: clamp(20px, 3vw, 40px); /* EDIT: space between the name card and About & contact. */
  min-height: calc(100svh - var(--header-h));
  padding: var(--name-card-top) var(--gutter) 48px;
}

/* Every object is as wide as --w units; its height follows from the photo. */
.note {
  width: calc(var(--w, 12) * var(--u));
}

/* The objects on the right, each at its own spot. */
.table-notes > .note {
  position: absolute;
  left: var(--x);
  top: var(--y);
}


/* ---- Notes (the main buttons) ---- */
.note {
  position: relative;
  display: block;
  color: var(--ink);
  text-decoration: none;
}


.note:hover,
.note:focus-visible {
  z-index: 2;
}

/* Layer 1: the slow Balatro-style sway. Paused (still) until the note is hovered;
   it pauses again where it is when the mouse leaves, so it never jumps. */
.note-body {
  display: block;
  transform-origin: 50% 85%;
  animation: note-sway 7s ease-in-out infinite; /* EDIT: higher = slower sway. */
  animation-delay: var(--phase, 0s);
  animation-play-state: paused;
}

.note:hover .note-body,
.note:focus-visible .note-body {
  animation-play-state: running;
}

@keyframes note-sway {
  0%, 100% { transform: translateY(0) rotate(calc(var(--tilt, 0deg) - 1.6deg)); }
  50%      { transform: translateY(-8px) rotate(calc(var(--tilt, 0deg) + 1.6deg)); }
}

/* Layer 2: hover — grows and leans toward the cursor (angles set by scripts/landing.js). */
.note-tilt {
  display: block;
  transform: perspective(800px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(var(--scale, 1));
  transition: transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.note:hover .note-tilt,
.note:focus-visible .note-tilt {
  --scale: 1.14; /* EDIT: hover size. */
}

/* Shadow under each object, so it lies on the table. */
.note .sm {
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.28));
  transition: filter 0.5s ease;
}

.note:hover .sm,
.note:focus-visible .sm {
  filter: drop-shadow(0 20px 16px rgba(0, 0, 0, 0.3)); /* Lifted off the table. */
}

/* Typed label under each note. Remove it from landing.html once a note image has its own word on it. */
.note-label {
  /* Under the object, on the right: its right edge lines up with the object's right edge
     (also when the label is wider than the object). EDIT: 12px = space above it. */
  display: table;
  position: relative;
  left: 100%;
  translate: -100% 0;
  margin: 12px 0 0;
  padding: 2px 10px;
  background-color: #ffffff;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: rotate(-2deg);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
}

/* Phones and small tablets: name card and About & contact on top,
   then the other objects two per row (the hand placement is switched off). */
@media (max-width: 900px) {
  .table-side {
    width: min(100%, 360px);
  }
  .note-about {
    width: 100%;
  }
  .table-notes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: center;
    gap: 32px 20px;
    width: 100%;
  }
  .table-notes > .note {
    position: relative;
    left: auto;
    top: auto;
    width: auto;
    max-width: 100%;
  }
  /* The tall vase would otherwise become huge at full column width. */
  .table-notes .sm-frame {
    max-height: 220px;
    object-fit: contain;
  }
  .table-notes > .note:first-child {
    grid-column: 1 / -1;
    justify-self: center;
    width: 70%;
  }
}


/* ==== 7. ABOUT + CONTACT ================================================ */
body#about {
  --visual-w: 40vw; /* EDIT: width of the hands column. */
}

/* Left: the hands stop-motion. Fixed to the screen, so it never moves while you scroll
   (the footer slides over its bottom edge at the end). The left arm touches the screen
   edge, the right arm touches the vertical line. */
.about-visual {
  position: fixed;
  z-index: 0;
  top: var(--header-h);
  bottom: 0;
  left: 0;
  width: var(--visual-w);
  display: flex;
  align-items: center;
  border-right: 1px solid var(--ink);
}

.hands-box {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
}

.hands-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  visibility: hidden;
}

.hands-frame.is-active {
  visibility: visible;
}

.about-story {
  margin-left: var(--visual-w);
  min-height: calc(100svh - var(--header-h)); /* Footer never sits higher than the screen bottom. */
  padding: clamp(40px, 8vh, 88px) var(--gutter) 88px clamp(32px, 5vw, 80px);
}

/* Footer slides over the hands column at the very end. */
body#about .site-footer {
  position: relative;
  z-index: 1;
}

.story-block {
  max-width: 580px;
  margin-bottom: 72px;
}

.about-story h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(3rem, 6vw, 5.5rem);
  line-height: 0.95;
  margin-bottom: 24px;
}

/* "I'm Frank de Mol": its own line under the big "Hello,".
   EDIT: 0.5em = half the size of "Hello,". */
.about-story h1 .h1-sub {
  display: block;
  margin-top: 0.12em;
  font-size: 0.5em;
  line-height: 1;
}

.story-block h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  line-height: 1.05;
  margin-bottom: 16px;
}

.story-block p + p {
  margin-top: 12px;
}

.lead {
  font-size: 1.05rem;
}

/* "Currently looking for" — the most important line for schools and studios. */
.looking-for {
  margin-top: 28px;
  padding: 18px 20px;
  background-color: var(--mint-light);
  border-left: 4px solid var(--marker);
}

/* The photo at the top of the about text (portrait + cut-out hands; the see-through part
   of the photo shows the paper behind it). As wide as the text column. */
.about-header {
  display: block;
  width: 100%;
  height: auto;
  margin-bottom: 32px; /* EDIT: space between the photo and "About me" */
}

/* ---- Contact: the table texture with a white see-through layer on top ---- */
.contact-block {
  position: relative;
  max-width: 640px;
  padding: clamp(28px, 4vw, 48px);
  background: #a9a39e url("Images/web/table.webp") center / cover;
}

.contact-block::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.724); /* EDIT: last number = how white the layer is. */
}

.contact-block > * {
  position: relative; /* Keep the text above the white layer. */
}

.contact-block h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  line-height: 1;
  margin-bottom: 8px;
}

.contact-block > p {
  margin-bottom: 28px;
}

/* The email address: the main thing people come here for. */
.contact-email {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 16px;
  margin-bottom: 28px;
}

.contact-email a {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.1;
  color: var(--marker);
  text-decoration-thickness: 1px;
  text-underline-offset: 6px;
  overflow-wrap: anywhere;
}

/* Other ways to reach you: label on the left, link on the right. */
.contact-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 28px;
  font-size: 0.9rem;
}

.contact-list > div {
  display: contents; /* The row wrappers don't break the two-column grid. */
}

.contact-list dt {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding-top: 3px;
}

.contact-list a {
  text-decoration: none;
  border-bottom: 1px solid rgba(31, 26, 23, 0.3);
}

.contact-list a:hover {
  color: var(--marker);
  border-bottom-color: var(--marker);
}

@media (max-width: 820px) {
  .about-visual {
    position: relative; /* Not fixed on phones — it would cover the text. */
    top: auto;
    width: 100%;
    border-right: none;
  }
  .about-story {
    margin-left: 0;
    padding: 24px var(--gutter) 64px;
  }
}

/* ---- Privacy page (privacy.html): one calm column of text ---- */
.legal-page {
  min-height: calc(100svh - var(--header-h));
  padding: clamp(40px, 8vh, 88px) var(--gutter) 88px;
}

.legal-page .story-block {
  margin-bottom: 48px;
}

.legal-page h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.6rem, 5vw, 4.2rem);
  line-height: 0.95;
  margin-bottom: 20px;
}



/* ==== 8. PORTFOLIO ====================================================== */
/* The same table as the landing page, very faint, fixed behind the work.
   EDIT: --portfolio-wash = how much cream lies over the table (last number: 1 = no table visible). */
body#portfolio {
  --portfolio-wash: rgba(249, 247, 243, 0.8);
}

body#portfolio::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--portfolio-wash), var(--portfolio-wash)),
    url("Images/web/table.webp");
  background-size: cover;
  background-position: center;
  pointer-events: none;
}

.work-intro {
  padding: var(--name-card-top) var(--gutter) 28px;
}


/* ---- Filter bar: sticks right under the top bar while scrolling ---- */
.filter-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  padding: 12px var(--gutter);
  /* Same texture as the bottom bar (only its solid part, without the torn edge).
     The chips are paper slips on top of it, like the footer text. */
  background: #c9cdb8 url("Images/web/bar-texture.webp") left center / auto 100% repeat-x;
  box-shadow: 0 4px 10px rgba(31, 26, 23, 0.18);
}

.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto; /* On phones the tabs scroll sideways instead of wrapping. */
  scrollbar-width: none;
}

/* Square tabs. */
.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.chip:hover {
  background-color: var(--mint-light);
}

.chip[aria-pressed="true"] {
  background-color: var(--ink);
  color: var(--paper);
}

.chip-count {
  font-size: 0.7rem;
  opacity: 0.55;
}

/* ---- Short intro per discipline (only visible when that filter is active) ---- */
/* Shown on a mint card. */
.discipline-intro {
  max-width: min(68ch, calc(100% - 2 * var(--gutter)));
  margin: 32px var(--gutter) 0;
  padding: 14px 18px;
  background-color: var(--mint-light);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* ---- All work: projects and studies together in one grid ----
   Projects are bigger (2 columns wide, 2 rows tall) and come first; studies fill in
   around them. A coloured line under each card says what it is. */
.work-section {
  --line-project: #78a894;  /* EDIT: blue-green from the bottom bar illustration */
  --line-study: #eee8b5;    /* EDIT: yellow from the bottom bar (a little deeper, so it shows on paper) */
  --line-size: 5px;         /* EDIT: thickness of the coloured line */
  padding: 40px var(--gutter) 24px;
}

/* EDIT: 230px = the smallest width of a study card (smaller = more columns). */
.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  grid-auto-flow: dense; /* studies fill the gaps next to the big project cards */
  gap: 32px 24px;
}

/* Both kinds of card: a photo print with a paper border and the coloured line under it. */
.project-card > a,
.study {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: var(--paper);
  border-bottom: var(--line-size) solid var(--line-project);
  box-shadow: 0 10px 22px rgba(31, 26, 23, 0.14);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s ease;
}

.study {
  border-bottom-color: var(--line-study);
}

/* Hover (both kinds): the print lifts a little and the photo zooms in slightly. */
.project-card > a:hover,
.project-card > a:focus-visible,
.study:hover,
.study:has(.study-open:focus-visible) {
  transform: translateY(-6px);
  box-shadow: 0 22px 36px rgba(31, 26, 23, 0.2);
}

.project-card > a:hover .project-media img,
.project-card > a:hover .project-media video,
.study:hover .study-open img {
  transform: scale(1.03);
}

/* ---- Project cards: 2 columns wide and 2 rows tall ---- */
.project-card {
  grid-column: span 2;
  grid-row: span 2;
}

.project-card > a {
  padding: 12px 12px 16px;
  text-decoration: none;
}

.project-media {
  position: relative;
  flex: 1;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background-color: var(--paper-deep);
}

.project-media img,
.project-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.project-card h3 {
  margin-top: 12px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(1.6rem, 2.4vw, 2rem);
  line-height: 1.05;
}

.project-meta {
  margin-top: 2px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---- Study cards: 1 column, 1 row ---- */
.study {
  padding: 10px 10px 14px;
  cursor: zoom-in; /* the whole card opens the study, not just the photo */
}

.study-open {
  position: relative;
  flex: 1;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: none;
  background: var(--paper-deep);
  cursor: zoom-in;
}

.study-open img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; /* the full photo is shown when the study is opened */
  transition: transform 0.4s ease;
}

.study h3 {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* The date under each study (from study.txt, or the date the photo was taken). */
.study .study-date {
  margin-top: 6px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.study h3 + .study-date {
  margin-top: 2px;
}

/* The short explanation (the text in study.txt under the top lines) is only shown in the
   enlarged view, not on the card. It stays in the page so the enlarged view can read it. */
.study .study-note {
  display: none;
}

/* Phones: projects full width, studies two next to each other (so projects stay bigger). */
@media (max-width: 560px) {
  .work-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 12px;
  }

  .project-card {
    grid-column: span 2;
    grid-row: auto;
  }

  .study {
    padding: 6px 6px 10px;
  }
}

/* Grey box shown where a real photo still needs to go. */
.media-placeholder {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background:
    repeating-linear-gradient(45deg, transparent 0 12px, rgba(31, 26, 23, 0.05) 12px 13px),
    var(--paper-deep);
}

.empty-state {
  width: fit-content;
  margin: 64px auto;
  padding: 14px 20px;
  background-color: var(--bar);
  text-align: center;
  color: var(--ink-soft);
}

/* ---- Lightbox for studies ----
   One study at a time: a paper sheet with the photo in an outlined frame, and under it
   two outlined boxes (title + date | short explanation) split by a line. */
.lightbox {
  --lb-line: rgba(31, 26, 23, 0.35);   /* EDIT: colour of the thin outlines */
  --lb-gap: 14px;                      /* EDIT: space between the boxes */
  width: min(1100px, 94vw);
  max-height: 96vh;
  margin: auto;
  padding: var(--lb-gap);
  border: none;
  background: var(--paper);
  color: var(--ink);
  overflow: auto;
}

.lightbox::backdrop {
  background-color: rgba(20, 17, 15, 0.86);
}

/* × in the top-right corner, sitting on the photo frame. */
.lightbox-close {
  position: absolute;
  top: calc(var(--lb-gap) + 10px);
  right: calc(var(--lb-gap) + 10px);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 0;
  background-color: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover {
  background-color: var(--mint-light);
}

/* The photo frame. EDIT: 68vh = how tall the photo may get (part of the screen height). */
.lightbox-stage {
  position: relative;
  display: grid;  /* the two photo layers lie exactly on top of each other */
  border: 1px solid var(--lb-line);
  background-color: var(--paper-deep);
}

.lightbox-photo {
  grid-area: 1 / 1;
  display: block;
  width: 100%;
  height: 68vh;
  object-fit: contain;
  opacity: 0;
  /* EDIT: 0.18s = how long the old photo takes to fade out, and the new one to fade in.
     If you change it, also change FADE = 180 in scripts/portfolio.js. */
  transition: opacity 0.18s ease;
}

.lightbox-photo.is-shown {
  opacity: 1;
}

/* Opening a study: the first photo is there at once, without fading. */
.lightbox-photo.no-fade {
  transition: none;
}

/* The → and ← on the photo, to the next/previous photo of this study. */
.lightbox-arrow {
  position: absolute;
  z-index: 2;
  top: 50%;
  translate: 0 -50%;
  display: flex;               /* the arrow sits exactly in the middle of its box */
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 0;
  background-color: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-arrow:hover {
  background-color: var(--mint-light);
}

.lightbox-arrow svg {
  display: block;
  width: 20px;   /* EDIT: size of the arrow inside the box */
  height: 20px;
}

.lightbox-arrow--prev { left: 14px; }
.lightbox-arrow--next { right: 14px; }
.lightbox-arrow[hidden] { display: none; }

/* The small photos, at the bottom of the photo. The one you're looking at gets a
   thick outline. EDIT: 20px = their height. */
.lightbox-thumbs {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 12px;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 5px;
  max-width: calc(100% - 28px);
  overflow-x: auto;
}

.lightbox-thumbs[hidden] {
  display: none;
}

.lightbox-thumbs button {
  flex: none;
  padding: 1px;
  border: 1px solid var(--lb-line);
  border-radius: 0;
  background-color: var(--paper);
  cursor: pointer;
  opacity: 0.75;
  transition: opacity 0.2s ease;
}

.lightbox-thumbs button:hover {
  opacity: 1;
}

.lightbox-thumbs button[aria-current="true"] {
  opacity: 1;
  border: 2px solid var(--ink);
  padding: 0;
}

.lightbox-thumbs img {
  display: block;
  height: 20px;
  width: auto;
}

/* Under the photo: title + date | line | short explanation. */
.lightbox-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--lb-gap);
  margin-top: var(--lb-gap);
}

.lightbox.has-note .lightbox-info {
  /* EDIT: title box 1 part, the line, explanation box 3 parts (so 1/4 and 3/4). */
  grid-template-columns: minmax(0, 1fr) 1px minmax(0, 3fr);
}

.lightbox-box {
  padding: 14px 18px;
  border: 1px solid var(--lb-line);
}

.lightbox-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.7rem;
  line-height: 1.1;
}

.lightbox-title:empty {
  display: none; /* Studies without a title only show their date. */
}

.lightbox-date {
  margin-top: 4px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.lightbox-divider {
  display: none;
  background-color: var(--ink);
}

.lightbox-note {
  display: none;
  font-size: 0.9rem;
  line-height: 1.55;
}

.lightbox.has-note .lightbox-divider,
.lightbox.has-note .lightbox-note {
  display: block;
}

/* Phones: everything stacked, smaller photo frame and controls. */
@media (max-width: 620px) {
  .lightbox { --lb-gap: 10px; }
  .lightbox-photo { height: 52vh; }
  .lightbox.has-note .lightbox-info { grid-template-columns: minmax(0, 1fr); }
  .lightbox.has-note .lightbox-divider { display: none; }
  .lightbox-arrow { width: 36px; height: 36px; }
  .lightbox-arrow--prev { left: 8px; }
  .lightbox-arrow--next { right: 8px; }
  .lightbox-thumbs img { height: 18px; }
}

/* ==== 9. PROJECT CASE-STUDY PAGE ======================================== */
.project-hero {
  width: 100%;
  max-height: 80vh;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background-color: var(--paper-deep);
}

.project-hero img,
.project-hero video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Title + story on the left, the facts box on the right (as tall as the left side). */
.project-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(260px, 24vw, 360px); /* EDIT: last value = facts box width. */
  gap: 32px clamp(32px, 5vw, 72px);
  padding: 56px var(--gutter) 48px;
}

.project-head:not(:has(.project-facts)) {
  grid-template-columns: minmax(0, 1fr);
}

.project-head h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.8rem, 6vw, 5rem);
  line-height: 0.95;
  margin-bottom: 20px;
}

.project-head .lead {
  max-width: 62ch;
}

/* Quick facts (year, role, materials …): a white box with a list, each label above
   its value, thin lines between the items. */
.project-facts {
  display: flex;
  flex-direction: column;
  padding: 8px 24px;
  border: 1px solid rgba(31, 26, 23, 0.35); /* Same thin outline as the chapter text boxes. */
  font-size: 0.85rem;
}

.project-facts > div {
  padding: 14px 0;
}

.project-facts > div + div {
  border-top: 1px solid rgba(31, 26, 23, 0.14);
}

.project-facts dt {
  margin-bottom: 4px;
  color: var(--ink-soft);
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
}

/*
  A chapter: a thin line on top, then a text box and the photos side by side.
  The text box is exactly as tall as the photos next to it and uses the same gap,
  so it reads as one more tile in the photo grid.
  EDIT: the first value of grid-template-columns = width of the text box.
*/
.process-step {
  --photo-gap: 12px; /* EDIT: space between the photos (and between the box and the photos). */
  display: grid;
  grid-template-columns: clamp(220px, 21vw, 320px) minmax(0, 1fr);
  gap: var(--photo-gap);
  margin: 0 var(--gutter);
  padding: 40px 0;
  border-top: 1px solid rgba(31, 26, 23, 0.18); /* EDIT: the line between chapters. */
}

.process-text {
  display: flex;
  flex-direction: column;
  padding: 24px 22px;
  border: 1px solid rgba(31, 26, 23, 0.35); /* EDIT: the thin outline of the boxes. */
}

.process-text .eyebrow {
  margin-bottom: 8px;
}

.process-step h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.2rem, 3.2vw, 3rem); /* EDIT: size of the chapter titles. */
  line-height: 1;
  margin-bottom: 14px;
}

.process-text p {
  font-size: 0.85rem;
  line-height: 1.6;
}

.process-text p + p {
  margin-top: 10px;
}

/* A chapter with only text: the box gets a comfortable reading width. */
.process-step--text-only {
  grid-template-columns: minmax(0, 720px);
}

/* Photos of a chapter in evenly filled rows of max 3 (set by build.py: 4 photos = 2 + 2,
   5 = 3 + 2). Photos in one row get the same height and are never cropped: each takes
   width in proportion to its shape (--ar). */
.process-images {
  display: grid;
  align-content: start;
  gap: var(--photo-gap);
}

.photo-row {
  display: flex;
  gap: var(--photo-gap);
}

.photo-row > img,
.photo-row > video {
  flex: var(--ar, 1) 1 0;
  min-width: 0;
  width: 100%;
  height: auto;
  background-color: var(--paper-deep);
}

/* A single tall photo would become huge across the full width; keep it within the screen. */
.photo-row > :only-child {
  flex: none;
  width: auto;
  max-width: 100%;
  max-height: 80vh;
}

/* Last chapter (usually the result): its first photo fills the whole photo side of the
   chapter, next to the text box, with the other photos underneath. A tall photo is kept
   within 90% of the screen height (--ar = its width ÷ height) and pushed to the left,
   lined up with the photos below. EDIT: "center" instead of "flex-start" centres it. */
.photo-row--feature {
  justify-content: flex-start;
}

.photo-row--feature > img,
.photo-row--feature > video {
  flex: none;
  width: min(100%, calc(90vh * var(--ar, 1.5)));
  max-width: 100%;
  max-height: none;
}

/* Photos placed above the first "# Heading" in project.txt: full width row. */
.process-step--photos {
  grid-template-columns: 1fr;
}

.project-next {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 40px var(--gutter);
  font-size: 0.85rem;
}

@media (max-width: 760px) {
  /* Phones: facts box under the story. */
  .project-head {
    grid-template-columns: minmax(0, 1fr);
  }
  /* Phones: text box on top, then every photo full width, one under the other. */
  .process-step {
    grid-template-columns: 1fr;
    padding: 28px 0;
  }
  .photo-row {
    flex-direction: column;
  }
  .photo-row > img,
  .photo-row > video {
    flex: none;
  }
}


/* ---- Enlarge a photo (project pages): click a photo to see it big ----
   The window is made by scripts/project.js. Close: ×, Esc, or click anywhere. */
#project .project-hero img,
#project .photo-row > img {
  cursor: zoom-in;
}

.zoom {
  max-width: 96vw;
  max-height: 96vh;
  margin: auto;
  padding: 12px;              /* EDIT: width of the paper border around the photo */
  border: none;
  background: var(--paper);
  overflow: hidden;
  cursor: zoom-out;
}

.zoom:focus {
  outline: none;
}

.zoom::backdrop {
  background-color: rgba(20, 17, 15, 0.86);
}

.zoom-photo {
  display: block;
  max-width: calc(96vw - 24px);
  max-height: calc(96vh - 24px);  /* the photo is never cropped: always fully visible */
  width: auto;
  height: auto;
  object-fit: contain;
  background-color: var(--paper-deep);
}

/* The × reuses the look of the studies' close button (.lightbox-close). */
.zoom .lightbox-close {
  top: 22px;
  right: 22px;
}
