/* style.css — design tokens + components for vivianmarsh.com */

/* ============ TYPE SCALE ============ */
:root {
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.25rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 4.5rem);
  --text-hero: clamp(2.75rem, 0.8rem + 6vw, 6rem);

  /* ============ SPACING (4px base) ============ */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* ============ RADIUS ============ */
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  --radius-xl: 0.75rem;
  --radius-full: 9999px;

  /* ============ TRANSITIONS ============ */
  --transition-interactive: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* ============ CONTENT WIDTHS ============ */
  --content-narrow: 640px;
  --content-default: 1000px;
  --content-wide: 1220px;
  --content-full: 100%;
  --content-prose: 68ch;

  /* ============ FONTS ============ */
  --font-display: 'Playfair Display', 'Iowan Old Style', Georgia, serif;
  --font-body: 'Source Sans 3', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;
}

/* ============ COLOR — LIGHT (default) ============ */
:root,
[data-theme='light'] {
  --color-bg: #f6f3ee;
  --color-surface: #fbf9f5;
  --color-surface-2: #fdfcfa;
  --color-surface-offset: #efebe2;
  --color-surface-offset-2: #e7e1d5;
  --color-surface-dynamic: #ddd4c3;
  --color-divider: #ddd4c2;
  --color-border: #cec3ac;

  --color-text: #1d1b17;
  --color-text-muted: #6c6559;
  --color-text-faint: #a89f8c;
  --color-text-inverse: #f8f5ee;

  --color-primary: #7a3626;
  --color-primary-hover: #5c2a1c;
  --color-primary-active: #431e14;
  --color-primary-highlight: #e6d5ca;

  --color-warning: #8a5a1e;
  --color-error: #8a2f2f;
  --color-success: #3f6a3a;

  --shadow-sm: 0 1px 2px oklch(0.2 0.02 60 / 0.07);
  --shadow-md: 0 6px 16px oklch(0.2 0.02 60 / 0.09);
  --shadow-lg: 0 16px 40px oklch(0.2 0.02 60 / 0.14);
}

/* ============ COLOR — DARK ============ */
[data-theme='dark'] {
  --color-bg: #15130f;
  --color-surface: #1b1815;
  --color-surface-2: #201c18;
  --color-surface-offset: #1e1a15;
  --color-surface-offset-2: #251f19;
  --color-surface-dynamic: #2d2620;
  --color-divider: #2a2420;
  --color-border: #3b332a;

  --color-text: #ece6da;
  --color-text-muted: #a89e8b;
  --color-text-faint: #6f6656;
  --color-text-inverse: #211d17;

  --color-primary: #d18b6d;
  --color-primary-hover: #e0a486;
  --color-primary-active: #edbb9d;
  --color-primary-highlight: #3d2c22;

  --color-warning: #cc9a4f;
  --color-error: #d17575;
  --color-success: #7fae74;

  --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.35);
  --shadow-md: 0 6px 16px oklch(0 0 0 / 0.4);
  --shadow-lg: 0 16px 40px oklch(0 0 0 / 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg: #15130f;
    --color-surface: #1b1815;
    --color-surface-2: #201c18;
    --color-surface-offset: #1e1a15;
    --color-surface-offset-2: #251f19;
    --color-surface-dynamic: #2d2620;
    --color-divider: #2a2420;
    --color-border: #3b332a;
    --color-text: #ece6da;
    --color-text-muted: #a89e8b;
    --color-text-faint: #6f6656;
    --color-text-inverse: #211d17;
    --color-primary: #d18b6d;
    --color-primary-hover: #e0a486;
    --color-primary-active: #edbb9d;
    --color-primary-highlight: #3d2c22;
    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.35);
    --shadow-md: 0 6px 16px oklch(0 0 0 / 0.4);
    --shadow-lg: 0 16px 40px oklch(0 0 0 / 0.5);
  }
}

/* ============ GRAIN TEXTURE (subtle, focal areas only) ============ */
.grain {
  position: absolute;
  inset: 0;
  opacity: 0.05;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============ LAYOUT PRIMITIVES ============ */
.container {
  max-width: var(--content-default);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.container--wide {
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.container--prose {
  max-width: var(--content-prose);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.section {
  padding-block: clamp(var(--space-16), 9vw, var(--space-32));
}
.section--tight {
  padding-block: clamp(var(--space-10), 5vw, var(--space-16));
}

/* ============ TYPOGRAPHY ELEMENTS ============ */
body {
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
}
.label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-text-faint);
}
h1,
h2,
h3,
.font-display {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--color-text);
}
h1 {
  font-size: var(--text-hero);
  font-weight: 500;
  letter-spacing: -0.01em;
}
h2 {
  font-size: var(--text-2xl);
  font-weight: 500;
}
h3 {
  font-size: var(--text-lg);
  font-weight: 600;
}
p {
  color: var(--color-text);
}
.lede {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  line-height: 1.55;
  max-width: 46ch;
}
.prose {
  max-width: var(--content-prose);
  font-size: var(--text-base);
  line-height: 1.75;
}
.prose p {
  margin-bottom: var(--space-6);
  max-width: 100%;
}
.prose p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 3.4em;
  float: left;
  line-height: 0.85;
  padding-right: var(--space-2);
  padding-top: var(--space-1);
  font-weight: 600;
  color: var(--color-primary);
}
.pull {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-lg);
  line-height: 1.5;
  color: var(--color-text);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  padding-block: var(--space-6);
  margin-block: var(--space-8);
}
a {
  color: var(--color-primary);
  text-decoration: none;
}
a.text-link {
  text-decoration: underline;
  text-decoration-color: oklch(from var(--color-primary) l c h / 0.35);
  text-underline-offset: 3px;
}
a.text-link:hover {
  text-decoration-color: currentColor;
}

/* ============ HEADER / NAV ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: oklch(from var(--color-bg) l c h / 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid oklch(from var(--color-text) l c h / 0.08);
  transition:
    transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.header--hidden {
  transform: translateY(-100%);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-4);
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text);
}
.brand svg {
  width: 34px;
  height: 34px;
  color: var(--color-primary);
}
.brand-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.nav {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}
.nav-links {
  display: flex;
  gap: var(--space-6);
}
.nav-links a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: 500;
}
.nav-links a:hover,
.nav-links a[aria-current='page'] {
  color: var(--color-primary);
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  border: 1px solid oklch(from var(--color-text) l c h / 0.12);
}
.theme-toggle:hover {
  color: var(--color-primary);
  border-color: oklch(from var(--color-primary) l c h / 0.4);
}
.theme-toggle svg {
  width: 17px;
  height: 17px;
}
.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  color: var(--color-text);
}
.nav-toggle svg {
  width: 22px;
  height: 22px;
}

/* ============ SKIP LINK ============ */
.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--space-2);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  z-index: 100;
}
.skip-link:focus {
  left: var(--space-2);
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
}
.btn-ghost {
  border-color: oklch(from var(--color-text) l c h / 0.18);
  color: var(--color-text);
}
.btn-ghost:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ============ HERO ============ */
.hero {
  padding-block: clamp(var(--space-16), 10vw, var(--space-32)) clamp(var(--space-12), 7vw, var(--space-24));
  position: relative;
  overflow: hidden;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: var(--space-16);
  align-items: center;
  max-width: var(--content-wide);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.hero-copy h1 {
  margin-block: var(--space-5) var(--space-6);
}
.hero-actions {
  display: flex;
  gap: var(--space-4);
  margin-top: var(--space-8);
  flex-wrap: wrap;
}
.hero-portrait {
  position: relative;
  justify-self: end;
}
.hero-portrait-frame {
  width: min(360px, 100%);
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.hero-portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hero-portrait-rule {
  position: absolute;
  right: calc(-1 * var(--space-6));
  top: 12%;
  bottom: 12%;
  width: 2px;
  background: var(--color-primary);
  opacity: 0.55;
}

/* ============ SECTION HEADERS ============ */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-10);
  flex-wrap: wrap;
}
.section-head h2 {
  margin-top: var(--space-2);
}

/* ============ ESSAY CARDS ============ */
.essay-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-8);
}
.essay-card {
  display: flex;
  flex-direction: column;
  padding: var(--space-8);
  background: var(--color-surface);
  border: 1px solid oklch(from var(--color-text) l c h / 0.08);
  border-radius: var(--radius-lg);
  min-height: 100%;
}
.essay-card:first-child {
  background: var(--color-surface-offset);
}
.essay-card h3 {
  font-size: var(--text-xl);
  margin-block: var(--space-4) var(--space-4);
  line-height: 1.25;
}
.essay-card p {
  color: var(--color-text-muted);
  flex-grow: 1;
  margin-bottom: var(--space-6);
}
.essay-card .btn-ghost {
  align-self: flex-start;
}

/* ============ ESSAY DETAIL HEADER ============ */
.essay-hero {
  padding-block: clamp(var(--space-12), 7vw, var(--space-20)) var(--space-10);
  border-bottom: 1px solid var(--color-divider);
}
.essay-meta {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  margin-bottom: var(--space-5);
  color: var(--color-text-faint);
}
.essay-title {
  font-size: clamp(2rem, 1.2rem + 3.4vw, var(--text-3xl));
  max-width: 22ch;
}
.essay-byline {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-6);
}
.essay-byline img {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  object-fit: cover;
}
.essay-byline-name {
  font-weight: 600;
  font-size: var(--text-sm);
}
.essay-byline-role {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ============ ABOUT PAGE ============ */
.about-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: var(--space-16);
  align-items: start;
}
.about-portrait-frame {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.about-facts {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-8);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-divider);
}
.about-fact dt {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: var(--space-1);
}
.about-fact dd {
  font-size: var(--text-base);
}

/* ============ CONTACT CARD ============ */
.contact-card {
  background: var(--color-surface-offset);
  border-radius: var(--radius-lg);
  padding: var(--space-10);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8);
  flex-wrap: wrap;
}

/* ============ RELATED / NEXT ============ */
.related {
  border-top: 1px solid var(--color-divider);
  padding-top: var(--space-10);
  margin-top: var(--space-12);
}
.related-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--color-divider);
}
.related-link:hover h3 {
  color: var(--color-primary);
}

/* ============ FOOTER ============ */
.footer {
  border-top: 1px solid var(--color-divider);
  padding-block: var(--space-16) var(--space-10);
  margin-top: var(--space-8);
}
.footer-grid {
  display: flex;
  justify-content: space-between;
  gap: var(--space-10);
  flex-wrap: wrap;
  margin-bottom: var(--space-12);
}
.footer-col h4 {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: var(--space-4);
}
.footer-col a {
  display: block;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
}
.footer-col a:hover {
  color: var(--color-primary);
}
.footer-bottom {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-divider);
}

/* ============ SCROLL REVEAL ============ */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============ NOVEL TEASER ============ */
.teaser {
  background: var(--color-surface-offset);
  border-radius: var(--radius-lg);
  padding: clamp(var(--space-10), 6vw, var(--space-16));
  position: relative;
  overflow: hidden;
}
.teaser-label {
  margin-bottom: var(--space-4);
}
.teaser h2 {
  max-width: 26ch;
}
.teaser p {
  color: var(--color-text-muted);
  max-width: 56ch;
  margin-top: var(--space-5);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .hero-grid,
  .about-grid {
    grid-template-columns: 1fr;
  }
  .hero-portrait {
    justify-self: start;
    order: -1;
  }
  .hero-portrait-frame {
    width: min(280px, 60vw);
  }
  .hero-portrait-rule {
    display: none;
  }
  .essay-grid {
    grid-template-columns: 1fr;
  }
  .about-portrait-frame img {
    max-width: 280px;
  }
}

@media (max-width: 720px) {
  .nav-links {
    position: fixed;
    inset: 64px var(--space-4) auto var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    flex-direction: column;
    padding: var(--space-4);
    gap: var(--space-1);
    box-shadow: var(--shadow-lg);
    display: none;
  }
  .nav-links.is-open {
    display: flex;
  }
  .nav-links a {
    padding: var(--space-3) var(--space-3);
    width: 100%;
  }
  .nav-toggle {
    display: inline-flex;
  }
  .contact-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .footer-grid {
    gap: var(--space-8);
  }
}

@media (max-width: 520px) {
  .prose p:first-of-type::first-letter {
    font-size: 2.6em;
  }
}
