/* Roger Nicholas portfolio
   Layout: one sheet of paper. The landing page is a full-bleed sheet to paint on;
   the home and project pages are a single centred column of sections on the same paper. */

/* ---------- Tokens ---------- */
:root {
  /* colour */
  --paper: #F5ECD9;               /* warm cream at the top of the screen */
  --paper-cool: #E3E7EC;          /* and colder towards the bottom */
  --paper-deep: #E8E1D3;          /* default image placeholder */
  --ink: #1B1A17;
  --ink-soft: #5C574E;            /* secondary text, captions */
  --accent: #2B3FA0;              /* ultramarine, the landing paint */
  --on-accent: #F2EDE3;
  --on-accent-soft: rgba(242, 237, 227, 0.72);
  --rule: var(--ink);
  --rule-on-accent: rgba(242, 237, 227, 0.35);

  /* type: Bricolage Grotesque for titles and navigation, Fragment Mono for text */
  --f-display: "Bricolage Grotesque", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --f-text: "Fragment Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --t-hero: clamp(40px, 6vw, 84px);    /* footer line, project page title */
  --t-title: clamp(34px, 4.4vw, 56px); /* section titles, menu */
  --t-item: clamp(22px, 2.2vw, 30px);  /* project titles in the grid */
  --t-lead: clamp(16px, 1.4vw, 18px);  /* bio */
  --t-text: 15px;
  --t-nav: 15px;
  --t-label: 12px;

  /* space */
  --s-1: 8px;
  --s-2: 16px;
  --s-3: 24px;
  --s-4: 40px;
  --s-5: 64px;
  --s-6: 96px;
  --s-7: 128px;
  --gutter: 24px;
  --page: 1360px;      /* header and footer width */
  --column: 1080px;    /* content width */
  --bar: 72px;         /* header height */

  color-scheme: light;
}
@media (max-width: 640px) {
  :root { --gutter: 16px; --s-6: 72px; --s-7: 88px; }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  background: var(--paper);
}
/* the paper: warm cream under the header, turning colder towards the bottom of the screen */
html::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  z-index: -1;
  height: 100vh;
  height: 100lvh;
  pointer-events: none;
  background: linear-gradient(to bottom, var(--paper) var(--bar), var(--paper-cool));
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; } /* menu and nav links glide to their section */
}
[id] { scroll-margin-top: calc(var(--bar) + var(--s-3)); }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--f-text);
  font-size: var(--t-text);
  line-height: 1.6;
  transition: opacity 0.3s ease;
}
/* coming back to the projects list: hidden until it is back at the same spot */
.returning body { opacity: 0; transition: none; }

/* fade up as they come into view (Site.reveal) */
@media screen and (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(var(--s-3));
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--delay, 0s);
  }
  .reveal.shown { opacity: 1; transform: none; }
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variation-settings: "opsz" 96;
  text-wrap: balance;
}
p, figure { margin: 0; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* paper grain, drawn once as an SVG noise tile */
.grain::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.35;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.40  0 0 0 0 0.32  0 0 0 0.35 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* small uppercase mono labels: years, kinds, footer details */
.label {
  font-family: var(--f-text);
  font-size: var(--t-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wrap {
  max-width: var(--page);
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
}

/* content Roger still needs to supply */
.ph {
  background: rgba(43, 63, 160, 0.08);
  border-bottom: 1px dashed var(--accent);
}

/* an image, or a tinted placeholder of the same shape until the image exists */
.shot {
  position: relative;
  aspect-ratio: var(--ratio, 4 / 5);
  max-width: 100%;
  background: var(--tone, var(--paper-deep));
}
.shot img { display: block; width: 100%; height: 100%; object-fit: cover; }
.shot .ph-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--s-1);
  text-align: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 20px;
  border: 1px solid currentColor;
  border-radius: 999px;
  background: none;
  color: var(--accent);
  font-family: var(--f-display);
  font-size: var(--t-nav);
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}
.pill:hover { background: var(--accent); color: var(--on-accent); }

/* ---------- Landing ---------- */
.landing, .landing body { height: 100%; overflow: hidden; }

.sheet {
  position: relative;
  height: 100vh;
  height: 100dvh;
  min-height: 520px;
  overflow: hidden;
}
#paper {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}
.sheet-center {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.name {
  pointer-events: auto;
  padding: 12px 8px;
  color: var(--accent);
  font-family: var(--f-display);
  font-size: clamp(26px, 3.2vw, 40px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variation-settings: "opsz" 96;
  transition: opacity 0.25s ease;
}
.name:hover { color: var(--accent); opacity: 0.7; }

/* ---------- Header and menu ---------- */
body::before { /* paints the band above the sticky header on phones */
  content: "";
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  height: env(safe-area-inset-top, 0px);
  background: var(--paper);
}

.site-header {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  height: var(--bar);
}
.logo {
  color: var(--accent);
  font-family: var(--f-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variation-settings: "opsz" 96;
}
.logo:hover { color: var(--accent); opacity: 0.7; }

.nav { display: flex; align-items: center; gap: var(--s-4); }
.nav-links {
  display: flex;
  gap: var(--s-3);
  font-family: var(--f-display);
  font-size: var(--t-nav);
  font-weight: 500;
}
/* wide screens show the links; phones get the Menu button instead */
@media (max-width: 820px) { .nav-links { display: none; } }
@media (min-width: 821px) { #menu-open { display: none; } }

.menu {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow-y: auto;
  padding-block: env(safe-area-inset-top, 0px) calc(env(safe-area-inset-bottom, 0px) + var(--s-4));
  background: var(--accent);
  color: var(--on-accent);
}
.menu[hidden] { display: none; }
.menu a:hover { color: var(--on-accent); opacity: 0.7; }
.menu .logo, .menu .pill { color: var(--on-accent); }
.menu .pill:hover { background: var(--on-accent); color: var(--accent); }
.menu .bar { border-bottom: 1px solid var(--rule-on-accent); }
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-4);
  padding-block: var(--s-5);
}
.menu-main {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  font-family: var(--f-display);
  font-size: var(--t-title);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variation-settings: "opsz" 96;
}
.menu-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: var(--f-display);
  font-size: var(--t-nav);
  font-weight: 500;
}
.menu-col .head { color: var(--on-accent-soft); font-weight: 400; }

/* ---------- Home: bio ---------- */
.about {
  display: grid;
  grid-template-columns: auto minmax(0, 30ch) auto;
  justify-content: center;
  align-items: center;
  gap: var(--s-6);
  padding-block: var(--s-7) var(--s-6);
  text-align: center;
}
.about-text {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.about p {
  font-size: var(--t-lead);
  line-height: 1.65;
  text-wrap: pretty;
}
/* short phrases either side of the text */
.aside {
  font-family: var(--f-display);
  font-size: var(--t-nav);
  font-weight: 500;
  color: var(--accent);
}
@media (max-width: 1100px) { .about { gap: var(--s-4); } }
@media (max-width: 820px) {
  .about { grid-template-columns: 1fr 1fr; }
  .about-text { grid-column: 1 / -1; grid-row: 1; }
  .aside-left { justify-self: start; }
  .aside-right { justify-self: end; }
}

/* ---------- Home: carousel, drifting right ---------- */
.works { padding-bottom: var(--s-7); }
.track { overflow: hidden; }
.belt {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  width: max-content;
  padding-right: var(--s-5); /* matches the gap so the loop seam is even */
  will-change: transform;
}
.work {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
}
.work .shot { height: clamp(220px, 32vw, 380px); max-width: 86vw; }
.work figcaption {
  width: max-content;
  max-width: calc(100% + var(--s-4));
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) {
  .track { overflow-x: auto; }
}

/* ---------- Home: projects, side by side in rows ---------- */
.projects {
  max-width: var(--column);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-5);
  padding-bottom: var(--s-7);
}
.projects-title { font-size: var(--t-title); }
.project-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-6);
}
.project-row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: var(--s-4);
}
.tile {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tile .shot { width: 100%; transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
.tile:hover { color: inherit; }
.tile:hover .shot { transform: scale(1.03); }
.tile:hover h3 { color: var(--accent); }

/* image | label + title | text, separated by thin rules */
.tile-text { border-top: 1px solid var(--rule); padding-top: 10px; }
.tile-text .meta { padding-bottom: 6px; color: var(--accent); }
.tile-text h3 {
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  font-size: var(--t-item);
  transition: color 0.2s ease;
}
.tile-text .summary { max-width: 48ch; }
.load-error { color: var(--ink-soft); text-align: center; }

/* projects without images: one line each, under the rows */
.project-more {
  width: 100%;
  max-width: 820px;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--rule);
}
.project-more li {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--s-3);
  padding-block: 14px;
  border-bottom: 1px solid var(--rule);
}
.project-more .label { padding-top: 5px; color: var(--accent); }
.project-more h3 {
  font-size: 19px;
  letter-spacing: -0.01em;
  line-height: 1.25;
  font-variation-settings: "opsz" 24;
  transition: color 0.2s ease;
}
.project-more h3::after { content: " →"; color: var(--accent); }
.project-more a:hover { color: inherit; }
.project-more a:hover h3 { color: var(--accent); }
.project-more p { color: var(--ink-soft); }
@media (max-width: 640px) {
  .project-more li { grid-template-columns: 1fr; gap: 4px; }
  .project-more .label { padding-top: 0; }
}

/* field filter under the Projects title */
.filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--s-1) var(--s-3);
  margin-top: calc(var(--s-3) - var(--s-5));
}
.filters button {
  padding: 6px 2px;
  border: 0;
  border-bottom: 1px solid transparent;
  background: none;
  color: var(--ink-soft);
  font-family: var(--f-display);
  font-size: var(--t-nav);
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.filters button:hover { color: var(--accent); }
.filters button[aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.project-list { transition: opacity 0.25s ease; }
.project-list.fading { opacity: 0; }

/* ---------- Project page ---------- */
.detail {
  max-width: var(--column);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-5);
  padding-block: var(--s-6) var(--s-7);
}
.detail-back {
  align-self: flex-start;
  margin-block: calc(-1 * var(--s-5)) calc(-1 * var(--s-3));
  padding-block: 10px;
  color: var(--accent);
  font-family: var(--f-display);
  font-size: var(--t-nav);
  font-weight: 500;
}
.detail-back:hover { opacity: 0.7; }
.detail-head {
  width: 100%;
  max-width: 60ch;
  text-align: center;
}
.detail-head .meta { padding-bottom: 6px; color: var(--accent); }
.detail-head h1 {
  margin-bottom: var(--s-2);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--rule);
  font-size: var(--t-hero);
}
/* a film, in the Vimeo player */
.video { width: 100%; aspect-ratio: 16 / 9; background: var(--ink); }
.video iframe { display: block; width: 100%; height: 100%; border: 0; }
.video.blocked { aspect-ratio: auto; background: none; }
.video-link { position: relative; display: block; overflow: hidden; }
.video-link .shot { width: 100%; transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
.video-link:hover .shot { transform: scale(1.03); }
.video-link .play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent);
  color: var(--on-accent);
}
.video-link:hover .play { background: var(--on-accent); color: var(--accent); }
.gallery {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--s-3);
}
.gallery-item {
  width: min-content; /* the caption wraps to the image's width */
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.gallery-item .shot { height: clamp(220px, 34vw, 440px); }
.gallery-item:only-child .shot { height: clamp(240px, 46vw, 600px); }
.gallery-item figcaption { color: var(--ink-soft); font-size: 13px; text-align: center; }
.detail-body {
  max-width: 60ch;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  text-align: center;
}
.detail-body .tech { color: var(--accent); }
.detail-body .pill { align-self: center; margin-top: var(--s-1); }
.detail-nav {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-2) var(--s-3);
  padding-top: var(--s-3);
  border-top: 1px solid var(--rule);
  font-family: var(--f-display);
  font-size: var(--t-nav);
  font-weight: 500;
}
.detail-nav a { padding-block: 10px; color: var(--accent); }
.detail-nav a:hover { opacity: 0.7; }

@media (max-width: 640px) {
  .gallery-item { width: 100%; }
  .gallery-item .shot, .gallery-item:only-child .shot { width: 100%; height: auto; }
  .detail-nav { justify-content: center; }
}

/* ---------- CV ---------- */
.cv {
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  padding-block: var(--s-6) var(--s-7);
}
.cv-head { text-align: center; }
.cv-head h1 {
  margin-bottom: var(--s-2);
  padding-bottom: var(--s-2);
  border-bottom: 1px solid var(--rule);
  font-size: var(--t-hero);
}
.cv-head p { color: var(--ink-soft); }
.cv-section h2 { margin-bottom: var(--s-2); font-size: var(--t-item); }
.cv-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.cv-list li {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: var(--s-3);
  padding-block: 14px;
  border-bottom: 1px solid var(--rule);
}
.cv-list .label { padding-top: 5px; color: var(--accent); }
.cv-list h3 {
  font-size: 19px;
  letter-spacing: -0.01em;
  line-height: 1.25;
  font-variation-settings: "opsz" 24;
}
.cv-list p { color: var(--ink-soft); }
.cv-list h3 a::after, .cv-list ul a::after { content: " →"; color: var(--accent); }
.cv-list ul {
  margin: var(--s-1) 0 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-wrap: pretty;
}
.cv-list ul li { padding: 0; border: 0; display: list-item; }
.cv-list ul li::marker { color: var(--accent); }
@media (max-width: 640px) {
  .cv-list li { grid-template-columns: 1fr; gap: 4px; }
  .cv-list .label { padding-top: 0; }
}

/* ---------- Footer ---------- */
.site-footer { background: var(--accent); color: var(--on-accent); }
.site-footer a:hover { color: var(--on-accent); opacity: 0.7; }
.site-footer .pill { color: var(--on-accent); }
.site-footer .pill:hover { background: var(--on-accent); color: var(--accent); opacity: 1; }
.site-footer .wrap {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
  padding-block: var(--s-6) calc(env(safe-area-inset-bottom, 0px) + var(--s-4));
}
.cta {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4) var(--s-5);
}
.cta h2 { flex: 999 1 520px; min-width: 0; font-size: var(--t-hero); line-height: 1; }
.cta .pill { height: 56px; padding: 0 28px; }
.foot-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--s-2) var(--s-4);
  padding-top: var(--s-3);
  border-top: 1px solid var(--rule-on-accent);
}
.site-footer .ph { background: rgba(242, 237, 227, 0.1); border-bottom-color: var(--on-accent-soft); }

/* bigger tap areas on touch screens, without moving anything */
@media (pointer: coarse) {
  .foot-row a,
  .menu-col a { padding-block: 12px; margin-block: -12px; }
  .nav-links a { padding: 12px; margin: -12px; }
  .filters button { min-width: 44px; padding-block: 12px; }
}

/* ---------- Not found ---------- */
.missing {
  min-height: calc(100vh - var(--bar));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  text-align: center;
}
.missing h1 { font-size: var(--t-title); }
