/* 01-tokens.css */
/* Design tokens. Monochrome dark theme: white is the only highlight colour for
   the interface; purple is reserved for data drawn in charts.
   Hierarchy comes from type size, weight and tone, not from boxes and borders. */
:root {
  color-scheme: dark;

  /* Surfaces */
  --bg: #0c0c0d;
  --bg-soft: #121214;

  /* Text, from loudest to quietest */
  --text-strong: #ffffff;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --text-faint: #8b8b94;

  /* Used sparingly: the occasional hairline and diagram strokes */
  --rule: rgb(255 255 255 / 0.09);
  --rule-strong: rgb(255 255 255 / 0.18);

  /* Data colour, only for values drawn in charts */
  --data: #a78bfa;
  --data-strong: #c4b5fd;

  /* Light backdrop for charts that were made on white */
  --paper: #f1f1f2;

  /* Type */
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1.0625rem;
  --text-lg: clamp(1.1875rem, 1.1rem + 0.35vw, 1.3125rem);
  --text-xl: clamp(1.5rem, 1.3rem + 0.9vw, 1.875rem);
  --text-2xl: clamp(2.375rem, 1.6rem + 3.4vw, 4rem);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: clamp(4rem, 3rem + 4vw, 7rem);

  --radius: 12px;

  --container: 1120px;
  --gutter: clamp(20px, 5vw, 48px);
  --measure: 40rem;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --duration: 200ms;
}

/* 02-base.css */
/* Reset and element defaults */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 5rem;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--text-strong);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p,
ul,
ol,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

p {
  text-wrap: pretty;
}

img,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

a {
  color: var(--text-strong);
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
  transition: color var(--duration) var(--ease), text-decoration-color var(--duration) var(--ease);
}

a:hover {
  text-decoration-color: currentColor;
}

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

::selection {
  background: var(--text-strong);
  color: var(--bg);
}

strong {
  color: var(--text-strong);
  font-weight: 600;
}

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

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -3rem;
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--text-strong);
  color: var(--bg);
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: var(--space-4);
}

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

/* 03-layout.css */
/* Page frame: container, header, sections, footer.
   Sections use an editorial grid: a narrow heading column and a content column. */
.container {
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Header: no rule, just a soft blur once content scrolls under it */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgb(12 12 13 / 0.78);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: 4rem;
}

.brand {
  color: var(--text-strong);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav ul {
  display: flex;
  gap: var(--space-5);
  padding: 0;
  list-style: none;
}

.site-nav a {
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text-strong);
}

@media (max-width: 520px) {
  .site-nav ul {
    gap: var(--space-4);
  }
}

@media (max-width: 560px) {
  .brand__rest {
    display: none;
  }
}

/* Sections */
.section {
  display: grid;
  gap: var(--space-6);
  padding-block: var(--space-8);
}

.section__title {
  font-size: var(--text-lg);
}

.section__intro {
  margin-top: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  max-width: 22rem;
}

@media (min-width: 900px) {
  .section {
    grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
    gap: var(--space-7);
  }

  .section__head {
    position: sticky;
    top: 6rem;
    align-self: start;
  }
}

/* Footer */
.site-footer {
  padding-block: var(--space-7) var(--space-6);
  color: var(--text-faint);
  font-size: var(--text-sm);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
}

.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
  padding: 0;
  list-style: none;
}

.site-footer__links a {
  color: var(--text-muted);
  text-decoration: none;
}

.site-footer__links a:hover {
  color: var(--text-strong);
}

/* 04-components.css */
/* Reusable building blocks. None of them draws a box: they rely on type and space. */

/* Calls to action: one solid button, everything else is a text link */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-6);
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: 0 var(--space-5);
  border-radius: 999px;
  background: var(--text-strong);
  color: var(--bg);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: background var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.button:hover {
  background: #d4d4d8;
}

.button:active {
  transform: translateY(1px);
}

.text-link {
  color: var(--text-strong);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
}

.text-link .arrow {
  display: inline-block;
  margin-left: 0.3em;
  color: var(--text-muted);
  transition: transform var(--duration) var(--ease), color var(--duration) var(--ease);
}

.text-link:hover .arrow {
  transform: translateX(3px);
  color: var(--text-strong);
}

.text-link--external:hover .arrow {
  transform: translate(2px, -2px);
}

/* Lists that read as running text: "Python, Random Forest, ARIMA".
   Inline items with trailing commas wrap like a normal sentence. */
.tag-list {
  padding: 0;
  list-style: none;
  color: var(--text-faint);
  font-size: var(--text-sm);
}

.tag-list li {
  display: inline-block;
  white-space: nowrap;
}

.tag-list li:not(:last-child)::after {
  content: ',';
  margin-right: 0.4em;
}

.topics {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-1) var(--space-3);
}

.status {
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* Key figures: a large number over a short label, no frame */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5) var(--space-7);
  padding: 0;
  list-style: none;
}

/* The label comes first in the markup (read first by screen readers) but the
   number is shown on top, so all numbers in a row line up. */
.stat {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: var(--space-1);
  max-width: 14rem;
}

.stat__value {
  order: -1;
}

.stat__value {
  color: var(--text-strong);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.stat__label {
  color: var(--text-faint);
  font-size: var(--text-xs);
  line-height: 1.5;
}

/* Large key figures: a 2 × 2 grid on phones, one row when there is room */
@media (max-width: 640px) {
  .stats--large {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-5) var(--space-5);
  }
}

.stats--large .stat__value {
  font-size: var(--text-xl);
}

/* Running text */
.prose {
  display: grid;
  gap: var(--space-4);
  max-width: var(--measure);
  color: var(--text-muted);
}

.prose strong {
  color: var(--text);
}

/* Figures: charts made on white sit on a soft light backdrop, nothing else */
.figure {
  display: grid;
  gap: var(--space-3);
}

.figure__frame {
  padding: clamp(0.5rem, 1.5vw, 1rem);
  border-radius: var(--radius);
  background: var(--paper);
}

.figure__frame img {
  width: 100%;
}

.figure figcaption {
  max-width: var(--measure);
  color: var(--text-faint);
  font-size: var(--text-sm);
  line-height: 1.55;
}

/* 05-home.css */
/* Home page: hero, project list, skills, background */

/* Hero */
.hero {
  display: grid;
  gap: var(--space-6);
  align-items: center;
  padding-block: clamp(3.5rem, 2rem + 7vw, 8rem) var(--space-7);
}

.hero__text {
  display: grid;
  gap: var(--space-5);
  max-width: 42rem;
}

.hero__title {
  font-size: var(--text-2xl);
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.hero__role {
  margin-top: calc(-1 * var(--space-2));
  color: var(--text);
  font-size: var(--text-lg);
}

.hero__tagline {
  max-width: 36rem;
  color: var(--text-muted);
  font-size: var(--text-lg);
  line-height: 1.6;
}

.hero .actions {
  margin-top: var(--space-2);
}

.hero__photo {
  order: -1;
  width: 6.5rem;
  aspect-ratio: 1;
  object-fit: cover;
  object-position: 50% 20%;
  border-radius: 50%;
  filter: grayscale(0.15);
}

@media (min-width: 760px) {
  .hero {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-8);
  }

  .hero__photo {
    order: 0;
    width: clamp(11rem, 17vw, 14rem);
    border-radius: 50%;
  }
}

/* Projects: a list separated by space, not by boxes */
.projects {
  display: grid;
  gap: clamp(3rem, 2rem + 3vw, 4.5rem);
}

.project {
  display: grid;
  gap: var(--space-3);
  max-width: 46rem;
}

.project__meta {
  color: var(--text-faint);
  font-size: var(--text-sm);
}

.project__title {
  font-size: var(--text-xl);
  letter-spacing: -0.025em;
}

.project__title a {
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 300ms var(--ease);
}

.project__title a:hover {
  background-size: 100% 1px;
}

.project__summary {
  color: var(--text-muted);
}

.project__note {
  color: var(--text-faint);
  font-size: var(--text-sm);
}

/* Three figures always share one row, even on a phone */
.project .stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 11rem));
  gap: var(--space-4) clamp(1rem, 4vw, 2.5rem);
  margin-block: var(--space-3) var(--space-1);
}

.project__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
}

/* Skills: label / value rows */
.skill-rows {
  display: grid;
  gap: var(--space-5);
}

.skill-row {
  display: grid;
  gap: var(--space-1);
}

.skill-row dt {
  color: var(--text-faint);
  font-size: var(--text-sm);
}

.skill-row .tag-list {
  color: var(--text);
  font-size: var(--text-base);
}

.skill-row--quiet .tag-list {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.skill-row--quiet:first-of-type,
.skill-row:not(.skill-row--quiet) + .skill-row--quiet {
  margin-top: var(--space-4);
}

@media (min-width: 640px) {
  .skill-row {
    grid-template-columns: 13rem minmax(0, 1fr);
    gap: var(--space-5);
    align-items: baseline;
  }
}

/* Background: education and experience as dated entries */
.background {
  display: grid;
  gap: var(--space-7);
}

.background__heading {
  margin-bottom: var(--space-4);
  color: var(--text-faint);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0;
}

.entries {
  display: grid;
  gap: var(--space-5);
  padding: 0;
  list-style: none;
}

.entry {
  display: grid;
  gap: var(--space-1);
}

@media (min-width: 640px) {
  .entry {
    grid-template-columns: 13rem minmax(0, 1fr);
    gap: var(--space-5);
    align-items: baseline;
  }
}

.entry__period {
  color: var(--text-faint);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.entry__title {
  font-size: var(--text-base);
  letter-spacing: -0.01em;
}

.entry__subtitle {
  color: var(--text-muted);
}

.entry__description {
  margin-top: var(--space-1);
  max-width: var(--measure);
  color: var(--text-faint);
  font-size: var(--text-sm);
}

/* 06-case-study.css */
/* Case-study pages: a long-form article with the same editorial grid as the home page */

/* Header */
.case-header {
  padding-block: var(--space-6) var(--space-7);
}

.back-link {
  display: inline-flex;
  gap: var(--space-2);
  margin-bottom: var(--space-7);
  color: var(--text-faint);
  font-size: var(--text-sm);
  text-decoration: none;
}

.back-link:hover {
  color: var(--text-strong);
}

.case-header__grid {
  display: grid;
  gap: var(--space-6);
  align-items: start;
}

@media (min-width: 860px) {
  .case-header__grid:has(.case-header__aside) {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-8);
  }
}

.case-header__text {
  display: grid;
  gap: var(--space-4);
  max-width: 46rem;
}

.case-header__title {
  font-size: var(--text-2xl);
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.case-header__meta {
  color: var(--text-faint);
  font-size: var(--text-sm);
}

.case-header__lead {
  margin-top: var(--space-2);
  color: var(--text);
  font-size: var(--text-lg);
  line-height: 1.6;
}

.case-header .tag-list {
  margin-top: var(--space-2);
}

/* Black line-art logo on white, shown as white line art: inverted, then the
   (now black) background drops out against the dark page with screen blending */
.case-logo {
  width: 9rem;
  filter: invert(1) grayscale(1);
  mix-blend-mode: screen;
  opacity: 0.92;
}

/* Key figures and the process line sit directly under the header */
.case-study > .stats {
  padding-bottom: var(--space-6);
}

/* Process at a glance: "Clean & merge → Engineer features → Analyse → Model" */
.flow ol {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
}

.flow li:not(:last-child)::after {
  content: '→';
  margin-inline: 0.75em;
  color: var(--text-faint);
}

.flow a {
  color: var(--text-muted);
  text-decoration: none;
}

.flow a:hover {
  color: var(--text-strong);
}

/* Chapters: prose first, then the evidence that backs it */
.chapter__body {
  display: grid;
  gap: var(--space-6);
}

/* One highlighted result per chapter: larger, brighter text, nothing around it */
.highlight {
  max-width: 36rem;
  color: var(--text-strong);
  font-size: var(--text-xl);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.chapter .figure {
  max-width: 52rem;
}

/* Data overview: "10 sessions × 6 pilots × 6 files = ~360 CSV files" */
.data-overview {
  display: grid;
  gap: var(--space-3);
}

.data-equation {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2) var(--space-3);
  color: var(--text-muted);
}

.data-equation__term strong {
  margin-right: 0.2em;
  font-size: var(--text-xl);
  letter-spacing: -0.02em;
}

.data-equation__operator {
  color: var(--text-faint);
}

.data-files {
  color: var(--text-faint);
  font-size: var(--text-sm);
}

.data-files code {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.95em;
}

/* Previous / next */
.case-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-5);
  padding-block: var(--space-7) var(--space-5);
}

.case-nav__link {
  display: grid;
  gap: var(--space-1);
  text-decoration: none;
}

.case-nav__link--next {
  margin-left: auto;
  text-align: right;
}

.case-nav__label {
  color: var(--text-faint);
  font-size: var(--text-sm);
}

.case-nav__title {
  color: var(--text-strong);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: -0.015em;
}

.case-nav__link:hover .case-nav__title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

/* 07-diagrams.css */
/* Inline SVG diagrams. Layers are told apart by tone, not by outlines. */
.diagram-figure {
  display: grid;
  gap: var(--space-3);
}

.diagram-figure figcaption {
  max-width: var(--measure);
  color: var(--text-faint);
  font-size: var(--text-sm);
}

.diagram-figure figcaption strong {
  color: var(--text);
  font-weight: 500;
}

.diagram {
  width: 100%;
  height: auto;
  font-family: var(--font-sans);
}

.diagram text {
  fill: var(--text-muted);
  font-size: 15px;
}

/* Cross-section */
.xs-outside {
  fill: rgb(255 255 255 / 0.015);
}

.xs-roof {
  fill: rgb(255 255 255 / 0.24);
}

.xs-insulation {
  fill: rgb(255 255 255 / 0.06);
}

.xs-hatch {
  stroke: rgb(255 255 255 / 0.1);
  stroke-width: 2;
}

.xs-room {
  fill: rgb(255 255 255 / 0.03);
}

.cross-section .xs-layer-label {
  fill: var(--text);
  font-weight: 600;
  paint-order: stroke;
  stroke: #1b1b1c;
  stroke-width: 6px;
  stroke-linejoin: round;
}

.xs-probe {
  stroke: var(--text-faint);
  stroke-width: 2;
}

.xs-leader {
  stroke: var(--rule-strong);
  stroke-dasharray: 3 4;
}

.xs-sensor circle {
  fill: var(--text-strong);
  stroke: var(--bg);
  stroke-width: 3;
}

.cross-section .xs-sensor-label {
  fill: var(--text);
}

.xs-sensor-id {
  font-weight: 700;
  fill: var(--text-strong);
}

.cross-section .xs-axis {
  fill: var(--text-faint);
  font-size: 13px;
  font-style: italic;
}

.diagram-figure--cross-section {
  max-width: 32rem;
}

/* Radar template */
.diagram-figure--radar {
  max-width: 34rem;
}

.radar-ring {
  fill: none;
  stroke: var(--rule);
}

.radar-ring--outer {
  stroke: var(--rule-strong);
}

.radar-axis {
  stroke: var(--rule-strong);
}

.radar-centre {
  fill: var(--text-faint);
}

/* The filled shape: translucent purple so the rings stay visible through it */
.radar-shape__area {
  fill: var(--data);
  fill-opacity: 0.32;
  stroke: var(--data);
  stroke-width: 2;
  stroke-linejoin: round;
}

.radar-shape__point {
  fill: var(--data-strong);
}

.radar .radar-label {
  fill: var(--text);
}
