/*
 * Foundation tokens — "Spec Sheet"
 * Swiss engineering manual aesthetic: cool achromatic, true black ink on
 * cool paper, ONE cadmium red used surgically. No warmth, no gradients,
 * no glass, no lift-on-hover, no decorative second accent.
 */

:root {
  /* Type — JetBrains Mono (UI/labels/numbers/headings) + Newsreader (body prose). */
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;

  /* Modular type scale — every component pulls from this. */
  --t-11: 0.6875rem;
  --t-12: 0.75rem;
  --t-14: 0.875rem;
  --t-16: 1rem;
  --t-18: 1.125rem;
  --t-20: 1.25rem;
  --t-24: 1.5rem;
  --t-32: 2rem;
  --t-44: 2.75rem;
  --t-64: 4rem;
  --t-96: 6rem;

  /* COLOR — cool achromatic, no warm bias. Hue intentionally near-zero chroma. */
  --paper:    #F4F4F4;          /* cool light grey paper, not warm off-white */
  --paper-2:  #ECECEC;
  --paper-3:  #E2E2E2;
  --ink:      #0A0A0A;          /* true black, slight lift off pure to avoid grey-on-grey */
  --ink-2:    #5A5A5A;           /* secondary text — neutral grey, not brown */
  --rule:     #CFCFCF;
  --rule-2:   #9A9A9A;
  --mark:     #E0241B;           /* cadmium red — the only color in the system */
  --mark-ink: #B11A12;           /* red-on-red text */

  /* Surface aliases (legacy variable names so component CSS keeps working). */
  --primary-color: var(--ink);
  --accent-color: var(--mark);
  --background-color: var(--paper);
  --secondary-background-color: var(--paper-2);
  --text-color: var(--ink);
  --text-color-secondary: var(--ink-2);
  --border-color: var(--rule);
  --card-background-color: var(--paper);
  --tag-background-color: var(--paper-2);

  /* Radius — purposeful, not uniform. Sharp by default. */
  --r-0: 0px;
  --r-2: 2px;
  --r-pill: 999px;
  --border-radius: var(--r-0);

  /* Spacing — 4px base. */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;
  --spacing-xs: var(--s-1);
  --spacing-sm: var(--s-2);
  --spacing-md: var(--s-4);
  --spacing-lg: var(--s-5);
  --spacing-xl: var(--s-6);

  /* Layout */
  --measure: 62ch;
  --gutter: var(--s-5);
  --header-height: 44px;
  --sidebar-width: 300px;

  /* Motion — instant by default. No spring, no bounce. */
  --ease-step: steps(1, end);
  --ease-snap: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur-1: 80ms;
  --dur-2: 160ms;
  --dur-3: 320ms;

  --box-shadow: none;
  --box-shadow-hover: none;
  --shadow-modal: 0 24px 48px -16px rgba(10,10,10,0.25);

  --z-index-header: 100;
  --z-index-sidebar: 200;
  --z-index-modal: 300;

  /* Legacy type-size aliases */
  --font-family: var(--font-serif);
  --font-size-xs: var(--t-12);
  --font-size-sm: var(--t-14);
  --font-size-base: var(--t-16);
  --font-size-lg: var(--t-20);
  --font-size-xl: var(--t-24);
  --font-size-2xl: var(--t-32);
  --font-size-3xl: var(--t-44);
}

/* Reset */
* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 16px);
}

section[id] { scroll-margin-top: calc(var(--header-height) + 16px); }

body {
  font-family: var(--font-serif);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.55;
  font-size: var(--t-16);
  overflow-x: hidden;
  font-feature-settings: "kern", "ss01";
  -webkit-font-smoothing: antialiased;
}

/* Headings: monospace, structural, all-caps for h2 (section labels). */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.05;
  margin-bottom: var(--s-4);
  color: var(--ink);
}
h1 { font-size: clamp(var(--t-64), 9vw, var(--t-96)); font-weight: 700; letter-spacing: -0.04em; }
h2 { font-size: var(--t-32); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; }
h3 { font-size: var(--t-20); font-weight: 500; }
h4 { font-size: var(--t-12); font-weight: 700; text-transform: uppercase; letter-spacing: 0.10em; color: var(--ink-2); }

p { margin-bottom: var(--s-4); max-width: var(--measure); }
img { max-width: 100%; height: auto; display: block; }

/* Eyebrow label — mono, all-caps, used everywhere a section needs identification. */
.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--t-11);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-2);
  margin-bottom: var(--s-3);
}

/* Body prose — confident serif, no decorative italics or pull-quotes. */
.lede {
  font-family: var(--font-serif);
  font-size: clamp(var(--t-20), 2.4vw, var(--t-24));
  line-height: 1.35;
  color: var(--ink);
  margin-bottom: var(--s-5);
  max-width: 38ch;
  font-weight: 400;
}

/* Links — underlined by default, red on hover. The cadmium accent only appears here and on .mark. */
a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--rule-2);
  transition: color var(--dur-1) var(--ease-step), text-decoration-color var(--dur-1) var(--ease-step);
}
a:hover { color: var(--mark); text-decoration-color: var(--mark); }

/* The accent — used on .mark to draw the eye to ONE thing per view. */
.mark { color: var(--mark); }

button { cursor: pointer; border: none; font: inherit; background: none; color: inherit; }

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* BUTTONS — rectangular, monospace, no gradient, no glow, no rounding.
   Default action: outlined black. Primary action: solid black. Hover: invert.
   Red is reserved for one CTA per page; it's a flag, not a fill. */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-5);
  font-family: var(--font-mono);
  font-size: var(--t-12);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  text-decoration: none;
  border: 1px solid var(--ink);
  border-radius: var(--r-0);
  background: var(--paper);
  color: var(--ink);
  transition: background var(--dur-1) var(--ease-step), color var(--dur-1) var(--ease-step), transform var(--dur-1) var(--ease-snap);
}
.btn:hover { background: var(--ink); color: var(--paper); text-decoration: none; }
.btn:active { transform: translate(1px, 1px); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--mark); border-color: var(--mark); color: var(--paper); }
.btn-secondary { background: var(--paper); color: var(--ink); border-color: var(--rule-2); }
.btn-secondary:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-outline { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-outline:hover { background: var(--ink); color: var(--paper); }
.btn-sm { padding: 6px var(--s-3); font-size: var(--t-11); }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* Form */
input, textarea, select {
  width: 100%;
  padding: var(--s-3);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-0);
  font-family: var(--font-mono);
  font-size: var(--t-14);
  background: var(--paper);
  color: var(--ink);
  margin-bottom: var(--s-4);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--mark);
  outline-offset: -1px;
  border-color: var(--mark);
}

.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); position: relative; z-index: 1; }

.portfolio-container { position: relative; z-index: 2; }
.text-center { text-align: center; }
.divider { height: 1px; background: var(--rule); margin: var(--s-4) 0; width: 100%; }
.hidden { display: none !important; }

/* Loader — single-line CLI style. Square dots, step animation. */
.loader {
  position: fixed; inset: 0;
  background: var(--paper);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-3); z-index: 10000;
  font-family: var(--font-mono); font-size: var(--t-12);
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ink-2);
  transition: opacity var(--dur-3) var(--ease-snap);
}
.loader p { font-family: var(--font-mono); margin: 0; max-width: none; }
.loader .spinner { display: flex; gap: 4px; }
.loader .spinner div {
  width: 8px; height: 8px;
  background: var(--ink);
  border-radius: var(--r-0);
  animation: hmiBlink 0.9s var(--ease-step) infinite;
}
.loader .spinner .dot1 { animation-delay: 0s; }
.loader .spinner .dot2 { animation-delay: 0.3s; }
.loader .spinner .dot3 { animation-delay: 0.6s; background: var(--mark); }
@keyframes hmiBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0.15; }
}

/* Status pill — outline with red dot inside. Used in header + hero. */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 2px var(--s-2);
  border: 1px solid var(--ink);
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: var(--t-11);
  text-transform: uppercase;
  letter-spacing: 0.10em;
  color: var(--ink);
  background: var(--paper);
}
.status-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--mark);
  animation: ledBlink 1.6s var(--ease-snap) infinite;
}
@keyframes ledBlink { 0%, 60% { opacity: 1; } 80%, 100% { opacity: 0.25; } }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* Dark theme — invert ink/paper, keep red intact. */
body.dark-theme {
  --paper:   #0E0E0E;
  --paper-2: #161616;
  --paper-3: #1F1F1F;
  --ink:     #F0F0F0;
  --ink-2:   #9A9A9A;
  --rule:    #2A2A2A;
  --rule-2:  #3F3F3F;
  --background-color: var(--paper);
  --secondary-background-color: var(--paper-2);
  --text-color: var(--ink);
  --text-color-secondary: var(--ink-2);
  --border-color: var(--rule);
  --card-background-color: var(--paper);
  --tag-background-color: var(--paper-2);
}
