/* =========================================================
   PORTFOLIO TEMPLATE
   1. Tokens (colours, type, spacing) - change the look here
   2. Base
   3. Layout: sidebar + main
   4. Shared pieces (buttons, tags, placeholders)
   5. Sections
   6. Case study dialog
   7. Motion, print
   ========================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  --bg: #f1f4f1;
  --surface: #ffffff;
  --ink: #17282b;
  --muted: #55686a;
  --line: #cbd6d1;
  --primary: #0b6b5b;
  --primary-ink: #ffffff;
  --mark: #f4b942;
  --tint: #e0ebe6;
  --error: #a8321f;

  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, sans-serif;

  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.6rem;
  --step-3: clamp(1.9rem, 1.4rem + 2vw, 2.6rem);

  --sidebar: 15.5rem;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --section-gap: clamp(4rem, 9vw, 7rem);
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --not-a-colour: "666c61677b6373735f69735f736f757263655f746f6f7d";
  --radius-s: 6px;
  --radius-l: 18px;
}

/* Dark theme: applied when the visitor picks it, or when their device
   prefers dark and they haven't picked light. Keep both blocks in sync. */
[data-theme="dark"] {
  --bg: #0f1e1e;
  --surface: #172a2a;
  --ink: #e7efeb;
  --muted: #9db1ad;
  --line: #2b4341;
  --primary: #62d2b8;
  --primary-ink: #0f1e1e;
  --tint: #1d3534;
  --error: #ff9c8a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1e1e;
    --surface: #172a2a;
    --ink: #e7efeb;
    --muted: #9db1ad;
    --line: #2b4341;
    --primary: #62d2b8;
    --primary-ink: #0f1e1e;
    --tint: #1d3534;
    --error: #ff9c8a;
  }
}

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

html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.1;
  margin: 0;
  text-wrap: balance;
}
h2 { font-size: var(--step-3); font-weight: 700; letter-spacing: -0.02em; margin-bottom: 1.5rem; }
h3 { font-size: var(--step-1); font-weight: 650; letter-spacing: -0.01em; }

p { margin: 0 0 1em; max-width: 68ch; }
ul, ol { margin: 0; padding: 0; }
img { max-width: 100%; display: block; }

a { color: var(--primary); text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--mark);
  outline-offset: 3px;
  border-radius: 2px;
}

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

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--ink); color: var(--bg); padding: 0.6rem 1rem; border-radius: var(--radius-s);
}
.skip-link:focus { top: 1rem; }

.progress { position: fixed; inset: 0 0 auto 0; height: 4px; z-index: 60; pointer-events: none; }
.progress span { display: block; height: 100%; width: 100%; background: var(--mark); transform: scaleX(0); transform-origin: left; }

/* The short version hides anything marked data-detail */
body[data-view="short"] [data-detail] { display: none; }

/* ---------- 3. Layout ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  padding: 2.25rem 1.5rem 1.5rem 2rem;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow-y: auto;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700; font-size: var(--step-1);
  color: var(--ink); text-decoration: none;
}
.menu-btn { display: none; }

.sidebar__panel { display: flex; flex-direction: column; flex: 1; margin-top: 2rem; }

.nav-list { list-style: none; display: grid; gap: 0.15rem; }
.nav-list a {
  display: block; padding: 0.4rem 0.75rem; margin-left: -0.75rem;
  color: var(--muted); text-decoration: none;
  border-left: 3px solid transparent;
}
.nav-list a:hover { color: var(--ink); }
.nav-list a[aria-current="true"] {
  color: var(--ink); font-weight: 600; border-left-color: var(--mark);
}

.controls { margin-top: auto; padding-top: 2rem; display: grid; gap: 0.5rem; }
.control {
  font: inherit; font-size: var(--step--1); text-align: left;
  padding: 0.55rem 0.75rem; cursor: pointer;
  color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: var(--radius-s);
}
.control:hover { border-color: var(--ink); }
.control kbd {
  float: right; font-family: var(--font-mono); font-size: 0.8em;
  padding: 0 0.4em; border: 1px solid var(--line); border-radius: 4px;
}
.control[aria-pressed="true"] { background: var(--tint); border-color: var(--primary); }

main { padding: 0 var(--gutter); max-width: 62rem; width: 100%; }
main > section { padding-block: calc(var(--section-gap) / 2); }
main > section + section { border-top: 1px solid var(--line); }

.section-note { color: var(--muted); margin-top: -0.75rem; margin-bottom: 2rem; }

/* Tablet and phone: sidebar turns into a top bar with a dropdown menu */
@media (max-width: 56rem) {
  .shell { display: block; }
  html { scroll-padding-top: 4.5rem; }

  .sidebar {
    position: sticky; top: 0; z-index: 50;
    height: auto; padding: 0; overflow: visible;
    background: var(--bg); border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar__bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.7rem var(--gutter);
  }
  .menu-btn {
    display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
    padding: 0.5rem 0.9rem; min-height: 44px;
    color: var(--ink); background: transparent;
    border: 1px solid var(--line); border-radius: var(--radius-s);
  }
  .sidebar__panel {
    display: none; margin: 0;
    position: absolute; left: 0; right: 0; top: 100%;
    max-height: calc(100vh - 4rem); overflow-y: auto;
    padding: 0.75rem var(--gutter) 1.5rem;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .sidebar.is-open .sidebar__panel { display: flex; }
  .nav-list a { padding-block: 0.7rem; }
  .controls { grid-template-columns: 1fr 1fr; padding-top: 1rem; }
  .control { min-height: 44px; }
  .control--wide { grid-column: 1 / -1; }
  .control kbd { display: none; }
}

/* ---------- 4. Shared pieces ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0.6rem 1.15rem;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--ink); background: transparent;
  border: 1.5px solid var(--ink); border-radius: 999px;
  transition: background-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--ink); color: var(--bg); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn--primary:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.link-btn {
  font: inherit; color: var(--primary); cursor: pointer;
  background: none; border: 0; padding: 0;
  text-decoration: underline; text-underline-offset: 0.2em;
}

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tags li {
  font-size: var(--step--1); padding: 0.2rem 0.65rem;
  background: var(--tint); border-radius: 999px;
}

.placeholder {
  display: grid; place-items: center; text-align: center;
  color: var(--muted); font-size: var(--step--1);
  border: 1.5px dashed var(--line); border-radius: var(--radius-l);
  background:
    repeating-linear-gradient(135deg, transparent 0 14px, var(--tint) 14px 15px),
    var(--surface);
}

.plain-list { list-style: none; display: grid; gap: 1rem; }
.plain-list li { display: grid; gap: 0.1rem; }
.plain-list span { color: var(--muted); font-size: var(--step--1); }
.plain-list--links { gap: 0.5rem; }

/* ---------- 5. Sections ---------- */

/* Intro */
main > .intro { padding-top: clamp(3rem, 12vh, 7rem); }

.intro__status {
  display: flex; align-items: center; gap: 0.6rem;
  color: var(--muted); margin-bottom: 1.5rem;
}
.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--primary); flex: none; }

.intro__name {
  font-size: clamp(3.4rem, 13vw, 9rem);
  font-weight: 800; line-height: 0.9; letter-spacing: -0.045em;
}
.intro__name span { display: block; }

.intro__rule {
  height: clamp(10px, 1.6vw, 18px); width: min(100%, 26rem);
  background: var(--mark); margin: 1.5rem 0 2rem;
  transform-origin: left;
}

.intro__lede { font-size: var(--step-1); line-height: 1.5; max-width: 34ch; max-width: min(100%, 40rem); }
.intro__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 2rem 0 1.5rem; }
.intro__hint { color: var(--muted); margin: 0; }

/* About */
.about { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3rem); }
.about__text p:first-child { font-size: var(--step-1); line-height: 1.5; }
.about__photo { aspect-ratio: 4 / 5; width: 100%; object-fit: cover; border-radius: var(--radius-l); }
.facts { margin: 1.25rem 0 0; display: grid; gap: 0.75rem; }
.facts dt { color: var(--muted); font-size: var(--step--1); }
.facts dd { margin: 0; font-weight: 600; }

@media (max-width: 40rem) {
  .about { grid-template-columns: 1fr; }
  .about__photo { max-width: 16rem; }
}

/* Skills */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 2rem; }
.skill-group h3 { margin-bottom: 0.75rem; }

/* Work experience */
.timeline { border-left: 2px solid var(--line); margin-left: 0.35rem; }
.job { position: relative; padding: 0 0 0 1.75rem; }
.job + .job { margin-top: 0.5rem; }
.job::before {
  content: ""; position: absolute; left: -0.45rem; top: 1.35rem;
  width: 0.75rem; height: 0.75rem; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--primary);
}
.job[open]::before { background: var(--primary); }

.job summary {
  list-style: none; cursor: pointer;
  display: grid; gap: 0.1rem;
  padding: 0.9rem 2.5rem 0.9rem 0; position: relative;
}
.job summary::-webkit-details-marker { display: none; }
.job summary::after {
  content: "+"; position: absolute; right: 0.5rem; top: 0.9rem;
  font-family: var(--font-display); font-size: var(--step-2); line-height: 1; color: var(--primary);
}
.job[open] summary::after { content: "\2212"; }
.job__dates { color: var(--muted); font-size: var(--step--1); }
.job__title { font-family: var(--font-display); font-size: var(--step-1); font-weight: 650; }
.job__org { color: var(--muted); }
.job summary:hover .job__title { color: var(--primary); }

.job__body { padding-bottom: 1.25rem; }
.job__body ul { padding-left: 1.2rem; display: grid; gap: 0.4rem; max-width: 68ch; }

/* Featured projects */
.feature {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(1.25rem, 3vw, 2.5rem); align-items: center;
  padding: clamp(1rem, 2.5vw, 1.75rem);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l);
}
.feature + .feature { margin-top: 1.5rem; }
.feature:nth-of-type(even) .feature__media { order: 2; }
.feature__media { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; border-radius: calc(var(--radius-l) - 6px); }
.feature__text h3 { font-size: var(--step-2); }
.feature__meta { color: var(--muted); font-size: var(--step--1); margin: 0.3rem 0 0.9rem; }
.feature__actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.25rem; }

@media (max-width: 44rem) {
  .feature { grid-template-columns: 1fr; }
  .feature:nth-of-type(even) .feature__media { order: 0; }
}

/* Smaller projects */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.filter {
  font: inherit; cursor: pointer; min-height: 40px; padding: 0.35rem 0.95rem;
  color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 999px;
}
.filter:hover { border-color: var(--ink); }
.filter[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.filter-count { color: var(--muted); font-size: var(--step--1); margin: 0.9rem 0 1rem; min-height: 1.4em; }

.cards { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 1rem; }
.card {
  display: flex; flex-direction: column; gap: 0.6rem;
  padding: 1.15rem 1.25rem 1.25rem;
  border-top: 4px solid var(--primary);
  background: var(--surface); border-radius: 0 0 var(--radius-s) var(--radius-s);
}
.card[hidden] { display: none; }
.card p { margin: 0; color: var(--muted); }
.card > a { margin-top: auto; padding-top: 0.4rem; font-weight: 600; }

/* Volunteering */
.rows { list-style: none; }
.row { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 1.5rem; padding: 1.25rem 0; }
.row + .row { border-top: 1px solid var(--line); }
.row p { margin-bottom: 0.4rem; }
.row__dates, .row__org { color: var(--muted); }
.row__dates { font-size: var(--step--1); padding-top: 0.2rem; }
@media (max-width: 36rem) { .row { grid-template-columns: 1fr; gap: 0.25rem; } }

/* Education and awards */
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 2rem; }
.columns h3 { margin-bottom: 1rem; padding-bottom: 0.6rem; border-bottom: 2px solid var(--ink); }

/* Testimonials */
.quotes { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.5rem; }
.quote { margin: 0; padding-left: 1.25rem; border-left: 6px solid var(--mark); }
.quote blockquote { margin: 0; }
.quote blockquote p { font-family: var(--font-display); font-size: var(--step-1); line-height: 1.35; }
.quote figcaption { color: var(--muted); font-size: var(--step--1); }
.quote figcaption strong { display: block; color: var(--ink); font-size: var(--step-0); }

/* Resume */
.resume {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.25rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--tint); border-radius: var(--radius-l);
}
.resume p { margin: 0; font-size: var(--step-1); max-width: 28ch; }
.resume__actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

/* Security notes */
.secnotes { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3rem); align-items: start; }
@media (max-width: 44rem) { .secnotes { grid-template-columns: 1fr; } }
.checks { list-style: none; display: grid; gap: 0.9rem; }
.checks li { padding-left: 1.4rem; position: relative; max-width: 60ch; }
.checks li::before {
  content: ""; position: absolute; left: 0; top: 0.5em;
  width: 0.6rem; height: 0.6rem; background: var(--primary);
}
.ctf { padding: 1.25rem 1.4rem 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); }
.ctf h3 { margin-bottom: 0.6rem; }
.ctf__progress { font-family: var(--font-mono); font-weight: 600; }

/* Contact */
.contact { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: clamp(1.5rem, 5vw, 4rem); }
@media (max-width: 44rem) { .contact { grid-template-columns: 1fr; } }

.form { display: grid; gap: 1.1rem; justify-items: start; }
.field { display: grid; gap: 0.35rem; width: 100%; }
.field label { font-weight: 600; }
.field input, .field textarea {
  font: inherit; color: var(--ink); width: 100%;
  padding: 0.7rem 0.85rem;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-s);
}
.field textarea { resize: vertical; }
.field input:focus-visible, .field textarea:focus-visible { outline-offset: 0; border-color: var(--ink); }
.field [aria-invalid="true"] { border-color: var(--error); }
.field__error { color: var(--error); font-size: var(--step--1); margin: 0; }
.form__status { color: var(--muted); margin: 0; min-height: 1.5em; }

.contact__links h3 { margin-bottom: 1rem; }
.contact__email { display: grid; gap: 0.25rem; justify-items: start; margin-bottom: 1.5rem; }
.contact__email a { font-family: var(--font-display); font-size: var(--step-1); font-weight: 650; overflow-wrap: anywhere; }

/* Footer */
.footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem;
  padding: 2rem 0 3rem; border-top: 1px solid var(--line);
  color: var(--muted); font-size: var(--step--1);
}
.footer p { margin: 0; }

/* ---------- 6. Case study dialog ---------- */
.case {
  width: min(46rem, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.5rem); max-height: calc(100dvh - 1.5rem);
  padding: 0; border: 0; border-radius: var(--radius-l);
  background: var(--bg); color: var(--ink);
  overscroll-behavior: contain;
}
.case::backdrop { background: rgba(10, 24, 24, 0.65); }
.case__inner { padding: clamp(1.25rem, 4vw, 2.5rem); }
.case__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.5rem; }
.case__head h2 { margin: 0; }
.case__head .feature__meta { margin-bottom: 0; }
.case__media { aspect-ratio: 16 / 9; }
.case h3 { margin: 2rem 0 0.6rem; }
.case ol { padding-left: 1.3rem; display: grid; gap: 0.5rem; max-width: 68ch; }
.case__links { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 2rem; }

.results {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1rem;
  margin: 1.5rem 0 0; padding: 1.25rem 0;
  border-block: 1px solid var(--line);
}
.results div { display: flex; flex-direction: column-reverse; }
.results dt { color: var(--muted); font-size: var(--step--1); }
.results dd { margin: 0; font-family: var(--font-display); font-size: var(--step-2); font-weight: 700; }

/* Terminal: always dark, whatever the theme */
.term {
  width: min(44rem, calc(100vw - 1.5rem));
  height: min(32rem, calc(100vh - 1.5rem)); height: min(32rem, calc(100dvh - 1.5rem));
  padding: 0; border: 1px solid #2b4341; border-radius: 12px;
  background: #0b1717; color: #d7e6e0;
  font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.5;
}
.term[open] { display: flex; flex-direction: column; }
.term::backdrop { background: rgba(10, 24, 24, 0.65); }
.term__bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0.6rem 0.5rem 1rem; border-bottom: 1px solid #2b4341; color: #9db1ad;
}
.term__close {
  font: inherit; cursor: pointer; min-height: 36px; padding: 0.2rem 0.8rem;
  color: #d7e6e0; background: transparent; border: 1px solid #2b4341; border-radius: 6px;
}
.term__close:hover { border-color: #d7e6e0; }
.term__out { flex: 1; overflow-y: auto; padding: 0.9rem 1rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.term__out div { min-height: 1.5em; }
.term__out .is-cmd { color: #9db1ad; }
.term__out .is-good { color: #62d2b8; }
.term__out .is-warn { color: #f4b942; }
.term__form { display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 1rem; border-top: 1px solid #2b4341; }
.term__prompt { color: #62d2b8; font-weight: 700; }
.term__form input {
  flex: 1; min-width: 0; font: inherit; font-size: 1rem; color: inherit;
  background: transparent; border: 0; padding: 0.3rem 0; caret-color: #f4b942;
}
.term__form input:focus-visible { outline: none; }
.term__form:focus-within { box-shadow: inset 0 2px 0 #f4b942; }

/* ---------- 7. Motion and print ---------- */
@media (prefers-reduced-motion: no-preference) {
  .intro__name span { animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .intro__name span:nth-child(2) { animation-delay: 0.08s; }
  .intro__rule { animation: draw 0.6s 0.35s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .case[open] { animation: rise 0.25s ease-out both; }

  @keyframes rise { from { opacity: 0; transform: translateY(0.35em); } }
  @keyframes draw { from { transform: scaleX(0); } }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

@media print {
  .sidebar, .progress, .skip-link, .intro__actions, .intro__hint,
  .filters, .filter-count, .form, #printBtn, .footer a, .feature__actions, .ctf .btn { display: none !important; }
  .shell { display: block; }
  body { background: #fff; color: #000; font-size: 11pt; }
  main { padding: 0; max-width: none; }
  main > section { padding-block: 1.25rem; break-inside: avoid; }
  .intro__name { font-size: 40pt; }
  .card[hidden] { display: flex; }
  .contact { grid-template-columns: 1fr; }
}
