/* ============================================================
   STYLE.CSS — Base styles, design tokens, reset, typography
   ------------------------------------------------------------
   Two-font system:
     • Serif (warnock-pro / Palatino) for editorial body & display
     • System sans for UI chrome (buttons, labels, nav, code)

   Two themes:
     • Light: warm cream / sepia (paper)
     • Dark : warm charcoal / aged-parchment-inverted
   ============================================================ */

:root {
  /* ── Surfaces (warm paper palette) ─────────────────────── */
  --bg-primary:    #f5f0e8;
  --bg-secondary:  #ede7db;
  --bg-accent:     #e0d5c1;
  --bg-card:       #fbf8f3;
  --surface-1:     #fbf8f3;
  --surface-2:     #f2ebdf;
  --surface-3:     #e6dac7;

  /* ── Text ──────────────────────────────────────────────── */
  --text-primary:   #1f1a14;
  --text-secondary: #4a4237;
  --text-muted:     #756a5b;

  /* ── Accent (warm espresso) ────────────────────────────── */
  --accent:         #2b231a;
  --accent-hover:   #46372a;
  --accent-light:   rgba(43, 35, 26, 0.10);
  --accent-warm:    #9b6f3f;
  --accent-warm-soft: rgba(155, 111, 63, 0.16);
  --ring:           rgba(43, 35, 26, 0.32);

  /* ── Status / feedback ─────────────────────────────────── */
  --success:        #4f7a3a;
  --success-bg:     rgba(79, 122, 58, 0.12);
  --error:          #a04438;
  --error-bg:       rgba(160, 68, 56, 0.12);

  /* ── Code ──────────────────────────────────────────────── */
  --code-bg:        #f1e9dc;
  --code-text:      #201a13;
  --code-inline-bg: #ece3d5;
  --code-border:    #d7cab6;

  /* ── GitHub graph cells ────────────────────────────────── */
  --github-cell-empty: #ddd4c6;
  --github-cell-1:  rgba(43, 35, 26, 0.16);
  --github-cell-2:  rgba(43, 35, 26, 0.34);
  --github-cell-3:  rgba(43, 35, 26, 0.58);
  --github-cell-4:  rgba(43, 35, 26, 0.80);

  /* ── Borders & shadows ─────────────────────────────────── */
  --border:         #d4c9b8;
  --border-light:   #e5ded2;
  --border-strong:  #b9ab93;
  --shadow-sm:      0 1px 3px rgba(31, 26, 20, 0.06);
  --shadow-md:      0 4px 14px rgba(31, 26, 20, 0.08);
  --shadow-lg:      0 12px 32px rgba(31, 26, 20, 0.10);
  --shadow-hover:   0 10px 28px rgba(31, 26, 20, 0.12);

  /* ── Typography ────────────────────────────────────────── */
  /* Display + body: warm editorial serif */
  --font-serif: warnock-pro, Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif;
  /* UI chrome: clean system sans */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Code */
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", "Roboto Mono", Menlo, Consolas, monospace;
  /* Back-compat alias used by older rules */
  --font-body: var(--font-serif);

  --font-size-xs:   0.75rem;
  --font-size-sm:   0.875rem;
  --font-size-base: 1.125rem;
  --font-size-lg:   1.25rem;
  --font-size-xl:   1.5rem;
  --font-size-2xl:  2rem;
  --font-size-3xl:  2.5rem;
  --font-size-4xl:  3.25rem;
  --font-size-5xl:  4.25rem;

  --line-height-tight:   1.15;
  --line-height-snug:    1.4;
  --line-height-normal:  1.62;
  --line-height-relaxed: 1.78;
  --letter-spacing-tight: -0.022em;
  --letter-spacing-wide:  0.08em;
  --measure: 64ch;
  --measure-wide: 76ch;

  /* ── Spacing ───────────────────────────────────────────── */
  --space-xs:  0.25rem;
  --space-sm:  0.5rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* ── Sidebar ───────────────────────────────────────────── */
  --sidebar-w:        72px;
  --sidebar-expanded: 248px;

  /* ── Layout ────────────────────────────────────────────── */
  --max-width:        1080px;
  --border-radius-sm: 4px;
  --border-radius:    8px;
  --border-radius-lg: 14px;
  --border-radius-xl: 20px;

  /* ── Motion ────────────────────────────────────────────── */
  --ease-out:        cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out:     cubic-bezier(0.65, 0, 0.35, 1);
  --transition-fast: 160ms var(--ease-out);
  --transition-base: 280ms var(--ease-out);
  --transition-slow: 500ms var(--ease-out);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-serif);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--text-primary);
  background:
    radial-gradient(130% 105% at 0% 0%, var(--accent-light), transparent 62%),
    radial-gradient(90% 70% at 100% 100%, rgba(43, 35, 26, 0.05), transparent 66%),
    var(--bg-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "liga" 1, "kern" 1;
  font-variant-ligatures: common-ligatures;
  min-height: 100vh;
}

/* Allow normal scroll on blog/404 pages */
.blog-page { overflow: auto; }

img, svg { max-width: 100%; height: auto; display: block; }

a {
  font-family: inherit;
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  line-height: var(--line-height-tight);
  font-weight: 400;
  letter-spacing: var(--letter-spacing-tight);
  color: var(--text-primary);
}

p, li, blockquote, cite, figcaption {
  font-family: var(--font-serif);
}

ul, ol { list-style: none; }

/* UI chrome defaults to sans */
button,
input,
textarea,
select,
.ui,
.nav,
.label,
[class*="__label"],
[class*="__date"],
[class*="__year"],
[class*="__meta"],
[class*="__tag"],
[class*="__category"] {
  font-family: var(--font-sans);
}

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

code, kbd, pre, samp { font-family: var(--font-mono); }

/* Selection */
::selection {
  background: var(--accent);
  color: var(--bg-primary);
}

/* ════════════════════════════════════════════════════════════
   ACCESSIBILITY
════════════════════════════════════════════════════════════ */

/* Skip-to-content link */
.skip-link {
  position: fixed;
  top: -100px;
  left: var(--space-md);
  z-index: 10000;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--bg-primary);
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  border-radius: var(--border-radius);
  transition: top var(--transition-fast);
}
.skip-link:focus,
.skip-link:focus-visible {
  top: var(--space-md);
  color: var(--bg-primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

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

/* Universal focus ring */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.sidebar__link:focus-visible,
.mobile-nav-link:focus-visible,
.blog-card__inner:focus-visible,
.contact__social:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
  border-radius: var(--border-radius);
}

/* ════════════════════════════════════════════════════════════
   PAPER TEXTURE (subtle noise overlay)
════════════════════════════════════════════════════════════ */
body::after {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 9999; opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat; background-size: 256px;
}

/* ════════════════════════════════════════════════════════════
   SCROLL CONTAINER (home page)
════════════════════════════════════════════════════════════ */
.scroll-container {
  position: fixed;
  top: 0; bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -ms-overflow-style: none;
  scrollbar-width: none;
  scroll-behavior: smooth;
}
.scroll-container::-webkit-scrollbar { display: none; }

/* ════════════════════════════════════════════════════════════
   SECTIONS — base
════════════════════════════════════════════════════════════ */
.section {
  min-height: 100vh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: var(--space-4xl) var(--space-3xl) var(--space-2xl);
  overflow: hidden;
  isolation: isolate;
}

.section__inner {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Section eyebrow + title pair */
.section__eyebrow {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--font-size-xs);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-warm);
  margin-bottom: var(--space-md);
}

.section__title {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4.2vw, 3rem);
  color: var(--text-primary);
  margin-bottom: var(--space-2xl);
  position: relative;
  display: inline-block;
  letter-spacing: var(--letter-spacing-tight);
}
.section__title::after {
  content: "";
  display: block;
  width: 56px;
  height: 2px;
  background: var(--accent);
  margin-top: var(--space-md);
  border-radius: 2px;
}

/* ════════════════════════════════════════════════════════════
   BUTTONS
════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  letter-spacing: 0.04em;
  font-weight: 500;
  padding: 0.78rem 1.5rem;
  border-radius: var(--border-radius);
  transition: background var(--transition-base),
              color var(--transition-base),
              border-color var(--transition-base),
              transform var(--transition-fast),
              box-shadow var(--transition-base);
  cursor: pointer;
  border: 1.5px solid transparent;
  white-space: nowrap;
  will-change: transform;
}

.btn--primary {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}
.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--bg-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn--secondary {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}
.btn--secondary:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn--ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.btn--full { width: 100%; }
.btn:active { transform: scale(0.97); transition-duration: 80ms !important; }
.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.65;
  cursor: not-allowed;
  pointer-events: none;
}

/* ════════════════════════════════════════════════════════════
   FORMS
════════════════════════════════════════════════════════════ */
.form__group { margin-bottom: var(--space-lg); }

.form__label {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-weight: 600;
}

.form__input {
  width: 100%;
  padding: 0.8rem 1rem;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1.5px solid var(--border);
  border-radius: var(--border-radius);
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast),
              background var(--transition-fast);
  outline: none;
}
.form__input::placeholder { color: var(--text-muted); }
.form__input:hover { border-color: var(--border-strong); }
.form__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form__input:focus-visible {
  box-shadow: 0 0 0 3px var(--ring);
}
.form__input[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 3px var(--error-bg);
}
.form__textarea { resize: vertical; min-height: 130px; }

.form__error {
  display: block;
  margin-top: var(--space-xs);
  font-family: var(--font-sans);
  font-size: var(--font-size-xs);
  color: var(--error);
  min-height: 1em;
}

.form__status {
  margin-top: var(--space-md);
  padding: 0.7rem 1rem;
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  border-radius: var(--border-radius);
  border: 1px solid transparent;
}
.form__status--success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
}
.form__status--error {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error);
}

/* ════════════════════════════════════════════════════════════
   REVEAL / SECTION ANIMATIONS
════════════════════════════════════════════════════════════ */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease-out),
              transform 0.6s var(--ease-out);
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal--delay-1 { transition-delay: 0.06s; }
.reveal--delay-2 { transition-delay: 0.12s; }
.reveal--delay-3 { transition-delay: 0.18s; }
.reveal--delay-4 { transition-delay: 0.24s; }
.reveal--delay-5 { transition-delay: 0.30s; }

.section--entering .section__inner {
  animation: sectionEnter 0.6s var(--ease-out) both;
}
.section--leaving .section__inner {
  animation: sectionLeave 0.36s ease-in both;
}
@keyframes sectionEnter {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes sectionLeave {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-16px); }
}

.section--entering .section__title::after {
  animation: lineGrow 0.5s 0.25s var(--ease-out) both;
}
@keyframes lineGrow {
  from { transform: scaleX(0); transform-origin: left; }
  to   { transform: scaleX(1); transform-origin: left; }
}

/* ════════════════════════════════════════════════════════════
   MICRO-INTERACTIONS
════════════════════════════════════════════════════════════ */
a.underline-hover {
  position: relative;
  text-decoration: none;
}
a.underline-hover::after {
  content: '';
  position: absolute;
  left: 0; bottom: -1px;
  width: 100%; height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--transition-base);
}
a.underline-hover:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

.sidebar__link.active .sidebar__icon {
  transform: scale(1.12);
  transition: transform var(--transition-fast);
}

/* ════════════════════════════════════════════════════════════
   FOOTER
════════════════════════════════════════════════════════════ */
.footer {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: var(--space-md) var(--space-xl);
  text-align: center;
  font-family: var(--font-sans);
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  letter-spacing: 0.06em;
  border-top: 1px solid var(--border-light);
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE BASE
════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root {
    --font-size-5xl: 3.25rem;
    --font-size-4xl: 2.75rem;
    --sidebar-w: 64px;
  }
  .section { padding: var(--space-3xl) var(--space-2xl) var(--space-2xl); }
}

@media (max-width: 768px) {
  :root {
    --font-size-5xl: 2.75rem;
    --font-size-4xl: 2.25rem;
    --font-size-3xl: 2rem;
  }
  .scroll-container { left: 0; }
  .section { padding: var(--space-3xl) var(--space-lg) var(--space-xl); }
}

@media (max-width: 480px) {
  :root {
    --font-size-5xl: 2.25rem;
    --font-size-4xl: 1.875rem;
    --font-size-3xl: 1.625rem;
    --font-size-2xl: 1.4rem;
  }
  .section { padding: var(--space-2xl) var(--space-md) var(--space-xl); }
  .btn { padding: 0.7rem 1.2rem; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
  .scroll-container { scroll-snap-type: none; scroll-behavior: auto; }
}

/* Print */
@media print {
  body { overflow: visible; background: #fff; color: #000; }
  body::after { display: none; }
  .sidebar, .menu-btn, .mobile-theme-btn,
  .mobile-overlay, .skip-link,
  .hero__scroll-hint, .footer,
  .contact__form { display: none !important; }
  .scroll-container { position: static; left: 0; overflow: visible; scroll-snap-type: none; }
  .section { min-height: auto; page-break-inside: avoid; padding: 1.5rem 0; scroll-snap-align: none; }
  .section::before, .section__bg-decoration { display: none; }
  a { color: inherit; text-decoration: underline; }
}

/* ════════════════════════════════════════════════════════════
   DARK THEME — warm aged-parchment-inverted (deep espresso)
════════════════════════════════════════════════════════════ */
html.theme-transitioning,
html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition:
    background-color 320ms ease,
    border-color     320ms ease,
    color            320ms ease,
    box-shadow       320ms ease !important;
}

[data-theme="dark"] {
  /* Surfaces — warm dark browns, NOT cool slate */
  --bg-primary:    #1a1612;
  --bg-secondary:  #15110d;
  --bg-accent:     #251e16;
  --bg-card:       #221c14;
  --surface-1:     #221c14;
  --surface-2:     #2a2218;
  --surface-3:     #34291d;

  /* Text — warm cream, high contrast */
  --text-primary:   #f0e8d8;
  --text-secondary: #c9bfa8;
  --text-muted:     #968b75;

  /* Accent — soft cream, replaces cold blue */
  --accent:         #e8d9b8;
  --accent-hover:   #f3e6c5;
  --accent-light:   rgba(232, 217, 184, 0.12);
  --accent-warm:    #c9a373;
  --accent-warm-soft: rgba(201, 163, 115, 0.18);
  --ring:           rgba(232, 217, 184, 0.42);

  /* Status */
  --success:        #93c47d;
  --success-bg:     rgba(147, 196, 125, 0.14);
  --error:          #d98a7e;
  --error-bg:       rgba(217, 138, 126, 0.14);

  /* Code */
  --code-bg:        #15100a;
  --code-text:      #ede4cf;
  --code-inline-bg: #251e16;
  --code-border:    #3a2f22;

  /* GitHub graph */
  --github-cell-empty: #2d251a;
  --github-cell-1:  rgba(232, 217, 184, 0.20);
  --github-cell-2:  rgba(232, 217, 184, 0.42);
  --github-cell-3:  rgba(232, 217, 184, 0.66);
  --github-cell-4:  rgba(232, 217, 184, 0.92);

  /* Borders & shadows */
  --border:         #3a2f22;
  --border-light:   #2d251a;
  --border-strong:  #4d3e2c;
  --shadow-sm:      0 1px 3px  rgba(0, 0, 0, 0.45);
  --shadow-md:      0 4px 14px rgba(0, 0, 0, 0.55);
  --shadow-lg:      0 12px 32px rgba(0, 0, 0, 0.65);
  --shadow-hover:   0 10px 28px rgba(0, 0, 0, 0.55);

  color-scheme: dark;
}

[data-theme="dark"] body {
  background:
    radial-gradient(130% 110% at 0% 0%, rgba(232, 217, 184, 0.10), transparent 62%),
    radial-gradient(100% 80% at 100% 100%, rgba(0, 0, 0, 0.55), transparent 68%),
    var(--bg-primary);
}

[data-theme="dark"] body::after {
  opacity: 0.04;
  mix-blend-mode: overlay;
}

[data-theme="dark"] .timeline::before {
  background: linear-gradient(
    to bottom,
    var(--accent) 0%,
    var(--border) 100%
  );
}

[data-theme="dark"] ::selection {
  background: var(--accent);
  color: var(--bg-primary);
}
