/* ===========================================================================
   ercin.info — "Sovereign" design system
   Precision-engineering aesthetic: deep petrol, bone, copper signal.
   =========================================================================== */

/* --- Fonts (self-hosted, variable, latin subset) ------------------------- */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/space-grotesk.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("/fonts/jetbrains-mono.woff2") format("woff2");
}

/* --- Tokens -------------------------------------------------------------- */
:root {
  --ink:        #0C2125;   /* near-black petrol, primary background */
  --ink-2:      #102b30;   /* raised panels / diagram canvas (opaque) */
  --ink-3:      #0a1b1e;   /* deepest wells */
  --bone:       #ECE7DC;   /* primary text on dark */
  --steel:      #7C97A0;   /* muted captions, secondary text */
  --signal:     #D98A4B;   /* copper — accent, active nodes, links */
  --signal-dim: #8A5A30;   /* hover / pressed copper */
  --line:       #2A4248;   /* hairlines, node borders, dividers */

  --font-display: "Space Grotesk", "Inter Tight", sans-serif;
  --font-body:    "Inter", system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", "IBM Plex Mono", monospace;

  --step--1: clamp(0.83rem, 0.8rem + 0.15vw, 0.9rem);
  --step-0:  clamp(1rem, 0.95rem + 0.25vw, 1.13rem);
  --step-1:  clamp(1.33rem, 1.2rem + 0.6vw, 1.6rem);
  --step-2:  clamp(1.78rem, 1.5rem + 1.4vw, 2.55rem);
  --step-3:  clamp(2.37rem, 1.9rem + 2.4vw, 4rem);

  --maxw: 1100px;
  --pad: clamp(1.25rem, 5vw, 3rem);
  --gap: clamp(3rem, 8vw, 6rem);

  --radius: 10px;
  --hair: 1px solid var(--line);

  color-scheme: dark;
}

/* --- Reset / base -------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  background: var(--ink);
  color: var(--bone);
  font-family: var(--font-body);
  font-size: var(--step-0);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

a {
  color: var(--signal);
  text-decoration: none;
  text-underline-offset: 3px;
}
a:hover { color: var(--signal-dim); text-decoration: underline; }

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

::selection { background: var(--signal); color: var(--ink); }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.015em;
}

.mono {
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: var(--step--1);
  color: var(--steel);
}

/* --- Layout helpers ------------------------------------------------------ */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--pad); }

main { flex: 1 0 auto; }

section { padding-block: var(--gap); }
section + section { border-top: var(--hair); }

.eyebrow {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--step--1);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--signal);
  display: block;
}

.section-head {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: var(--step--1);
  font-weight: 500;
  color: var(--steel);
  margin-bottom: 1.75rem;
}

.lede { color: var(--steel); font-size: var(--step-1); max-width: 60ch; line-height: 1.5; }

/* --- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5ch;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--step--1);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.85em 1.4em;
  border-radius: 8px;
  border: 1px solid var(--signal);
  background: var(--signal);
  color: var(--ink);
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.btn:hover { background: var(--signal-dim); border-color: var(--signal-dim); color: var(--bone); text-decoration: none; }

.btn--ghost {
  background: transparent;
  color: var(--bone);
  border-color: var(--line);
}
.btn--ghost:hover { background: transparent; border-color: var(--signal); color: var(--signal); }

.textlink {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--steel);
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
}
.textlink:hover { color: var(--signal); border-color: var(--signal); text-decoration: none; }

/* --- Site header / nav --------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--ink) 86%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: var(--hair);
}
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 64px;
}
.logotype {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-0);
  letter-spacing: -0.01em;
  color: var(--bone);
}
.logotype:hover { color: var(--signal); text-decoration: none; }
.logotype .dot { color: var(--signal); }

.nav-links { display: flex; align-items: center; gap: clamp(1rem, 3vw, 2rem); list-style: none; padding: 0; }
.nav-links a {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--steel);
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--bone); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--signal); }

/* --- Hero ---------------------------------------------------------------- */
.hero { padding-block: clamp(3rem, 8vw, 6rem) clamp(2.5rem, 6vw, 4.5rem); }
.hero .eyebrow { margin-bottom: 1.25rem; }
.hero h1 {
  font-size: var(--step-3);
  max-width: 18ch;
  margin-bottom: 1.5rem;
}
.hero-sub { color: var(--steel); font-size: var(--step-1); max-width: 56ch; line-height: 1.5; }
.hero-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 1.25rem 1.75rem; margin-top: 2.25rem; }

/* --- Architecture diagram ------------------------------------------------ */
.diagram-figure { margin-top: clamp(2.5rem, 6vw, 4rem); }
.diagram-canvas {
  background:
    radial-gradient(120% 150% at 50% 0%, color-mix(in srgb, var(--signal) 7%, transparent), transparent 58%),
    var(--ink-2);
  border: var(--hair);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.6vw, 1.75rem);
  overflow: hidden;
}
.diagram-canvas svg { width: 100%; height: auto; }
.diagram-caption {
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--steel);
  letter-spacing: 0.02em;
}

.dg-svg { width: 100%; height: auto; display: block; }
.dg-grid { opacity: 0.55; }
.dg-box, .dg-led, .dg-title { transition: stroke 0.3s ease, fill 0.3s ease; }

/* Resting accent (reduced-motion): anchor the entry node in copper. */
.dg-node.dg-rest .dg-box { stroke: var(--signal); }
.dg-node.dg-rest .dg-led { fill: var(--signal); }

/* Load orchestration: each node flashes copper as the request passes. */
.dg-node.dg-pulse .dg-box   { animation: dgPulseBox 0.85s ease-out both; }
.dg-node.dg-pulse .dg-led   { animation: dgPulseLed 0.85s ease-out both; }
.dg-node.dg-pulse .dg-title { animation: dgPulseTitle 0.85s ease-out both; }
@keyframes dgPulseBox {
  0%   { stroke: var(--line); }
  20%  { stroke: var(--signal); }
  100% { stroke: var(--line); }
}
@keyframes dgPulseLed {
  0%, 100% { fill: var(--line); }
  20%      { fill: var(--signal); }
}
@keyframes dgPulseTitle {
  0%, 100% { fill: var(--bone); }
  20%      { fill: var(--signal); }
}

/* Perpetual flow: LEDs/borders light in sync with the travelling packet.
   Phase is offset per node via --flow-begin so the glow tracks the dot. */
.dg-flowsync.dg-flow-on .dg-led {
  animation: dgFlowLed var(--flow-dur, 6.5s) linear var(--flow-begin, 0s) infinite;
}
.dg-flowsync.dg-flow-on .dg-box {
  animation: dgFlowBox var(--flow-dur, 6.5s) linear var(--flow-begin, 0s) infinite;
}
@keyframes dgFlowLed {
  0%   { fill: var(--signal); }
  9%   { fill: var(--line); }
  100% { fill: var(--line); }
}
@keyframes dgFlowBox {
  0%   { stroke: var(--signal); }
  9%   { stroke: var(--line); }
  100% { stroke: var(--line); }
}

@media (prefers-reduced-motion: reduce) {
  .dg-node.dg-pulse .dg-box,
  .dg-node.dg-pulse .dg-led,
  .dg-node.dg-pulse .dg-title,
  .dg-flowsync.dg-flow-on .dg-led,
  .dg-flowsync.dg-flow-on .dg-box { animation: none; }
}

/* --- Proof strip --------------------------------------------------------- */
.proof {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: var(--hair);
  border-radius: var(--radius);
  overflow: hidden;
}
.proof-item { background: var(--ink); padding: clamp(1.25rem, 3vw, 1.75rem); }
.proof-item .k {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--step-1);
  color: var(--signal);
  letter-spacing: 0.01em;
  display: block;
  margin-bottom: 0.4rem;
}
.proof-item .v { color: var(--steel); font-size: var(--step--1); line-height: 1.45; }

/* --- Generic content blocks --------------------------------------------- */
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.6fr);
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: start;
}
.prose p { max-width: 68ch; }
.prose p + p { margin-top: 1.1rem; }

/* --- Cards (selected work) ---------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
.card {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--ink-2);
  border: var(--hair);
  border-radius: var(--radius);
  padding: 1.5rem;
  color: inherit;
  transition: border-color 0.18s ease, transform 0.18s ease, background 0.18s ease;
}
.card:hover { border-color: var(--signal); transform: translateY(-3px); text-decoration: none; background: color-mix(in srgb, var(--ink-2) 80%, var(--signal) 6%); }
.card h3 { font-size: var(--step-1); color: var(--bone); }
.card p { color: var(--steel); font-size: var(--step-0); }
.card .arrow { margin-top: auto; font-family: var(--font-mono); font-size: var(--step--1); color: var(--signal); text-transform: uppercase; letter-spacing: 0.06em; }

/* --- CTA band ------------------------------------------------------------ */
.cta-band { text-align: center; }
.cta-band h2 { font-size: var(--step-2); max-width: 22ch; margin-inline: auto; margin-bottom: 1.75rem; }

/* --- Case studies (Work) ------------------------------------------------- */
.case {
  display: grid;
  grid-template-columns: minmax(0, 0.7fr) minmax(0, 2fr);
  gap: clamp(1rem, 4vw, 3rem);
  padding-block: clamp(2.25rem, 5vw, 3.25rem);
}
.case + .case { border-top: var(--hair); }
.case .case-eyebrow { position: sticky; top: 88px; align-self: start; }
.case h2 { font-size: var(--step-2); margin-bottom: 1rem; }
.case .ctx { color: var(--steel); margin-bottom: 1rem; }
.case .owned { margin-bottom: 1rem; }
.case .result {
  border-left: 2px solid var(--signal);
  padding-left: 1rem;
  color: var(--bone);
  font-weight: 500;
  margin-bottom: 1.25rem;
}
.stack {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--steel);
  letter-spacing: 0.02em;
  background: var(--ink-3);
  border: var(--hair);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  display: inline-block;
}

/* --- Writing list -------------------------------------------------------- */
.posts { list-style: none; padding: 0; }
.post {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem 2rem;
  padding-block: 1.5rem;
  align-items: baseline;
}
.post + .post { border-top: var(--hair); }
.post h3 { font-size: var(--step-1); font-weight: 500; }
.post h3 a { color: var(--bone); }
.post h3 a:hover { color: var(--signal); }
.post .summary { color: var(--steel); font-size: var(--step-0); grid-column: 1 / -1; max-width: 70ch; }
.post .date { font-family: var(--font-mono); font-size: var(--step--1); color: var(--steel); white-space: nowrap; }
.posts-note { color: var(--steel); font-size: var(--step--1); margin-top: 2rem; font-family: var(--font-mono); }

/* --- Contact ------------------------------------------------------------- */
.contact-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(1.5rem, 5vw, 4rem); align-items: start; }
.contact-actions { display: flex; flex-direction: column; gap: 1rem; align-items: flex-start; }
.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.1rem; }
.field label { font-family: var(--font-mono); font-size: var(--step--1); text-transform: uppercase; letter-spacing: 0.06em; color: var(--steel); }
.field input, .field textarea {
  font-family: var(--font-body);
  font-size: var(--step-0);
  color: var(--bone);
  background: var(--ink-2);
  border: var(--hair);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
}
.field input:focus, .field textarea:focus { border-color: var(--signal); outline: none; }
.field textarea { min-height: 130px; resize: vertical; }

/* --- Footer -------------------------------------------------------------- */
.site-footer {
  flex-shrink: 0;
  border-top: var(--hair);
  padding-block: 2.5rem;
  margin-top: var(--gap);
}
.footer-inner { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; justify-content: space-between; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; list-style: none; padding: 0; }
.footer-links a, .copyright {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.04em;
  color: var(--steel);
}
.footer-links a:hover { color: var(--signal); text-decoration: none; }

/* --- Skip link ----------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  background: var(--signal);
  color: var(--ink);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  z-index: 100;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0.5rem; text-decoration: none; }

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

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
  .case { grid-template-columns: 1fr; }
  .case .case-eyebrow { position: static; }
  .contact-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .proof { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .nav-links { gap: 0.85rem; }
  .post { grid-template-columns: 1fr; }
  .post .date { order: -1; }
}
@media (max-width: 420px) {
  .proof { grid-template-columns: 1fr; }
}
