/* =========================================================
   rajavel.me
   Full-screen hero with a playful greeting and an illustration
   of me at my desk; an experience timeline of logo circles and
   cards; certifications, projects, about; contact in a dialog.
   Dark first, with a light theme.
   ========================================================= */

@font-face {
  font-family: "Geist";
  src: url("/fonts/geist-sans-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* ---------- Tokens ---------- */
:root {
  --font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --radius: 14px;
  --radius-sm: 8px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --wrap: 1040px;
}

/* Colours live in palette.css (Sage & cream). */

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ul, ol { margin: 0; }
[hidden] { display: none !important; }
ul, ol { padding: 0; list-style: none; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: fixed; left: 16px; top: -100px; z-index: 100;
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent);
}
.skip:focus { top: 12px; }

.wrap { width: min(100% - 48px, var(--wrap)); margin-inline: auto; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  position: fixed; top: 18px; right: 18px; z-index: 30;
  display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 1px solid transparent; border-radius: 50%;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  color: var(--accent);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.5s var(--spring);
}
.theme-toggle:hover { border-color: var(--border-hover); transform: rotate(45deg); }
.theme-toggle svg { width: 20px; height: 20px; }
.icon-sun { display: block; }
.icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .icon-sun { display: none; }
  :root:not([data-theme="dark"]) .icon-moon { display: block; }
}

/* ---------- Section links ---------- */
/* A pill of section links that slides in once the hero is mostly gone (main.js adds .is-shown). */
.jump {
  position: fixed; top: 18px; left: 50%; z-index: 30;
  max-width: calc(100% - 36px);
  padding: 4px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--bg); /* solid, so text scrolling underneath never reads through the links */
  box-shadow: var(--shadow);
  translate: -50% 0;
  transition: opacity 0.3s, translate 0.4s var(--ease), visibility 0.3s;
}
.js .jump:not(.is-shown) { opacity: 0; visibility: hidden; translate: -50% -16px; }
.jump ul { position: relative; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-radius: 999px; }
/* When the row scrolls sideways, fade whichever edge has more links past it (main.js sets the classes). */
.jump ul {
  --fade-l: 0px; --fade-r: 0px;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
          mask-image: linear-gradient(to right, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
}
.jump ul.more-l { --fade-l: 36px; }
.jump ul.more-r { --fade-r: 36px; }
.jump ul::-webkit-scrollbar { display: none; }
.jump a {
  display: block;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--text-2);
  font-size: 0.9rem; font-weight: 600; line-height: 1.25;
  white-space: nowrap;
  transition: color 0.2s, background-color 0.2s;
}
.jump a:hover { color: var(--text); background: var(--surface); }
.jump a[aria-current="true"] { color: var(--on-accent); background: var(--accent); }
.jump a:focus-visible { outline-offset: -2px; border-radius: 999px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; min-width: 200px; padding: 0 24px;
  border: 0; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--on-accent);
  font: 650 1rem/1 var(--font);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.2) inset, 0 6px 18px -8px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: background-color 0.15s, transform 0.15s var(--ease), box-shadow 0.2s;
}
.btn:hover { background: var(--accent-hover); color: var(--on-accent); transform: translateY(-1px); }
.btn:active { transform: scale(0.98); }
.btn svg { flex: none; width: 18px; height: 18px; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-quiet { background: var(--quiet); color: var(--text); box-shadow: 0 1px 0 rgb(255 255 255 / 0.05) inset; }
.btn-quiet:hover { background: var(--quiet-hover); color: var(--text); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 96px clamp(24px, 7vw, 120px) 112px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(50% 60% at 82% 70%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 70%),
    var(--bg);
}

/* The mark sits level with the theme button, lined up with the hero text. */
.mark {
  position: absolute; top: 20px; left: clamp(24px, 7vw, 120px); z-index: 1;
  width: 40px; height: 40px;
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--border), var(--shadow);
  animation: pop 0.5s var(--spring) 0.3s both;
}

.hero-content { position: relative; z-index: 1; max-width: 640px; display: grid; gap: 22px; }

.hero h1 { display: grid; gap: 0.1em; font-weight: 750; letter-spacing: -0.035em; line-height: 1.05; }
.hello { font-size: clamp(1.5rem, 3.3vw, 2.5rem); color: var(--text); }
.name {
  width: fit-content;
  padding-bottom: 0.08em;
  font-size: clamp(2.5rem, 5.5vw, 4.25rem);
  background: var(--grad) 0 0 / 400% 100%;
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rise 0.6s var(--ease) 0.75s both, flow 16s linear infinite;
}

/* Letters of "Hi, my name is" drop in with a tumble, and bounce when hovered. */
.hello .ch { display: inline-block; }
.hello.play .ch {
  animation: tumble 0.7s var(--spring) both;
  animation-delay: calc(var(--i) * 0.035s);
}
.hello .ch.boing { animation: boing 0.6s var(--spring); animation-delay: 0s; }
.hello .sp { display: inline-block; width: 0.28em; }

.intro {
  max-width: 34ch;
  color: var(--text-2);
  font-size: clamp(1.125rem, 1.6vw, 1.375rem);
  line-height: 1.55;
  animation: rise 0.6s var(--ease) 0.9s both;
}
.where {
  display: inline-flex; align-items: center; gap: 7px;
  margin-top: -8px;
  color: var(--muted);
  font-size: 1rem; font-weight: 550;
  animation: rise 0.6s var(--ease) 1s both;
}
.where svg { width: 18px; height: 18px; color: var(--accent); }
.intro a { color: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: 4px; text-decoration-thickness: 2px; }
.intro a:hover { color: var(--accent); }

.actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.hero .actions .btn { animation: pop 0.5s var(--spring) 1.1s both; }
.hero .actions .btn + .btn { animation-delay: 1.2s; }

.chevron {
  position: absolute; left: clamp(24px, 7vw, 120px); bottom: 22px; z-index: 1;
  display: grid; place-items: center;
  width: 44px; height: 44px; margin-left: -8px; /* line the arrow up with the text above it */
  color: var(--accent);
  animation: bob 2.6s ease-in-out infinite;
}
.chevron svg { width: 30px; height: 30px; stroke-width: 2.25; }

@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: none; } }
@keyframes flow { to { background-position: 400% 0; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
@keyframes tumble {
  from { opacity: 0; transform: translateY(-0.9em) rotate(var(--r, 20deg)) scale(0.6); }
  to { opacity: 1; transform: none; }
}
@keyframes boing {
  30% { transform: translateY(-0.28em) rotate(var(--r, 10deg)) scale(1.1); }
  60% { transform: translateY(0.05em) rotate(calc(var(--r, 10deg) * -0.4)); }
  100% { transform: none; }
}

/* ---------- Illustration: me at my desk ---------- */
/* --p (0 → 1) is how far the hero has scrolled away; main.js sets it on .hero. */
.me {
  --skin: #a86f4c;
  --skin-shade: #8c5636;
  --hair: #141110;
  --laptop: #c5ccd6;
  --laptop-shade: #9aa4b2;

  position: absolute; right: clamp(8px, 4vw, 72px); bottom: -2px;
  width: min(48vw, 640px); height: auto;
  stroke: none; overflow: visible;
  animation: rise 0.9s var(--ease) 0.5s both;
  translate: 0 calc(var(--p, 0) * 90px);
}
.hero-content { translate: 0 calc(var(--p, 0) * -50px); opacity: calc(1 - var(--p, 0) * 0.85); }

.me .beam-wrap { opacity: calc(1 - var(--p, 0) * 1.4); }
.me .beam { fill: var(--accent); opacity: 0.08; animation: flicker 4s ease-in-out infinite; }
.me .floor-shadow { fill: var(--text); opacity: 0.07; }
.me .desk { fill: var(--desk); }
.me .desk-leg { fill: var(--desk-leg); }
.me .pot { fill: #b8673f; }
.me .leaf { fill: #5f8f5c; }
.me .leaf.l2 { fill: #74a36f; }
.me .plant { transform-box: fill-box; transform-origin: 50% 100%; animation: sway 6s ease-in-out infinite; }
.me .cup { fill: var(--card-solid); stroke: var(--muted); stroke-width: 3; }
.me .cup-handle { fill: none; stroke: var(--muted); stroke-width: 4; }
.me .steam { fill: none; stroke: var(--muted); stroke-width: 3; stroke-linecap: round; opacity: 0; animation: steam 3.2s ease-out infinite; }
.me .steam.s2 { animation-delay: 1.6s; }
.me .laptop { fill: var(--laptop); }
.me .laptop-shade { fill: var(--laptop-shade); }
.me .screen { stroke: var(--accent); stroke-width: 3; }
/* The lid closes as you scroll away, hinged where it meets the base. */
.me .lid { transform-box: view-box; transform-origin: 202px 348px; rotate: calc(var(--p, 0) * 101deg); }
.me .chair { fill: var(--chair); }
.me .jeans { fill: var(--jeans); }
.me .shoe { fill: #2a2522; }
.me .hoodie { fill: var(--hoodie); }
.me .hoodie-shade { fill: var(--hoodie-shade); }
.me .string { fill: none; stroke: color-mix(in srgb, var(--hoodie) 40%, #fff); stroke-width: 2.5; stroke-linecap: round; }
.me .string-tip { fill: none; stroke: color-mix(in srgb, var(--hoodie) 25%, #fff); stroke-width: 4; stroke-linecap: round; }
.me .rib { fill: none; stroke: color-mix(in srgb, var(--hoodie-shade) 80%, #000); stroke-width: 1.5; opacity: 0.5; }
.me .hood-lining { fill: color-mix(in srgb, var(--hoodie-shade) 70%, #000); }
.me .neck { fill: var(--skin-shade); }
.me .skin { fill: var(--skin); }
.me .skin-shade { fill: var(--skin-shade); }
.me .hair { fill: var(--hair); }
.me .brow { fill: none; stroke: var(--hair); stroke-width: 4; stroke-linecap: round; }
.me .eye { fill: #140f0d; transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
.me .mouth { fill: none; stroke: var(--skin-shade); stroke-width: 3; stroke-linecap: round; }
.me .hand { animation: type 0.42s ease-in-out infinite alternate; }
.me .hand-far { animation: type 0.5s ease-in-out 0.25s infinite alternate; }
/* Typing stops, and I lean back, once the laptop starts closing. */
.me .head { transform-box: view-box; transform-origin: 420px 260px; animation: nod 7s ease-in-out infinite; rotate: calc(var(--p, 0) * 6deg); }
.hero.is-away .me .hand, .hero.is-away .me .hand-far { animation-play-state: paused; }

@keyframes type { to { transform: translateY(-4px); } }
@keyframes blink { 0%, 46%, 50%, 100% { transform: scaleY(1); } 48% { transform: scaleY(0.1); } }
@keyframes nod { 0%, 72%, 100% { transform: none; } 80%, 90% { transform: rotate(-3deg); } }
@keyframes sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg); } }
@keyframes steam { 0% { opacity: 0; transform: translateY(6px); } 30% { opacity: 0.55; } 100% { opacity: 0; transform: translateY(-14px); } }
@keyframes flicker { 0%, 100% { opacity: 0.06; } 50% { opacity: 0.11; } }

/* ---------- Sections ---------- */
.section { padding: clamp(88px, 13vh, 150px) 0 0; scroll-margin-top: 16px; }

.heading {
  width: fit-content;
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  line-height: 1.1;
  font-weight: 750;
  letter-spacing: -0.04em;
  background: var(--heading);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}
.section .heading { margin-bottom: 44px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; margin-bottom: 44px; }
.section-head .heading { margin: 0; }

.sep { opacity: 0.45; margin: 0 4px; }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  color: var(--tag-text);
  font-size: 0.78rem; font-weight: 650; letter-spacing: 0.01em;
  vertical-align: 2px;
}

/* ---------- Experience timeline ---------- */
.timeline { display: grid; gap: 22px; }

.job { position: relative; display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 32px; align-items: center; }
/* The line through the logos: a faint track, and a fill that draws down
   as you scroll (main.js sets --t-top, --t-len and --fill). */
.timeline { position: relative; }
.timeline::before, .timeline::after {
  content: "";
  position: absolute; left: 43px; top: var(--t-top, 44px);
  width: 2px; border-radius: 2px;
}
.timeline::before { height: var(--t-len, 0px); background: var(--border); }
.timeline::after {
  height: calc(var(--t-len, 0px) * var(--fill, 0));
  background: linear-gradient(transparent, var(--accent) 40px);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 60%, transparent);
}
.logo { z-index: 2; }
.job.is-lit .logo { box-shadow: 0 0 0 1px var(--border), 0 0 0 7px var(--bg), 0 0 0 8px var(--accent); }
.job.is-lit .logo img { filter: none; opacity: 1; }
/* Logos that come on a solid background fill the whole circle with it. */
.logo.logo-fill { background: var(--logo-bg); filter: var(--logo-filter); transition: transform 0.5s var(--spring), box-shadow 0.3s, filter 0.4s; }
.logo.logo-fill img { width: 86%; height: 86%; filter: none; opacity: 1; }
.job.is-lit .logo.logo-fill, .job:hover .logo.logo-fill { filter: none; }

.logo {
  position: relative;
  display: grid; place-items: center;
  width: 88px; height: 88px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 1px var(--border), 0 0 0 7px var(--bg), 0 0 0 8px var(--border);
  overflow: hidden;
  transition: transform 0.5s var(--spring), box-shadow 0.3s;
}
.logo img {
  width: 66%; height: 66%;
  object-fit: contain;
  filter: var(--logo-filter);
  opacity: 0.85;
  transition: filter 0.4s, opacity 0.4s;
}
.job:hover .logo { transform: rotate(-6deg) scale(1.04); box-shadow: 0 0 0 1px var(--border-hover), 0 0 0 7px var(--bg), 0 0 0 8px var(--accent); }
.job:hover .logo img, .job:focus-within .logo img { filter: none; opacity: 1; }

.job-card {
  position: relative; z-index: 1; /* above the timeline line, which crosses the cards on phones */
  display: grid; gap: 6px;
  padding: 24px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.25s,
    opacity 0.7s var(--ease), translate 0.7s var(--ease);
}
/* Each card waits, faded, until the line reaches its logo, then slides out from the line. */
.js .job-card { opacity: 0.5; translate: -28px 0; }
.js .job.is-lit .job-card, .js .job:focus-within .job-card { opacity: 1; translate: 0 0; }
@media (prefers-reduced-motion: reduce) { .js .job-card { opacity: 1; translate: none; } }
.job:hover .job-card { transform: translateX(4px); border-color: var(--border-hover); box-shadow: var(--shadow-hover); }

.job-role { color: var(--text-2); font-size: 0.95rem; font-weight: 550; }
.job-role .tag { margin-left: 6px; }
/* Dates and product names never break at their dash or hyphen ("2020–" / "2023"). */
.when, .nw { white-space: nowrap; }
.job-sum { max-width: 68ch; margin-top: 4px; color: var(--text-2); font-size: 1.0625rem; text-wrap: pretty; }


/* ---------- Cards (certs, projects) ---------- */
.card {
  position: relative;
  padding: 26px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--text);
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease), border-color 0.25s;
}
a.card:hover { transform: translateY(-3px); border-color: var(--border-hover); box-shadow: var(--shadow-hover); color: var(--text); }

.certs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.cert { display: grid; grid-template-columns: 72px minmax(0, 1fr); align-items: center; gap: 2px 20px; height: 100%; }
.cert img {
  grid-row: span 2;
  width: 72px; height: 72px; padding: 4px;
  border-radius: 50%; background: #fff;
  object-fit: contain;
  filter: var(--logo-filter);
  transition: filter 0.4s, transform 0.5s var(--spring);
}
.cert:hover img { filter: none; transform: rotate(-10deg) scale(1.06); }
.cert-name { align-self: end; font-weight: 700; font-size: 1.0625rem; letter-spacing: -0.01em; line-height: 1.35; transition: color 0.2s; }
.cert-meta { align-self: start; color: var(--muted); font-size: 0.925rem; }
.cert:hover .cert-name { color: var(--accent); }

.arrow { display: inline-block; transition: transform 0.3s var(--ease); }
a:hover .arrow { transform: translate(3px, -3px); }
.more { display: inline-block; margin-top: 26px; font-weight: 650; }

.projects { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.project { display: grid; gap: 12px; justify-items: start; }
.project h3 { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.25; }
.project p { color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { padding: 3px 10px; border: 1px solid var(--border-hover); border-radius: 999px; color: var(--muted); font-size: 0.85rem; font-weight: 550; }
.project-link::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(80% 60% at 100% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%);
  opacity: 0; transition: opacity 0.35s;
}
.project-link:hover::after { opacity: 1; }
.go { color: var(--accent); font-weight: 650; }

/* ---------- About ---------- */
.about { padding-bottom: clamp(88px, 13vh, 150px); }
.about-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 56px; align-items: start; }
.about .heading { margin-bottom: 24px; }
.body { max-width: 62ch; color: var(--text-2); font-size: 1.125rem; text-wrap: pretty; }
.body + .body { margin-top: 16px; }
.body a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
code {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: 600 0.9em/1.4 var(--mono);
  white-space: nowrap;
}
.about .actions { margin-top: 28px; }
.about .actions .btn { min-width: 0; }

.avatar {
  --skin: #a86f4c; --skin-shade: #8c5636; --hair: #141110; --shirt: var(--hoodie);
  width: 100%; height: auto;
  stroke: none;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--border), 0 0 0 10px var(--bg), 0 0 0 11px var(--border-hover), var(--shadow);
  transition: transform 0.6s var(--spring);
}
.avatar:hover { transform: rotate(-4deg) scale(1.02); }
.avatar .avatar-bg { fill: color-mix(in srgb, var(--accent) 16%, var(--card-solid)); }
.avatar .shirt { fill: var(--shirt); }
.avatar .neck, .avatar .ear { fill: var(--skin-shade); }
.avatar .skin { fill: var(--skin); }
.avatar .hair { fill: var(--hair); }
.avatar .collar { fill: var(--shirt); }
.avatar .hood { fill: var(--hoodie-shade); }
.avatar .hood-lining { fill: color-mix(in srgb, var(--hoodie-shade) 70%, #000); }
.avatar .string { fill: none; stroke: color-mix(in srgb, var(--hoodie) 40%, #fff); stroke-width: 4; stroke-linecap: round; }
.avatar .string-tip { fill: none; stroke: color-mix(in srgb, var(--hoodie) 25%, #fff); stroke-width: 7; stroke-linecap: round; }
.avatar .brow { fill: none; stroke: var(--hair); stroke-width: 4.5; stroke-linecap: round; }
.avatar .eyes { fill: #140f0d; transform-box: fill-box; transform-origin: center; animation: blink 6s infinite 1s; }
.avatar .mouth { fill: none; stroke: var(--skin-shade); stroke-width: 3.5; stroke-linecap: round; }

/* ---------- Footer ---------- */
.foot { padding: 26px 0; border-top: 1px solid var(--border); background: var(--bg-2); }
.foot-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 28px; }
.copy { margin-right: auto; color: var(--muted); font-size: 0.9rem; }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.foot-links a {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.9rem; font-weight: 550;
  transition: color 0.2s, background-color 0.2s;
}
.foot-links a:hover { color: var(--text); background: var(--surface); }
.foot-links svg { width: 16px; height: 16px; }
.top {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border: 1px solid var(--border-hover); border-radius: 50%;
  color: var(--muted);
  transition: color 0.2s, border-color 0.2s, transform 0.3s var(--ease);
}
.top:hover { color: var(--accent); border-color: var(--accent); transform: translateY(-3px); }
.top svg { width: 18px; height: 18px; stroke-width: 2; }

@media (max-width: 640px) {
  .foot-inner { justify-content: center; text-align: center; }
  .foot-links { justify-content: center; width: 100%; }
  .copy { margin: 0; order: 2; }
  /* Finger-sized tap targets (44px) for the links and the back-to-top button. */
  .foot-links a { min-height: 44px; padding: 0 12px; }
  .top { order: 3; width: 44px; height: 44px; }
}

/* ---------- Contact dialog ---------- */
.dialog {
  width: min(100% - 32px, 580px);
  max-height: calc(100% - 32px);
  padding: 28px;
  border: 1px solid var(--border-hover);
  border-radius: 18px;
  background: var(--card-solid);
  color: var(--text);
  box-shadow: 0 40px 80px -24px rgb(0 0 0 / 0.6);
}
.dialog[open] { animation: dialog-in 0.35s var(--spring); }
.dialog:focus, .dialog:focus-visible { outline: none; }
.dialog::backdrop {
  background: rgb(3 5 8 / 0.65);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  animation: fade 0.3s ease;
}
/* Without JavaScript, the "Contact me" links still show the form. */
html:not(.js) .dialog:target { display: block; position: fixed; inset: 0; margin: auto; height: fit-content; z-index: 50; }

@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }

.dialog-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: start; gap: 16px; }
.dialog-avatar { width: 48px; height: 48px; border-radius: 12px; box-shadow: 0 0 0 1px var(--border); }
.dialog h2 { font-size: 1.625rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.15; }
.dialog-lead { margin-top: 4px; color: var(--muted); font-size: 0.975rem; line-height: 1.5; }
.close {
  display: grid; place-items: center;
  width: 40px; height: 40px; margin: -4px -8px 0 0;
  border-radius: 50%;
  color: var(--muted);
  transition: color 0.2s, background-color 0.2s, transform 0.3s var(--spring);
}
.close:hover { color: var(--text); background: var(--surface); transform: rotate(90deg); }
.close svg { width: 20px; height: 20px; }

/* The route: four stops in equal columns, joined by three hops. main.js lights
   .node and .hop with .is-on, and sets data-state="sending" | "sent" | "failed". */
.route {
  position: relative;
  margin: 22px 0 24px; padding: 14px 4px 10px;
  border: 1px solid var(--border); border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 5%, var(--card-solid));
}
.route-nodes { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.node {
  display: grid; justify-items: center; gap: 6px;
  color: var(--muted);
  font-size: 0.8125rem; font-weight: 600;
  transition: color 0.3s;
}
.node .dot { display: grid; place-items: center; width: 28px; height: 28px; }
.node .dot::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  background: var(--card-solid);
  box-shadow: 0 0 0 2px var(--border-hover);
  transition: background-color 0.3s, box-shadow 0.4s var(--spring);
}
.node img { width: 28px; height: 28px; border-radius: 8px; filter: grayscale(1); opacity: 0.55; transition: filter 0.4s, opacity 0.4s, box-shadow 0.4s; }
.node.is-on { color: var(--accent); }
.node.is-on .dot::before { background: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 0 0 6px color-mix(in srgb, var(--accent) 20%, transparent); }
.node.is-on img { filter: none; opacity: 1; box-shadow: 0 0 0 2px var(--accent); }

/* The line runs between the centres of the first and last stops (12.5% in from each side). */
.route-line {
  position: absolute; left: 12.5%; right: 12.5%; top: 27px;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  height: 2px;
}
.hop { position: relative; background: var(--border-hover); }
.hop::after {
  content: ""; position: absolute; inset: 0;
  background: var(--accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.5s var(--ease);
}
.hop.is-on::after { transform: scaleX(1); }
.packet {
  position: absolute; left: 0; top: 50%; z-index: 2;
  width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  opacity: 0;
}
.route[data-state="sending"] .packet { animation: packet 1s var(--ease) infinite; }
@keyframes packet { 0% { left: 0; opacity: 0; } 12%, 88% { opacity: 1; } 100% { left: 100%; opacity: 0; } }
/* A failed send stops halfway along the last hop, in red. */
.route[data-state="failed"] .hop:nth-child(3)::after { background: var(--danger); transform: scaleX(0.5); }
.route[data-state="failed"] .node[data-node="me"] { color: var(--danger); }

.form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; align-content: start; }
.field label { font-size: 0.925rem; font-weight: 600; }
.optional { margin-left: 4px; color: var(--muted); font-size: 0.8125rem; font-weight: 500; }
.field input, .field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-hover); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 1rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field ::placeholder { color: var(--muted); opacity: 0.7; }
.field textarea { resize: vertical; min-height: 130px; }
.field input:hover, .field textarea:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border-hover)); }
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.field [aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 0.875rem; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 4px; }
.form-actions .btn { min-width: 0; }
.alt { color: var(--muted); font-size: 0.95rem; font-weight: 600; }
.alt:hover { color: var(--accent); }
.form-status:empty { display: none; }
.form-status { flex-basis: 100%; font-size: 0.95rem; }
.form-status[data-tone="error"] { color: var(--danger); }
.trap { position: absolute; left: -9999px; }

/* Sent: replaces the form once the message is delivered. */
.sent { display: grid; justify-items: start; gap: 8px; animation: rise 0.45s var(--ease) both; }
.sent h3 { display: flex; align-items: center; gap: 10px; font-size: 1.375rem; font-weight: 750; letter-spacing: -0.02em; }
.sent h3:focus { outline: none; }
.sent h3 svg {
  width: 30px; height: 30px; padding: 5px;
  border-radius: 50%;
  background: var(--accent); color: var(--on-accent);
  stroke-width: 2.5;
  animation: pop 0.5s var(--spring) 0.15s both;
}
.sent p { color: var(--text-2); }
.sent strong { color: var(--text); font-weight: 650; overflow-wrap: anywhere; }
.sent .btn { min-width: 0; margin-top: 10px; }

/* ---------- Reveal on scroll (JS adds .is-hidden only to below-fold items) ---------- */
[data-reveal].is-hidden { opacity: 0; transform: translateY(28px); }
[data-reveal] { transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }

/* ---------- Narrow screens ---------- */
@media (max-width: 1100px) {
  .me { width: min(44vw, 520px); opacity: 0.9; }
}

@media (max-width: 900px) {
  /* The illustration joins the flow under the text, so it can never overlap it,
     and sits at the bottom of the hero when there's room to spare. */
  .hero { padding-top: 110px; padding-bottom: 0; justify-content: flex-start; }
  .hero-content { margin-bottom: 40px; }
  /* It takes whatever height the text leaves in the first screen (never less
     than 180px), so the whole scene, down to the floor, is visible without scrolling. */
  .me { position: relative; right: auto; bottom: auto; flex: 1 1 0; min-height: 180px; width: 100%; max-width: 460px; height: auto; margin: 0 auto -2px; animation: none; }
  .chevron { display: none; }
  .projects, .certs { grid-template-columns: 1fr; }
  .about-grid { grid-template-columns: 1fr; gap: 36px; }
  .avatar { width: 180px; }
}

@media (max-width: 640px) {
  .hero { padding: 96px 22px 0; }
  .btn { min-width: max-content; flex: 1 1 160px; } /* too wide for the row? take a row of its own */
  .job { grid-template-columns: 1fr; gap: 0; }
  /* The role gets a line of its own, with the dates and tag under it, so a long
     role never leaves the "|" hanging at the end of a line. */
  .job-role .role { display: block; }
  .job-role .sep { display: none; }
  .logo { width: 72px; height: 72px; margin: 0 0 -36px 20px; z-index: 2; box-shadow: 0 0 0 1px var(--border), 0 0 0 5px var(--bg); }
  .timeline::before, .timeline::after { left: 55px; }
  .job-card { padding: 48px 20px 20px; }
  .job:hover .job-card { transform: none; }
  .form-row { grid-template-columns: 1fr; }
  .dialog { padding: 22px; }
  .dialog-avatar { width: 40px; height: 40px; border-radius: 10px; }
  /* Keep the Send button in view on a phone before any scrolling: the intro line runs
     the full width under the avatar row, and the route and fields sit closer together. */
  .dialog-head { row-gap: 10px; }
  .dialog-head > div { display: contents; }
  .dialog h2 { grid-column: 2; grid-row: 1; align-self: center; }
  .dialog-lead { grid-column: 1 / -1; grid-row: 2; margin-top: 0; }
  .route { margin: 16px 0; padding: 10px 4px 8px; }
  .form { gap: 12px; }
  .form-row { gap: 12px; }
  .field textarea { min-height: 96px; height: 96px; }
  .card { padding: 22px; }
  .cert { grid-template-columns: 56px minmax(0, 1fr); gap: 2px 16px; }
  .cert img { width: 56px; height: 56px; }
  .theme-toggle { top: 12px; right: 12px; }
  .mark { top: 14px; left: 22px; }
  .jump { top: 12px; left: 12px; right: 68px; max-width: none; translate: none; }
  .js .jump:not(.is-shown) { translate: 0 -16px; }
}

/* Short screens with the illustration under the text (an iPhone SE, say):
   tighten the hero so the desk scene still has room in the first screen. */
@media (max-width: 900px) and (max-height: 720px) {
  .hero { padding-top: 72px; }
  .hero-content { gap: 16px; margin-bottom: 24px; }
  .hello { font-size: 1.25rem; }
  .name { font-size: 2rem; }
  .intro { font-size: 1rem; line-height: 1.5; }
  .where { margin-top: -6px; font-size: 0.9375rem; }
  .hero .actions { gap: 10px; margin-top: 4px; }
  .hero .btn { min-height: 46px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
  [data-reveal].is-hidden { opacity: 1; transform: none; }
}

/* ---------- High-contrast mode ---------- */
/* Gradient text is see-through text over a background, and forced colours drop
   the background: give it a solid fill. Mark the current section link without colour. */
@media (forced-colors: active) {
  .name, .heading { background: none; -webkit-text-fill-color: currentColor; }
  .jump a[aria-current="true"] { text-decoration: underline; text-underline-offset: 4px; }
}

/* ---------- Illustration: arms ---------- */
.me .sleeve-far { fill: none; stroke: var(--hoodie-shade); stroke-width: 24; stroke-linecap: round; stroke-linejoin: round; }
.me .sleeve-edge { fill: none; stroke: var(--hoodie-shade); stroke-width: 31; stroke-linecap: round; stroke-linejoin: round; }
.me .sleeve { fill: none; stroke: var(--hoodie); stroke-width: 26; stroke-linecap: round; stroke-linejoin: round; }
.me .cuff { fill: none; stroke: var(--hoodie-shade); stroke-width: 26; stroke-linecap: round; }
.me .cuff-far { fill: none; stroke: color-mix(in srgb, var(--hoodie-shade) 75%, #000); stroke-width: 24; stroke-linecap: round; }

/* ---------- Print ---------- */
/* A clean, light, one-column printout: no illustration, buttons or floating
   controls, every card fully visible, and solid text instead of gradients
   (browsers often skip backgrounds when printing). */
@media print {
  /* :not([data-print]) only raises specificity, to beat palette.css's theme rules. */
  :root:not([data-print]) {
    color-scheme: light;
    --bg: #fff; --bg-2: #fff;
    --card: #fff; --card-solid: #fff;
    --surface: #efece5; --border: #d9d2c4; --border-hover: #cbc2b1;
    --text: #1f2a24; --text-2: #3c4a42; --muted: #5a675f;
    --accent: #2f6249; --tag-text: #2f6249;
    --shadow: none; --shadow-hover: none;
    --logo-filter: none;
  }
  @page { margin: 16mm 14mm; }
  body { font-size: 11pt; }
  /* Printing doesn't run animations, so anything that fades in would stay invisible. */
  *, *::before, *::after { animation: none !important; transition: none !important; }
  h2, h3 { break-after: avoid; }

  .skip, .theme-toggle, .jump, .chevron, .me, .mark, .actions, .avatar, .top, .dialog,
  .foot-links [data-contact], .timeline::after { display: none !important; }

  .hero { min-height: 0; padding: 0 24px 20px; border: 0; background: none; }
  .hero-content { max-width: none; opacity: 1; translate: none; }
  .name, .heading { background: none; -webkit-text-fill-color: currentColor; color: var(--accent); }
  .section { padding-top: 28px; }
  .section .heading, .section-head { margin-bottom: 18px; }
  .about { padding-bottom: 20px; }

  .js .job-card, [data-reveal].is-hidden { opacity: 1; translate: none; transform: none; }
  .job, .card { break-inside: avoid; }
  .job-card, .card { box-shadow: none; }
  .logo img { opacity: 1; }

  .foot { padding: 12px 0 0; background: none; }
  .foot-links a[href^="http"]::after { content: " (" attr(href) ")"; color: var(--muted); }
}
