/* ============================================================
   DANIEL FRENCH — Design System
   The Examined Life, Built in Code
   ============================================================ */

/* --- Google Fonts Import --- */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&family=DM+Sans:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400&family=IBM+Plex+Mono:ital,wght@0,300;0,400;0,500;1,300;1,400&display=swap');

/* ============================================================
   CSS CUSTOM PROPERTIES — TOKEN SYSTEM
   ============================================================ */
:root {
  /* --- Dark Register --- */
  --bg-primary:    #080C12;
  --bg-surface:    #0E1520;
  --bg-glass:      rgba(255, 255, 255, 0.04);

  /* --- Light Register --- */
  --paper:         #F5F0E8;
  --ink:           #1A1410;

  /* --- Accents --- */
  --red:           #C8373C;
  --amber:         #A8956A;
  --slate:         #6B8FBF;

  /* --- Text Hierarchy (dark bg) --- */
  --text-primary:  #e8e4f0;
  --text-secondary:rgba(232, 228, 240, 0.65);
  --text-muted:    rgba(232, 228, 240, 0.35);

  /* --- Borders --- */
  --border:        rgba(232, 228, 240, 0.10);
  --border-amber:  rgba(168, 149, 106, 0.30);
  --border-slate:  rgba(107, 143, 191, 0.25);

  /* --- Typography --- */
  --font-display:  'Cormorant Garamond', 'Georgia', serif;
  --font-body:     'DM Sans', 'Helvetica Neue', 'Arial', sans-serif;
  --font-mono:     'IBM Plex Mono', 'Courier New', monospace;

  /* --- Type Scale --- */
  --text-xs:    0.70rem;
  --text-sm:    0.85rem;
  --text-base:  1.00rem;
  --text-lg:    1.20rem;
  --text-xl:    1.50rem;
  --text-2xl:   2.00rem;
  --text-3xl:   3.00rem;
  --text-4xl:   4.50rem;
  --text-5xl:   6.00rem;
  --text-6xl:   8.00rem;
  --text-hero: clamp(5rem, 14vw, 11rem);

  /* --- Spacing --- */
  --space-1:  0.25rem;
  --space-2:  0.50rem;
  --space-3:  0.75rem;
  --space-4:  1.00rem;
  --space-6:  1.50rem;
  --space-8:  2.00rem;
  --space-12: 3.00rem;
  --space-16: 4.00rem;
  --space-24: 6.00rem;
  --space-32: 8.00rem;

  /* --- Layout --- */
  --max-w:       1280px;
  --max-w-prose: 720px;
  --nav-h:       72px;

  /* --- Transitions --- */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.76, 0, 0.24, 1);
  --t-fast:   0.15s;
  --t-base:   0.30s;
  --t-slow:   0.60s;
  --t-enter:  0.80s;
}

/* ============================================================
   BASE RESET & DEFAULTS
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  overflow-x: hidden;
  cursor: none;
}

/* Suppress default cursor on every interactive element so
   the custom crosshair is never doubled by the browser pointer */
a,
button,
input,
textarea,
select,
label,
[role="button"],
[tabindex] {
  cursor: none !important;
}

/* ============================================================
   ENGINEERING GRID BACKGROUND
   Fixed, ultra-subtle, like graph paper / PCB
   ============================================================ */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(var(--border-slate) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-slate) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.018;
}

/* Light-register override */
body.light-page {
  background-color: var(--paper);
  color: var(--ink);
}

body.light-page::before {
  background-image:
    linear-gradient(rgba(26,20,16,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26,20,16,0.06) 1px, transparent 1px);
  opacity: 1;
}

/* ============================================================
   CUSTOM CURSOR
   ============================================================ */
#cursor {
  position: fixed;
  top: 0; left: 0;
  width: 20px; height: 20px;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: transform var(--t-fast) var(--ease-out),
              opacity var(--t-fast) ease;
}

#cursor svg {
  width: 100%; height: 100%;
  transition: transform var(--t-base) var(--ease-out);
}

#cursor.hover svg {
  transform: scale(1.6);
}

#cursor.hover .cursor-line {
  stroke: var(--amber);
}

body.light-page #cursor .cursor-line {
  stroke: var(--ink);
}

/* ============================================================
   PAGE TRANSITION OVERLAY
   ============================================================ */
#page-transition {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  transform-origin: left;
  transform: scaleX(0);
  z-index: 9000;
  pointer-events: none;
}

#page-transition::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 3px; height: 100%;
  background: var(--red);
  transform-origin: top;
}

/* ============================================================
   NAVIGATION
   ============================================================ */
#site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 800;
  display: flex;
  align-items: center;
  padding: 0 var(--space-8);
  transition: background var(--t-base) ease, border-color var(--t-base) ease;
}

#site-nav.scrolled {
  background: rgba(8, 12, 18, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.nav-monogram {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.15em;
  color: var(--amber);
  text-decoration: none;
  margin-right: auto;
  transition: opacity var(--t-fast) ease;
}

.nav-monogram:hover { opacity: 0.7; }

.nav-chapters {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  list-style: none;
}

.nav-chapters a {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--t-fast) ease;
  position: relative;
}

.nav-chapters a::after {
  content: '';
  position: absolute;
  bottom: -4px; left: 0; right: 0;
  height: 1px;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-base) var(--ease-out);
}

.nav-chapters a:hover,
.nav-chapters a.active {
  color: var(--text-primary);
}

.nav-chapters a:hover::after,
.nav-chapters a.active::after {
  transform: scaleX(1);
}

.nav-chapters .nav-arrow {
  color: var(--red);
  font-size: var(--text-base);
  font-family: var(--font-body);
}

/* ============================================================
   LAYOUT UTILITIES
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--space-8);
}

.container--prose {
  max-width: var(--max-w-prose);
}

.section {
  position: relative;
  z-index: 1;
  padding: var(--space-24) 0;
}

.section--flush { padding: 0; }
.section--lg    { padding: var(--space-32) 0; }

/* ============================================================
   TYPOGRAPHY — COMPONENT CLASSES
   ============================================================ */

/* Display — Cormorant */
.display {
  font-family: var(--font-display);
  font-weight: 300;
  line-height: 0.95;
  letter-spacing: -0.02em;
}

.display--hero {
  font-size: var(--text-hero);
  line-height: 0.90;
  font-weight: 300;
}

.display--chapter {
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 300;
  line-height: 1.0;
}

.display--section {
  font-size: clamp(2rem, 4vw, 3.5rem);
  font-weight: 400;
}

.display--pull {
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  font-style: italic;
  font-weight: 300;
  line-height: 1.3;
}

/* Mono — IBM Plex Mono */
.mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.mono--label {
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.mono--chapter-num {
  font-size: var(--text-sm);
  color: var(--red);
  letter-spacing: 0.10em;
}

/* Body — DM Sans */
.body-text {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text-secondary);
}

.body-text--sm {
  font-size: var(--text-sm);
}

/* ============================================================
   GHOST CHAPTER NUMERALS
   ============================================================ */
.ghost-numeral {
  font-family: var(--font-display);
  font-size: clamp(12rem, 30vw, 24rem);
  font-weight: 700;
  color: var(--text-primary);
  opacity: 0.035;
  position: absolute;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

/* ============================================================
   RED RULE
   ============================================================ */
.red-rule {
  display: block;
  width: 60px;
  height: 2px;
  background: var(--red);
  border: none;
  margin: var(--space-6) 0;
}

.red-rule--full {
  width: 100%;
}

.amber-rule {
  display: block;
  height: 1px;
  background: var(--border-amber);
  border: none;
  width: 100%;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-decoration: none;
  padding: 0.85rem 2rem;
  border: none;
  cursor: none;
  transition:
    background var(--t-base) var(--ease-out),
    color var(--t-base) var(--ease-out),
    border-color var(--t-base) var(--ease-out),
    transform var(--t-fast) var(--ease-out);
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--red);
  color: #fff;
}

.btn--primary:hover {
  background: #d94044;
}

.btn--ghost {
  background: transparent;
  color: var(--slate);
  border: 1px solid var(--slate);
}

.btn--ghost:hover {
  background: rgba(107, 143, 191, 0.08);
  border-color: var(--slate);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  transition: border-color var(--t-base) ease;
}

.card:hover {
  border-color: var(--border-amber);
}

/* ============================================================
   TAGS
   ============================================================ */
.tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.25rem 0.6rem;
  display: inline-block;
}

.tag--red   { color: var(--red);   border-color: rgba(200,55,60,0.3);  }
.tag--amber { color: var(--amber); border-color: rgba(168,149,106,0.3); }
.tag--slate { color: var(--slate); border-color: rgba(107,143,191,0.3); }

/* ============================================================
   STATS STRIP
   ============================================================ */
.stats-strip {
  background: var(--paper);
  color: var(--ink);
  padding: var(--space-12) 0;
  position: relative;
  z-index: 1;
}

.stats-strip::before,
.stats-strip::after {
  content: '';
  display: block;
  width: 100%;
  height: 1px;
  background: var(--border-amber);
  position: absolute;
  left: 0;
}

.stats-strip::before { top: 0; }
.stats-strip::after  { bottom: 0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}

.stat-item {
  text-align: center;
  padding: var(--space-8) var(--space-6);
  border-right: 1px solid rgba(26,20,16,0.12);
}

.stat-item:last-child { border-right: none; }

.stat-number {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 400;
  color: var(--red);
  line-height: 1;
  display: block;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  color: var(--ink);
  opacity: 0.6;
  margin-top: var(--space-2);
  display: block;
  text-transform: uppercase;
}

/* ============================================================
   SCROLL REVEAL ANIMATIONS
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity var(--t-enter) var(--ease-out),
    transform var(--t-enter) var(--ease-out);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal-left {
  opacity: 0;
  transform: translateX(-32px);
  transition:
    opacity var(--t-enter) var(--ease-out),
    transform var(--t-enter) var(--ease-out);
}

.reveal-left.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Staggered children */
.stagger > * { transition-delay: 0s; }
.stagger > *:nth-child(1) { transition-delay: 0.05s; }
.stagger > *:nth-child(2) { transition-delay: 0.15s; }
.stagger > *:nth-child(3) { transition-delay: 0.25s; }
.stagger > *:nth-child(4) { transition-delay: 0.35s; }
.stagger > *:nth-child(5) { transition-delay: 0.45s; }

/* ============================================================
   PULSE DOT
   ============================================================ */
.pulse-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--amber);
  margin-left: var(--space-2);
  vertical-align: middle;
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-field {
  position: relative;
  margin-bottom: var(--space-8);
}

.form-field label {
  position: absolute;
  top: 1rem; left: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  pointer-events: none;
  transition:
    top var(--t-base) var(--ease-out),
    font-size var(--t-base) var(--ease-out),
    color var(--t-base) var(--ease-out);
}

.form-field input,
.form-field textarea {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  padding: 1rem 0 0.5rem;
  outline: none;
  resize: none;
  cursor: none;
  transition:
    border-color var(--t-base) ease,
    box-shadow var(--t-base) ease;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field input:not(:placeholder-shown),
.form-field textarea:not(:placeholder-shown) {
  border-bottom-color: var(--red);
  box-shadow: 0 2px 0 -1px rgba(200, 55, 60, 0.10);
}

.form-field input:focus ~ label,
.form-field input:not(:placeholder-shown) ~ label,
.form-field textarea:focus ~ label,
.form-field textarea:not(:placeholder-shown) ~ label {
  top: -0.75rem;
  font-size: 0.60rem;
  color: var(--red);
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: transparent;
}

/* ============================================================
   CHAPTER OPENER
   ============================================================ */
.chapter-opener {
  min-height: 60vh;
  display: flex;
  align-items: flex-end;
  padding-top: calc(var(--nav-h) + var(--space-16));
  padding-bottom: var(--space-16);
  position: relative;
  overflow: hidden;
}

.chapter-opener .container {
  position: relative;
  z-index: 2;
}

/* ============================================================
   COLOPHON
   ============================================================ */
.colophon {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  color: var(--text-muted);
  text-align: center;
  padding: var(--space-8) 0 var(--space-6);
}

/* ============================================================
   HAMBURGER BUTTON — hidden on desktop
   ============================================================ */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  padding: 6px;
  flex-shrink: 0;
  z-index: 900;
  position: relative;
}

.nav-hamburger__line {
  display: block;
  width: 22px;
  height: 1.5px;
  background: var(--text-primary);
  transform-origin: center;
  transition:
    transform var(--t-base) var(--ease-out),
    opacity var(--t-base) ease;
}

/* X state when menu is open */
.nav-hamburger[aria-expanded="true"] .nav-hamburger__line:first-child {
  transform: translateY(3.25px) rotate(45deg);
}

.nav-hamburger[aria-expanded="true"] .nav-hamburger__line:last-child {
  transform: translateY(-3.25px) rotate(-45deg);
}

/* On the CV (light) page the hamburger lines invert to stay on dark nav */

/* ============================================================
   MOBILE MENU OVERLAY
   ============================================================ */
.mobile-menu {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 18, 0.98);
  z-index: 750;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--nav-h) + var(--space-8)) var(--space-8) var(--space-16);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition:
    opacity 0.40s var(--ease-out),
    transform 0.40s var(--ease-out);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.mobile-menu.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.mobile-menu__list {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.mobile-menu__list li {
  border-bottom: 1px solid var(--border);
}

.mobile-menu__list li:first-child {
  border-top: 1px solid var(--border);
}

.mobile-menu__list a {
  display: flex;
  align-items: baseline;
  gap: var(--space-6);
  padding: var(--space-5) 0;
  text-decoration: none;
  color: var(--text-secondary);
  transition:
    color var(--t-fast) ease,
    padding-left var(--t-base) var(--ease-out);
}

.mobile-menu__list a:hover,
.mobile-menu__list a.active {
  color: var(--text-primary);
  padding-left: var(--space-2);
}

.mobile-menu__num {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 300;
  color: var(--text-muted);
  min-width: 52px;
  line-height: 1;
  transition: color var(--t-base) ease;
}

.mobile-menu__list a:hover .mobile-menu__num,
.mobile-menu__list a.active .mobile-menu__num {
  color: var(--red);
}

.mobile-menu__title {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: 400;
}

.mobile-menu__contact .mobile-menu__num {
  font-family: var(--font-body);
  font-size: 1.4rem;
  font-weight: 300;
  min-width: 52px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  :root {
    --nav-h: 60px;
  }

  /* Hide desktop chapter list, show hamburger */
  .nav-chapters {
    display: none;
  }

  .nav-hamburger {
    display: flex;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stat-item:nth-child(2) { border-right: none; }
  .stat-item:nth-child(3) { border-right: 1px solid rgba(26,20,16,0.12); }

  .ghost-numeral { font-size: clamp(8rem, 40vw, 16rem); }

  .display--hero { font-size: clamp(4rem, 18vw, 7rem); }

  .container { padding: 0 var(--space-6); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   TOUCH DEVICE — hide custom cursor, restore native cursor
   ============================================================ */
@media (hover: none) {
  #cursor {
    display: none !important;
  }

  body,
  a,
  button,
  input,
  textarea,
  select,
  label,
  [role="button"],
  [tabindex] {
    cursor: auto !important;
  }
}
