/* Mister — values taken from the Figma frame "Mister_Home" (1920px wide) */

@font-face {
  font-family: "KMR Waldenburg Medium";
  src: url("fonts/kmr-waldenburg-medium.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "KMR Waldenburg Bold";
  src: url("fonts/kmr-waldenburg-medium.woff2") format("woff2");   /* "Bold" text now set in the Medium weight */
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "KMR Waldenburg";
  src: url("fonts/kmr-waldenburg-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
:root {
  --margin: 20px;          /* page margin */
  --gap: 0px;              /* gap between images */
  --space: 80px;           /* vertical gap between sections */
  --columns: 4;            /* images per row on large screens (1440px and up) */
  --tile-ratio: 16 / 9;    /* shape of every gallery tile */
  --tile-min: 120px;       /* smallest tile width: about 15 per row at 1920px, 3 on a phone */
  --type: clamp(14px, calc(2.0833vw - 11px), 29px);  /* 29px at 1920 */
  --leading: calc(34 / 29); /* 34px line height at 29px */
  --tracking: -0.02em;     /* -0.72px at 36px */
  --tile-bg: #d9d9d9;      /* placeholder while an image loads */
}

/* Columns drop as the window narrows, so tiles stay a similar size instead of shrinking */
@media (max-width: 1439px) { :root { --columns: 3; } }
@media (max-width: 1023px) { :root { --columns: 2; } }
@media (max-width: 899px)  { :root { --margin: 12px; --space: 52px; --type: 18px; --leading: calc(41 / 36); } }  /* phones: 18px text, 52px gaps */
@media (max-width: 599px)  { :root { --tile-min: 105px; } }  /* phones: 3 thumbnails per row */

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

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

/* Colour themes: light grey (default) and black, switched with the footer circles */
:root { --bg: #efefef; --fg: #000; }   /* light theme: light grey background */
html.theme-dark { --bg: #111; --fg: #efefef; --tile-bg: #2a2a2a; }   /* dark theme: softened black, light grey text */
html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  transition: background-color 0.4s ease, color 0.4s ease;
  font-family: "KMR Waldenburg", "Helvetica Neue", Arial, sans-serif;
  font-weight: 400;
  font-size: var(--type);
  line-height: var(--leading);
  letter-spacing: var(--tracking);
  -webkit-font-smoothing: antialiased;
}

main { padding: calc(var(--margin) / 2) var(--margin) var(--margin); }

p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: inherit; text-underline-offset: 0.12em; text-decoration-thickness: 0.05em; }

/* Animated underline: on hover the line wipes out to the right, then redraws from the left */
.link {
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-size: 100% 0.05em;
  background-position: 100% 100%;
  padding-bottom: 0.04em;
}
.link:hover,
.link:focus-visible {
  animation: link-wipe 0.6s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}
@keyframes link-wipe {
  0%   { background-size: 100% 0.05em; background-position: 100% 100%; }
  50%  { background-size: 0% 0.05em;   background-position: 100% 100%; }
  50.01% { background-size: 0% 0.05em; background-position: 0% 100%; }
  100% { background-size: 100% 0.05em; background-position: 0% 100%; }
}
/* Links with no line at rest: line draws in from the left on hover, exits right */
.link--reveal {
  background-size: 0% 0.05em;
  background-position: 100% 100%;
  transition: background-size 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}
.link--reveal:hover,
.link--reveal:focus-visible {
  animation: none;
  background-size: 100% 0.05em;
  background-position: 0% 100%;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .link:hover, .link:focus-visible { animation: none; opacity: 0.6; }
  .link--reveal { transition: none; }
}

.intro { max-width: 100%; margin: 0; font: inherit; letter-spacing: inherit; }  /* main heading, styled as body text */

/* Two-column info block: services on the left third, facts from the second third */
.info {
  display: grid;
  grid-template-columns: 1fr 2fr;
  column-gap: var(--margin);
  margin-top: var(--space);
}
.facts p + p { margin-top: calc(var(--leading) * 1em); }

/* Solid dot before Credentials (Figma: 29px at 40px type, centred on the line) */
.dot {
  flex: none;
  width: 0.725em;
  height: 0.725em;
  margin-right: calc(0.5em - 3px);
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: inset 0 0 0 0.035em currentColor;   /* stays as the outline when the fill fades */
  transition: background-color 0.25s ease;
}
/* Credentials hover: solid dot becomes an outline circle, underline draws in */
.credentials:has(.cred-link:hover) .dot,
.credentials:has(.cred-link:focus-visible) .dot { background-color: transparent; }
.cred-email { margin-left: auto; }   /* right-aligned on the Credentials line */

@media (max-width: 699px) {
  .info { grid-template-columns: 1fr; row-gap: calc(var(--leading) * 1em); }
  .info { margin-top: calc(var(--leading) * 1em); }  /* same one-line gap as Product Design → 246 */
}

/* ---------- Gallery ---------- */
/* Small, same-size thumbnails in one grid (like dia.studio): as many ~80px tiles as fit per row.
   Clicking opens the whole, uncropped image in the viewer. */
.groups { margin-top: var(--space); }

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tile-min), 1fr));
  gap: var(--gap);
}

.tile {
  margin: 0;
  aspect-ratio: var(--tile-ratio);
  background: var(--tile-bg);
  overflow: hidden;
}
.tile img, .tile video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Load effect: a tiny blurred preview of each image shows first, then the full image
   fades in from blurred to sharp. Only with JavaScript, so images never stay hidden. */
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--preview) center / cover no-repeat;
  filter: blur(16px);
  transform: scale(1.15);   /* hides the soft edges the blur creates */
}
.tile img, .tile video { position: relative; }
.js .tile img, .js .tile video {
  opacity: 0;
  filter: blur(16px);
  transform: scale(1.04);
  transition: opacity 0.7s ease, filter 0.9s ease, transform 0.9s ease;
}
.js .tile.is-loaded img, .js .tile.is-loaded video { opacity: 1; filter: none; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .js .tile img, .js .tile video { filter: none; transform: none; transition: opacity 0.2s linear; }
}

/* ---------- About text (below the gallery) ---------- */
.about { margin-top: var(--space); }
.about p + p { margin-top: calc(var(--leading) * 1em); }
.about .strapline + p { margin-top: 0; }   /* one blank line between paragraphs */
/* Text in the right-hand column (lined up with "246 websites…") */
.about-detail {
  margin-top: calc(var(--leading) * 1em);   /* one blank line, so all three paragraphs read as one block */
  display: grid;
  grid-template-columns: 1fr 2fr;
  column-gap: var(--margin);
}
.about-detail-text { grid-column: 2; }
/* First paragraph sits in the same right-hand column, so both paragraphs line up */
.about-intro {
  display: grid;
  grid-template-columns: 1fr 2fr;
  column-gap: var(--margin);
}
.about-intro > p { grid-column: 2; }
.about-intro > .strapline { grid-column: 1; text-indent: 0; }   /* strapline in the left column, level with the first line */
@media (max-width: 699px) {
  .about-detail, .about-intro { grid-template-columns: 1fr; }
  .about-detail-text, .about-intro > p { grid-column: 1; }
  .about-intro { row-gap: calc(var(--leading) * 1em); }   /* phones: strapline, blank line, then paragraph */
}

/* Full-width line above the footer */
.rule {
  border: 0;
  border-top: 1px solid currentColor;
  margin: var(--space) 0 0;
}

/* "● work" link in the studio paragraph: opens the Credentials PDF, same hover as Credentials */
.inline-cred { color: inherit; text-decoration: none; white-space: nowrap; }
.inline-cred .dot {
  display: inline-block;
  vertical-align: -0.02em;   /* sits on the baseline, cap-height tall, like the letters */
  margin-right: 0;
}
.inline-cred .dot + .link { margin-left: 0.25em; }   /* same as a word space either side of the dot */
.inline-cred:hover .dot,
.inline-cred:focus-visible .dot { background-color: transparent; }
.inline-cred:hover .link--reveal,
.inline-cred:focus-visible .link--reveal { background-size: 100% 0.05em; background-position: 0% 100%; }

/* ---------- Footer ---------- */
/* "▲ Top": solid triangle drawn in CSS so it matches the dots; whole thing is the link */
.top-link {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}
.tri {
  flex: none;
  width: 0.8em;
  height: 0.7em;
  margin-right: calc(0.5em - 3px);   /* same gap as the dot before Credentials */
  background: currentColor;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.top-link:hover .link--reveal,
.top-link:focus-visible .link--reveal { background-size: 100% 0.05em; background-position: 0% 100%; }
.footer {
  display: grid;
  grid-template-columns: 1fr 2fr;
  column-gap: var(--margin);
  margin-top: calc(var(--leading) * 1em);   /* one line below the rule, same as "Let's work together." */
}
.contact { display: flex; flex-direction: column; }

/* Top row of the contact column: text on the left, theme circles + clock on the right */
.contact-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--margin);
}
.theme-clock {
  display: flex;
  align-items: center;
  height: calc(var(--leading) * 1em);   /* one line high, so it sits on the first line */
  flex: none;
}
.theme-btn {
  font-size: inherit;   /* buttons don't inherit text size by default */
  flex: none;
  width: 0.725em;
  height: 0.725em;
  padding: 0;
  margin: 0 0.3em 0 0;
  border: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 0.035em var(--fg);   /* outline in the text colour */
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.4s ease;
}
.theme-btn--dark  { background: #111; }   /* click for dark */
.theme-btn--light { background: #efefef; }   /* click for light grey */
.theme-btn:hover { transform: scale(1.15); }
.theme-btn:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }
.clock {
  margin-left: 0;
  font-variant-numeric: tabular-nums;   /* digits don't jiggle as the seconds tick */
}

.footer-base {
  margin-top: auto;
  padding-top: calc(var(--leading) * 1em);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
@media (max-width: 699px) {
  .footer { grid-template-columns: 1fr; row-gap: calc(var(--leading) * 1em); }
}

/* ---------- Gallery tiles are clickable ---------- */
.gallery .tile { cursor: pointer; position: relative; }

/* Hovered image: black overlay plus a white arrow that slides in, to show it opens */
.gallery .tile::after {
  content: "";
  z-index: 1;
  position: absolute;
  inset: 0;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath d='M6 24h34M27 11l13 13-13 13' fill='none' stroke='white' stroke-width='3.5'/%3E%3C/svg%3E")
      calc(50% - 6px) 50% / 24px no-repeat;   /* no dark overlay: image shows in full colour */
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.45));   /* keeps the white arrow visible on light images */
  opacity: 0;
  transition: opacity 0.3s ease, background-position 0.3s ease;
  pointer-events: none;
}
@media (hover: hover) {
  .gallery .tile:hover::after { opacity: 1; background-position: 50% 50%, 0 0; }
}
.gallery .tile:focus-visible::after { opacity: 1; background-position: 50% 50%, 0 0; }
.gallery .tile:focus-visible { outline: 2px solid var(--fg); outline-offset: -2px; }

/* ---------- Image viewer (Figma: Image_Viewer) ---------- */
html.viewer-open { overflow: hidden; }

.viewer {
  --edge: 20px;                                         /* distance from screen edge */
  --label-row: calc(var(--leading) * var(--type));      /* one line of text */
  --gutter: calc(var(--edge) + 4.6 * var(--type));      /* keeps image clear of Previous / Next */
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  color: var(--fg);
  animation: viewer-in 0.25s ease-out;
}
.viewer[hidden] { display: none; }
.viewer:focus { outline: none; }
@keyframes viewer-in { from { opacity: 0; } }

.viewer-count, .viewer-close, .viewer-prev, .viewer-next { position: absolute; z-index: 2; margin: 0; }
.viewer-count { top: var(--edge); left: var(--edge); }   /* reads "233/240", with the two numbers side by side */
.viewer-close   { top: var(--edge); right: var(--edge); }
/* Project name: a light pill centred at the top of the image (positioned by viewer.js) */
.viewer-project {
  position: absolute;
  z-index: 2;
  margin: var(--pill-inset) 0 0;
  transform: translateX(-50%);   /* centred on the image */
  --pill-inset: clamp(10px, 1.1vw, 20px);
  padding: 0.5em 1em 0.55em;
  font-size: clamp(14px, 0.6em, 20px);
  line-height: 1;
  white-space: nowrap;
  color: #000;
  background: rgba(239, 239, 239, 0.92);
  border-radius: 999px;
  pointer-events: none;
}
.viewer-project[hidden] { display: none; }
.viewer-prev    { bottom: calc(var(--edge) + 1.375 * var(--type)); left: var(--edge); }
.viewer-next    { bottom: calc(var(--edge) + 1.375 * var(--type)); right: var(--edge); }

.viewer button {
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  color: inherit;
  background-color: transparent;
  border: 0;
  padding: 0 0 0.04em;
  cursor: pointer;
}

/* Area the image fills: top 20px, bottom level with Previous / Next */
.viewer-stage {
  position: absolute;
  top: var(--edge);
  bottom: calc(var(--edge) + 1.375 * var(--type));
  left: var(--gutter);
  right: var(--gutter);
  display: flex;
  align-items: center;
  justify-content: center;
}
.viewer-img[hidden] { display: none; }
.viewer-img {
  display: block;
  max-width: none;
  background: var(--tile-bg);
  user-select: none;
  -webkit-user-drag: none;
}

/* Arrow that follows the pointer over the image */
.viewer-cursor {
  position: fixed;
  top: 0;
  left: 0;
  margin: -32px 0 0 -32px;
  color: #fff;
  mix-blend-mode: difference;   /* stays visible on light and dark images */
  pointer-events: none;
  opacity: 0;
  z-index: 3;
}
.viewer-cursor svg { display: block; transition: transform 0.2s ease; }
.viewer-cursor[data-dir="prev"] svg { transform: rotate(180deg); }
.viewer-cursor.is-visible { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  .viewer-img { cursor: none; }
}

/* Smaller screens: numbers on top, Previous / Next underneath, image in between */
@media (max-width: 699px) {
  .viewer { --edge: 12px; }
  .viewer-prev, .viewer-next { bottom: var(--edge); }
  .viewer-stage {
    top: calc(var(--edge) * 2 + var(--label-row));   /* room for the counter */
    bottom: calc(var(--edge) * 2 + var(--label-row));
    left: var(--edge);
    right: var(--edge);
  }
}

/* Preview repeats (see PREVIEW_FILL in build.mjs): desktop only */
/* (repeats now show on all screen sizes) */

/* Black and white thumbnails: colour comes back on hover; the viewer always shows colour.
   To switch off, delete this block. */
.gallery .tile { filter: grayscale(1); transition: filter 0.4s ease; }
@media (hover: hover) { .gallery .tile:hover { filter: none; } }
.gallery .tile:focus-visible { filter: none; }

/* No hover arrow: hovering just brings the colour back */
.gallery .tile::after { display: none; }

/* First-line indent on full paragraphs (intro and about text), not on lists */
.intro, .about p { text-indent: 2.5em; }


/* Registration mark: half size, top aligned with the top of the capital M
   (Waldenburg: cap height 714, ® top 731 units, so raise by 0.714 - 0.3655 = 0.3485em of the text = 0.697em of the mark) */
.reg { font-size: 0.5em; line-height: 0; position: relative; top: -0.697em; margin-left: 0.04em; }

/* Live Projects: an outlined circle with a ↗ arrow (the viewer's arrow, turned 45°) appears after the name on hover.
   Placed outside the link's box so the underline stays under the name only. */
.projects a { position: relative; }
.projects a::before,
.projects a::after {
  content: "";
  position: absolute;
  left: 100%;
  top: 50%;
  width: 0.725em;
  height: 0.725em;
  margin: -0.33em 0 0 0.3em;   /* same size and gap as the other circles */
  border-radius: 50%;
  opacity: 0;
  transform: translateX(-0.2em);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.projects a::after { box-shadow: inset 0 0 0 0.035em currentColor; }   /* stroke, like the theme circles */
.projects a::before {
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath transform='rotate(-45 24 24)' d='M6 24h34M27 11l13 13-13 13' fill='none' stroke='black' stroke-width='5'/%3E%3C/svg%3E") center / 68% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath transform='rotate(-45 24 24)' d='M6 24h34M27 11l13 13-13 13' fill='none' stroke='black' stroke-width='5'/%3E%3C/svg%3E") center / 68% no-repeat;
}
.projects a:hover::before, .projects a:hover::after,
.projects a:focus-visible::before, .projects a:focus-visible::after { opacity: 1; transform: none; }

/* "● work" links: a big blue circle with an arrow grows in behind the text on hover */
.about, .info, .footer, .years { isolation: isolate; }   /* keeps the circles behind the text but above the page */
.inline-cred, .email-link, .credentials { position: relative; }
.inline-cred::before, .email-link::before, .credentials::before {
  content: "";
  position: absolute;
  z-index: -1;
  left: 0.36em;                 /* centred on the dot */
  top: 50%;
  width: 4.5em;
  height: 4.5em;
  border-radius: 50%;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath transform='rotate(-45 24 24)' d='M6 24h34M27 11l13 13-13 13' fill='none' stroke='white' stroke-width='3.5'/%3E%3C/svg%3E")
      center / 30% no-repeat,
    #0163ff;
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
  pointer-events: none;
}
.inline-cred:hover::before, .email-link:hover::before,
.credentials:has(.cred-link:hover)::before, .credentials:has(.cred-link:focus-visible)::before,
.inline-cred:focus-visible::before, .email-link:focus-visible::before { transform: translate(-50%, -50%) scale(1); opacity: 1; }
/* Email links have no dot: the arrow sits just before the address, in the clear space to its left */
.email-link::before { left: -1.1em; }
@media (prefers-reduced-motion: reduce) { .inline-cred::before, .email-link::before, .credentials::before { transition: opacity 0.2s linear; } }
.inline-cred:hover .dot,
.inline-cred:focus-visible .dot { visibility: hidden; }   /* the orange circle's arrow takes the dot's place */

/* Credentials: the circle grows from its dot (the line's first item), and the dot hides under it */
.credentials::before { left: 0.3625em; }   /* centred on its dot */
.credentials:has(.cred-link:hover) .dot,
.credentials:has(.cred-link:focus-visible) .dot { visibility: hidden; }

/* Row above the image bank: "2006 —— 2025" in the left column, Credentials and email in the
   right-hand columns, then a full-width rule 10px above the images */
.years {
  display: grid;
  grid-template-columns: 1fr 2fr;
  column-gap: var(--margin);
  align-items: center;
  margin: 0 0 10px;
  padding-bottom: calc(var(--leading) * 0.5em);
  border-bottom: 1px solid currentColor;
}
.years p { margin: 0; }
.years-range, .credentials { display: flex; align-items: center; }
@media (max-width: 699px) {
  .years { grid-template-columns: 1fr; row-gap: calc(var(--leading) * 1em); }
}
.years-line {
  width: 2.5em;
  height: 0;
  margin: 0 0.4em;
  border-top: 1px solid currentColor;
}

/* ---------- Enquiry form (below the footer) ---------- */
.enquiry { margin-top: var(--space); }
.enquiry-year {
  margin: 0;
  padding-bottom: calc(var(--leading) * 0.5em);
  border-bottom: 1px solid currentColor;
}
.enquiry-year .years-line { margin-right: 0; }
.enquiry-title {
  margin: calc(var(--leading) * 1em) 0 0;
  font: inherit;   /* same size as the rest of the text */
}
/* Heading starts in the second column, lined up with the footer's contact details;
   the form sits on the right, one column wide */
.enquiry-title { margin-left: calc((100% - var(--margin)) / 3 + var(--margin)); }
.enquiry-form {
  display: grid;
  gap: calc(var(--leading) * 1em);
  width: calc((100% - var(--margin)) / 3);
  margin: calc(var(--leading) * 1.5em) 0 0 auto;
}
.enquiry-form p { margin: 0; }
.field { display: block; }
.field input, .field textarea {
  display: block;
  width: 100%;
  padding: 0 0 0.6em;
  border: 0;
  border-bottom: 1px solid currentColor;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.7em;
  line-height: 1.3;
  outline: none;
  resize: vertical;
}
.field textarea { min-height: 9em; }
.field input::placeholder, .field textarea::placeholder { color: currentColor; opacity: 0.45; }
.field input:focus, .field textarea:focus { border-bottom-width: 2px; padding-bottom: calc(0.6em - 1px); }
.enquiry-send {
  margin-top: 0.4em;
  padding: 0.35em 1em 0.4em;
  border: 0;
  border-radius: 0;
  background: var(--fg);
  color: var(--bg);
  font: inherit;
  cursor: pointer;
  transition: background-color 0.35s ease, color 0.35s ease, opacity 0.2s ease;
}
.enquiry-send:hover, .enquiry-send:focus-visible { background: #0163ff; color: #fff; }   /* fades to the hover blue */
.enquiry-send:disabled { opacity: 0.5; cursor: default; }
/* Status message sits just under the button without adding space, so the gap below the
   button matches the gap below the rule (both one --space) */
.enquiry-form { position: relative; }
.enquiry-status { position: absolute; top: 100%; left: 0; margin-top: 0.6em !important; font-size: 0.7em; }
.hp { position: absolute; left: -9999px; }
@media (max-width: 699px) {
  .enquiry-title, .enquiry-form { margin-left: 0; }
  .enquiry-form { width: 100%; }
  .field input, .field textarea { font-size: 16px; }   /* stops iPhones zooming in on tap */
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
/* Lets the hover circles on Credentials and the email show over the top of the image bank.
   The gallery gets its own lower layer, and the row is forced onto its own layer too, because
   Safari can otherwise paint the (filtered) thumbnails above it. */
.gallery { position: relative; z-index: 0; }
.years { position: relative; z-index: 2; transform: translateZ(0); }

/* ---------- Opening message ----------
   Timeline: words drop in one by one (0.2s–1.3s), hold, lift away (2.5s–3.1s),
   then a page-coloured panel grows from the centre (3.1s–4.0s) and the screen fades to the site. */
.intro-screen { display: none; }
.js:not(.no-intro) .intro-screen {
  display: flex;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: var(--margin);
  background: #000;
  color: #fff;
  overflow: hidden;
  animation: intro-out 0.45s ease 4s forwards;
}
.intro-words { margin: 0; text-align: center; }
.intro-words .w {
  display: inline-block;
  opacity: 0;
  transform: translateY(-0.9em);
  animation:
    intro-word-in 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) calc(0.2s + var(--i) * 0.12s) forwards,
    intro-word-out 0.45s cubic-bezier(0.6, 0, 0.8, 0.4) calc(2.5s + var(--i) * 0.06s) forwards;
}
.intro-reveal {
  position: absolute;
  inset: 0;
  background: var(--bg);
  transform: scale(0);
  animation: intro-reveal 0.9s cubic-bezier(0.76, 0, 0.24, 1) 3.1s forwards;
}
/* Animations wait until the page is actually on screen */
.js:not(.intro-go) .intro-screen,
.js:not(.intro-go) .intro-screen .w,
.js:not(.intro-go) .intro-reveal { animation-play-state: paused; }
@keyframes intro-word-in  { to { opacity: 1; transform: none; } }
@keyframes intro-word-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-0.9em); } }
@keyframes intro-reveal   { from { transform: scale(0.06); } to { transform: scale(1); } }
@keyframes intro-out      { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  .intro-words .w { animation: none; opacity: 1; transform: none; }
  .intro-reveal { display: none; }
  .js:not(.no-intro) .intro-screen { animation-duration: 0.3s; animation-delay: 1.5s; }
}

/* ---------- Wordmark at the foot of the page ----------
   KMR Waldenburg Medium, scaled by footer.js so "Mister®" runs the full width between the margins */
.wordmark {
  margin-top: calc(var(--leading) * 1em);   /* same gap as the rule above "Let's work together." */
  padding-top: calc(var(--margin) * 0.75);
  border-top: 1px solid currentColor;
  white-space: nowrap;
  overflow-y: clip;   /* the big letters' invisible line space no longer adds scroll room below the logo */
}
.wordmark-text {
  display: inline-block;
  font-family: "KMR Waldenburg Bold", "KMR Waldenburg Medium", "KMR Waldenburg", "Helvetica Neue", Arial, sans-serif;
  font-size: 22vw;            /* starting size; footer.js fits it exactly */
  line-height: 0.78;          /* trims the space below the baseline */
  letter-spacing: -0.035em;
  white-space: nowrap;
}
/* ® under the arm of the r, sitting on the baseline, its right edge level with the end of the
   r's arm, as in the logo. Numbers come from KMR Waldenburg Medium: r ink ends at 0.371em of a
   0.393em advance; ® is 0.811em wide inside a 0.852em advance and dips 0.017em below the baseline. */
.wordmark-reg {
  font-size: 0.13em;
  letter-spacing: 0;
  margin-left: -0.765em;     /* pulls the ® back under the r's arm */
  position: relative;
  top: -0.017em;             /* bottom of the ® on the baseline */
}

/* Live Projects: the same big blue circle as the other links, growing just after the name
   (replaces the small outlined circle) */
.projects a::after { content: none; }
.projects a::before {
  z-index: -1;
  left: calc(100% + 1.1em);
  top: 50%;
  width: 4.5em;
  height: 4.5em;
  margin: 0;
  -webkit-mask: none;
          mask: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath transform='rotate(-45 24 24)' d='M6 24h34M27 11l13 13-13 13' fill='none' stroke='white' stroke-width='3.5'/%3E%3C/svg%3E")
      center / 30% no-repeat,
    #0163ff;
  transform: translate(-50%, -50%) scale(0.2);
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
}
.projects a:hover::before,
.projects a:focus-visible::before { opacity: 1; transform: translate(-50%, -50%) scale(1); }
@media (prefers-reduced-motion: reduce) { .projects a::before { transition: opacity 0.2s linear; } }
/* Opening paragraph: first line starts in the second column, in line with "246 websites…" below */
.intro { text-indent: calc((100% - var(--margin)) / 3 + var(--margin)); }
@media (max-width: 699px) { .intro { text-indent: 2.5em; } }   /* phones are one column */
/* Credentials sits on the right-hand margin of the dates row */

/* Colour-mode circles on the dates row, at the start of the second column (where Credentials was);
   Credentials shares that column, on the right */
.years .theme-switch { grid-row: 1; grid-column: 2; justify-self: stretch; display: flex; align-items: center; }   /* lines up with the Credentials dot above */
.years .credentials { grid-row: 1; grid-column: 2; justify-self: start; }
@media (max-width: 699px) {
  .years .theme-switch, .years .credentials { grid-row: 2; grid-column: 1; }
}

/* ---------- Image size: Small (default) / Large (tiles twice the size) ---------- */
.size-switch { display: inline-flex; gap: 0.6em; margin-left: 1.1em; }
.size-btn {
  padding: 0;
  border: 0;
  background-color: transparent;   /* keeps the underline (a background image) */
  color: inherit;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
  opacity: 0.35;                 /* the option not in use is faded */
  transition: opacity 0.2s ease;
}
.size-btn:hover, .size-btn[aria-pressed="true"] { opacity: 1; }
.size-btn:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }
html.tiles-medium { --tile-min: 240px; }                      /* 2x Small: about 7 per row at 1920px */
html.tiles-large { --tile-min: 360px; }                       /* 3x Small: about 5 per row at 1920px */
@media (max-width: 599px) {
  html.tiles-medium { --tile-min: 160px; }                    /* phones: 2 per row */
  html.tiles-large { --tile-min: 300px; }                     /* phones: 1 per row */
}

/* Footer: Credentials on the line under the clock, right-aligned */
.theme-clock { flex-direction: column; align-items: flex-end; height: auto; }
.theme-clock .clock { line-height: var(--leading); }
.footer-cred { margin: 0; display: flex; align-items: center; }

/* "Mister" at the start of the intro, in bold */
.brand-name { font-family: "KMR Waldenburg Bold", "KMR Waldenburg Medium", "KMR Waldenburg", "Helvetica Neue", Arial, sans-serif; }

/* Hovering a service colours the images tagged with it (tags live in services.json) */
.svc { cursor: default; transition: opacity 0.2s ease; }
.services.svc-active .svc { opacity: 0.35; }
.services.svc-active .svc.is-on { opacity: 1; }
@media (hover: hover) { .gallery .tile.svc-match { filter: none; } }

/* Credentials / "work" links: a small looping film of the credentials follows the pointer on hover */
.cred-preview {
  position: fixed;
  left: 0; top: 0;
  z-index: 50;
  width: 500px;
  aspect-ratio: 16 / 9;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: #000 center / cover no-repeat;
}
.cred-preview video { display: block; width: 100%; height: 100%; object-fit: cover; }
.cred-preview.is-on { opacity: 1; }
@media (hover: none) { .cred-preview { display: none; } }
/* While a service is hovered, the other (black and white) images fade back so the colour ones stand out */
.gallery .tile { transition: filter 0.4s ease, opacity 0.3s ease; }
@media (hover: hover) { .gallery.svc-on .tile:not(.svc-match) { opacity: 0.2; } }

/* ---------- Viewer film strip (replaces Previous / Next) ---------- */
.viewer { --strip-h: 50px; }
.viewer-prev, .viewer-next { display: none; }
.viewer-stage { bottom: calc(var(--edge) * 2 + var(--strip-h)); }
.viewer-strip {
  position: absolute;
  left: var(--edge);
  right: var(--edge);
  bottom: var(--edge);
  height: var(--strip-h);
  display: flex;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  overscroll-behavior: contain;
  z-index: 2;
}
.viewer-strip::-webkit-scrollbar { display: none; }
.viewer-thumb {
  flex: 0 0 auto;
  height: 100%;
  padding: 0 !important;
  background: var(--tile-bg) !important;
  filter: grayscale(1);
  opacity: 0.5;
  transition: opacity 0.2s ease, filter 0.2s ease;
}
.viewer-thumb img { display: block; height: 100%; width: auto; pointer-events: none; }
.viewer-thumb:hover, .viewer-thumb:focus-visible { filter: none; opacity: 1; }
.viewer-thumb.is-current { filter: none; opacity: 1; }
@media (max-width: 699px) {
  .viewer { --strip-h: 44px; }
  .viewer-stage { bottom: calc(var(--edge) * 2 + var(--strip-h)); }
}
@media (hover: hover) and (pointer: fine) {
  .viewer.is-pointing { cursor: none; }
}

/* Full screen button, left of Close */
.viewer-tools { position: absolute; z-index: 2; top: var(--edge); right: var(--edge); display: flex; align-items: center; gap: 0; }
.viewer-tools .viewer-close { position: static; }
.viewer .viewer-full { display: flex; align-items: center; padding: 0; opacity: 1; transition: opacity 0.2s ease; }
.viewer .viewer-full[hidden] { display: none; }
.viewer .viewer-full:hover, .viewer .viewer-full:focus-visible { opacity: 0.6; }
.viewer-full svg { width: 64px; height: 64px; }
.viewer-full .icon-exit { display: none; }
.viewer.is-full .viewer-full .icon-enter { display: none; }
.viewer.is-full .viewer-full .icon-exit { display: block; }

/* Close: an X drawn with the same line weight as the viewer arrow (64px box, 3.5/48 stroke).
   Negative margin lines the visible X up with the screen edge. */
.viewer .viewer-close { display: block; padding: 0; margin: -17px -17px -17px -9px; line-height: 0; transition: opacity 0.2s ease; }
.viewer .viewer-close svg { display: block; width: 64px; height: 64px; }
.viewer .viewer-close:hover, .viewer .viewer-close:focus-visible { opacity: 0.6; }
@media (max-width: 699px) {
  .viewer .viewer-close { margin: -12px -12px -12px -6px; }
  .viewer .viewer-close svg { width: 46px; height: 46px; }
}
/* Full screen icon: same 64px box and line weight as the X; its visible part lines up with the X */
.viewer .viewer-full { margin: -17px 0 -17px 0; line-height: 0; }
@media (max-width: 699px) { .viewer-full svg { width: 46px; height: 46px; } .viewer .viewer-full { margin: -12px 0; } }

/* Close and full screen icons sized to the counter's figures (about 0.72em tall), same line weight as the arrow */
.viewer { --icon-box: calc(0.66em * 48 / 22); --icon-pull: calc(var(--icon-box) * -13 / 48); }
.viewer-tools { height: calc(var(--leading) * 1em); }
.viewer .viewer-close svg, .viewer-full svg { width: var(--icon-box) !important; height: var(--icon-box) !important; }
.viewer .viewer-close { margin: var(--icon-pull) var(--icon-pull) var(--icon-pull) 0 !important; }
.viewer .viewer-full { margin: var(--icon-pull) calc(var(--icon-pull) + 0.55em) var(--icon-pull) 0 !important; }
.viewer-tools svg path, .viewer-tools svg rect { vector-effect: non-scaling-stroke; stroke-width: max(1.3px, calc(0.095em - 0.2px)); }
/* Fullscreen as a word, same size as the counter */
.viewer .viewer-full { display: inline-block; margin: 0 1em 0 0 !important; line-height: inherit; opacity: 1; }
.viewer .viewer-full:hover, .viewer .viewer-full:focus-visible { opacity: 1; }

/* Counter, Fullscreen and X: drawn in white with "difference" blending, so each letter
   inverts where it crosses an image — dark on light, light on dark (works in both themes) */
.viewer-count, .viewer-tools { color: #fff; mix-blend-mode: difference; }

/* Fullscreen: film strip tucks away; a "Thumbnails" toggle opens it as a tray over the image */
.viewer-tray-toggle { display: none; }
.viewer.is-full .viewer-stage { bottom: var(--edge); }
.viewer.is-full .viewer-strip {
  background: var(--bg);
  box-shadow: 0 0 0 var(--edge) var(--bg);
  transform: translateY(calc(100% + var(--edge) * 2 + 2px));
  transition: transform 0.35s cubic-bezier(.2,.7,.2,1);
  z-index: 3;
}
.viewer.is-full.tray-open .viewer-strip { transform: none; }
.viewer.is-full .viewer-tray-toggle {
  display: block;
  position: absolute;
  z-index: 4;
  left: 50%;
  bottom: var(--edge);
  transform: translateX(-50%);
  color: #fff;
  mix-blend-mode: difference;
  transition: bottom 0.35s cubic-bezier(.2,.7,.2,1);
}
.viewer.is-full.tray-open .viewer-tray-toggle { bottom: calc(var(--edge) * 2 + var(--strip-h) + 0.4em); }

/* Viewer: image runs the full height of the window (desktop); film strip tucks into a "Thumbnails" tray */
.viewer.is-tall .viewer-stage { top: 0; bottom: 0; left: 0; right: 0; overflow: hidden; }
.viewer.is-tall .viewer-stage img, .viewer.is-tall .viewer-stage video { max-width: none; flex: none; }
.viewer.is-tall .viewer-strip {
  background: var(--bg); box-shadow: 0 0 0 var(--edge) var(--bg);
  transform: translateY(calc(100% + var(--edge) * 2 + 2px));
  transition: transform 0.35s cubic-bezier(.2,.7,.2,1); z-index: 3;
}
.viewer.is-tall.tray-open .viewer-strip { transform: none; }
.viewer.is-tall .viewer-tray-toggle {
  display: block; position: absolute; z-index: 4; left: 50%; bottom: var(--edge);
  transform: translateX(-50%); color: #fff; mix-blend-mode: difference;
  transition: bottom 0.35s cubic-bezier(.2,.7,.2,1);
}
.viewer.is-tall.tray-open .viewer-tray-toggle { bottom: calc(var(--edge) * 2 + var(--strip-h) + 0.4em); }

/* Bold labels: Output, Selected clients, Featured on */
.facts b, .about b, .contact b, .projects b, .services b { font-family: "KMR Waldenburg Bold", "KMR Waldenburg", sans-serif; font-weight: 400; }

/* Strapline "Building brands that matter" in bold (the ® stays regular) */
.strapline { font-family: "KMR Waldenburg Bold", "KMR Waldenburg", sans-serif; font-weight: 400; }
.strapline .reg { font-family: "KMR Waldenburg", sans-serif; }

/* Credentials sits at the foot of the facts column, level with the last service (Product Design) */
.facts { display: flex; flex-direction: column; }
.facts .credentials { margin-top: auto; padding-top: calc(var(--leading) * 1em); }

/* Small / Medium / Large stays on the right of the dates row */
.years .size-switch { margin-left: calc(0.2em - 3px); }   /* same gap as the Credentials dot to its word (0.3em button margin + this) */

/* Phones: project name + service as plain small text under the counter, no pill */
@media (max-width: 699px) {
  .viewer .viewer-project { background: none; padding: 0; margin: 0; transform: none; color: #fff; mix-blend-mode: difference; font-size: 14px; }
}

/* "Thumbnails" toggle: same pill as the project name + service label */
.viewer .viewer-tray-toggle {
  font-size: clamp(14px, 0.6em, 20px); line-height: 1; white-space: nowrap;
  padding: 0.5em 1em 0.55em !important; border-radius: 999px;
  background: rgba(239, 239, 239, 0.92) !important; background-image: none !important;
  color: #000 !important; mix-blend-mode: normal !important;
}
.viewer .viewer-tray-toggle:hover, .viewer .viewer-tray-toggle:focus-visible { background: #fff !important; }

/* Featured on: no first-line indent */
.about p.no-indent { text-indent: 0; }

/* "Viewing:" label before Small / Medium / Large */
.size-label b { font-family: "KMR Waldenburg Bold", "KMR Waldenburg", sans-serif; font-weight: 400; }

/* Image viewer text (counter, Fullscreen, X) set smaller, matching Idea 3 */
.viewer { --type: clamp(14px, calc(0.9vw + 6px), 20px) !important; font-size: var(--type); }
@media (max-width: 699px) { .viewer { --type: 14.7px !important; } }

/* ---------- List / Grid view switch ---------- */
.view-gap { width: 0.6em; }
.view-btn {
  padding: 0; border: 0; background-color: transparent; color: inherit; font: inherit; line-height: inherit;
  cursor: pointer; opacity: 0.35; transition: opacity 0.2s ease;
}
.view-btn:hover, .view-btn[aria-pressed="true"] { opacity: 1; }
.view-btn:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }
html.view-list .size-btn { opacity: 0.35; }
html.view-list .size-btn:hover { opacity: 1; }

/* ---------- List view: one row per project, three images fade in on hover ---------- */
.work-list { display: none; margin: -10px 0 0; padding-bottom: calc(var(--space) * 0.6); border-bottom: 1px solid currentColor; }   /* line above "Building brands that matter" */
html.view-list .gallery { display: none; }
html.view-list .work-list { display: block; }
.wl-head, .wl-row { display: grid; grid-template-columns: calc((100% - var(--margin)) / 3) 3fr 2fr 1fr; column-gap: var(--margin); }   /* 2nd column starts in line with the Credentials / theme dots */
.wl-head { display: none !important; }   /* column labels removed */
.wl-head span:last-child, .wl-num { text-align: right; }
.wl-rows { font-size: var(--type); line-height: var(--leading); }   /* same size as the rest of the site */
.wl-row {
  width: 100%; padding: 0.3em 0; border: 0; background: none; font: inherit; line-height: inherit; letter-spacing: inherit;
  text-align: left; color: var(--fg); cursor: pointer;
}
.wl-row + .wl-row { border-top: 1px solid currentColor; }   /* line between each listing */
.wl-row > span:not(.wl-pvs) { opacity: 1; transition: opacity 0.2s; }   /* full black at rest */
.wl-rows:hover .wl-row > span:not(.wl-pvs) { opacity: 0.3; }   /* the others grey out on hover */
.wl-rows .wl-row:hover > span:not(.wl-pvs), .wl-rows .wl-row:focus-visible > span:not(.wl-pvs) { opacity: 1; }
.wl-row:focus-visible { outline: none; }
@media (hover: none) { .wl-row > span:not(.wl-pvs) { opacity: 1; } }
@media (max-width: 759px) {
  .wl-head, .wl-row { grid-template-columns: 1fr 1fr 2.4em; }
  .wl-svc { display: none; }
}
.wl-pvs { position: fixed; inset: 96px 40px; z-index: 50; pointer-events: none; display: none; }
@media (min-width: 1024px) and (hover: hover) {
  .wl-pvs { display: flex; justify-content: space-between; column-gap: 20px; }
  .wl-pv { display: flex; opacity: 0; transition: opacity 0.25s; }
  .wl-pv img { display: block; width: 100%; height: auto; max-height: 100%; object-fit: contain; }
  .wl-pv-xs { width: 16.6667%; } .wl-pv-s { width: 25%; } .wl-pv-m { width: 33.3333%; }
  .wl-pv-top { align-self: flex-start; } .wl-pv-middle { align-self: center; } .wl-pv-bottom { align-self: flex-end; }
  .wl-row.is-ready:hover .wl-pv { opacity: 1; transition: opacity 0.5s; }
  .wl-row.is-ready:hover .wl-pv:nth-child(1) { transition-delay: 0.1s; }
  .wl-row.is-ready:hover .wl-pv:nth-child(2) { transition-delay: 0.2s; }
  .wl-row.is-ready:hover .wl-pv:nth-child(3) { transition-delay: 0.3s; }
}
.layout-switch { display: inline-flex; gap: 0.6em; margin-left: auto; }   /* Layout: G L on the right */
/* Capabilities hover: matching projects stay black, the rest grey out */
.work-list.svc-on .wl-row > span:not(.wl-pvs) { opacity: 0.3; }
.work-list.svc-on .wl-row.svc-match > span:not(.wl-pvs) { opacity: 1; }
/* Phones: dividing line under Credentials, below the client list */
@media (max-width: 699px) {
  .facts .credentials { padding-bottom: calc(var(--leading) * 0.5em); border-bottom: 1px solid currentColor; }   /* same gap as the line under Viewing */
}
.cred-top .cred-link { margin-left: 0.3em; }   /* word space after "View:" */
.cred-top { align-items: baseline; }
.cred-top::before { left: -1.1em; }   /* no dot here: the arrow circle sits just before "View:", like the email link */
@media (max-width: 699px) { .work-list { padding-bottom: 0; } }   /* phones: last line sits like the others */
