:root {
  --bg: #ffffff;
  --fg: #000000;
  --muted: rgba(0, 0, 0, 0.45);
  --stroke: #000000;
  --stroke-soft: rgba(0, 0, 0, 0.25);
  --gutter: 10px;
  --cell: 10px;
  --header-h: 44px;
  --intro-bg: #ff7a14;   /* site load intro background (read by main.js too) */
  --fs: 18px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #ffffff; --fg: #000000; }
}
/* Inverted mode, toggled by the footer dot: black page, white and grey text, every image and
   video turned into a desaturated negative that blends by exclusion with the colour glows. */
html:root[data-theme="dark"] {
  --bg: #000000;
  --fg: #ffffff;
  --muted: rgba(255, 255, 255, 0.5);
  --stroke: #ffffff;
  --stroke-soft: rgba(255, 255, 255, 0.3);
}
html[data-theme="dark"] body { background: #000; }
html[data-theme="dark"] img,
html[data-theme="dark"] video {
  filter: grayscale(1) invert(1);
  mix-blend-mode: exclusion;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  transition: background-color .35s ease, color .35s ease;
  font-family: "Instrument Serif", Georgia, "Times New Roman", serif;
  font-size: var(--fs);
  line-height: 1.35;
  letter-spacing: -0.01em;
  font-feature-settings: "tnum" 1, "ss01" 1;
  padding: 0 var(--gutter);
}
a { color: inherit; text-decoration: none; }
a:hover { opacity: 0.55; }
img, video { display: block; width: 100%; height: auto; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

/* ---------- header / footer ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr;
  height: var(--header-h);
}
.site-header a { display: flex; align-items: center; padding: 0 var(--cell); font-size: 20px; }
.site-header a:first-child { padding-left: 0; }
.site-header a:nth-child(2) { justify-content: center; }
.site-header a:last-child { justify-content: flex-end; padding-right: 0; }
.site-name { font-family: "Schibsted Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 20px; letter-spacing: -0.01em; font-feature-settings: normal; }
.site-footer {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  margin-top: 80px;
}
.site-footer > * { padding: 12px var(--cell) 14px; }
.site-footer > :first-child { padding-left: 0; }
.site-footer > :last-child { text-align: right; padding-right: 0; }
.btn-contact { font-size: 20px; }   /* plain text link, same as the nav bar items */
.footer-dot { display: flex; justify-content: center; align-items: center; background: none; border: 0; cursor: pointer; font: inherit; color: inherit; }
.footer-dot::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--fg); transition: background-color .35s ease; }   /* same mark as the favicon; click to invert the site */
.footer-dot:hover::before { transform: scale(1.15); }
main { min-height: calc(100vh - 140px); }

/* ---------- home grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 80px 2px;   /* 2px between columns */
  margin-top: calc(50vh - var(--header-h));   /* first row starts half way down the viewport */
  position: relative;
}
.tile {
  display: flex; flex-direction: column;
  padding: 0;
}
.tile-media { position: relative; background: var(--media-bg, transparent); aspect-ratio: var(--media-ar, auto); display: flex; align-items: center; }
.tile-media img, .tile-media video { width: 100%; }
.tile-media img, .tile-media video { transition: opacity .25s ease; }
/* On hover the tile's edges close in: the frame is clipped inward by --tile-inset while the media
   itself stays put at the same size, so the picture is cropped rather than shrunk and the glow
   shows through the freed-up edge. */
:root { --tile-inset: 14px; --tile-ease: cubic-bezier(.16, 1, .3, 1); }   /* expo-out: fast start, long soft settle */
.tile-media { clip-path: inset(0); transition: clip-path .9s var(--tile-ease); }
@media (hover: hover) { .tile:hover .tile-media { clip-path: inset(var(--tile-inset)); } }
/* Soft colour blob under the grid that follows the cursor and bleeds across tiles. */
.grid-glow {
  position: absolute; left: 0; top: 0; z-index: -1; pointer-events: none;
  width: var(--size, 600px); height: var(--size, 600px);
  margin: calc(var(--size, 600px) / -2) 0 0 calc(var(--size, 600px) / -2);
  border-radius: 50%;
  background: #d2ff00;
  filter: blur(60px);
  opacity: 0;
  transition: opacity .35s ease, background-color .35s ease;
  will-change: transform;
}
.grid-glow.on { opacity: 1; }
@media (hover: hover) {
  .tile:hover .tile-media { background: transparent; }   /* let the hover colour show through on grey-backed tiles */
}
/* Cursor-following exclusion: a layer of the tile's colour sits over the media and blends by
   exclusion, but only inside a soft circle that tracks the glow's (eased) position. The media
   outside the circle stays untouched. --mx/--my are set by main.js in media-box pixels;
   --glow-r (on .grid) is the circle's radius, matched to the glow's size. */
.tile-x {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: var(--tile-bg, #d2ff00);
  mix-blend-mode: exclusion;
  opacity: 0; transition: opacity .6s var(--tile-ease, ease);
  -webkit-mask: radial-gradient(circle var(--glow-r, 260px) at var(--mx, 50%) var(--my, 50%), #000 0%, #000 30%, transparent 100%);
          mask: radial-gradient(circle var(--glow-r, 260px) at var(--mx, 50%) var(--my, 50%), #000 0%, #000 30%, transparent 100%);
}
@media (hover: hover) { .tile:hover .tile-x { opacity: 1; } }
.tile-tags {
  display: inline-flex; align-items: center; flex-shrink: 0;
  color: var(--fg); white-space: nowrap;
  transition: opacity .12s ease, transform .4s cubic-bezier(.2, .9, .2, 1);
}
.tile-tags span + span::before { content: ", "; }
@media (hover: hover) {
  .tile-tags { opacity: 0; transform: translateY(8px); }
  .tile:hover .tile-tags { opacity: 1; transform: none; }
}
.tile:hover { opacity: 1; }
.tile-caption {
  display: flex; flex-direction: row; justify-content: space-between; align-items: baseline; gap: 8px;   /* client name left, specialisms right */
  margin-top: 4px;          /* sits close under the media */
  padding: 0 8px;           /* indented slightly in from the media's left and right edges */
}
@media (max-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr); row-gap: 40px; }   /* half the desktop 80px between rows */
}

/* ---------- project page ---------- */
.project-head {
  display: grid;
  grid-template-columns: 3fr 9fr;
  gap: var(--gutter) 100px;   /* 100px between the intro column and the What text */
  padding: 100px 0;   /* 100px below the nav, 100px above the first image */
}
.ph-meta { display: flex; flex-direction: column; gap: 14px; }
.ph-title { display: flex; gap: 16px; align-items: baseline; }
.ph-title h1 { font-size: var(--fs); font-weight: 400; margin: 0; }
.ph-desc, .ph-link {
  font-family: "Schibsted Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.4; letter-spacing: -0.01em; font-feature-settings: normal;
}
.ph-desc p { margin: 0; max-width: 40ch; }
/* Specialisms: Instrument Serif, the same face and size the tile tags and Index use (inherited from body). */
.ph-cats { color: var(--muted); margin-top: -10px; }   /* tucks under the title, closer than the column gap */
.ph-link a { display: inline-flex; align-items: center; gap: 6px; }
.ph-link .ext-icon { width: 11px; height: 11px; }
.ph-what { font-size: clamp(20px, 1.9vw, 30px); line-height: 1.3; letter-spacing: -0.01em; max-width: 60ch; }
.ph-what p { margin: 0 0 .7em; }
.ph-what p:last-child { margin-bottom: 0; }
.ph-what-block + .ph-what-block { margin-top: 1.2em; }
.ph-what { padding-top: 24px; }
.project-nav {
  display: grid; grid-template-columns: 1fr 1fr;
  margin-top: var(--gutter);
}
.project-nav a { padding: 12px var(--cell); }
.project-nav a:first-child { padding-left: 0; }
.project-nav a:last-child { text-align: right; padding-right: 0; }
.project-nav .pn-label { display: block; color: var(--muted); margin-bottom: 2px; }
@media (max-width: 900px) {
  .project-head { grid-template-columns: 1fr auto; }
  .ph-meta { grid-column: 1; }
  .project-head > .ph-desc { grid-column: 1 / -1; }   /* Misc Work: intro drops under the title block */
  .ph-what { grid-column: 1 / -1; font-size: 20px; margin-top: var(--gutter); }
  .project-nav a { padding: 12px 6px; }
}

/* ---------- project gallery: one item per row, alternating sides ---------- */
.gallery {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gutter);
  padding-top: 0;
  align-items: start;
}
.g-item { margin: 0; min-width: 0; }
.g-item img, .g-item video { width: 100%; }
.g-solo-l, .g-solo-r { grid-column: 1 / -1; width: calc(50% - 50px); }
.g-solo-r { justify-self: end; }
@media (max-width: 520px) {
  .gallery { grid-template-columns: minmax(0, 1fr); }
  .g-solo-l, .g-solo-r { width: 100%; }
}

/* ---------- info ---------- */
.info-intro { padding: 8px 0 56px; }
.home-intro { padding: 120px 0 0; }   /* same intro as the Info page, sat under the home grid */
.info-intro p {
  font-size: clamp(28px, 4vw, 52px); line-height: 1.12; letter-spacing: -0.01em;
  max-width: 28em; margin: 0;
}
.info-cols { display: grid; grid-template-columns: 1fr 2fr; }
.info-cols > * { padding: 12px var(--cell) 40px; }
.info-contact { padding-left: 0; }
.info-contact a { text-decoration: underline; text-underline-offset: 2px; }
.info-bio p { font-size: 20px; line-height: 1.4; max-width: 70ch; }
@media (max-width: 900px) {
  .info-cols { grid-template-columns: 1fr; }
  .info-cols > * { padding: 12px 0 24px; }
  .info-bio p { font-size: 18px; }
}

/* ---------- index list: rows with a hover strip of up to five thumbnails (no dividers) ---------- */
.index-list { padding-top: 4px; }
.idx-item { display: block; }
.idx-item:hover { opacity: 1; }
.idx-row { display: grid; grid-template-columns: 2fr 3fr; align-items: center; }
.idx-row > span { display: block; padding: 7px var(--cell); }
.idx-row > span:first-child { padding-left: 0; }
.idx-item:hover .idx-row > span:first-child { opacity: 0.55; }
.idx-strip { display: block; height: 0; overflow: hidden; transition: height .4s cubic-bezier(.2, .8, .2, 1); }
.idx-strip-in { display: flex; gap: var(--gutter); padding: 6px 0 14px; }
.idx-thumb { display: block; flex: 1 1 0; min-width: 0; max-width: 220px; }   /* five always fit the strip width */
.idx-thumb img, .idx-thumb video { height: 130px; width: 100%; object-fit: cover; display: block; }
.idx-count { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
@media (hover: hover) {
  .idx-item:hover .idx-strip { height: 172px; }
}
/* Titles line up with the left edge of the "Index" link in the nav (set as --index-x by main.js). */
@media (min-width: 901px) {
  .index-list { padding-left: calc(var(--index-x, 50vw) - var(--gutter)); }
  .index-panel .index-list { padding-left: 0; }
}
@media (max-width: 900px) {
  .idx-row { grid-template-columns: 1fr auto; }
  .idx-row > span:nth-child(2) { color: var(--muted); }
  /* Thumbnails always open on mobile: one horizontally scrolling strip per project. */
  .idx-strip { display: block; height: auto; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .idx-strip::-webkit-scrollbar { display: none; }
  .idx-strip-in { gap: 6px; padding: 2px 0 12px; width: max-content; }
  .idx-thumb { flex: 0 0 auto; width: 96px; max-width: none; }
  .idx-thumb img, .idx-thumb video { height: 72px; }
  .idx-count { margin-top: 2px; font-size: 11px; }
}

@media (max-width: 900px) {
  /* Mobile order: Index (left) · Fowski studio. (centre) · Info (right). */
  .site-header { grid-template-columns: 1fr auto 1fr; white-space: nowrap; }
  .site-header a { padding: 0 8px; }
  .site-header a:first-child { order: 2; justify-content: center; }
  .site-header a:nth-child(2) { order: 1; justify-content: flex-start; padding-left: 0; }
  .site-header a:last-child { order: 3; padding-right: 0; }
}

/* ---------- project pages: cursor glow in the project colour ---------- */
.page-glow {
  position: fixed; left: 0; top: 0; z-index: -1; pointer-events: none;
  width: var(--size, 640px); height: var(--size, 640px);
  margin: calc(var(--size, 640px) / -2) 0 0 calc(var(--size, 640px) / -2);
  border-radius: 50%;
  background: var(--c, #d2ff00);
  filter: blur(60px);
  opacity: 0;
  transition: opacity .5s ease;
  will-change: transform;
}
.page-glow.on { opacity: 1; }
@media (hover: none) { .page-glow { display: none; } }


/* ---------- slide-out panels for Index and Info ---------- */
.info-overlay, .index-overlay {
  position: fixed; inset: 0; z-index: 5;           /* below the sticky header, which stays on top */
  visibility: hidden; pointer-events: none;
  transition: visibility 0s linear .4s;
}
.info-overlay.open, .index-overlay.open { visibility: visible; pointer-events: auto; transition-delay: 0s; }
.info-panel, .index-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  overflow: auto;
  padding: calc(var(--header-h) + var(--gutter)) var(--gutter) var(--gutter);
  background: var(--bg);
  border-left: 1px solid var(--stroke);
  transform: translateX(100%);
  transition: transform .5s cubic-bezier(.24, 1, .29, 1);
}
.info-overlay.open .info-panel, .index-overlay.open .index-panel { transform: translateX(0); }
.info-overlay.closing .info-panel, .index-overlay.closing .index-panel { transition-timing-function: cubic-bezier(.6, 0, .9, .5); transition-duration: .35s; }
.info-panel { width: 25vw; min-width: 320px; }
.index-panel { width: 65vw; }
@media (min-width: 901px) {
  /* The slide-out starts just left of the titles, so its edge sits one gutter (plus its 1px border) from the text. */
  .index-panel { width: calc(100vw - var(--index-x, 50vw) + var(--gutter) + 1px); }
}
.info-panel .info-contact {
  font-family: "Schibsted Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;   /* same as the project titles */
  font-size: 16px; line-height: 1.35; letter-spacing: -0.01em; font-feature-settings: normal;
}
/* In the panel the whole block stays sans at one size, name included. */
.info-panel .info-contact .co, .info-panel .info-contact .name { font: inherit; letter-spacing: inherit; font-feature-settings: inherit; }
.info-panel .info-contact p { margin: 0 0 1.4em; }
.info-panel .info-contact p:last-child { margin-bottom: 2.4em; }
.info-panel .info-bio p { font-size: 18px; line-height: 1.4; margin: 0; }
.info-panel .info-bio p + p { margin-top: 1em; }   /* the summary, then the longer bio */
@media (max-width: 1200px) {
  .info-panel { width: 50vw; }
}
@media (max-width: 900px) {
  .info-panel, .index-panel { width: 100vw; min-width: 0; border-left: 0; }
}

/* ---------- project names: Schibsted Grotesk everywhere ---------- */
.tile-caption > span:first-child, .ph-title h1, .project-nav a, .idx-row > span:first-child {
  font-family: "Schibsted Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px; letter-spacing: -0.01em; font-feature-settings: normal;
}

/* ---------- scroll reveal: items rise 80px over .6s (power2.inOut) with a small random delay ---------- */
.js-reveal .tile, .js-reveal .g-item {
  opacity: 0;
  transform: translateY(80px);
  transition: opacity .6s cubic-bezier(.45, 0, .55, 1) var(--d, 0s), transform .6s cubic-bezier(.45, 0, .55, 1) var(--d, 0s);
}
.js-reveal .tile.in, .js-reveal .g-item.in { opacity: 1; transform: none; }   /* final state has no transform, so the exclusion blend still works */
@media (prefers-reduced-motion: reduce) {
  .js-reveal .tile, .js-reveal .g-item { opacity: 1; transform: none; transition: none; }
}

/* ---------- Lenis smooth scroll ---------- */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }
.lenis.lenis-stopped { overflow: hidden; }

/* Page transition (ajax navigation): the old page fades down and out, the new one fades up. */
.page-out { animation: page-fade-out .15s linear forwards, page-slide-out .15s cubic-bezier(.4, 0, 1, 1) forwards; pointer-events: none; }
.page-in { animation: page-fade-in .25s linear forwards, page-slide-in .25s cubic-bezier(0, 0, .2, 1) forwards; }
/* Colour-wipe transition: the same fade-up, held back (--hold, set per navigation in main.js) until the colour is clearing. */
.page-in.page-in-held { animation-delay: var(--hold, 0ms); animation-fill-mode: both; }
/* Full-screen WebGL canvas for the colour-dissolve page transition (main.js). Hidden when idle. */
#page-wipe { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 9999; pointer-events: none; visibility: hidden; }
html.is-transitioning { cursor: wait; }
html.is-transitioning main, html.is-transitioning .site-footer { pointer-events: none; }
@keyframes page-fade-out { from { opacity: 1 } to { opacity: 0 } }
@keyframes page-fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes page-slide-out { from { transform: translateY(0) } to { transform: translateY(15px) } }
@keyframes page-slide-in { from { transform: translateY(30px) } to { transform: translateY(0) } }
@media (prefers-reduced-motion: reduce) { .page-out, .page-in { animation: none; } }

/* Employment history at the foot of the Info panel and page. */
.info-history {
  font-family: "Schibsted Grotesk", system-ui, sans-serif; font-size: 16px; line-height: 1.4;
  letter-spacing: -0.01em; font-feature-settings: normal; margin-top: 56px;
}
.info-history h2 { font: inherit; color: var(--muted); margin: 0 0 14px; }
.info-history ul { list-style: none; margin: 0; padding: 0; }
.info-history li { display: flex; justify-content: space-between; gap: 24px; padding: 10px 0; }
.info-history .xp-co, .info-history .xp-when { color: var(--muted); }
/* Company names in the serif, sized up a touch so they sit level with the grotesk around them. */
.info-history .xp-co, .info-contact .co {
  font-family: "Instrument Serif", Georgia, "Times New Roman", serif;
  font-size: 1.15em; letter-spacing: -0.01em; font-feature-settings: "tnum" 1, "ss01" 1;
}
.info-contact .name { font-size: 1.35em; line-height: 1.1; }
.info-history .xp-when { white-space: nowrap; }
.info-bio .info-history { max-width: 60ch; }
.info-panel .info-history { margin-top: 40px; font-size: 15px; }

/* ---------- site load intro (home page; main.js) ----------
   The orange screen and wordmark show only while html.intro is set (before first paint, unless reduced
   motion). main and footer stay hidden until the intro hands them to the usual page-in animation. */
#intro { display: none; }
html.intro { overflow: hidden; }
html.intro #intro, #intro.over {
  display: grid; align-items: end; justify-items: start;      /* wordmark sits at the bottom left of the viewport */
  padding: var(--gutter);
  position: fixed; inset: 0; z-index: 9990;                  /* under #page-wipe (9999), which takes over the orange */
  background: var(--intro-bg); color: #000;
}
html.intro main, html.intro .site-footer { opacity: 0; }
/* Once the dissolve has started the wordmark floats above its canvas with no background of its own (html.intro is gone by then). */
html #intro.over { z-index: 10000; background: transparent; pointer-events: none; }
.intro-word {
  font-family: "Schibsted Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;   /* same face as the nav bar */
  font-size: clamp(40px, 12vw, 260px); line-height: 1; letter-spacing: -0.045em; font-feature-settings: normal;
  white-space: nowrap; display: flex;
}
/* Single-letter reveal: every letter sits in its own clipped cell and rises out of the bottom edge, left to right
   (--i is the letter's index). On exit the letters sink back out of sight, F first. */
.ch { display: inline-block; overflow: hidden; padding: .1em .05em .14em; margin: -.1em -.05em -.14em; }   /* padding keeps the glyph edges from clipping; the margin cancels it */
.ch.sp { width: .26em; margin: 0; padding: 0; }
.ch > span { display: inline-block; transform: translateY(115%); }
#intro.on .ch > span { transform: none; transition: transform .6s cubic-bezier(.16, 1, .3, 1) calc(var(--i) * 36ms); }
#intro.off .ch > span { transform: translateY(115%); transition: transform .6s cubic-bezier(.7, 0, .84, 0) calc(var(--i) * 36ms); }   /* the entry played backwards: same time, curve reversed, sinking back below the bottom edge; the F starts and the full stop goes last */
/* If main.js never runs, let the page through after a few seconds rather than leave the orange screen up. */
@keyframes intro-failsafe { to { opacity: 0; visibility: hidden; } }
@keyframes intro-failsafe-in { to { opacity: 1; } }
html.intro #intro { animation: intro-failsafe .3s 8s forwards; }
html.intro main, html.intro .site-footer { animation: intro-failsafe-in .3s 8s forwards; }
