/* ==========================================================================
   foundry.dk — hand-written, no framework, no build step
   Direction: "The Document" — a typeset engineering document.
   ========================================================================== */

/* ---- tokens ------------------------------------------------------------ */
:root {
  color-scheme: light dark;

  --paper: #F7F6F1;
  --ink: #0A0A0A;
  --ink-60: rgba(10, 10, 10, .62);
  --ink-35: rgba(10, 10, 10, .38);
  --rule: rgba(10, 10, 10, .14);
  --hatch: rgba(10, 10, 10, .05);
  --accent: #C2410C;             /* oxide — matte, never neon */

  --font-sans: 'Familjen Grotesk', 'Familjen Fallback', system-ui, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Plex Fallback', ui-monospace, 'Courier New', monospace;

  --w-page: 68.75rem;            /* 1100px */
  --w-prose: 62ch;
  --pad-x: clamp(1.25rem, 5vw, 3rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0E0E0C;
    --ink: #F2F1EC;
    --ink-60: rgba(242, 241, 236, .66);
    --ink-35: rgba(242, 241, 236, .40);
    --rule: rgba(242, 241, 236, .16);
    --hatch: rgba(242, 241, 236, .055);
    --accent: #F0631F;
  }
}

/* ---- fonts (self-hosted, latin subset) --------------------------------- */
@font-face {
  font-family: 'Familjen Grotesk';
  src: url('fonts/familjen-grotesk-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'IBM Plex Mono';
  src: url('fonts/ibm-plex-mono-latin-400-normal.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
/* metric-matched fallbacks: measured against the real files, so the swap
   from system font to webfont causes no layout shift */
@font-face {
  font-family: 'Familjen Fallback';
  src: local('Arial');
  size-adjust: 95.23%;
  ascent-override: 102.5%;
  descent-override: 22.5%;
  line-gap-override: 0%;
}
@font-face {
  font-family: 'Plex Fallback';
  src: local('Courier New');
  size-adjust: 100%;
  ascent-override: 102.5%;
  descent-override: 27.5%;
  line-gap-override: 0%;
}

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

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

body {
  margin: 0;
  border-top: 2px solid var(--accent);  /* the line */
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ol, figure { margin: 0; }
img, svg { max-width: 100%; height: auto; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
  text-decoration-color: var(--ink-35);
}
a:hover {
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
}

::selection { background: var(--accent); color: var(--paper); }

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

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--paper);
  padding: .5rem 1rem;
  z-index: 10;
}
.skip:focus { left: var(--pad-x); }

.wrap {
  max-width: var(--w-page);
  margin-inline: auto;
  padding-inline: var(--pad-x);
}

/* mono utility — all metadata on the site */
.mono {
  font-family: var(--font-mono);
  font-size: .8125rem;
  font-weight: 400;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-60);
}

/* ---- masthead ----------------------------------------------------------- */
.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--rule);
}
.brand {
  display: flex;
  align-items: center;
  gap: .625rem;
  text-decoration: none;
  color: var(--ink);
}
.brand .mark { display: block; }
.wordmark {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: .14em;
}
.masthead .mono a { text-decoration: none; }
.masthead .mono a:hover { color: var(--accent); }

/* ---- hero ---------------------------------------------------------------- */
.hero { padding-block: clamp(4rem, 13vh, 8rem) clamp(3rem, 8vh, 5rem); }

.hero h1 {
  font-size: clamp(2.4rem, calc(1.2rem + 6vw), 6.25rem);
  line-height: .98;
  font-weight: 600;
  letter-spacing: -.015em;
  max-width: 24ch;
  text-wrap: balance;
}

.hero .sub {
  margin-top: 1.5rem;
  font-size: clamp(1.125rem, calc(1rem + .6vw), 1.375rem);
  color: var(--ink-60);
  max-width: 34ch;
}

.hero .note {
  margin-top: 0.875rem;
  font-size: clamp(1rem, calc(0.95rem + .25vw), 1.125rem);
  color: var(--ink-60);
  max-width: 48ch;
}

.hero-rail {
  margin-top: clamp(2.5rem, 7vh, 4.5rem);
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem 2rem;
  font-size: .75rem;
}
.hero-rail .cue { text-decoration: none; color: var(--accent); }
.hero-rail .cue:hover { color: var(--ink); }

/* load-in: pure CSS, time-based — completes with or without JS */
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.hero > * { animation: rise .45s cubic-bezier(.2, .6, .2, 1) both; }
.hero > *:nth-child(2) { animation-delay: .07s; }
.hero > *:nth-child(3) { animation-delay: .14s; }
.hero > *:nth-child(4) { animation-delay: .21s; }

/* ---- sections ------------------------------------------------------------ */
.section { margin-block-start: clamp(5.5rem, 14vh, 9rem); position: relative; }

.section-head {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: clamp(1.75rem, 5vh, 2.75rem);
}
.section-no { color: var(--ink-35); }
.section-head h2 {
  font-size: clamp(1.4rem, calc(1.1rem + 1vw), 1.75rem);
  font-weight: 600;
  letter-spacing: -.01em;
}

/* at wide viewports the section number moves into the left margin,
   like a printed document */
@media (min-width: 77.5rem) {
  .section-no { position: absolute; left: -4.5rem; top: .5rem; }
}

/* ---- 01 what we do -------------------------------------------------------- */
.cards { display: grid; grid-template-columns: 1fr; }
.card {
  padding-block: 1.75rem;
  border-top: 1px solid var(--rule);
}
.card h3 { font-size: 1.125rem; font-weight: 600; margin-bottom: .625rem; }
.card p { color: var(--ink-60); max-width: 44ch; }
.card .terms {
  display: block;
  font-size: .75rem;
  text-transform: none;
  letter-spacing: .04em;
  margin-bottom: .875rem;
  color: var(--ink-60);
}

@media (min-width: 56.25rem) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  .card { padding: .25rem 2rem 0 0; border-top: 0; border-left: 1px solid var(--rule); padding-left: 2rem; }
  .card:first-child { border-left: 0; padding-left: 0; }
}

/* ---- 02 the standard ------------------------------------------------------ */
.standard { max-width: var(--w-prose); }
.standard p + p { margin-top: 1.25rem; }
.standard .lede { font-weight: 500; }

/* ---- 03 the stack ---------------------------------------------------------- */
.stack-intro { max-width: var(--w-prose); margin-bottom: 2rem; color: var(--ink-60); }

.stack { position: relative; }

.strata {
  list-style: none;
  padding: 0;
  border-bottom: 1px solid var(--rule);
  counter-reset: none;
}

.stratum {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  grid-template-areas: "no name" "no terms";
  align-items: baseline;
  column-gap: .5rem;
  padding-block: 1.375rem;
  border-top: 1px solid var(--rule);
}
.stratum-no { grid-area: no; font-size: .8125rem; color: var(--ink-35); }
.stratum h3 {
  grid-area: name;
  font-size: clamp(1.125rem, calc(1rem + .8vw), 1.5rem);
  font-weight: 500;
  letter-spacing: -.01em;
}
.stratum .terms {
  grid-area: terms;
  margin-top: .5rem;
  font-size: .75rem;
  letter-spacing: .06em;
  text-transform: none;
}

/* the accent belongs to the top stratum only */
.stratum--ai { border-top: 2px solid var(--accent); }
.stratum--ai .stratum-no { color: var(--accent); }

/* the foundation is cut like bedrock in a section drawing */
.stratum--foundation {
  background: repeating-linear-gradient(-45deg,
    transparent 0 7px, var(--hatch) 7px 8px);
}

/* hover: the layer under the pointer takes full ink, the rest recede */
@media (hover: hover) {
  .strata:hover .stratum { opacity: .55; transition: opacity .25s ease; }
  .strata:hover .stratum:hover { opacity: 1; }
}

/* dimension rail — desktop only; the drawing gains its annotations */
.stack-dim { display: none; }

@media (min-width: 56.25rem) {
  .stack { padding-left: 4.25rem; }

  .stack-dim {
    display: block;
    position: absolute;
    left: 1.375rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--ink-35);
  }
  .stack-dim::before,               /* arrowhead, pointing down: dependency */
  .stack-dim::after {
    content: "";
    position: absolute;
    left: -3px;
    border-left: 3.5px solid transparent;
    border-right: 3.5px solid transparent;
  }
  .stack-dim::before { top: 0; border-bottom: 6px solid var(--ink-35); }
  .stack-dim::after { bottom: 0; border-top: 6px solid var(--ink-35); }

  .stack-dim span {
    position: absolute;
    top: 50%;
    left: -0.6875rem;
    transform: rotate(180deg) translateY(50%);
    writing-mode: vertical-rl;
    font-family: var(--font-mono);
    font-size: .6875rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-35);
    background: var(--paper);
    padding-block: .625rem;
  }

  /* boundary ticks, one per stratum edge */
  .stratum { position: relative; }
  .stratum::before {
    content: "";
    position: absolute;
    left: -2.875rem;
    top: -1px;
    width: .875rem;
    height: 1px;
    background: var(--ink-35);
  }
  .strata::after {
    content: "";
    position: absolute;
    left: 1.375rem;
    bottom: 0;
    width: .875rem;
    height: 1px;
    background: var(--ink-35);
    transform: translateY(0);
  }

  .stratum {
    grid-template-columns: 3.25rem minmax(11rem, 16rem) 1fr;
    grid-template-areas: "no name terms";
  }
  .stratum .terms { margin-top: 0; text-align: right; }
}

/* scroll reveal — strata settle bottom-first; gated on .js so a no-JS
   visitor always sees the finished drawing */
.js .stack .stratum {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .5s cubic-bezier(.2, .6, .2, 1),
              transform .5s cubic-bezier(.2, .6, .2, 1);
}
.js .stack .stratum:nth-child(5) { transition-delay: 0s; }     /* foundation first */
.js .stack .stratum:nth-child(4) { transition-delay: .12s; }
.js .stack .stratum:nth-child(3) { transition-delay: .24s; }
.js .stack .stratum:nth-child(2) { transition-delay: .36s; }
.js .stack .stratum:nth-child(1) { transition-delay: .48s; }   /* ai lands last */
.js .stack.is-in .stratum { opacity: 1; transform: none; }

.contact-cta {
  display: inline-block;
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -.005em;
}

/* ---- footer ---------------------------------------------------------------- */
.footer {
  margin-top: clamp(5.5rem, 14vh, 9rem);
  border-top: 1px solid var(--rule);
  padding-block: 2rem 2.5rem;
}
.footer p { font-size: .8125rem; }
.footer p + p { margin-top: .5rem; }
.footer a { text-decoration-color: var(--ink-35); }
.footer a:hover { text-decoration-color: var(--accent); }

/* copy-to-clipboard affordance (revealed by JS) */
.copy {
  font-family: var(--font-mono);
  font-size: .6875rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-60);
  background: none;
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: .1875rem .5625rem;
  margin-left: .625rem;
  cursor: pointer;
}
.copy:hover { color: var(--accent); border-color: var(--accent); }
.copy.is-done { color: var(--accent); border-color: var(--accent); }

/* ---- contact page ------------------------------------------------------------ */
.contact-page { min-height: 100svh; display: flex; flex-direction: column; }
.contact-page > .masthead,
.contact-page > .contact-main { width: 100%; }  /* auto margins on flex items must not shrink-wrap */
.contact-main { flex: 1; padding-block: clamp(3.5rem, 10vh, 6rem); }

.contact-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}
.contact-mark { color: var(--ink); flex-shrink: 0; }
.contact-head h1 {
  font-size: clamp(1.75rem, calc(1.3rem + 2vw), 2.5rem);
  font-weight: 600;
  letter-spacing: -.01em;
}

.entries { display: grid; grid-template-columns: 1fr; gap: 0; margin-top: 2.5rem; }
.entry { padding-block: 2.25rem; border-top: 1px solid var(--rule); }
.entry h2 {
  font-size: clamp(1.5rem, calc(1.2rem + 1.4vw), 2rem);
  font-weight: 600;
  letter-spacing: -.01em;
  margin-bottom: .875rem;
  text-wrap: balance;
}
.entry p { color: var(--ink-60); max-width: 40ch; }
.entry .mail {
  display: inline-block;
  margin-top: 1.375rem;
  font-family: var(--font-mono);
  font-size: .9375rem;
  letter-spacing: .02em;
}

@media (min-width: 51.25rem) {
  .entries { grid-template-columns: 1fr 1fr; }
  .entry { border-top: 1px solid var(--rule); padding-right: 3rem; }
  .entry + .entry { border-left: 1px solid var(--rule); padding-left: 3rem; padding-right: 0; }
}

.contact-meta {
  border-top: 1px solid var(--rule);
  padding-block: 2rem 2.5rem;
}
.contact-meta p { font-size: .8125rem; }

/* ---- 404 ------------------------------------------------------------------ */
.notfound { min-height: 100svh; display: grid; place-content: center; gap: 1rem; text-align: left; }
.notfound h1 { font-size: clamp(2rem, 6vw, 3rem); font-weight: 600; }

/* ---- motion & print -------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .js .stack .stratum { opacity: 1; transform: none; }
}

@media print {
  .masthead .mono, .hero-rail .cue, .copy { display: none; }
  body { font-size: 11pt; }
}
