/* ==========================================================================
   Wrong With Data — main stylesheet
   1. Fonts   2. Tokens   3. Base   4. Layout   5. Components   6. Motion
   ========================================================================== */

/* 1. Fonts (self-hosted: no requests to third parties, no GDPR issue) ---- */
@font-face {
  font-family: "Manrope";
  src: url("../fonts/manrope-latin-var.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jetbrains-mono-latin-var.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

/* 2. Tokens -------------------------------------------------------------- */
:root {
  /* Brand palette (sampled from the logo) */
  --paper: #faf8f5;
  --ink: #0c1521;
  --ink-muted: #566070;
  --signal: #f35b30;        /* logo accent: large text, marks */
  --signal-text: #c23e17;   /* accent for small text (AA on paper) */
  --rule: #e3ded5;

  --font-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Type scale (1.25 ratio) */
  --step--1: 0.875rem;
  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-2: 1.25rem;

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;

  --measure: 40rem;
  --gutter: clamp(1.25rem, 5vw, 4rem);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0c1521;
    --ink: #f2efe9;
    --ink-muted: #a3abb8;
    --signal-text: #ff7a50;
    --rule: #243044;
  }
}

:root[data-theme="dark"] {
  --paper: #0c1521;
  --ink: #f2efe9;
  --ink-muted: #a3abb8;
  --signal-text: #ff7a50;
  --rule: #243044;
}

/* 3. Base ---------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--signal-text);
}

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

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

/* 4. Layout -------------------------------------------------------------- */
.page {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100svh;
  min-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  padding-inline: var(--gutter);
}

.hero {
  align-self: center;
  width: 100%;
  max-width: 60rem;
  margin-inline: auto;
  padding-block: var(--space-5);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  width: 100%;
  max-width: 60rem;
  margin-inline: auto;
  padding-block: var(--space-3);
  border-top: 1px solid var(--rule);
  color: var(--ink-muted);
  font-size: var(--step--1);
}

.site-footer p {
  margin: 0;
}

/* 5. Components ---------------------------------------------------------- */

/* Language switch */
.lang-switch {
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
  width: 100%;
  max-width: 60rem;
  margin-inline: auto;
  padding-top: var(--space-2);
  font-family: var(--font-mono);
  font-size: var(--step--1);
}

.lang-switch a {
  padding: 0.5rem 0.625rem;
  color: var(--ink-muted);
  text-decoration: none;
}

.lang-switch a:hover {
  color: var(--ink);
}

.lang-switch a[aria-current="page"] {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--signal);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

/* Brand block — logo + tagline scale together, like the original lockup */
.brand {
  width: min(100%, 44rem);
  container-type: inline-size;
}

.logo {
  margin: 0;
  line-height: 0;
}

.logo svg {
  display: block;
  width: 100%;
  height: auto;
}

.logo-prompt,
.logo-cursor,
.logo-ink {
  fill: var(--ink);
}

.logo-accent {
  fill: var(--signal);
}

/* In the lockup the tagline starts at 14.2% and spans ~79% of the width */
.tagline {
  margin: 1.2em 0 0;
  padding-left: 14.2%;
  font-family: var(--font-mono);
  font-size: var(--step-1);
  font-size: max(0.75rem, 3.6cqi);
  font-weight: 500;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

/* Console — the site "auditing itself" */
.console {
  max-width: var(--measure);
  margin: var(--space-5) 0 0;
  padding: var(--space-1) 0 var(--space-1) var(--space-3);
  border-left: 3px solid var(--ink);
  font-family: var(--font-mono);
  font-size: clamp(0.8125rem, 1.6vw, 0.9375rem);
  line-height: 1.9;
}

.console p {
  margin: 0;
}

.console-cmd {
  color: var(--ink-muted);
}

.console-cmd .prompt {
  margin-right: 1ch;
  color: var(--ink);
}

.console-cmd .typed {
  --chars: 27; /* length of the command text in index.html */
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  vertical-align: bottom;
  white-space: nowrap;
}

.console-steps {
  margin: var(--space-1) 0 0;
  padding: 0;
  list-style: none;
}

.console-steps li {
  display: grid;
  grid-template-columns: 2ch 12ch 1fr;
  align-items: baseline;
}

.console-steps li:nth-child(1) { --i: 0; }
.console-steps li:nth-child(2) { --i: 1; }
.console-steps li:nth-child(3) { --i: 2; }

.console-steps .mark {
  color: var(--signal-text);
}

.console-steps .step {
  font-weight: 700;
}

@media (max-width: 30rem) {
  .console-steps li {
    grid-template-columns: 2ch 1fr;
  }

  .console-steps .detail {
    grid-column: 2;
    margin-bottom: var(--space-1);
    color: var(--ink-muted);
  }
}

.contact {
  max-width: var(--measure);
  margin: var(--space-4) 0 0;
  font-size: var(--step-1);
}

.contact a {
  font-weight: 700;
  white-space: nowrap;
}

/* 404 variant */
.error-code {
  margin: var(--space-4) 0 0;
  font-family: var(--font-mono);
  font-size: clamp(var(--step-1), 3vw, 1.5rem);
  font-weight: 500;
}

.error-code .mark {
  color: var(--signal-text);
}

/* 6. Motion -------------------------------------------------------------
   One orchestrated load sequence: the command types itself, then the three
   steps of the tagline resolve one by one. Everything is visible by default;
   motion is only added when the user has not asked to reduce it.        */
@media (prefers-reduced-motion: no-preference) {
  .logo-cursor {
    animation: blink 1.1s steps(1, end) 2.6s infinite;
  }

  .console-cmd .typed {
    width: calc(var(--chars) * 1ch);
    animation: type 0.9s steps(var(--chars), end) 0.4s both;
  }

  .console-steps li {
    animation: reveal 0.01s linear both;
    animation-delay: calc(1.5s + var(--i) * 0.45s);
  }

  .console ~ .contact {
    animation: reveal 0.4s ease-out 3s both;
  }
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes type {
  from {
    width: 0;
  }
}

@keyframes reveal {
  from {
    opacity: 0;
  }
}

.logo a {
  display: block;
}
