/* =====================================================================
   tedpun.com
   Black and white, geometric titles (League Spartan) with a serif
   partner (Libre Baskerville), one electric-blue marker.
   The name is fixed to the foot of the window; work rises behind it.
   Light or dark follows the visitor's system setting until they use the
   mode button; their choice is then remembered (see script.js).
   ===================================================================== */

/* ---------- tokens ---------- */
:root {
  color-scheme: light dark;
  --bg: #FFFFFF;
  --text: #0A0A0A;
  --muted: #4A4A4A;
  --line: rgb(10 10 10 / 0.2);
  --accent: #2B4BFF;      /* marker fill */
  --on-accent: #FFFFFF;   /* text on the marker */
  --ink: #2B4BFF;         /* accent as text on the page ground */

  --display: "League Spartan", "Futura", "Century Gothic", sans-serif;
  --serif: "Libre Baskerville", "Baskerville", Georgia, serif;

  --max: 1200px;
  --gutter: clamp(20px, 5vw, 80px);
  --top: clamp(28px, 5vw, 64px);
  --name: clamp(56px, min(13vw, 21vh), 190px);
  --nav: 46px;
  --plate: calc(clamp(116px, min(16vw, 26vh), 224px) + var(--nav));
  --plate-min: 0.6;       /* plate height once the name has settled */
  --plate-solid: 34%;
  --entry: clamp(56px, 8vw, 120px);
  --section-gap: clamp(88px, 11vw, 168px);
  --radius: 2px;
  --out: cubic-bezier(0.16, 1, 0.3, 1);
  --swash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 14' preserveAspectRatio='none'%3E%3Cpath d='M0 8C48 0 92 13 140 6s52-2 60 0c-14 1-36 1-60 3C94 14 50 4 0 8Z'/%3E%3C/svg%3E");
}
/* dark: by system setting, unless the visitor chose light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0B0B;
    --text: #FFFFFF;
    --muted: #B8B8B8;
    --line: rgb(255 255 255 / 0.24);
    --ink: #8097FF;
  }
}
/* dark: by the visitor's choice. Keep these values the same as the block above. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0B0B0B;
  --text: #FFFFFF;
  --muted: #B8B8B8;
  --line: rgb(255 255 255 / 0.24);
  --ink: #8097FF;
}
:root[data-theme="light"] { color-scheme: light; }
@media (max-width: 600px) { :root { --plate-min: 0.72; --plate-solid: 18%; } }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 24px; scroll-padding-bottom: calc(var(--plate) + 24px); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 1rem/1.7 var(--serif); -webkit-font-smoothing: antialiased;
  caret-color: var(--ink); overflow-x: clip;
}
p, h1, h2, h3, h4, ul, ol, dl, dd, figure { margin: 0; }
h2, h3 { text-wrap: balance; }
.nb { white-space: nowrap; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.22em; text-decoration-color: var(--ink); }
a:hover { text-decoration-thickness: 2px; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 4px; border-radius: var(--radius); }
.skip { position: absolute; left: 12px; top: -120px; z-index: 60; background: var(--text); color: var(--bg); padding: 12px 16px; text-decoration: none; }
.skip:focus { top: 12px; }
.todo { border-bottom: 1px dashed currentColor; }

/* small tracked capitals, in the geometric face */
.label, .plate nav, .work-facts dt, .work-story h4, .work-sites h4, .sub, .skills dt, .i-type {
  font: 500 0.8125rem/1.4 var(--display); letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
}

/* ---------- name plate: name above a hairline, menu beneath ---------- */
.plate {
  position: fixed; inset: auto 0 0 0; height: var(--plate); z-index: 20;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end;
  padding: 0 var(--gutter) clamp(10px, 1.4vw, 22px); pointer-events: none;
}
.plate-bg {
  position: absolute; inset: 0; transform-origin: center bottom; transform: scaleY(var(--plate-min));
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 0%, transparent), var(--bg) var(--plate-solid));
}
.name {
  position: relative; font: 600 var(--name)/0.9 var(--display); letter-spacing: -0.045em; white-space: nowrap;
  transform-origin: left bottom; transform: scale(0.42); pointer-events: auto;
}
.name a { display: inline-block; text-decoration: none; }
.plate nav {
  position: relative; align-self: stretch; display: flex; gap: 4px; min-height: var(--nav);
  border-top: 1px solid var(--line); color: var(--text); pointer-events: auto;
}
.plate nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; text-decoration: none; }
.plate nav a:first-child { padding-left: 0; }
.plate nav a:hover { text-decoration: underline; text-underline-offset: 0.35em; }
.plate nav a[aria-current] { color: var(--ink); }
@media (max-width: 360px) { .plate nav a { padding: 0 9px; } }

/* mode button: sits at the right end of the menu row. script.js shows it. */
.mode {
  position: absolute; right: calc(var(--gutter) - 13px); bottom: clamp(10px, 1.4vw, 22px);
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--text);
  display: grid; place-items: center; cursor: pointer; pointer-events: auto;
}
.mode[hidden] { display: none; }
.mode::before { /* half-filled disc; turns over when the mode changes */
  content: ""; width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid currentColor;
  background: linear-gradient(90deg, currentColor 50%, transparent 0);
  transition: transform 0.7s var(--out);
}
.mode:hover::before { transform: rotate(30deg); }
.mode[aria-pressed="true"]::before { transform: rotate(180deg); }
.mode[aria-pressed="true"]:hover::before { transform: rotate(210deg); }
/* forced colours (Windows contrast themes) drop background images; keep the half fill so the state shows */
@media (forced-colors: active) {
  .mode::before { forced-color-adjust: none; border-color: ButtonText; background: linear-gradient(90deg, ButtonText 50%, Canvas 0); }
}

/* the name catches the accent once on load, and again on hover */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .name a {
    background: linear-gradient(100deg, var(--text) 42%, var(--ink) 50%, var(--text) 58%) 100% 0 / 320% 100% no-repeat;
    -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
    transition: background-position 1.4s var(--out);
  }
  .name a:hover, .name a:focus-visible { background-position: 0 0; }
}

/* ---------- page ---------- */
main { max-width: calc(var(--max) + 2 * var(--gutter)); margin: 0 auto; padding: var(--top) var(--gutter) calc(var(--plate) + 96px); }
.section + .section { margin-top: var(--section-gap); }

/* section label: words on a marker block, then a rule */
.label { display: flex; align-items: center; gap: 20px; padding-bottom: 40px; }
.label span {
  padding: 7px 10px 5px 12px; border-radius: var(--radius); color: var(--on-accent);
  background: linear-gradient(var(--accent), var(--accent)) 0 0 / 100% 100% no-repeat;
}
.label::after { content: ""; height: 1px; flex: 1; background: var(--text); opacity: 0.25; transform-origin: left; }

/* ---------- intro: the whole first screen ---------- */
.intro {
  min-height: calc(100vh - var(--top)); min-height: calc(100svh - var(--top));
  padding-bottom: calc(var(--plate) + 16px);
  display: flex; flex-direction: column; justify-content: flex-end;
}
.intro-text { display: flex; flex-direction: column; gap: 28px; }
.intro h2 { font: 500 clamp(2.25rem, min(6.2vw, 9vh), 5.5rem)/1.06 var(--display); letter-spacing: -0.03em; max-width: 20ch; }
.intro h2 .k {
  display: inline-block; padding: 0 0.14em 0.04em; margin: 0 -0.04em; border-radius: var(--radius);
  font: italic 400 0.9em/1 var(--serif); letter-spacing: -0.01em; color: var(--on-accent);
  background: linear-gradient(var(--accent), var(--accent)) 0 0 / 100% 100% no-repeat;
}
.intro-p { max-width: 54ch; font-size: 1.0625rem; color: var(--muted); }
.avail { max-width: 54ch; }
.avail a { white-space: nowrap; }
@media (max-width: 400px) { .intro h2 { font-size: 2rem; } .intro-text { gap: 18px; } .intro-p { font-size: 1rem; line-height: 1.6; } }
@media (min-width: 860px) {
  .intro-text { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 36px clamp(32px, 6vw, 88px); align-items: start; }
  .intro h2 { grid-column: 1 / -1; }
}

/* ---------- work at a glance (built by script.js from the entries) ---------- */
#work { padding-top: clamp(48px, 7vw, 96px); }
.index { padding-bottom: var(--entry); }
.index ol { list-style: none; padding: 0; margin: 0; border-bottom: 1px solid var(--line); }
.index li { border-top: 1px solid var(--line); }
.index a {
  display: grid; grid-template-columns: 13.5em minmax(0, 1fr); align-items: baseline; gap: 2px 24px;
  min-height: 48px; padding: 14px 0; text-decoration: none;
}
.i-title { /* the marker sweeps across the title on hover and focus */
  justify-self: start; padding: 0.12em 0.2em 0.02em; margin: -0.12em -0.2em -0.02em; border-radius: var(--radius);
  font: 500 clamp(1.375rem, 2.6vw, 2.125rem)/1.15 var(--display); letter-spacing: -0.015em;
  background: linear-gradient(var(--accent), var(--accent)) 0 0 / 0% 100% no-repeat;
  transition: background-size 0.4s var(--out), color 0.2s 0.1s;
}
.index a:hover .i-title, .index a:focus-visible .i-title { background-size: 100% 100%; color: var(--on-accent); }
.i-type { order: -1; white-space: nowrap; }
@media (max-width: 640px) { .index a { grid-template-columns: 1fr; } }

/* ---------- work entry ---------- */
.work { position: relative; border-top: 1px solid var(--line); padding: var(--entry) 0; display: grid; gap: clamp(36px, 5vw, 64px); }
.work:last-of-type { padding-bottom: 0; }
.work::before { /* a marker stroke rides the rule above each entry, crossing it as the entry scrolls by */
  content: ""; position: absolute; inset: -2px 0 auto 0; height: 3px;
  background: linear-gradient(var(--accent), var(--accent)) 0 0 / clamp(48px, 12%, 140px) 100% no-repeat;
}
.work-top { display: grid; gap: 32px clamp(32px, 6vw, 88px); align-items: center; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.work-head { display: flex; flex-direction: column; gap: 18px; }
.work h3 { font: 500 clamp(2rem, 4.2vw, 3.875rem)/1.04 var(--display); letter-spacing: -0.025em; }
.work-summary { max-width: 34ch; font-size: clamp(1.0625rem, 1.5vw, 1.25rem); line-height: 1.5; color: var(--muted); text-wrap: balance; }
.work-link a { display: inline-flex; align-items: center; min-height: 44px; }
.work-note { color: var(--muted); }
.work-media { display: grid; place-items: center; }
.work-media img { display: block; width: 100%; max-width: 560px; height: auto; }

.work-body { display: grid; gap: 36px clamp(32px, 6vw, 88px); grid-template-columns: 1fr; }
@media (min-width: 860px) { .work-body { grid-template-columns: minmax(280px, 1fr) minmax(0, 1.9fr); } }
.work-facts { display: grid; align-content: start; line-height: 1.5; }
.work-facts > div { display: grid; grid-template-columns: 8em minmax(0, 1fr); align-items: baseline; gap: 0 16px; padding: 11px 0; border-top: 1px solid var(--line); }
.work-facts > div:last-child { border-bottom: 1px solid var(--line); }
.work-story { display: grid; gap: 28px clamp(28px, 4vw, 56px); grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); align-content: start; }
.work-story .result { grid-column: 1 / -1; }
.work-story h4 { margin-bottom: 10px; }
.work-story p, .work-story ul { color: var(--muted); max-width: 62ch; }
.work-story ul { padding-left: 1.1em; display: grid; gap: 6px; }
.work-story .result p { font: italic 400 clamp(1.375rem, 2.3vw, 2rem)/1.25 var(--serif); color: var(--text); max-width: 30ch; text-wrap: balance; }

/* a strip of related sites under one entry */
.work-sites h4 { margin-bottom: 20px; }
.work-sites ul { list-style: none; padding: 0; display: grid; gap: 32px clamp(20px, 3vw, 40px); grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr)); }
.work-sites a { display: grid; gap: 12px; text-decoration: none; }
.work-sites img { display: block; width: 100%; height: auto; }
.work-sites span { color: var(--muted); line-height: 1.45; }
.work-sites strong { display: block; color: var(--text); font-weight: 700; text-decoration: underline; text-decoration-color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 0.22em; }
.work-sites a:hover strong { text-decoration-thickness: 2px; }

/* ---------- about ---------- */
.about { display: grid; gap: 48px clamp(32px, 6vw, 88px); grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.about-bio { display: flex; flex-direction: column; gap: 16px; }
.bio-1 { font: italic 400 clamp(1.375rem, 2.2vw, 1.8125rem)/1.35 var(--serif); max-width: 26ch; }
.bio-1::first-letter { /* drop cap as a marker block */
  float: left; font: 600 2.6em/1 var(--display); padding: 0.06em 0.2em; margin: 0.04em 0.16em 0 0;
  background: var(--accent); color: var(--on-accent);
}
.bio-2 { max-width: 54ch; color: var(--muted); }
.about-bio .sub { margin-top: 28px; }
.skills { display: grid; gap: 14px; }
.skills dd { color: var(--muted); max-width: 54ch; }
.about-xp { display: flex; flex-direction: column; gap: 12px; }
.xp { list-style: none; padding: 0; font-variant-numeric: tabular-nums; }
.xp li { display: grid; grid-template-columns: 9em 1fr; gap: 4px 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.xp li:last-child { border-bottom: 1px solid var(--line); }
.xp strong { display: block; font-weight: 700; }
.xp-years, .xp div span, .edu { color: var(--muted); }
.edu { padding-top: 8px; }
@media (max-width: 420px) { .xp li { grid-template-columns: 1fr; } }

/* ---------- contact ---------- */
.contact { view-timeline: --contact block; view-timeline-inset: 0px var(--plate); }
.contact address { font-style: normal; }
.email { position: relative; display: inline-block; font: italic 400 clamp(1.625rem, 4.2vw, 3.625rem)/1.1 var(--serif); text-decoration: none; overflow-wrap: anywhere; padding-bottom: 0.1em; }
.email::after { /* pen stroke */
  content: ""; position: absolute; left: 0; right: 0; bottom: -0.06em; height: 0.18em; background: var(--accent);
  -webkit-mask: var(--swash) center / 100% 100% no-repeat; mask: var(--swash) center / 100% 100% no-repeat;
  transition: transform 0.6s var(--out);
}
.email:hover::after, .email:focus-visible::after { transform: scaleY(1.7); }
.contact-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 28px; margin-top: 24px; }
.contact-links a { display: inline-flex; align-items: center; min-height: 44px; }

/* =====================================================================
   Motion. Everything above is the finished page; motion only adds to it.
   ===================================================================== */
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes name-in {
  0% { opacity: 0; transform: translateY(28%); background-position: 100% 0; }
  45% { opacity: 1; transform: none; background-position: 100% 0; }
  100% { opacity: 1; transform: none; background-position: 0 0; }
}
@keyframes wipe-x { from { -webkit-mask-position: 100% 0; mask-position: 100% 0; } to { -webkit-mask-position: 0 0; mask-position: 0 0; } }
@keyframes wipe-y { from { -webkit-mask-position: 0 100%; mask-position: 0 100%; opacity: 0.2; } to { -webkit-mask-position: 0 0; mask-position: 0 0; opacity: 1; } }
@keyframes mark { from { background-size: 0% 100%; color: var(--text); } to { background-size: 100% 100%; color: var(--on-accent); } }
@keyframes pen { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes fill { from { background-size: 0% 100%; color: var(--text); } to { background-size: 100% 100%; color: var(--on-accent); } }
@keyframes travel { from { background-position: 0 0; } to { background-position: 100% 0; } }
@keyframes rule { from { transform: scaleX(0); } to { transform: none; } }
@keyframes name-settle { from { transform: none; } to { transform: scale(0.42); } }
@keyframes plate-shrink { from { transform: none; } to { transform: scaleY(var(--plate-min)); } }

/* on load: the first screen arrives */
@media (prefers-reduced-motion: no-preference) {
  .intro h2 {
    -webkit-mask: linear-gradient(to right, #000 50%, transparent 62%) 0 0 / 300% 100% no-repeat;
            mask: linear-gradient(to right, #000 50%, transparent 62%) 0 0 / 300% 100% no-repeat;
    animation: wipe-x 2s cubic-bezier(0.3, 0, 0.2, 1) 0.15s backwards;
  }
  .intro h2 .k { animation: mark 0.8s cubic-bezier(0.5, 0, 0.2, 1) 1.5s backwards; }
  .intro h2 .k ~ .k { animation-delay: 1.85s; }
  .intro-p { animation: rise 1.2s var(--out) 1s backwards; }
  .avail { animation: rise 1.2s var(--out) 1.15s backwards; }
  .name a { animation: name-in 2.4s var(--out) 0.5s backwards; }
  .plate nav { animation: fade 1.2s var(--out) 1.2s backwards; }
}

/* on scroll: the name settles into a bar, work arrives as it clears the plate */
@media (prefers-reduced-motion: no-preference) and (min-height: 481px) {
  @supports (animation-timeline: view()) {
    .name { animation: name-settle linear both; animation-timeline: scroll(root); animation-range: 0px 600px; }
    .plate-bg { animation: plate-shrink linear both; animation-timeline: scroll(root); animation-range: 120px 600px; }
    .label::after { animation: rule linear both; animation-timeline: view(); animation-range: entry 0% cover 30%; }
    .label span { animation: fill linear both; animation-timeline: view(); animation-range: entry 20% cover 28%; }
    .work::before { animation: travel linear both; animation-timeline: view(); animation-range: entry 0% exit 100%; }
    .work-media img {
      -webkit-mask: linear-gradient(to bottom, #000 50%, transparent 60%) 0 0 / 100% 300% no-repeat;
              mask: linear-gradient(to bottom, #000 50%, transparent 60%) 0 0 / 100% 300% no-repeat;
      animation: wipe-y linear both; animation-timeline: view(); animation-range: entry 0% cover 40%;
    }
    /* timed against the contact block clearing the plate, so it always finishes before the page ends */
    .email::after { animation: pen linear both; animation-timeline: --contact; animation-range: entry 35% entry 100%; }
  }
}

/* mode change: the whole page cross-fades (View Transitions); older browsers fade colours instead */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.6s; animation-timing-function: ease-in-out; }
.mode-fade, .mode-fade *, .mode-fade *::before, .mode-fade *::after {
  transition: background-color 0.6s ease-in-out, color 0.6s ease-in-out, border-color 0.6s ease-in-out !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
