/* Self-hosted fonts (Fraunces, JetBrains Mono — SIL Open Font License), latin + latin-ext */
/* Fraunces italic latin-ext */
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/fraunces-italic-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Fraunces italic latin */
@font-face {
  font-family: 'Fraunces';
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/fraunces-italic-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Fraunces normal latin-ext */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/fraunces-normal-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Fraunces normal latin */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/fraunces-normal-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* JetBrains Mono normal latin-ext */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/jetbrains-normal-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* JetBrains Mono normal latin */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/jetbrains-normal-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* JetBrains Mono normal latin-ext */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/jetbrains-normal-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* JetBrains Mono normal latin */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(fonts/jetbrains-normal-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Palette sampled from portrait.jpg:
   terracotta tiles/hair #9e6140–#b9714d, peach skin/tiles #d29570, olive tee #735531, cocoa jacket #433731 */
:root {
  --bg: #f6efe7;
  --fg: #2b211c;
  --muted: #8c7566;
  --rule: #e5d6c8;
  --accent: #a65d3a;
  --peach: #d29570;
  --olive: #735531;
  --grad: linear-gradient(90deg, #9e6140, #d29570, #b9714d, #735531, #9e6140);
  --gutter: clamp(16px, 5vw, 64px);
  --serif: "Fraunces", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #1a1411;
  --fg: #f2e5d8;
  --muted: #a08b7c;
  --rule: #33281f;
  --accent: #e09a72;
  --peach: #d88f65;
  --olive: #b48a52;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1411;
    --fg: #f2e5d8;
    --muted: #a08b7c;
    --rule: #33281f;
    --accent: #e09a72;
    --peach: #d88f65;
    --olive: #b48a52;
    color-scheme: dark;
  }
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: clamp(17px, 1.1vw + 12px, 20px);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .4s, color .4s;
}

::selection { background: var(--peach); color: #2b211c; }

a { color: inherit; text-decoration: none; }

.mono {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- intro: elements fade up in sequence ---------- */

.intro { animation: fade-up .9s var(--ease) both; animation-delay: var(--delay, 0s); }
@keyframes fade-up { from { opacity: 0; translate: 0 18px; } }
@keyframes fade-down { from { opacity: 0; translate: 0 -12px; } }

/* ---------- top / bottom bars ---------- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px var(--gutter);
}

header.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  animation: fade-down .8s .1s var(--ease) both;
}

/* scroll progress, painted in the portrait's colours */
header.bar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--grad);
  transform-origin: left;
  transform: scaleX(var(--progress, 0));
}

.logo { font-weight: 500; padding: 12px 12px 12px 0; margin: -12px 0; transition: color .3s; }
.logo:hover { color: var(--accent); }
.clock { color: var(--muted); }
.clock #time { color: var(--fg); font-variant-numeric: tabular-nums; }
.clock .colon { animation: blink 2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.theme {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  transition: transform .5s var(--ease), color .3s;
}
.theme { -webkit-tap-highlight-color: transparent; }
.theme:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; border-radius: 50%; }
@media (hover: hover) {
  .theme:hover { transform: rotate(180deg); color: var(--accent); }
}

footer.bar {
  color: var(--muted);
  border-top: 1px solid var(--rule);
  margin-top: 96px;
}
footer a { padding: 12px 0; margin: -12px 0; transition: color .3s; }
footer a:hover { color: var(--accent); }

/* ---------- hero ---------- */

.hero {
  position: relative;
  min-height: calc(100svh - 70px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 var(--gutter) 10vh;
  overflow-x: clip;
}

.name {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(64px, 16vw, 240px);
  font-weight: 300;
  line-height: .86;
  letter-spacing: -.035em;
  font-variation-settings: "opsz" 144;
  cursor: default;
  user-select: none;
}
.name .line { display: block; }
.name .line + .line { padding-left: 1.2em; }
.name .ch {
  display: inline-block;
  font-weight: var(--w, 300);
  transition: font-weight .25s ease-out, color .25s;
  animation: rise 1s var(--ease) both;
  animation-delay: calc(var(--i) * 45ms + .15s);
}
.name .ch.hot { color: var(--accent); }
@keyframes rise {
  from { opacity: 0; translate: 0 .4em; filter: blur(10px); }
}

.tagline {
  position: relative;
  z-index: 1;
  max-width: 32ch;
  margin: 40px 0 0;
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1.3;
  font-weight: 350;
}
/* shimmering gradient word */
.tagline em {
  font-style: italic;
  background: var(--grad);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-right: .08em;
  animation: shimmer 6s linear infinite;
}
@keyframes shimmer { to { background-position: -300% 0; } }

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  color: var(--muted);
}
.status .sep { color: var(--rule); }
.status .years { color: var(--accent); }
/* fixed-width counter so counting up never reflows the text around it */
.years { display: inline-block; min-width: 1.15em; text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.status i {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3fb950;
  box-shadow: 0 0 0 0 #3fb95066;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px #3fb95000; }
  100% { box-shadow: 0 0 0 0 #3fb95000; }
}

/* ---------- portrait: original photo in an oval ---------- */

.portrait {
  position: absolute;
  top: 14vh;
  right: calc(var(--gutter) + 3vw);
  width: clamp(180px, 19vw, 300px);
  margin: 0;
  aspect-ratio: 3 / 4;
  isolation: isolate;
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .6s var(--ease);
}

.frame {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  animation: float 7s ease-in-out infinite alternate;
}
.frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
@keyframes float { to { translate: 0 -10px; } }

/* soft glow behind the oval, mixed from the photo's own colours */
.glow {
  will-change: transform;
  position: absolute;
  inset: -18%;
  z-index: -1;
  border-radius: 50%;
  background:
    radial-gradient(closest-side at 35% 40%, var(--peach), transparent),
    radial-gradient(closest-side at 70% 65%, var(--accent), transparent 80%);
  filter: blur(30px);
  opacity: .4;
  animation: breathe 9s ease-in-out infinite alternate, fade-up 1.2s .6s var(--ease) both;
}
@keyframes breathe {
  0%   { transform: scale(.92) rotate(0deg); }
  100% { transform: scale(1.08) rotate(40deg); }
}

/* text crawling around the oval (driven by script.js) */
.ring {
  position: absolute;
  inset: -11%;
  width: 122%;
  height: 122%;
  overflow: visible;
  pointer-events: none;
  animation: fade-up 1s 1.4s var(--ease) both;
}
.ring text {
  font-family: var(--mono);
  font-size: 4.2px;
  letter-spacing: .2px;
  fill: var(--muted);
  text-transform: uppercase;
}
.ring .dot { fill: var(--accent); }

/* tile-wall reveal on load (tiles are built in script.js) */
.tiles {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(8, 1fr);
  pointer-events: none;
}
.tiles i {
  background: var(--bg);
  animation: tile-out .5s var(--d, 0s) both var(--ease);
}
@keyframes tile-out { to { opacity: 0; scale: .4; } }

/* ---------- section rows ---------- */

.row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 3fr;
  gap: 24px var(--gutter);
  padding: 56px var(--gutter);
}
/* top rule draws itself in when the section appears */
.row::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--rule);
  transform-origin: left;
  transition: transform 1.2s var(--ease);
}
.row.reveal::before { transform: scaleX(0); }
.row.reveal.in::before { transform: scaleX(1); }

.label {
  margin: 0;
  font-weight: 400;
  color: var(--muted);
  position: sticky;
  top: 80px;
  align-self: start;
}
.label span { color: var(--accent); margin-right: 8px; }

.prose p { margin: 0 0 1em; max-width: 38ch; font-size: clamp(20px, 1.6vw, 26px); line-height: 1.4; font-weight: 350; }
.prose p:last-child { margin-bottom: 0; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list li,
.list li > a {
  display: grid;
  grid-template-columns: 9.5em 1fr auto;
  align-items: baseline;
  gap: 16px;
}
.list li {
  position: relative;
  padding: 16px 0;
  border-bottom: 1px solid var(--rule);
}
.list li:first-child { padding-top: 0; }
.list .when { color: var(--muted); }
.list .what { font-size: clamp(20px, 1.8vw, 28px); font-weight: 400; transition: color .3s; }
.list .where { color: var(--muted); text-align: right; font-style: italic; }

/* accent underline sweeps across a row on hover */
.list li::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: var(--grad);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform .6s var(--ease);
}
.list li:hover::after { transform: scaleX(1); transform-origin: left; }
#experience .list li:hover .what { color: var(--accent); }

/* rows stagger in after their section appears */
.reveal .list li { opacity: 0; translate: 0 14px; transition: opacity .7s var(--ease), translate .7s var(--ease); }
.reveal.in .list li { opacity: 1; translate: 0 0; transition-delay: calc(var(--i, 0) * 80ms + .15s); }

/* work list: whole row is a link, slides on hover */
.work li { display: block; }
.work li > a { grid-column: 1 / -1; transition: transform .35s var(--ease); }
.work li > a .what { transition: font-weight .35s, color .35s; }
.work li:hover > a { transform: translateX(12px); }
.work li:hover .what { font-weight: 600; color: var(--accent); font-style: italic; }
.work li > a:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }

/* ---------- toolkit marquee ---------- */

.skills { min-width: 0; }
.marquee {
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.track {
  will-change: transform;
  display: flex;
  width: max-content;
  animation: marquee 45s linear infinite;
}
.marquee:hover .track { animation-play-state: paused; }
.track span {
  font-size: clamp(28px, 3.2vw, 48px);
  font-weight: 300;
  font-style: italic;
  white-space: nowrap;
  padding-right: .6em;
  transition: color .3s, font-weight .3s;
}
.track span:hover { color: var(--accent); font-weight: 500; }
.track b { font-weight: 400; font-style: normal; padding-right: .6em; font-size: clamp(18px, 2vw, 28px); align-self: center; }
.track b:nth-of-type(3n + 1) { color: var(--accent); }
.track b:nth-of-type(3n + 2) { color: var(--peach); }
.track b:nth-of-type(3n) { color: var(--olive); }
@keyframes marquee { to { transform: translateX(-50%); } }

.skills .cert { display: block; margin-top: 8px; color: var(--muted); }
.skills .cert:first-of-type { margin-top: 28px; }

/* ---------- contact ---------- */

.email {
  font: inherit;
  font-size: min(80px, 8cqi);
  font-weight: 300;
  letter-spacing: -.02em;
  white-space: nowrap;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
  background-image: var(--grad);
  background-size: 0% 2px;
  background-position: 0 92%;
  background-repeat: no-repeat;
  transition: background-size .5s var(--ease), color .3s;
}
.email:hover, .email:focus-visible { background-size: 100% 2px; color: var(--accent); outline: none; }
.email.copied { animation: pop .5s var(--ease); }
@keyframes pop { 40% { scale: 1.03; } }

#contact .body { container-type: inline-size; }

.hint { display: block; margin-top: 12px; color: var(--muted); }

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 32px;
  list-style: none;
  padding: 0;
  margin: 40px 0 0;
}
.links a { display: inline-block; padding-top: 10px; border-bottom: 1px solid var(--rule); padding-bottom: 2px; transition: border-color .3s, color .3s, translate .3s var(--ease); }
.links a:hover { color: var(--accent); border-color: var(--accent); translate: 0 -3px; }

/* ---------- floating project preview ---------- */

.preview {
  position: fixed;
  top: 0;
  left: 0;
  width: 340px;
  aspect-ratio: 2 / 1;
  border-radius: 10px;
  overflow: hidden;
  pointer-events: none;
  z-index: 20;
  opacity: 0;
  scale: .6;
  transition: opacity .25s, scale .35s var(--ease);
  background: var(--olive) var(--img, none) center top / cover no-repeat;
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent),
    0 24px 60px -20px rgb(43 33 28 / .55);
}
.preview.on { opacity: 1; scale: 1; }

/* ---------- reveal on scroll ---------- */

.reveal > .label,
.reveal > .body { opacity: 0; translate: 0 24px; transition: opacity .8s var(--ease), translate .8s var(--ease); }
.reveal > .body { transition-delay: .1s; }
.reveal.in > .label,
.reveal.in > .body { opacity: 1; translate: 0 0; }

/* ---------- small screens ---------- */

@media (min-width: 721px) and (max-width: 1000px) {
  .list li, .list li > a { grid-template-columns: 7.5em 1fr; row-gap: 2px; }
  .list .where { grid-column: 2; text-align: left; }
  .name { font-size: 13vw; }
}

@media (max-width: 720px) {
  .clock { display: none; }
  .hero { min-height: auto; justify-content: flex-end; padding-top: 32px; }
  .portrait { position: relative; top: auto; right: auto; align-self: flex-end; width: 50%; margin: 24px 8% 72px 0; }
  .row { grid-template-columns: 1fr; padding-block: 40px; }
  .label { position: static; }
  .name .line + .line { padding-left: .6em; }
  .list li, .list li > a { grid-template-columns: 1fr; gap: 4px; }
  .list .where { text-align: left; }
  .preview { display: none; }
}

@media (hover: none) { .preview { display: none; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .tiles { display: none; }
  .track { flex-wrap: wrap; width: auto; }
  .track [data-dup] { display: none; }
}
