/* ================= Fonts =================
   Google Fonts, linked in index.html:
   Newsreader (serif) for the name and headings, Figtree for body text,
   Caveat for handwritten accents. */

/* ================= Tokens ================= */
:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #16181d;
  --muted: #666b75;
  --line: #e4e2dc;
  --blue: #6fb6ea;
  --blue-soft: #d9ecfa;
  --blue-ink: #1f6fae;
  --navy: #1d3a6b;

  --font-display: "Newsreader", Georgia, serif;
  --font-body: "Figtree", system-ui, sans-serif;
  --font-hand: "Caveat", cursive;

  --gutter: clamp(16px, 5vw, 64px);
  --max: 1120px;
  --frame: 1px solid var(--line); /* one border for every project image */
  --radius: 8px; /* one corner size for every box, card, image and button */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --nav-h: 68px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 12px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: clamp(15px, 1vw + 10px, 17px);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }

::selection { background: var(--blue-soft); }

:focus-visible { outline: 2px solid var(--blue-ink); outline-offset: 3px; border-radius: 6px; }

/* ================= Nav ================= */
.nav {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--nav-h);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter);
  transition: background .4s var(--ease), box-shadow .4s var(--ease), height .4s var(--ease);
}
.nav.scrolled {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--line);
  height: 58px;
}

/* hand-signed logo, used as a mask so it takes the text colour (and changes on hover) */
.logo { display: block; color: var(--ink); text-decoration: none; }
.logo-mark {
  display: block;
  height: 50px;
  aspect-ratio: 235 / 157; /* logo.png pixel size */
  background: currentColor;
  -webkit-mask: url("images/icons/logo.png") center / contain no-repeat;
  mask: url("images/icons/logo.png") center / contain no-repeat;
  transition: background-color .3s;
}
.logo:hover .logo-mark { color: var(--blue-ink); }

.nav-links { display: flex; align-items: center; gap: clamp(16px, 3vw, 36px); }
.nav-links a {
  position: relative;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 0;
  color: var(--muted);
  transition: color .3s;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform .45s var(--ease);
}
.nav-links a:hover,
.nav-links a.active { color: var(--ink); }
.nav-links a:hover::after,
.nav-links a.active::after { transform: scaleX(1); transform-origin: left; }

/* CV download: an outlined button at the end of the menu */
.nav-links .nav-cv {
  padding: 6px 14px;
  border: 1px solid var(--navy);
  border-radius: var(--radius);
  color: var(--navy);
  font-weight: 700;
  letter-spacing: .06em;
  transition: background .3s, color .3s;
}
.nav-links .nav-cv::after { display: none; } /* no hover underline */
/* download icon: arrow with a line underneath, drawn in the text colour */
.nav-cv .dl-icon {
  width: 1.05em; height: 1.05em;
  margin-left: 3px;
  vertical-align: -0.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-links .nav-cv:hover,
.nav-links .nav-cv:focus-visible { background: var(--navy); color: #fff; }

.nav-toggle {
  display: none;
  width: 40px; height: 40px;
  border: 0; background: none; cursor: pointer;
  position: relative;
}
.nav-toggle span {
  position: absolute; left: 9px; right: 9px; height: 2px;
  background: var(--ink); border-radius: 2px;
  transition: transform .35s var(--ease), top .35s var(--ease);
}
.nav-toggle span:first-child { top: 15px; }
.nav-toggle span:last-child { top: 23px; }
.nav-toggle[aria-expanded="true"] span:first-child { top: 19px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:last-child { top: 19px; transform: rotate(-45deg); }

@media (max-width: 680px) {
  .nav-toggle { display: block; z-index: 2; }
  .nav-links {
    position: fixed;
    inset: 0;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 28px;
    background: var(--bg);
    clip-path: circle(0 at calc(100% - 36px) 34px);
    transition: clip-path .6s var(--ease);
  }
  .nav-links.open { clip-path: circle(150% at calc(100% - 36px) 34px); }
  .nav-links a { font-family: var(--font-display); font-size: 28px; color: var(--ink); }
}

/* ================= Hero ================= */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--nav-h) + 24px) var(--gutter) 48px;
  text-align: center;
}

.hero-stage {
  position: relative;
  width: min(100%, 1000px);
  display: grid;
  place-items: center;
  --name-size: clamp(54px, 14vw, 172px);
}

/* Paint scribble behind the name (paths + texture filter live in index.html).
   Sits behind the letters but over the top of the portrait. */
.brush {
  position: absolute;
  top: calc(var(--name-size) * -0.15);
  left: -6%;
  width: 112%;
  height: calc(var(--name-size) * 1.3);
  overflow: visible;
  pointer-events: none;
  z-index: 2;
  transform: translateY(var(--brush-y, 0));
}
/* phones: keep the brush a little wider than the name instead of edge to edge */
@media (max-width: 680px) {
  .brush { left: 7%; width: 86%; }
}
.brush path {
  fill: none;
  stroke: var(--blue);
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Draw-on animation. script.js measures each path and sets --len, then adds .ready.
   (Measured lengths instead of pathLength="1", which some mobile browsers mishandle.)
   Without JS the strokes simply show in full. */
.brush.ready path {
  stroke-dasharray: var(--len) var(--len);
  stroke-dashoffset: var(--len);
  animation: scribble var(--dur) var(--delay) cubic-bezier(.45, .05, .35, 1) forwards;
}
/* opaque paint: each pass a slightly different blue, so the layers read like brushwork */
.brush .s1 { stroke-width: 88; --dur: .55s; --delay: .15s; stroke: #86bfe6; }
.brush .s2 { stroke-width: 76; --dur: .5s;  --delay: .6s;  stroke: #9dcbea; }
.brush .s3 { stroke-width: 46; --dur: .35s; --delay: 1.05s; stroke: #74b2de; }
@keyframes scribble { to { stroke-dashoffset: 0; } }

.name {
  position: relative;
  z-index: 3;
  margin: 0;
  display: flex;
  gap: .35em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--name-size);
  line-height: 1;
  letter-spacing: .01em;
  pointer-events: none;
}
.name .word { display: inline-flex; }

.portrait {
  position: relative;
  z-index: 1;
  margin-top: clamp(-90px, -8vw, -30px);
  width: clamp(180px, 30vw, 320px);
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  background: linear-gradient(160deg, #eef3f7, #e1e8ee);
  border: 1.5px solid var(--ink);
  overflow: hidden;
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .25s ease-out, box-shadow .4s;
  box-shadow: 0 18px 40px -30px rgba(22, 24, 29, .35);
}
.portrait img { width: 100%; height: 100%; object-fit: cover; }

.tagline {
  margin: clamp(28px, 5vw, 48px) 0 12px;
  font-size: clamp(18px, 2.2vw, 26px);
  font-weight: 500;
  max-width: 34ch;
}
.tagline em {
  font-style: normal;
  background: linear-gradient(transparent 62%, var(--blue-soft) 62%);
}

.scroll-cue {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-hand);
  font-size: 22px;
  text-decoration: none;
  color: var(--muted);
  transition: color .3s;
}
.scroll-cue:hover { color: var(--ink); }
.scroll-cue .arrow { display: inline-block; animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(5px); } }

/* ================= Sections ================= */
.section {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(64px, 10vw, 120px) var(--gutter);
}
#projects { padding-top: clamp(24px, 4vw, 48px); }
/* full-width tinted band behind a section, content stays in the column */
.band {
  --sec-bg: #f1eee6;
  background: var(--sec-bg);
  box-shadow: 0 0 0 100vmax var(--sec-bg);
  clip-path: inset(0 -100vmax);
  padding-top: clamp(80px, 12vw, 150px);
  padding-bottom: clamp(80px, 12vw, 150px);
}

.section-title {
  display: inline-flex; align-items: center; gap: 14px;
  margin: 0 0 clamp(32px, 5vw, 56px);
  padding-bottom: 12px;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: clamp(44px, 6.6vw, 72px);
  line-height: 1.1;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 14' preserveAspectRatio='none'%3E%3Cpath d='M3 9 C 50 4, 95 12, 150 7 S 240 3, 297 8' fill='none' stroke='%236fb6ea' stroke-width='4' stroke-linecap='round' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") no-repeat left bottom / 100% 14px;
}

/* hand-drawn icons (images/icons/*.png). Used as masks so they take the text colour. */
.icon {
  display: inline-block;
  flex: none;
  height: var(--h, 1.3em);
  width: auto;
  aspect-ratio: var(--ar, 1); /* each box matches its drawing, so nothing is shrunk to fit a square */
  vertical-align: -0.15em; /* sits on the text baseline like a letter, dipping just below it */
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
/* aspect ratios are the PNGs' pixel sizes */
.icon-waves  { --icon: url("images/icons/waves.png");  --ar: 97 / 109; }
.icon-cat    { --icon: url("images/icons/cat.png");    --ar: 146 / 105; --h: 1.1em; }
.icon-hand   { --icon: url("images/icons/hand.png");   --ar: 83 / 131; }
.icon-bulb   { --icon: url("images/icons/bulb.png");   --ar: 103 / 138; }
.icon-person { --icon: url("images/icons/person.png"); --ar: 91 / 187; --h: 1.45em; }


/* ================= Projects ================= */
.project {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: clamp(24px, 5vw, 64px);
  align-items: center;
  margin-bottom: clamp(56px, 9vw, 110px);
}
.project:last-child { margin-bottom: 0; }
.project.flip .media { order: 2; }

.media {
  position: relative;
  aspect-ratio: 16 / 10;
  width: 100%;
  border: var(--frame);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 30% 20%, var(--blue-soft), transparent 60%),
    linear-gradient(135deg, #f1f3f5, #e6e9ec);
  cursor: pointer;
  overflow: hidden;
  display: grid; place-items: center;
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .3s ease-out;
}
/* round play button (used on the game cover in the case study) */
.play {
  width: 68px; height: 68px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  background: var(--surface);
  display: grid; place-items: center;
  transition: transform .45s var(--ease), background .3s;
}
.play::before {
  content: "";
  margin-left: 5px;
  border-left: 18px solid var(--ink);
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  transition: border-color .3s;
}

.project-body h3 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.15;
}
.project-body p { margin: 0 0 12px; }
.meta { color: var(--muted); font-size: .9em; }

@media (max-width: 780px) {
  .project { grid-template-columns: 1fr; }
  .project.flip .media { order: 0; }
}

/* ================= Timeline ================= */
.journey {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: start;
}

.tl-wrap { position: relative; padding-left: 36px; }
.tl-wrap::before,
.tl-progress {
  content: "";
  position: absolute;
  left: 9px; top: 8px; bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--line);
}
.tl-progress {
  background: var(--blue);
  bottom: auto;
  height: max(0px, calc(var(--fill, 0px) - 8px));
  transition: height .6s var(--ease);
}

.timeline { list-style: none; margin: 0; padding: 0; }

/* plain text flow, so the icon follows the last word even when the title wraps */
.tl-group {
  display: block;
  margin: 40px 0 12px -36px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(20px, 2.4vw, 26px);
  line-height: 1.2;
  background: var(--sec-bg, var(--bg));
  position: relative;
}
.tl-group:first-child { margin-top: 0; }
/* timeline group icons: larger, and lowered so they sit centred on the words.
   margin-left: project titles already have a space before the icon, these don't.
   Negative block margins keep the taller icons from pushing a wrapped title's lines apart. */
.tl-group .icon { color: var(--blue-ink); margin: -0.4em 0 -0.4em .25em; }
.tl-group .icon-hand { --h: 1.6em; vertical-align: -0.25em; }
.tl-group .icon-bulb { --h: 1.6em; vertical-align: -0.1em; } /* the rays make it look lower than it is */
.tl-group .icon-person { --h: 1.8em; vertical-align: -0.45em; }
.nowrap { white-space: nowrap; }

.tl-item { position: relative; }
.tl-btn {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  margin: 2px 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  font-size: 1.02em;
  font-weight: 500;
  color: var(--muted);
  transition: background .3s, color .3s, transform .4s var(--ease);
}
/* timeline dot, centred on the vertical line */
.tl-btn::before {
  content: "";
  position: absolute;
  left: -32px; top: 24px;
  width: 12px; height: 12px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--muted);
  transition: background .3s, border-color .3s, transform .4s var(--ease);
}

.tl-btn:hover { color: var(--ink); background: color-mix(in srgb, var(--blue-soft) 45%, transparent); }
.tl-item.active .tl-btn { color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1.5px var(--blue); }
.tl-item.active .tl-btn::before { background: var(--blue); border-color: var(--blue); transform: scale(1.35); }
.tl-item.passed .tl-btn::before { background: var(--blue); border-color: var(--blue); }

/* handwritten hint under the section title; fades out after the first hover/tap */
.section-title:has(+ .tl-hint) { margin-bottom: 8px; }
.tl-hint {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 clamp(16px, 2.5vw, 26px);
  font-family: var(--font-hand);
  font-size: 24px;
  line-height: 1.2;
  color: var(--blue-ink);
  transition: opacity .6s var(--ease), visibility 0s .6s;
}
.tl-hint.gone { opacity: 0; visibility: hidden; } /* keeps its space, so nothing jumps */
.tl-hint-arrow {
  flex: none;
  width: 26px; height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: bob 1.8s ease-in-out infinite;
}
.tl-hint-hover { display: none; }
@media (hover: hover) and (min-width: 901px) {
  .tl-hint-hover { display: inline; }
  .tl-hint-tap { display: none; }
}

.tl-inline { display: none; }

/* detail card */
.detail {
  position: sticky;
  top: calc(var(--nav-h) + 32px);
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  padding: clamp(20px, 3vw, 32px);
  border: 1.5px solid var(--blue);
  border-radius: var(--radius);
  background: var(--surface);
}
.detail-inner,
.detail-img { transition: opacity .35s var(--ease), transform .45s var(--ease); }
.detail.swap .detail-inner,
.detail.swap .detail-img { opacity: 0; transform: translateY(10px); }

.detail-time { margin: 0 0 4px; font-family: var(--font-hand); font-size: 20px; color: var(--blue-ink); }
.detail-title { margin: 0 0 12px; font-family: var(--font-display); font-size: clamp(22px, 2.4vw, 28px); line-height: 1.2; }
.detail-desc { margin: 0 0 12px; }
.detail-learned { margin: 0; color: var(--muted); }
.detail-learned strong { color: var(--ink); font-weight: 600; }

/* timeline figures keep their own shape (diagrams are often wide) */
.tl-fig { margin: 0; }
.tl-fig img {
  width: 100%;
  border: var(--frame);
  border-radius: var(--radius);
  background: #fff;
}
.tl-fig figcaption { margin-top: 6px; font-size: 13px; line-height: 1.45; color: var(--muted); }
.detail-img[hidden] { display: none; }

@media (max-width: 900px) {
  .journey { grid-template-columns: 1fr; }
  .detail { display: none; }
  .tl-inline {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .5s var(--ease);
  }
  .tl-inline > div { overflow: hidden; }
  .tl-inline .card {
    margin: 4px 0 12px;
    padding: 18px;
    border: 1.5px solid var(--blue);
    border-radius: var(--radius);
    background: var(--surface);
  }
  .tl-inline .card p { margin: 0 0 10px; }
  .tl-item.active .tl-inline { grid-template-rows: 1fr; }
}

/* ================= About ================= */
.about-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: clamp(32px, 6vw, 96px);
  align-items: start;
}
@media (max-width: 820px) { .about-grid { grid-template-columns: 1fr; } }
.statement {
  margin: 0;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.35;
  font-weight: 400;
}
.scribble { background: linear-gradient(transparent 60%, var(--blue-soft) 60%); }
.about-facts { color: var(--muted); font-size: .95em; }
.about-facts p { margin: 0 0 18px; }
.about-facts .label {
  display: block;
  margin-bottom: 2px;
  font-family: var(--font-display); /* Newsreader */
  font-weight: 700;
  font-size: 1.15em;
  line-height: 1.3;
  color: var(--ink);
}

/* ================= Contact ================= */
.contact {
  background: var(--blue-soft);
  padding: clamp(64px, 10vw, 120px) var(--gutter) 32px;
  text-align: center;
}
.contact h2 {
  margin: 0 0 32px;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: clamp(40px, 6.6vw, 70px);
  line-height: 1.2;
}
/* label + address pairs: a centred two-column grid, labels on the left */
.contact-list {
  display: inline-grid;
  grid-template-columns: auto auto;
  align-items: baseline;
  gap: 12px 20px;
  margin: 0;
  text-align: left;
}
.contact-list dt {
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 12px;
  font-weight: 700;
}
.contact-list dd { margin: 0; }
.contact-list a {
  color: var(--navy);
  font-size: clamp(15px, 1.3vw, 17px);
  font-weight: 500;
  overflow-wrap: anywhere; /* a long address can wrap on very narrow screens */
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--blue-ink) 55%, transparent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 6px;
  transition: color .3s, text-decoration-color .3s;
}
.contact-list a:hover,
.contact-list a:focus-visible {
  color: var(--blue-ink);
  text-decoration-color: var(--blue-ink);
  text-decoration-thickness: 2.5px;
}
/* phones: label above its address, everything centred */
@media (max-width: 520px) {
  .contact-list { grid-template-columns: 1fr; gap: 4px; text-align: center; }
  .contact-list dd + dt { margin-top: 18px; }
}
.fine { margin: clamp(48px, 8vw, 90px) 0 0; font-size: 13px; color: var(--muted); }

/* ================= To top ================= */
.to-top {
  position: fixed;
  right: clamp(16px, 3vw, 32px);
  bottom: clamp(16px, 3vw, 32px);
  z-index: 40;
  width: 52px; height: 52px;
  border-radius: var(--radius);
  border: 1.5px solid var(--ink);
  background: var(--surface);
  display: grid; place-content: center; justify-items: center;
  text-decoration: none;
  font-weight: 600;
  line-height: 1;
  font-size: 16px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px);
  transition: opacity .4s, transform .5s var(--ease), background .3s, color .3s;
}
.to-top span { font-size: 10px; letter-spacing: .1em; margin-top: 3px; }
.to-top.show { opacity: 1; pointer-events: auto; transform: none; }
.to-top:hover { background: var(--ink); color: var(--bg); }

/* ================= Reduced motion ================= */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
}
