/* ==========================================================================
   cadegordon.com — globals
   Aesthetic: engineering-ledger editorial brutalism.
   Cream paper, ink black, single signal-teal accent.
   ========================================================================== */

/* ---- Design tokens ---------------------------------------------------- */
:root {
  /* Color — light (default) */
  --bg-primary:   #f4f1ea;   /* warm cream paper */
  --bg-secondary: #fbf9f4;   /* lifted surface */
  --bg-inset:     #ebe6dc;   /* recessed / specimen frame */
  --text-primary: #16150f;   /* near-black ink */
  --text-secondary:#5c574b;  /* muted ink */
  --text-faint:   #908a7c;
  --border:       #d8d1c2;   /* hairline */
  --border-strong:#16150f;   /* brutalist hard rule */

  /* Accent — signal teal */
  --accent:       #0e8c7d;   /* fills, large display */
  --accent-deep:  #08655a;   /* small accent text (AA on cream) */
  --accent-soft:  #d4e8e3;   /* tinted wash */

  /* Per-project accent (overridden on cards/pages) */
  --project-accent: var(--accent);

  /* Spacing scale (PRD) */
  --xs: 4px;  --sm: 8px;  --md: 16px;  --lg: 32px;  --xl: 64px;  --2xl: 128px;

  /* Type */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Archivo", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;

  --h1: clamp(2.75rem, 9vw, 7rem);
  --h2: clamp(2rem, 5vw, 3.25rem);
  --h3: clamp(1.4rem, 3vw, 1.9rem);
  --body: 1.0625rem;
  --small: 0.8125rem;

  /* Radii (PRD) */
  --r-sharp: 0px;   --r-std: 6px;   --r-soft: 14px;

  /* Shadows (PRD) */
  --sh-subtle: 0 2px 8px rgba(0,0,0,0.05);
  --sh-medium: 0 8px 24px rgba(0,0,0,0.10);
  --sh-hover:  0 22px 50px rgba(0,0,0,0.16);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);

  --gutter: clamp(1.25rem, 5vw, 5rem);
  --maxw: 1320px;
}

[data-theme="dark"] {
  --bg-primary:   #0c0c0d;
  --bg-secondary: #161617;
  --bg-inset:     #1c1c1e;
  --text-primary: #f4f1ea;
  --text-secondary:#a8a296;
  --text-faint:   #6b665b;
  --border:       #2a2a2c;
  --border-strong:#f4f1ea;
  --accent:       #2dd4bf;
  --accent-deep:  #5eead4;
  --accent-soft:  #123b36;
  --sh-subtle: 0 2px 8px rgba(0,0,0,0.4);
  --sh-medium: 0 8px 24px rgba(0,0,0,0.5);
  --sh-hover:  0 22px 50px rgba(0,0,0,0.6);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  font-family: var(--font-body);
  font-size: var(--body);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  overflow-x: hidden;
  transition: background 0.5s var(--ease-soft), color 0.5s var(--ease-soft);
  font-feature-settings: "ss01", "cv01";
}

/* Grain / paper texture overlay */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.045;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="dark"] body::before { mix-blend-mode: screen; opacity: 0.06; }

/* ---- Typography ------------------------------------------------------- */
h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-optical-sizing: auto;
}
h1 { font-size: var(--h1); }
h2 { font-size: var(--h2); }
h3 { font-size: var(--h3); line-height: 1.1; }

p { max-width: 62ch; }
a { color: inherit; text-decoration: none; }

.mono {
  font-family: var(--font-mono);
  font-size: var(--small);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.serif { font-family: var(--font-display); }
.accent-text { color: var(--accent-deep); }

/* Marker — highlighted accent word in headlines */
.marker {
  color: var(--project-accent, var(--accent));
  font-style: italic;
}

/* ---- Layout primitives ------------------------------------------------ */
.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-inline: var(--gutter);
}
.section { padding-block: clamp(4rem, 11vw, 9rem); position: relative; }

.rule { border: none; border-top: 1px solid var(--border); }
.rule-strong { border: none; border-top: 2px solid var(--border-strong); }

/* Section label: numbered ledger header */
.section-label {
  display: flex;
  align-items: baseline;
  gap: var(--md);
  margin-bottom: var(--xl);
  border-top: 2px solid var(--border-strong);
  padding-top: var(--md);
}
.section-label .idx {
  font-family: var(--font-mono);
  font-size: var(--small);
  color: var(--accent-deep);
  letter-spacing: 0.1em;
}
.section-label .name {
  font-family: var(--font-mono);
  font-size: var(--small);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-secondary);
}
.section-label .name::after {
  content: attr(data-meta);
  margin-left: auto;
  color: var(--text-faint);
}

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.6em;
  font-family: var(--font-mono);
  font-size: var(--small);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.95em 1.6em;
  border: 2px solid var(--border-strong);
  background: var(--text-primary);
  color: var(--bg-primary);
  border-radius: var(--r-sharp);
  cursor: pointer;
  transition: transform 0.4s var(--ease), background 0.3s, color 0.3s, box-shadow 0.4s var(--ease);
  position: relative;
  overflow: hidden;
}
.btn .arrow { transition: transform 0.4s var(--ease); }
.btn:hover { transform: translate(-2px,-2px); box-shadow: 6px 6px 0 var(--project-accent, var(--accent)); }
.btn:hover .arrow { transform: translateX(4px); }
.btn:active { transform: translate(0,0); box-shadow: 2px 2px 0 var(--project-accent, var(--accent)); }

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
}
.btn-ghost:hover { box-shadow: 6px 6px 0 var(--project-accent, var(--accent)); }

/* Text link with animated underline */
.link {
  position: relative;
  font-family: var(--font-mono);
  font-size: var(--small);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  display: inline-flex; align-items: center; gap: 0.4em;
}
.link::after {
  content: ""; position: absolute; left: 0; bottom: -3px;
  width: 100%; height: 1.5px; background: var(--project-accent, var(--accent));
  transform: scaleX(0); transform-origin: right; transition: transform 0.4s var(--ease);
}
.link:hover::after { transform: scaleX(1); transform-origin: left; }

/* ---- Header ----------------------------------------------------------- */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--md) var(--gutter);
  mix-blend-mode: difference;
  color: #fff;
}
.site-header.solid {
  mix-blend-mode: normal;
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.brand {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.78;
  transition: opacity 0.3s var(--ease);
}
.brand:hover { opacity: 1; }
.brand .dot { color: var(--accent); }
.nav { display: flex; align-items: center; gap: clamp(1rem, 3vw, 2.5rem); }
.nav a {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.nav a:hover { color: var(--accent); }

.theme-toggle {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1.5px solid currentColor;
  background: transparent; color: inherit;
  cursor: pointer; border-radius: 50%;
  transition: transform 0.4s var(--ease);
}
.theme-toggle:hover { transform: rotate(45deg); }
.theme-toggle svg { width: 16px; height: 16px; }

/* Bare floating theme toggle — just the emoji in the corner, no wrapper */
.theme-fab {
  position: fixed; top: 16px; right: 18px; z-index: 120;
  background: none; border: none; padding: 6px; cursor: pointer;
  font-size: 1.4rem; line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35));
  transition: transform 0.3s var(--ease);
}
.theme-fab:hover { transform: scale(1.15) rotate(-8deg); }
.theme-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }

/* ---- Footer ----------------------------------------------------------- */
.site-footer {
  border-top: 2px solid var(--border-strong);
  padding: var(--xl) var(--gutter) var(--lg);
}
.footer-grid {
  max-width: var(--maxw); margin: 0 auto;
  display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: var(--lg);
}
.footer-grid h3 { font-size: clamp(1.8rem, 5vw, 3rem); margin-bottom: var(--md); }
.footer-col h4 {
  font-family: var(--font-mono); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--text-faint); margin-bottom: var(--md);
}
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: var(--sm); }
.footer-col a:hover { color: var(--accent); }
.footer-base {
  max-width: var(--maxw); margin: var(--xl) auto 0;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: var(--sm);
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-faint);
  text-transform: uppercase; letter-spacing: 0.08em;
}

@media (max-width: 720px) {
  .footer-grid { grid-template-columns: 1fr; }
  .nav .nav-link { display: none; }
}

/* ---- Custom cursor (desktop, fine pointer) ---------------------------- */
.cursor-dot, .cursor-ring {
  position: fixed; top: 0; left: 0; pointer-events: none; z-index: 10000;
  border-radius: 50%; transform: translate(-50%, -50%);
  mix-blend-mode: difference;
}
.cursor-dot { width: 6px; height: 6px; background: #fff; }
.cursor-ring {
  width: 34px; height: 34px; border: 1px solid #fff;
  transition: width 0.3s var(--ease), height 0.3s var(--ease), background 0.3s;
}
.cursor-ring.hot { width: 54px; height: 54px; background: rgba(255,255,255,0.1); }
@media (hover: none), (pointer: coarse) {
  .cursor-dot, .cursor-ring { display: none; }
}

/* ---- Reveal animation state ------------------------------------------ */
[data-reveal] { opacity: 0; }
.no-js [data-reveal] { opacity: 1; }

/* ---- Accessibility ---------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--text-primary); color: var(--bg-primary);
  padding: var(--sm) var(--md); font-family: var(--font-mono); font-size: var(--small);
}
.skip-link:focus { left: var(--sm); top: var(--sm); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
