/* Stefan Caldare - Portfolio
   Accessibility target: WCAG 2.2 AA. Every text/background pair below was
   checked for contrast (see accessibility.html). */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --sunk: #F1EEE8;
  --text: #16171A;
  --muted: #565A61;
  --accent: #2342B8;
  --on-accent: #FFFFFF;
  --border: #8A8F98;   /* 3:1+ for UI boundaries */
  --hair: #E4DFD7;     /* decorative dividers only */
  --focus: #2342B8;

  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;

  --step--1: clamp(0.875rem, 0.86rem + 0.08vw, 0.9375rem);
  --step-0: clamp(1.0625rem, 1.03rem + 0.15vw, 1.1875rem);
  --step-1: clamp(1.25rem, 1.18rem + 0.35vw, 1.5rem);
  --step-2: clamp(1.5rem, 1.35rem + 0.75vw, 2rem);
  --step-3: clamp(1.875rem, 1.6rem + 1.4vw, 2.875rem);
  --step-4: clamp(2.375rem, 1.9rem + 2.4vw, 4.25rem);

  --space-xs: 0.5rem;
  --space-s: 1rem;
  --space-m: 1.5rem;
  --space-l: 2.5rem;
  --space-xl: 4rem;
  --space-2xl: clamp(4rem, 3rem + 5vw, 7.5rem);

  --measure: 42rem;
  --wide: 72rem;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101114;
    --surface: #181A1F;
    --sunk: #1F2229;
    --text: #EEEBE5;
    --muted: #A9ADB5;
    --accent: #9DB2FF;
    --on-accent: #101114;
    --border: #6F7580;
    --hair: #2A2D34;
    --focus: #9DB2FF;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--space-l);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
img, svg { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 var(--space-s); text-wrap: balance; }
h1, h2 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.015em; }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); font-weight: 650; letter-spacing: -0.005em; }
p, ul, ol, dl, figure { margin: 0 0 var(--space-m); }
p { text-wrap: pretty; }
strong { font-weight: 650; }

a { color: var(--accent); text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 0.14em; }

/* Focus: always visible, 3px, never removed (WCAG 2.4.7, 2.4.11/2.4.13) */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Skip link (WCAG 2.4.1) */
.skip-link {
  position: absolute;
  left: var(--space-s);
  top: -100px;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 650;
  border-radius: 8px;
  text-decoration: none;
}
.skip-link:focus { top: var(--space-s); }

.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;
}

.wrap { width: min(100% - 2rem, var(--wide)); margin-inline: auto; }
.prose { width: min(100% - 2rem, var(--measure)); margin-inline: auto; }

/* Header */
.site-header { border-bottom: 1px solid var(--hair); }
.site-header .wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-s);
  padding-block: var(--space-s);
}
.brand {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.25rem; }
.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;           /* target size, WCAG 2.5.8 */
  padding: 0 0.85rem;
  border-radius: 999px;
  color: var(--text);
  text-decoration: none;
  font-weight: 550;
  font-size: var(--step--1);
}
.site-nav a:hover { background: var(--sunk); }
.site-nav a[aria-current="page"] { background: var(--text); color: var(--bg); }

main { display: block; }
section { padding-block: var(--space-2xl) 0; }

.eyebrow {
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-s);
}
.lede { font-size: var(--step-1); line-height: 1.5; color: var(--text); max-width: 44rem; }
.muted { color: var(--muted); }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: var(--space-s); margin-top: var(--space-l); }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0 1.4rem;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  border: 2px solid var(--text);
  color: var(--text);
  background: transparent;
}
.button:hover { background: var(--sunk); }
.button--primary { background: var(--text); color: var(--bg); }
.button--primary:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Hero */
.hero { padding-block: var(--space-2xl) var(--space-xl); }
.hero h1 { max-width: 20ch; }

/* Proof strip */
.proof {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
}
.proof li { padding: var(--space-m) var(--space-m) var(--space-m) 0; }
.proof strong {
  display: block;
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-weight: 500;
  line-height: 1.1;
  color: var(--text);
}
.proof span { display: block; color: var(--muted); font-size: var(--step--1); margin-top: 0.35rem; line-height: 1.45; }

/* Section heading row */
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-s); margin-bottom: var(--space-l); }
.section-head h2 { margin: 0; }

/* Work cards */
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-l) var(--space-m); grid-template-columns: repeat(auto-fill, minmax(min(100%, 26rem), 1fr)); }
.card { position: relative; display: flex; flex-direction: column; }
.card__media {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--sunk);
  margin-bottom: var(--space-s);
  border: 1px solid var(--hair);
}
.card__media img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
.card__media--contain img { object-fit: contain; padding: 1rem; }
.card__meta { font-size: var(--step--1); color: var(--muted); margin-bottom: 0.35rem; }
.card h3 { font-size: var(--step-1); margin-bottom: 0.5rem; }
.card h3 a { color: var(--text); text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }  /* whole card clickable, single link */
.card h3 a:focus-visible { outline: none; }
.card:has(a:focus-visible) { outline: 3px solid var(--focus); outline-offset: 6px; border-radius: var(--radius); }
.card:hover h3 a { text-decoration: underline; text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; }
.card p { margin-bottom: 0.75rem; color: var(--muted); }
.card .result { margin-top: auto; margin-bottom: 0; font-weight: 600; color: var(--text); }
.card--feature { grid-column: 1 / -1; }
@media (min-width: 60rem) {
  .card--feature { display: grid; grid-template-columns: 1.3fr 1fr; gap: var(--space-l); align-items: center; }
  .card--feature .card__media { margin-bottom: 0; }
  .card--feature h3 { font-size: var(--step-2); font-family: var(--font-display); font-weight: 500; }
}

/* Clients line */
.clients { font-size: var(--step-1); line-height: 1.5; color: var(--muted); max-width: 52rem; }
.clients strong { color: var(--text); font-weight: 600; }

/* Principles */
.principles { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-l); grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); counter-reset: p; }
.principles li { counter-increment: p; border-top: 2px solid var(--text); padding-top: var(--space-s); }
.principles li::before { content: "0" counter(p); display: block; font-size: var(--step--1); color: var(--muted); font-weight: 600; margin-bottom: 0.5rem; }
.principles h3 { margin-bottom: 0.5rem; }
.principles p { color: var(--muted); margin: 0; }

/* Contact */
.contact { background: var(--sunk); border-radius: calc(var(--radius) * 2); padding: clamp(2rem, 1rem + 4vw, 4.5rem); margin-top: var(--space-2xl); }
.contact h2 { max-width: 18ch; }

/* Footer */
.site-footer { margin-top: var(--space-2xl); border-top: 1px solid var(--hair); padding-block: var(--space-l); font-size: var(--step--1); color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: var(--space-s) var(--space-l); justify-content: space-between; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 var(--space-m); }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text); }
.site-footer p { margin: 0; display: flex; align-items: center; min-height: 44px; }

/* ---------- Case study ---------- */
.breadcrumb ol { list-style: none; padding: 0; margin: 0 0 var(--space-l); display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; font-size: var(--step--1); }
.breadcrumb li + li::before { content: "/"; margin-right: 0.5rem; color: var(--muted); }
.breadcrumb a { display: inline-flex; min-height: 44px; align-items: center; }
.breadcrumb [aria-current="page"] { color: var(--muted); display: inline-flex; min-height: 44px; align-items: center; }

.cs-hero { padding-block: var(--space-l) var(--space-xl); }
.cs-hero h1 { max-width: 22ch; }

.summary {
  display: grid;
  gap: var(--space-l);
  grid-template-columns: 1fr;
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: calc(var(--radius) * 1.5);
  padding: clamp(1.5rem, 1rem + 2vw, 2.5rem);
}
@media (min-width: 56rem) { .summary { grid-template-columns: 1fr 1.2fr; } }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.6rem 1.25rem; margin: 0; }
.facts dt { font-size: var(--step--1); font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; padding-top: 0.2rem; }
.facts dd { margin: 0; }
.summary h2 { font-family: var(--font-body); font-size: var(--step--1); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: var(--space-s); }
.results { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-m); grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); }
.results strong { display: block; font-family: var(--font-display); font-weight: 500; font-size: var(--step-3); line-height: 1.05; }
.results span { display: block; color: var(--muted); font-size: var(--step--1); line-height: 1.45; margin-top: 0.35rem; }
.results--text strong { font-family: var(--font-body); font-size: var(--step-0); font-weight: 650; }

.toc { margin-top: var(--space-l); }
.toc h2 { font-family: var(--font-body); font-size: var(--step--1); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.25rem; }
.toc ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.toc a { display: inline-flex; align-items: center; min-height: 44px; font-size: var(--step--1); font-weight: 550; }

.cs-section { padding-top: var(--space-xl); }
.cs-section h2 { font-size: var(--step-2); }
.cs-section h3 { margin-top: var(--space-l); }
.cs-section ul, .cs-section ol { padding-left: 1.25rem; }
.cs-section li { margin-bottom: 0.4rem; }

.callout {
  border-left: 4px solid var(--accent);
  background: var(--surface);
  padding: var(--space-m);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-block: var(--space-l);
}
.callout p:last-child { margin-bottom: 0; }
.callout .label { display: block; font-size: var(--step--1); font-weight: 650; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 0.35rem; }

.decision { border-top: 1px solid var(--hair); padding-top: var(--space-m); margin-top: var(--space-l); }
.decision h3 { margin-top: 0; }
.decision dl { display: grid; grid-template-columns: 1fr; gap: 0.25rem; margin: 0; }
.decision dt { font-weight: 650; margin-top: 0.75rem; }
.decision dd { margin: 0; color: var(--text); }

/* Figures */
.figure { width: min(100% - 2rem, 64rem); margin: var(--space-xl) auto; }
.figure--narrow { width: min(100% - 2rem, var(--measure)); }
.figure__frame { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); overflow: hidden; }
.figure__frame img { width: 100%; }
.figure__frame--pad { padding: clamp(1rem, 0.5rem + 2vw, 2.5rem); background: var(--sunk); }
.figure__frame--pad img { border-radius: 8px; }
.figure figcaption { font-size: var(--step--1); color: var(--muted); margin-top: 0.75rem; max-width: var(--measure); line-height: 1.55; }
.figure figcaption a { display: inline-block; padding-block: 0.35rem; }
.gallery { display: grid; gap: var(--space-m); grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); align-items: start; }
.gallery img { border-radius: 10px; margin-inline: auto; }
.gallery--phones img { max-height: 42rem; width: auto; }

.diagram { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); padding: clamp(1rem, 0.5rem + 2vw, 2rem); color: var(--text); }
.diagram svg { width: 100%; height: auto; }
.diagram text { fill: currentColor; font-family: var(--font-body); }

.nda { display: inline-flex; align-items: center; gap: 0.5rem; font-size: var(--step--1); font-weight: 600; background: var(--sunk); border: 1px solid var(--border); border-radius: 999px; padding: 0.35rem 0.9rem; margin-bottom: var(--space-m); }

.next { margin-top: var(--space-2xl); border-top: 1px solid var(--hair); padding-top: var(--space-l); }
.next p { margin-bottom: 0.25rem; }
.next a { font-family: var(--font-display); font-size: var(--step-2); display: inline-block; padding-block: 0.25rem; }

/* Timeline (about) */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 1fr; gap: 0.25rem; padding-block: var(--space-m); border-top: 1px solid var(--hair); }
@media (min-width: 48rem) { .timeline li { grid-template-columns: 12rem 1fr; gap: var(--space-m); } }
.timeline .when { color: var(--muted); font-size: var(--step--1); font-variant-numeric: tabular-nums; padding-top: 0.2rem; }
.timeline h3 { margin-bottom: 0.25rem; font-size: var(--step-0); }
.timeline p { margin: 0; color: var(--muted); }

.about-grid { display: grid; gap: var(--space-l); align-items: start; }
@media (min-width: 52rem) { .about-grid { grid-template-columns: 16rem 1fr; } }
.portrait { border-radius: 50%; width: 12rem; height: 12rem; object-fit: cover; }

.more-list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-l); grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); }
.more-list h3 { margin-bottom: 0.35rem; }
.more-list p { color: var(--muted); margin-bottom: 0.5rem; }
.archive { list-style: none; padding: 0; margin: 0; }
.archive li { display: grid; gap: 0.25rem; padding-block: var(--space-s); border-top: 1px solid var(--hair); }
@media (min-width: 48rem) { .archive li { grid-template-columns: 5rem 16rem 1fr; gap: var(--space-m); } }
.archive .when { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Windows High Contrast / forced colors */
@media (forced-colors: active) {
  .button, .site-nav a[aria-current="page"], .nda, .summary, .callout { border: 1px solid CanvasText; }
  .card:has(a:focus-visible) { outline: 3px solid Highlight; }
}

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

@media print {
  .site-nav, .skip-link, .toc, .contact, .next { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; }
}

/* Diagrams and steps */
.flush-top { padding-top: 0 !important; margin-top: 0 !important; }
.dg-box { fill: var(--surface); stroke: var(--border); stroke-width: 2; }
.dg-accent { fill: var(--accent); }
.dg-on { fill: var(--on-accent) !important; }
.dg-muted { fill: var(--muted) !important; }
.dg-line { stroke: var(--border); }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-s); grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); counter-reset: s; }
.steps li { counter-increment: s; border-top: 3px solid var(--accent); padding-top: 0.75rem; }
.steps li::before { content: counter(s); display: block; font-size: var(--step--1); font-weight: 650; color: var(--muted); }
.steps strong { display: block; }
.steps span { display: block; color: var(--muted); font-size: var(--step--1); }

.card__media--type { display: grid; place-items: center; background: var(--text); border-color: var(--text); }
.card__media--type span { font-family: var(--font-display); font-size: var(--step-3); color: var(--bg); letter-spacing: -0.01em; padding: 1rem; text-align: center; }

.flow-list { display: none; margin: 0; padding-left: 1.25rem; }
.flow-list li { margin-bottom: 0.5rem; }
@media (max-width: 40rem) {
  .diagram svg { display: none; }
  .flow-list { display: block; }
}
.cs-section .timeline { padding-left: 0; }
@media (min-width: 48rem) { .timeline li { grid-template-columns: 9rem 1fr; } }
