/* Tokens: every color, size and space below comes from here. Light is the default; dark applies
   when the system asks for it (unless the visitor picked light) or when the visitor picked dark. */
:root {
  color-scheme: light;
  --bg: #fbfaf7;
  --surface: #ffffff;
  --text: #1a1d21;
  --muted: #4f5660;
  --line: #dedbd3;
  --line-strong: #8c867a;
  --accent: #0b5c55;
  --accent-strong: #073f3a;
  --on-accent: #ffffff;
  --live: #1f7a3a;
  --warn: #8a5a00;
  --down: #b42318;
  --focus: #b4530a;
  --zone: #f3f1ec;
  --grid: #ebe8e1;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-2: 1.375rem;
  --step-3: 1.75rem;
  --step-5: clamp(2.25rem, 1.5rem + 3.5vw, 3.75rem);

  --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: 4.5rem;

  --radius: 0.5rem;
  --measure: 44rem;
  --page: 72rem;
  --ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  interpolate-size: allow-keywords;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121416;
    --surface: #1a1d20;
    --text: #e8e6e1;
    --muted: #a9adb3;
    --line: #2e3337;
    --line-strong: #6b737b;
    --accent: #6fd3c2;
    --accent-strong: #a3e6da;
    --on-accent: #0c1f1c;
    --live: #5fd07f;
    --warn: #e3b341;
    --down: #f47067;
    --focus: #f5a25d;
    --zone: #16191b;
    --grid: #1c2023;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121416;
  --surface: #1a1d20;
  --text: #e8e6e1;
  --muted: #a9adb3;
  --line: #2e3337;
  --line-strong: #6b737b;
  --accent: #6fd3c2;
  --accent-strong: #a3e6da;
  --on-accent: #0c1f1c;
  --live: #5fd07f;
  --warn: #e3b341;
  --down: #f47067;
  --focus: #f5a25d;
  --zone: #16191b;
  --grid: #1c2023;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

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

.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

@media (min-width: 40em) {
  .wrap {
    padding-inline: var(--space-6);
  }
}

a {
  color: var(--accent);
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--accent-strong);
}

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

#projects:focus {
  outline: none;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-8));
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  z-index: 2;
}

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

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

/* Buttons */
.button,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover,
.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
}

.button-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.button-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

.button:disabled {
  cursor: progress;
  color: var(--muted);
}

.button:active:not(:disabled),
.theme-toggle:active {
  transform: translateY(1px);
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-4);
}

.monogram {
  display: inline-grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--mono);
  font-weight: 700;
  text-decoration: none;
}

.monogram:hover {
  background: var(--accent-strong);
  color: var(--on-accent);
}

.theme-toggle {
  font-size: var(--step--1);
  font-weight: 500;
}

.icon {
  width: 1.125rem;
  height: 1.125rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
}

.icon-fill {
  fill: currentColor;
  stroke: none;
}

/* Intro */
.intro {
  position: relative;
  padding-block: var(--space-7) var(--space-7);
}

.intro::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 2rem 2rem;
  mask-image: radial-gradient(ellipse 70% 80% at 20% 40%, black 30%, transparent 75%);
  pointer-events: none;
}

.intro > * {
  max-width: var(--measure);
}

.eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--step--1);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: var(--step-5);
  line-height: 1.05;
  letter-spacing: -0.025em;
}

.lede {
  margin: var(--space-4) 0 var(--space-5);
  font-size: var(--step-1);
  color: var(--muted);
  max-width: 38rem;
}

.facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  margin: 0 0 var(--space-6);
  max-width: 32rem;
}

.facts div {
  display: flex;
  flex-direction: column-reverse;
  padding-left: var(--space-3);
  border-left: 2px solid var(--accent);
}

.facts dt {
  color: var(--muted);
  font-size: var(--step--1);
  line-height: 1.3;
}

.facts dd {
  margin: 0;
  font-family: var(--mono);
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1.2;
}

.contact {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Layout: projects, then the architecture panel; side by side with a sticky panel when wide. */
.layout {
  display: grid;
  gap: var(--space-7);
  padding-bottom: var(--space-7);
}

@media (min-width: 70em) {
  .layout {
    grid-template-columns: minmax(0, 1fr) minmax(22rem, 26rem);
    align-items: start;
  }
}

@media (min-width: 70em) and (min-height: 48em) {
  .infra-panel {
    position: sticky;
    top: var(--space-5);
  }
}

.section-title {
  margin: 0 0 var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Project cards */
.project {
  position: relative;
  padding: var(--space-5) 0 var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--line);
}

.project::before {
  content: "";
  position: absolute;
  left: 0;
  top: var(--space-5);
  bottom: var(--space-6);
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
}

.project:hover::before,
.project:focus-within::before,
.project.is-linked::before {
  transform: scaleY(1);
}

.project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-4);
}

.project h3 {
  margin: 0;
  font-size: var(--step-2);
  line-height: 1.25;
}

.status {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--live);
}

.status[data-state="checking"] .dot,
.status[data-state="unknown"] .dot {
  background: var(--muted);
}

.status[data-state="degraded"] .dot {
  background: var(--warn);
}

.status[data-state="down"] .dot {
  background: var(--down);
}

.summary {
  margin: var(--space-3) 0;
}

.highlights {
  margin: 0 0 var(--space-4);
  padding-left: var(--space-5);
}

.highlights li + li {
  margin-top: var(--space-1);
}

/* Engineering notes: native disclosure; the open/close height animates where supported. */
.notes {
  margin: 0 0 var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.notes summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-4);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.notes summary::-webkit-details-marker {
  display: none;
}

.notes summary::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.notes[open] summary::after {
  transform: translateY(2px) rotate(-135deg);
}

.notes::details-content {
  block-size: 0;
  overflow: clip;
}

.notes[open]::details-content {
  block-size: auto;
}

.notes-body {
  padding: 0 var(--space-4) var(--space-2);
  border-top: 1px solid var(--line);
}

.notes-body p {
  margin: var(--space-3) 0;
}

.stack,
.access {
  margin: 0 0 var(--space-2);
  color: var(--muted);
  font-size: var(--step--1);
}

.label {
  margin-right: var(--space-2);
  color: var(--text);
  font-family: var(--mono);
  font-weight: 600;
}

.visit {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.visit::after {
  content: "→";
  margin-left: var(--space-2);
}

.visit:hover {
  background: var(--accent);
  color: var(--on-accent);
}

/* Architecture diagram */
.arch-figure {
  margin: 0;
}

.arch {
  display: block;
  width: 100%;
  max-width: 30rem;
  height: auto;
  margin-inline: auto;
  overflow: visible;
}

.arch text {
  fill: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  text-anchor: middle;
}

.arch .sub {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.zone rect {
  fill: var(--zone);
  stroke: var(--line-strong);
  stroke-dasharray: 3 4;
}

.zone text {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 400;
  text-anchor: start;
}

.node rect {
  fill: var(--surface);
  stroke: var(--line-strong);
}

.node-entry rect {
  stroke: var(--accent);
  stroke-width: 1.5;
}

.edge {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-dasharray: 4 5;
}

.edge-metrics {
  stroke: var(--muted);
}

.node-dot {
  fill: var(--muted);
}

.node-dot[data-state="up"] {
  fill: var(--live);
}

.node-dot[data-state="degraded"] {
  fill: var(--warn);
}

.node-dot[data-state="down"] {
  fill: var(--down);
}

/* Highlight one project's path: everything else fades. */
.arch [data-project] {
  transition: opacity 200ms ease;
}

.arch[data-active] [data-project]:not([data-project="all"]) {
  opacity: 0.2;
}

.arch[data-active="carwash"] [data-project="carwash"]:not([data-project="all"]),
.arch[data-active="dso"] [data-project="dso"]:not([data-project="all"]),
.arch[data-active="forge"] [data-project="forge"]:not([data-project="all"]) {
  opacity: 1;
}

.arch[data-active="carwash"] .edge[data-project="carwash"],
.arch[data-active="dso"] .edge[data-project="dso"],
.arch[data-active="forge"] .edge[data-project="forge"] {
  stroke-width: 2.5;
}

.arch-figure figcaption {
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: var(--step--1);
}

.live {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.live-summary {
  margin: 0;
  font-size: var(--step--1);
  font-variant-numeric: tabular-nums;
}

/* Error page */
.notfound {
  padding-block: var(--space-8);
}

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2) var(--space-5);
  padding-block: var(--space-6) var(--space-7);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--step--1);
}

.footer p {
  margin: 0;
}

/* Motion: only when the visitor hasn't asked for less. app.js sets .js-reveal only then, too. */
.js-reveal .reveal:not(.is-visible) {
  opacity: 0;
  transform: translateY(14px);
}

@media (prefers-reduced-motion: no-preference) {
  .js-reveal .reveal {
    transition: opacity 500ms ease, transform 600ms var(--ease-out);
  }

  .edge {
    animation: flow 1.2s linear infinite;
  }

  .node-dot[data-state="checking"],
  .status[data-state="checking"] .dot {
    animation: pulse 1s ease-in-out infinite alternate;
  }

  .project::before {
    transition: transform 220ms var(--ease-out);
  }

  .notes::details-content {
    transition: block-size 250ms var(--ease-out), content-visibility 250ms allow-discrete;
  }

  .notes summary::after {
    transition: transform 200ms ease;
  }

  .visit,
  .button,
  .theme-toggle,
  .monogram {
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 80ms ease;
  }
}

@keyframes flow {
  to {
    stroke-dashoffset: -18;
  }
}

@keyframes pulse {
  from {
    opacity: 1;
  }
  to {
    opacity: 0.35;
  }
}
