/* ============================================================
   STYLE.CSS — Base styles, variables, reset, typography
   ============================================================ */

:root {
  /* Paper background palette — warm browns stay here */
  --bg-primary:    #f5f0e8;
  --bg-secondary:  #ede7db;
  --bg-accent:     #e0d5c1;
  --bg-card:       #fbf8f3;
  --surface-1:     #fbf8f3;
  --surface-2:     #f2ebdf;
  --surface-3:     #e6dac7;

  /* Text */
  --text-primary:   #111111;
  --text-secondary: #4a4237;
  --text-muted:     #6d6458;

  /* Accent */
  --accent:         #2b231a;
  --accent-hover:   #46372a;
  --accent-light:   rgba(43, 35, 26, 0.10);
  --accent-warm:    #9b6f3f;
  --ring:           rgba(43, 35, 26, 0.28);

  /* Code */
  --code-bg:        #f1e9dc;
  --code-text:      #201a13;
  --code-inline-bg: #ece3d5;
  --code-border:    #d7cab6;
  --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;
  --shadow-sm:      0 1px 3px rgba(17, 17, 17, 0.05);
  --shadow-md:      0 4px 12px rgba(17, 17, 17, 0.08);
  --shadow-lg:      0 8px 30px rgba(17, 17, 17, 0.10);
  --shadow-hover:   0 8px 25px rgba(17, 17, 17, 0.12);

  /* Typography — exact font stack the user specified */
  --font-body: warnock-pro, Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, 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.75rem;
  --font-size-4xl:  3.5rem;
  --font-size-5xl:  4.5rem;

  --line-height-tight:   1.15;
  --line-height-normal:  1.66;
  --line-height-relaxed: 1.86;
  --letter-spacing-tight: -0.02em;
  --letter-spacing-wide:  0.08em;
  --measure: 68ch;
  --measure-wide: 78ch;

  /* 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:        64px;
  --sidebar-expanded: 220px;

  /* Layout */
  --max-width:        1060px;
  --border-radius:    6px;
  --border-radius-lg: 12px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 280ms ease;
  --transition-slow: 500ms ease;
}

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

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

body {
  font-family: var(--font-body);
  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;
  /* enable font features for Palatino/warnock-pro */
  font-feature-settings: "liga" 1, "kern" 1;
  font-variant-ligatures: common-ligatures;
}

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

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

a {
  font-family: var(--font-body);
  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-body);
  line-height: var(--line-height-tight);
  font-weight: 400;
  letter-spacing: var(--letter-spacing-tight);
}

p, li, span, label, td, th, blockquote, cite {
  font-family: var(--font-body);
}

ul, ol { list-style: none; }

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font-family: var(--font-body);
}

/* ── Subtle paper 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 ─────────────────────────────────────── */
.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-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;
}

.section__inner {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
}

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

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.72rem 1.6rem;
  font-weight: 500;
  border-radius: var(--border-radius);
  transition: all var(--transition-base);
  cursor: pointer;
  border: none;
  white-space: nowrap;
}

a:focus-visible,
button: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);
}

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

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

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

.btn--full { width: 100%; }

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

.form__label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
}

.form__input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  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);
  outline: none;
}
.form__input::placeholder { color: var(--text-muted); font-family: var(--font-body); }
.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__textarea { resize: vertical; min-height: 120px; }

/* ── Reveal animations ───────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.reveal--delay-1 { transition-delay: 0.08s; }
.reveal--delay-2 { transition-delay: 0.16s; }
.reveal--delay-3 { transition-delay: 0.24s; }
.reveal--delay-4 { transition-delay: 0.32s; }
.reveal--delay-5 { transition-delay: 0.40s; }

/* ── Section enter / exit animations ─────────────────────── */
/*  Each <section> fades + slides in when it becomes active.   */
.section {
  --section-ease: cubic-bezier(0.22, 1, 0.36, 1);
  /* initially invisible so the first snap-into-view triggers the enter */
}

/* State applied by scroll.js when a section enters viewport */
.section.section--entering .section__inner {
  animation: sectionEnter 0.65s var(--section-ease) both;
}
.section.section--leaving .section__inner {
  animation: sectionLeave 0.40s ease-in both;
}

@keyframes sectionEnter {
  from {
    opacity: 0;
    transform: translateY(32px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes sectionLeave {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* ── Interactive micro-interactions ──────────────────────── */

/* Buttons — springy press */
.btn {
  will-change: transform;
}
.btn:active {
  transform: scale(0.97) translateY(0) !important;
  transition-duration: 80ms !important;
}

/* Links — underline crawl */
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;
}

/* Input focus lift */
.form__input:focus {
  transform: translateY(-1px);
}

/* Section title — line grows on section enter */
.section--entering .section__title::after {
  animation: lineGrow 0.5s 0.25s var(--section-ease) both;
}
@keyframes lineGrow {
  from { transform: scaleX(0); transform-origin: left; }
  to   { transform: scaleX(1); transform-origin: left; }
}

/* Sidebar link — active indicator slides in */
.sidebar__link.active .sidebar__icon {
  transform: scale(1.12);
  transition: transform var(--transition-fast);
}

/* Scroll hint — already has bounce; add opacity pulse */
.hero__scroll-hint {
  animation: scrollHintPulse 3s ease-in-out infinite;
}
@keyframes scrollHintPulse {
  0%, 100% { opacity: 0.55; transform: translateY(0); }
  50%       { opacity: 1;   transform: translateY(6px); }
}

/* ── Footer ──────────────────────────────────────────────── */
.footer {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: var(--space-lg) var(--space-xl);
  text-align: center;
  font-family: var(--font-body);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --font-size-5xl: 3.25rem; --font-size-4xl: 2.75rem; }
  .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; /* no sidebar on mobile */
  }
  .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.75rem;
    --font-size-2xl: 1.5rem;
  }
  .section { padding: var(--space-2xl) var(--space-md) var(--space-xl); }
}

@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;
  }
}

/* ════════════════════════════════════════════════════════════
   DARK THEME — deep espresso / aged-parchment-inverted
   Activated via  data-theme="dark"  on <html>.
   Not pure black — warm dark browns throughout.
════════════════════════════════════════════════════════════ */

/* Smooth colour transition when theme switches */
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"] {
  /* ── Backgrounds ──────────────────────────────────────── */
  --bg-primary:    #12151b;
  --bg-secondary:  #0d1016;
  --bg-accent:     #1b212c;
  --bg-card:       #171c24;
  --surface-1:     #171c24;
  --surface-2:     #1f2631;
  --surface-3:     #283140;

  /* ── Text ─────────────────────────────────────────────── */
  --text-primary:   #e8edf4;
  --text-secondary: #bcc5d4;
  --text-muted:     #98a3b5;

  /* ── Accent ───────────────────────────────────────────── */
  --accent:         #a8bddb;
  --accent-hover:   #c1d2e8;
  --accent-light:   rgba(168, 189, 219, 0.18);
  --accent-warm:    #b2a28e;
  --ring:           rgba(193, 210, 232, 0.38);

  /* Code */
  --code-bg:        #0f141c;
  --code-text:      #dce5f3;
  --code-inline-bg: #1b2230;
  --code-border:    #2b3546;
  --github-cell-empty: #263041;
  --github-cell-1:  rgba(168, 189, 219, 0.24);
  --github-cell-2:  rgba(168, 189, 219, 0.45);
  --github-cell-3:  rgba(168, 189, 219, 0.68);
  --github-cell-4:  rgba(168, 189, 219, 0.92);

  /* ── Borders & shadows ────────────────────────────────── */
  --border:         #303949;
  --border-light:   #252d3a;
  --shadow-sm:      0 1px 3px  rgba(0, 0, 0, 0.35);
  --shadow-md:      0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg:      0 8px 30px rgba(0, 0, 0, 0.55);
  --shadow-hover:   0 8px 25px rgba(0, 0, 0, 0.50);

  color-scheme: dark;
}

/* Dark-mode paper noise: slightly stronger to read on dark bg */
[data-theme="dark"] body::after {
  opacity: 0.045;
  mix-blend-mode: overlay;
}

[data-theme="dark"] body {
  background:
    radial-gradient(130% 110% at 0% 0%, rgba(168, 189, 219, 0.16), transparent 62%),
    radial-gradient(100% 80% at 100% 100%, rgba(0, 0, 0, 0.30), transparent 68%),
    var(--bg-primary);
}

/* Sidebar border adapts */
[data-theme="dark"] .sidebar {
  border-right-color: var(--border);
}

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

/* Selection colour */
[data-theme="dark"] ::selection {
  background: rgba(168, 189, 219, 0.35);
  color: var(--text-primary);
}
