/* =========================================================================
   M. Kotantakis — portfolio site
   Hand-written CSS, no framework, no build step. ~13KB, one HTTP request.

   Theming: `color-scheme` on :root lets the browser theme scrollbars, form
   controls and the canvas. Colours are declared once with light-dark(), so
   there is no duplicate palette in a media query to drift out of sync.
   ========================================================================= */

:root {
  /* Dark first — this is a technical audience, and it matches the work. */
  color-scheme: dark light;

  --bg: light-dark(#ffffff, #0b0d12);
  --bg-alt: light-dark(#f6f7f9, #0f1218);
  --surface: light-dark(#ffffff, #151922);
  --surface-2: light-dark(#f1f3f6, #1b202b);

  --border: light-dark(#e3e6eb, #242b38);
  --border-strong: light-dark(#c9cfd8, #333c4d);

  --text: light-dark(#111722, #e9edf5);
  --text-muted: light-dark(#59637a, #98a3b8);
  /* Chosen by measurement, not by eye: this is the quietest text on the page
     and it still clears WCAG AA (4.5:1) against every surface it can land on,
     including surface-2 and accent-soft. The obvious "nice grey" here was
     3.05:1 in light mode and 4.19:1 in dark — both failures. */
  --text-faint: light-dark(#606978, #858fa3);

  --accent: light-dark(#2c5fe0, #6f9bff);
  --accent-soft: light-dark(#eaf0ff, #17203a);
  --accent-text: light-dark(#ffffff, #0b0d12);

  --radius: 14px;
  --radius-sm: 9px;

  --shell: 1120px;
  --gutter: clamp(1.125rem, 5vw, 3rem);

  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Inter,
    'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas,
    'Liberation Mono', monospace;

  accent-color: var(--accent);
}

:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark'] { color-scheme: dark; }

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

html {
  scroll-behavior: smooth;
  /* Anchored sections must not hide behind the sticky header. */
  scroll-padding-top: 5.5rem;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: clamp(0.975rem, 0.94rem + 0.18vw, 1.0625rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* Belt and braces against a stray wide child. */
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.021em;
  text-wrap: balance;
}

p { margin: 0; text-wrap: pretty; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }

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

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

.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
  inset-block-start: 0;
  z-index: 100;
  padding: 0.75rem 1.125rem;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { inset-inline-start: 0.5rem; inset-block-start: 0.5rem; }

.shell {
  inline-size: 100%;
  max-inline-size: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.shell--narrow { max-inline-size: 680px; }

/* ------------------------------------------------------------------ header */

.site-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 50;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-block-end: 1px solid var(--border);
}

/* color-mix is broadly supported, but an opaque fallback costs one line and
   guarantees the header is never unreadable. */
@supports not (background: color-mix(in oklab, red 50%, blue)) {
  .site-header { background: var(--bg); }
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  max-inline-size: var(--shell);
  margin-inline: auto;
  padding: 0.75rem var(--gutter);
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.nav__mark {
  display: grid;
  place-items: center;
  inline-size: 2rem;
  block-size: 2rem;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), light-dark(#7b3fe4, #a98bff));
  color: #fff;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nav__links {
  display: none;
  gap: 1.5rem;
  margin: 0;
  margin-inline-start: auto;
  padding: 0;
  list-style: none;
}
.nav__links a {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 550;
  text-decoration: none;
}
.nav__links a:hover { color: var(--text); }

.nav__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-inline-start: auto;
}
.nav__links + .nav__actions { margin-inline-start: 1.5rem; }

@media (max-width: 30rem) {
  .nav__brand > span:last-child { display: none; }
}

@media (min-width: 52rem) {
  .nav__links { display: flex; }
}

.theme-toggle {
  padding: 0.4375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }

/* ----------------------------------------------------------------- buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5625rem 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}
.button:hover { background: var(--surface-2); transform: translateY(-1px); }

.button--primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--accent-text);
}
.button--primary:hover { background: var(--accent); filter: brightness(1.08); }

.button--lg { padding: 0.75rem 1.375rem; font-size: 0.9375rem; }

/* -------------------------------------------------------------------- hero */

.hero { padding-block: clamp(3.5rem, 9vw, 7rem) clamp(2.5rem, 6vw, 4.5rem); }

.eyebrow {
  margin-block-end: 1rem;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero__title {
  max-inline-size: 19ch;
  font-size: clamp(2.125rem, 1.35rem + 3.6vw, 4rem);
  font-weight: 680;
  letter-spacing: -0.033em;
}
.hero__accent { display: block; color: var(--text-muted); }

.hero__lede {
  max-inline-size: 60ch;
  margin-block-start: 1.5rem;
  color: var(--text-muted);
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.1875rem);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-block-start: 2.25rem;
}

.hero__stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 3.5rem 0 0;
  padding: 0;
  list-style: none;
}
.hero__stack li {
  padding: 0.3125rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 0.75rem;
}

/* ---------------------------------------------------------------- sections */

.section { padding-block: clamp(3.25rem, 8vw, 6rem); }
.section--alt { background: var(--bg-alt); border-block: 1px solid var(--border); }

.section__title {
  font-size: clamp(1.625rem, 1.25rem + 1.6vw, 2.5rem);
  font-weight: 660;
}

.section__lede {
  max-inline-size: 58ch;
  margin-block-start: 0.875rem;
  color: var(--text-muted);
  font-size: 1.0625rem;
}

/* ------------------------------------------------------------------- cards */

.cards {
  display: grid;
  gap: 1.125rem;
  margin-block-start: 3rem;
  /* Columns appear only when each one has room to be readable. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
}

.card {
  padding: 1.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.card h3 { margin-block-end: 0.875rem; font-size: 1.125rem; font-weight: 640; }
.card p { color: var(--text-muted); font-size: 0.9375rem; }

.card__list {
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.5rem;
}
.card__list li {
  position: relative;
  padding-inline-start: 1.25rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.card__list li::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: 0.6em;
  inline-size: 0.4375rem;
  block-size: 0.4375rem;
  border-radius: 50%;
  background: var(--accent);
}

/* -------------------------------------------------------------- case study */

.case {
  display: grid;
  gap: clamp(1.75rem, 4vw, 3.5rem);
  align-items: start;
  padding-block: clamp(2.5rem, 5vw, 3.5rem);
  border-block-start: 1px solid var(--border);
  margin-block-start: 3rem;
}
.case:first-of-type { margin-block-start: 3rem; }

@media (min-width: 62rem) {
  .case { grid-template-columns: 1.15fr 0.85fr; }
  /* The diagram sticks while the long case text scrolls past it. */
  .case__figure { position: sticky; inset-block-start: 6rem; }
  .case--reverse .case__body { order: 2; }
  .case--reverse .case__figure { order: 1; }
}

.case__title {
  margin-block-end: 1.5rem;
  font-size: clamp(1.375rem, 1.1rem + 1.1vw, 1.875rem);
  font-weight: 650;
}

.case__section { margin-block-end: 1.5rem; }
.case__section h4 {
  margin-block-end: 0.5rem;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.case__section p { color: var(--text-muted); font-size: 0.9375rem; }
/* Global reset zeroes paragraph margins, so stacked paragraphs need their own gap. */
.case__section p + p { margin-block-start: 0.875rem; }
.case__section em { color: var(--text); font-style: normal; font-weight: 600; }

/* Repo link under each case study. Deliberately a text link, not a .button:
   the only button that should compete for attention is the Upwork CTA. */
.case__repo { margin-block-start: 1.25rem; font-size: 0.875rem; }
.case__repo a { font-weight: 600; text-decoration: none; }
.case__repo a:hover { text-decoration: underline; }

/* Screen-reader-only text: names the project inside an otherwise repeated link. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4375rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}
.tags li {
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
}

.case__figure { margin: 0; }
.case__figure figcaption {
  margin-block-start: 0.875rem;
  color: var(--text-faint);
  font-size: 0.8125rem;
  text-align: center;
}

/* ---------------------------------------------------------------- diagrams */

/*
  The diagrams are inline SVG using currentColor and CSS variables, so they
  re-theme with the page instead of needing a second exported image for dark
  mode — and they stay sharp at any zoom.
*/
.diagram {
  inline-size: 100%;
  block-size: auto;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.diagram__group rect {
  fill: var(--surface-2);
  stroke: var(--border-strong);
  stroke-width: 1;
}
.diagram__group--accent rect {
  fill: var(--accent-soft);
  stroke: var(--accent);
}

.diagram text {
  fill: var(--text);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
}
.diagram .diagram__sub {
  fill: var(--text-faint);
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 500;
}
.diagram__side text {
  fill: var(--text-faint);
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 500;
}

.diagram__arrows path {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 1.5;
  stroke-linecap: round;
}

/* ------------------------------------------------------------- principles */

.principles {
  display: grid;
  gap: 1.125rem;
  margin-block-start: 3rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
}

.principle {
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.principle h3 { margin-block-end: 0.625rem; font-size: 1rem; font-weight: 640; }
.principle p { color: var(--text-muted); font-size: 0.9rem; }

/* --------------------------------------------------------------------- cta */

.section--cta {
  border-block-start: 1px solid var(--border);
  text-align: center;
}
.section--cta .section__lede { margin-inline: auto; }

.cta__actions { margin-block-start: 2.25rem; }

.cta__note {
  margin-block-start: 1.75rem;
  color: var(--text-faint);
  font-size: 0.8125rem;
}

/* ------------------------------------------------------------------ footer */

.site-footer {
  padding-block: 2.5rem;
  border-block-start: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
}
.site-footer__muted { margin-block-start: 0.375rem; color: var(--text-faint); font-size: 0.8125rem; }
.site-footer a { font-size: 0.8125rem; }

/* ------------------------------------------------------------- reveal --- */

/*
  Progressive enhancement: the class is only added by JS once it has confirmed
  IntersectionObserver support AND that the visitor has not asked for reduced
  motion. With no JS, nothing is hidden — which is the point.
*/
.js-reveal .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 520ms ease, transform 520ms ease;
}
.js-reveal .reveal.is-visible { opacity: 1; transform: none; }
