/* ---------- Colours (change the theme here) ---------- */
/* Dark is the default. The light theme is the [data-theme="light"] block below.
   theme.js sets data-theme on <html> before paint; the toggle (main.js) flips it. */
:root {
  --bg: #0e1013;
  --panel: #15181d;
  --line: #23272e;
  --text: #d6dae0;
  --muted: #8a919c;
  --heading: #f2f4f7;
  --accent: #f5a524;        /* warm amber: engines, kitchens, code */
  --accent-soft: rgba(245, 165, 36, .12);
  --portrait-ink: var(--accent);
  /* Mouse pointer: the same arrow as the intro's agents (amber), green over anything you can click */
  --cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M2.5 2.5 L19.6 10.7 L12.5 12.5 L10.7 19.6 Z' fill='%23f5a524' stroke='%230e1013' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E") 2 2, auto;
  --cursor-link: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M2.5 2.5 L19.6 10.7 L12.5 12.5 L10.7 19.6 Z' fill='%233ddc84' stroke='%230e1013' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E") 2 2, pointer;
  --ok: #3ddc84;
  --card-hover: rgba(255, 255, 255, .025);   /* faint lift on hover */
  --term-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

/* Light theme: warm off-white paper, white cards. The accent goes a deeper amber
   so links, labels and chips keep 4.5:1 contrast (bright #f5a524 fails on white). */
:root[data-theme="light"] {
  --bg: #f7f6f3;
  --panel: #ffffff;
  --line: #e5e2db;
  --text: #40454c;
  --muted: #6a7078;
  --heading: #16181c;
  --accent: #a85d00;
  --accent-soft: rgba(168, 93, 0, .10);
  --portrait-ink: #4a2a08;   /* dot portrait on paper: dark sepia, so the face reads like a printed photo */
  --cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M2.5 2.5 L19.6 10.7 L12.5 12.5 L10.7 19.6 Z' fill='%23a85d00' stroke='%23ffffff' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E") 2 2, auto;
  --cursor-link: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M2.5 2.5 L19.6 10.7 L12.5 12.5 L10.7 19.6 Z' fill='%230f9d58' stroke='%23ffffff' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E") 2 2, pointer;
  --ok: #0f9d58;
  --card-hover: rgba(0, 0, 0, .03);
  --term-shadow: 0 16px 40px rgba(20, 20, 30, .10);
}

/* Ease the colours when you flip the theme (reduced-motion turns this off, see bottom) */
body, .term, .term-cmds button, .card, .agent, .contact-box, .badge,
.theme-toggle, .chip, .copy, .shot, .btn {
  transition: background-color .3s ease, border-color .3s ease, color .3s ease, box-shadow .3s ease;
}

/* ---------- Theme toggle (top-right, over everything) ---------- */
.theme-toggle {
  position: fixed; top: 16px; right: 16px; z-index: 20;
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); cursor: var(--cursor-link);
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 20px; height: 20px; display: block; }
/* Dark theme shows the sun (tap for light); light theme shows the moon (tap for dark) */
.theme-toggle .icon-moon { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* In light mode the primary button keeps the deep amber with white text; it darkens on hover */
:root[data-theme="light"] .btn.primary { color: #fff; }
:root[data-theme="light"] .btn.primary:hover { background: #8a4d00; }
:root[data-theme="light"] ::selection { color: #fff; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; cursor: var(--cursor); }
a, button, [role="button"], label, summary { cursor: var(--cursor-link); }
input, textarea, [contenteditable] { cursor: text; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent); color: #111; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Soft light that follows the mouse */
.glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(600px at var(--x, 50%) var(--y, 30%), rgba(245,165,36,.07), transparent 80%);
}

/* ---------- Layout: one column on phones, two columns on big screens ---------- */
.wrap {
  position: relative; z-index: 1;
  max-width: 1200px; margin: 0 auto; padding: 0 20px;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px;   /* minmax(0, …): a long line can't make a column wider than the screen */
}
.side { padding-top: 48px; }
main { padding: 16px 0 80px; }
@media (min-width: 1024px) {
  .wrap { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 64px; padding: 0 48px; }
  .side { padding: 72px 0 48px; }
  main { padding: 72px 0; }
}
/* Left side stays fixed while you scroll. It's short now (the terminal moved to the right
   column), so it fits any laptop; overflow-y keeps the socials reachable on short screens. */
@media (min-width: 1024px) {
  .side { position: sticky; top: 0; height: 100vh; padding: 72px 0 40px; display: flex; flex-direction: column; justify-content: space-between; overflow-y: auto; scrollbar-width: none; }
}

/* ---------- Terminal hero ---------- */
.term {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  font-family: var(--mono); font-size: 13px; overflow: hidden;
  box-shadow: var(--term-shadow);
}
.term-bar { display: flex; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.term-bar i { width: 10px; height: 10px; border-radius: 50%; background: #2c3139; }
.term-bar i:first-child { background: #ff5f57; } .term-bar i:nth-child(2) { background: #febc2e; } .term-bar i:nth-child(3) { background: #28c840; }
/* Fixed height so the page doesn't jump while it types; older lines scroll up like a real terminal */
.term-body {
  padding: 14px 16px; height: 210px; overflow-y: auto; overscroll-behavior: contain; cursor: text;
  scrollbar-width: thin; scrollbar-color: #3a3f47 transparent;
}
#term-intro { white-space: nowrap; }
@media (max-width: 480px) { #term-intro { white-space: normal; } }   /* phones: long intro lines wrap instead of running off the screen */
#term-log { white-space: pre-wrap; overflow-wrap: anywhere; }
.term-body .p { color: var(--accent); }
.term-body .o { color: var(--muted); }
.term-body .ok { color: var(--ok); }
.term-body .err { color: #ff7b72; }
.term-body .name { color: var(--heading); font-weight: 600; }
.term-body .k { color: var(--accent); display: inline-block; min-width: 11ch; margin-right: 1ch; }
.term-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.cursor { display: inline-block; width: 8px; height: 1.1em; background: var(--accent); vertical-align: -3px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.term-line { display: flex; gap: 1ch; margin: 0; }
.term-line[hidden] { display: none; }
.term-line input {
  flex: 1; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent;
  color: var(--heading); font: inherit; caret-color: var(--accent);
}
.term-line input::placeholder { color: var(--muted); }
/* The terminal has no focus ring of its own, so the box shows it */
.term:has(input:focus-visible) { border-color: var(--accent); }
@media (max-width: 420px) { .term { font-size: 12px; } .term-body { height: 200px; } }
/* 16px stops iPhones zooming the page when the input gets focus */
@media (hover: none) { .term-line input { font-size: 16px; } }

/* Tap-to-run shortcuts under the terminal (typing commands on a phone is a pain) */
.term-cmds { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.term-cmds button {
  min-height: 44px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  color: var(--muted); font: 13px var(--mono); cursor: var(--cursor-link); transition: color .2s, border-color .2s;
}
.term-cmds button::before { content: "$ "; color: var(--accent); }
.term-cmds button:hover { color: var(--heading); border-color: var(--accent); }
.term-cmds button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The terminal now leads the right column, so leave room before the first section */
.term-cmds { margin-bottom: 48px; }
@media (min-width: 1024px) { .term-cmds { margin-bottom: 64px; } }

h1 { font-size: clamp(34px, 5vw, 46px); line-height: 1.1; margin: 0 0 8px; color: var(--heading); letter-spacing: -.02em; }
.role { font-size: 18px; color: var(--heading); font-weight: 500; margin: 0; }
.tag { color: var(--muted); max-width: 340px; margin: 12px 0 0; }

/* Nav: a row of links on phones, a vertical list that tracks your position on desktop */
nav { display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 24px; }
nav a { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 6px 0; }
nav a:hover, nav a.active { color: var(--heading); }
@media (min-width: 1024px) {
  nav { display: block; margin-top: 40px; }
  nav a { display: flex; align-items: center; gap: 16px; padding: 9px 0; }
  nav a::before { content: ""; height: 1px; width: 32px; background: var(--muted); transition: width .25s, background .25s; }
  nav a:hover::before, nav a.active::before { width: 64px; background: var(--accent); }
}

.socials { display: flex; gap: 18px; margin-top: 28px; align-items: center; flex-wrap: wrap; }
.socials a { color: var(--muted); transition: color .2s, transform .2s; }
.socials a:hover { color: var(--accent); transform: translateY(-2px); }
.socials svg { width: 22px; height: 22px; display: block; }

/* Availability + main buttons under the name */
.avail { display: flex; align-items: center; gap: 8px; margin: 14px 0 0; font-size: 14px; color: var(--heading); }
.avail .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 20px 0 28px; }
.btn { font-size: 14px; font-weight: 600; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--accent); color: var(--accent); transition: background .2s, transform .2s; }
.btn:hover { background: var(--accent-soft); transform: translateY(-2px); }
.btn.primary { background: var(--accent); color: #111; }
.btn.primary:hover { background: #ffb73d; }

/* ---------- Sections ---------- */
section { margin-bottom: 96px; scroll-margin-top: 40px; }
@media (min-width: 1024px) { section { margin-bottom: 112px; scroll-margin-top: 72px; } }
.label { font-size: 13px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 0 0 20px; }
.label .sub { display: block; margin-top: 4px; font-size: 14px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--muted); }
p { margin: 0 0 16px; }
strong { color: var(--heading); font-weight: 600; }
.hl { color: var(--accent); }

/* Project cards: the whole card is a link */
.cards { display: grid; gap: 16px; }
.card { position: relative; padding: 20px 0; border-radius: 12px; border: 1px solid transparent; transition: opacity .25s, background .25s, border-color .25s; }
@media (min-width: 640px) { .card { padding: 22px; } }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.card h3 { margin: 0; color: var(--heading); font-size: 18px; }
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }   /* stretches the link over the card */
.card .arrow { display: inline-block; transition: transform .2s; color: var(--muted); }
.card:hover .arrow { transform: translate(3px, -3px); color: var(--accent); }
.card:hover h3 { color: var(--accent); }
.card p { color: var(--muted); font-size: 15px; }
.links { position: relative; z-index: 2; display: flex; gap: 16px; margin-top: 12px; font-size: 14px; }   /* stays clickable above the card link */
.links a { color: var(--heading); border-bottom: 1px solid var(--line); }
.links a:hover { color: var(--accent); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip { font-size: 12px; font-weight: 500; padding: 4px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.shot { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); margin-top: 16px; display: block; }

/* Demo login on the HabitQuest card: credentials a visitor can copy, so no sign-up needed.
   z-index keeps the copy buttons clickable above the card-wide link. */
.demo { position: relative; z-index: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.demo-label { font-size: 13px; color: var(--muted); }
.copy { font: 600 12px var(--mono); color: var(--accent); background: var(--accent-soft); border: 1px solid transparent; border-radius: 7px; padding: 0 10px; min-height: 32px; cursor: var(--cursor-link); transition: border-color .2s, color .2s; }
.copy span { opacity: .6; margin-left: 3px; }
.copy:hover { border-color: var(--accent); }
.copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.copy.done { color: var(--ok); }
.load-note { font-size: 13px; color: var(--muted); margin-top: 10px; }

/* Hover effects only for mouse users, so they don't get stuck on phones */
@media (hover: hover) {
  .cards:hover .card { opacity: .5; }
  .cards .card:hover { opacity: 1; background: var(--card-hover); border-color: var(--line); }
}

/* Live API badge */
.badge { font-family: var(--mono); font-size: 12px; color: var(--muted); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge.up { color: var(--ok); border-color: rgba(61,220,132,.35); }
.badge.up .dot { background: var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(61,220,132,.6); } 70% { box-shadow: 0 0 0 8px rgba(61,220,132,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,132,0); } }

/* CTF-C example agent run */
.agent { margin-top: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-family: var(--mono); font-size: 13px; height: 186px; white-space: nowrap; overflow: hidden; }
.agent .cap { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 6px; }
.agent .ln { opacity: 0; transform: translateY(4px); transition: opacity .3s, transform .3s; }
.agent .ln.show { opacity: 1; transform: none; }
.agent .k { color: var(--accent); display: inline-block; width: 11ch; }
.agent .ok { color: var(--ok); }
@media (max-width: 420px) { .agent { font-size: 12px; } }

/* Journey timeline */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--line), var(--accent)); }
.step { position: relative; margin-bottom: 28px; }
.step::before { content: ""; position: absolute; left: -28px; top: 7px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 2px solid var(--muted); }
.step.now::before { border-color: var(--accent); background: var(--accent); }
.step .when { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.step h3 { margin: 2px 0 4px; color: var(--heading); font-size: 16px; }
.step p { color: var(--muted); font-size: 15px; margin: 0; }
.step p a { color: var(--heading); border-bottom: 1px solid var(--line); }
.step p a:hover { color: var(--accent); border-color: var(--accent); }

.contact-box { padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
/* Skills list in About */
.skills { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 24px 0 0; font-size: 15px; }
.skills dt { font-family: var(--mono); font-size: 12px; color: var(--accent); text-transform: uppercase; letter-spacing: .08em; padding-top: 3px; }
.skills dd { margin: 0; color: var(--muted); }

.contact-box .note { color: var(--muted); font-size: 15px; }
.contact-box a.mail { font-family: var(--mono); color: var(--accent); font-size: 16px; word-break: break-all; }

/* Fade-in on scroll */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s ease; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- Dot portrait (portrait.js) ---------- */
/* Hidden on phones. On tablets and laptops it sits above the name. When the screen leaves enough empty space
   left of the page, portrait.js adds .beside and moves it there, lined up with the name and the buttons. */
.portrait { display: none; }
@media (min-width: 768px) {
  .portrait { display: block; width: 120px; aspect-ratio: 100 / 89; margin: 0 0 16px; }
  .portrait.beside { position: fixed; margin: 0; }
}

/* Laptops: the page is no longer centred. The portrait gets its own slot on the left, the name and the text next to it
   are bigger, and the right column (terminal and sections) sits a bit in from the right edge. Narrower or shorter screens
   keep the centred layout with the portrait above the name; very wide screens keep the centred 1200px page. */
@media (min-width: 1280px) and (max-width: 1679px) and (min-height: 700px) {
  :root { --pw: clamp(200px, 18vw, 300px); }
  .wrap {
    max-width: none; margin: 0; gap: 56px;
    padding: 0 clamp(56px, 6vw, 112px) 0 calc(var(--pw) + 72px);
    grid-template-columns: minmax(0, 1fr) minmax(0, 34vw);
  }
  h1 { font-size: clamp(44px, 3.5vw, 54px); }
  .role { font-size: 19px; }
  .tag { font-size: 17px; max-width: 380px; }
}

/* ---------- Intro (build.js) ---------- */
/* 1. Name: the whole page waits while dots form the name. 2. Build: crews of arrows build each piece, which stays
   hidden until its crew reveals it (build.js sets clip-path while typing or filling, then adds .built). */
html.build-pending .wrap { opacity: 0; }
html.build-layers [data-layer]:not(.built) { opacity: 0; }
/* Further down (right column blocks, project cards) is built by a crew as it scrolls in, instead of the plain fade */
html.agents .pb:not(.built), html.agents .card:not(.built) { opacity: 0; }
html.agents .card.built { opacity: 1; transform: none; transition: none; }
html.agents .timeline:not(:has(.step.built))::before { opacity: 0; }   /* the timeline line waits for its first step */
.wrap.build-fade { animation: buildFade .45s ease both; }
@keyframes buildFade { from { opacity: 0; } to { opacity: 1; } }
/* On top during the intro (never catches clicks), behind the page for the flock */
.build-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
.build-canvas.behind { z-index: 0; }

/* Respect people who turn motion off */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .reveal, .agent .ln { opacity: 1; transform: none; }
}

/* 404 page */
.notfound { max-width: 600px; margin: 0 auto; padding: 120px 20px; }
