/* ==========================================================================
   styles.css — Main stylesheet for the personal consultant site
   
   Structure:
   1. Custom properties (design tokens)
   2. CSS reset / base
   3. Typography
   4. Layout: header, nav, main, footer
   5. Components: hero, focus-area cards, project list, writing list, 
                  references, contact form, tag badges
   6. Dark mode overrides
   7. Utilities
   8. Media queries
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. DESIGN TOKENS
   -------------------------------------------------------------------------- */

:root {
  /* Fonts */
  --font-body:    'Work Sans', Georgia, sans-serif;
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-mono:    'Source Code Pro', monospace;

  /* Color palette */
  --color-bg:          #EDD9C0;      /* warm orange-paper */
  --color-surface:     #E3CCAA;      /* slightly darker paper */
  --color-border:      #1A1714;      /* solid ink border */
  --color-text:        #1A1714;      /* near-black ink */
  --color-text-muted:  #3A2E28;      /* darker for accessibility */
  --color-accent:      #7A1F0E;      /* dark maroon */
  --color-accent-hover:#5A1508;      /* deeper maroon */
  --color-accent-light:#F2E0D8;      /* tint for backgrounds */

  /* Spacing scale */
  --space-xs:   0.25rem;  /*  4px */
  --space-sm:   0.5rem;   /*  8px */
  --space-md:   1rem;     /* 16px */
  --space-lg:   1.5rem;   /* 24px */
  --space-xl:   2.5rem;   /* 40px */
  --space-2xl:  4rem;     /* 64px */
  --space-3xl:  6rem;     /* 96px */

  /* Typography scale */
  --text-sm:    0.875rem;   /* 14px */
  --text-base:  1rem;       /* 16px */
  --text-md:    1.125rem;   /* 18px */
  --text-lg:    1.25rem;    /* 20px */
  --text-xl:    1.5rem;     /* 24px */
  --text-2xl:   2rem;       /* 32px */
  --text-3xl:   2.75rem;    /* 44px */
  --text-4xl:   3.5rem;     /* 56px */

  /* Line heights */
  --leading-tight:  1.2;
  --leading-snug:   1.35;
  --leading-body:   1.65;

  /* Max widths */
  --max-prose:    68ch;    /* comfortable reading column */
  --max-content:  1100px;  /* site-wide container cap */

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;

  /* Border radius */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 12px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
}


/* --------------------------------------------------------------------------
   2. CSS RESET / BASE
   -------------------------------------------------------------------------- */

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

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

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cdefs%3E%3Cfilter id='f'%3E%3CfeGaussianBlur stdDeviation='0.9'/%3E%3C/filter%3E%3C/defs%3E%3Ccircle cx='6' cy='6' r='0.6' fill='rgba(26%2C23%2C20%2C0.22)' filter='url(%23f)'/%3E%3C/svg%3E");
}

img, video, audio, embed, object, iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: color var(--transition-fast), opacity var(--transition-fast);
}

a:hover {
  color: var(--color-accent-hover);
}

a:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

ul, ol {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
}

button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-xl) 0;
}


/* --------------------------------------------------------------------------
   3. TYPOGRAPHY
   -------------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--color-text);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl);  }
h4 { font-size: var(--text-lg);  }
h5 { font-size: var(--text-md);  }

p {
  max-width: var(--max-prose);
}

/* When a paragraph is inside a constrained container, don't double-constrain it */
.constrained p {
  max-width: none;
}

strong { font-weight: 600; }

em { font-style: italic; }

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

.text-muted {
  color: var(--color-text-muted);
}

.font-display {
  font-family: var(--font-display);
}

.lead {
  font-size: var(--text-md);
  line-height: 1.55;
  color: var(--color-text-muted);
}


/* --------------------------------------------------------------------------
   4. LAYOUT
   -------------------------------------------------------------------------- */

/* Outer wrapper — centers everything and adds side padding */
.site-wrapper {
  width: 100%;
  max-width: var(--max-content);
  margin-inline: auto;
  padding-inline: var(--space-lg);
}

/* ---- Site Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: 1rem 2rem;
}

.site-header__inner { display: contents; } /* compatibility shim */

/* Logo */
.site-logo {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--color-text);
}
.site-logo:hover { color: var(--color-accent); }

/* Navigation */
.site-nav {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.site-nav__list {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.site-nav__list a {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.95rem;
  font-weight: 400;
  text-decoration: none;
  color: var(--color-text-muted);
  border-bottom: 1px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.site-nav__list a:hover,
.site-nav__list a[aria-current="page"] {
  color: var(--color-text);
  border-bottom-color: var(--color-text);
}

/* Hide old controls */
.theme-toggle,
.nav-toggle { display: none !important; }

/* ---- Main content ---- */
main {
  flex: 1;
}

/* ---- Site Footer ---- */
.site-footer {
  border-top: 2px solid var(--color-border);
  margin-top: var(--space-3xl);
}

/* Contact zone at top of footer */
.site-footer__contact {
  padding: var(--space-2xl) 0;
  border-bottom: 1px solid var(--color-border);
}

/* Copyright / nav bar at bottom of footer */
.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  justify-content: space-between;
  align-items: center;
  padding-block: var(--space-lg);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.site-footer a {
  color: var(--color-text-muted);
}

.site-footer a:hover {
  color: var(--color-accent);
}

/* Generic page section spacing */
.page-section {
  padding-block: var(--space-2xl);
}

.page-section + .page-section {
  border-top: 1px solid var(--color-border);
}

/* Section heading with optional label */
.section-label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-sm);
}

.section-title {
  margin-bottom: var(--space-lg);
}


/* --------------------------------------------------------------------------
   5. COMPONENTS
   -------------------------------------------------------------------------- */

/* ---- Page header (inner page title area) ---- */
.page-header {
  padding-block: var(--space-2xl) var(--space-xl);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-xl);
}

.page-header h1 {
  margin-bottom: var(--space-sm);
}

.page-header p {
  color: var(--color-text-muted);
  font-size: var(--text-md);
}

/* ---- Hero ---- */
.hero {
  padding-block: var(--space-3xl);
}

.hero__eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-md);
  display: block;
}

.hero__headline {
  font-size: clamp(var(--text-2xl), 5vw, var(--text-4xl));
  line-height: var(--leading-snug);
  margin-bottom: var(--space-lg);
  max-width: 18ch;
}

.hero__body {
  font-size: var(--text-md);
  color: var(--color-text-muted);
  max-width: 54ch;
  margin-bottom: var(--space-xl);
  line-height: 1.7;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: center;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.625rem var(--space-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast), color var(--transition-fast), 
              box-shadow var(--transition-fast), border-color var(--transition-fast);
  cursor: pointer;
  border: 1.5px solid transparent;
}

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

.btn-primary:hover {
  background-color: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: #fff;
}

.btn-secondary {
  background-color: transparent;
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background-color: var(--color-surface);
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

/* ---- Focus area cards ---- */
.focus-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

.focus-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

.focus-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-accent);
}

.focus-card__icon {
  font-size: 1.75rem;
  margin-bottom: var(--space-md);
  display: block;
  line-height: 1;
}

.focus-card__title {
  font-size: var(--text-lg);
  margin-bottom: var(--space-sm);
}

.focus-card__body {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: var(--leading-body);
  max-width: none;
}

/* ---- Project / work list ---- */
.work-group {
  margin-bottom: var(--space-2xl);
}

.work-group__heading {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

/* project-item: year is a separate grid cell; body holds tags + all content */
.project-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xs) var(--space-md);
}

.project-item__year {
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* tags + meta inside the body div, not a sibling grid column */
.project-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  align-items: center;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.project-item__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: var(--leading-snug);
  margin-bottom: var(--space-xs);
}

.project-item__title a {
  text-decoration: none;
  color: var(--color-text);
}

.project-item__title a:hover {
  color: var(--color-accent);
}

.project-item__description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  max-width: var(--max-prose);
}

.project-item__links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.project-item__links a {
  font-size: var(--text-sm);
  font-weight: 500;
}

/* ---- Tag badges ---- */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
}

.tag {
  display: inline-block;
  padding: 0.2em 0.65em;
  font-size: 0.68rem;
  font-weight: 500;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-radius: 999px;
  background-color: var(--color-accent-light);
  color: var(--color-accent-hover);
  text-decoration: none;
  white-space: nowrap;
}

/* ---- Writing list ---- */
.writing-section {
  margin-bottom: var(--space-2xl);
}

.writing-section__heading {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.writing-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.writing-item {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: var(--space-sm) var(--space-md);
  align-items: start;
}

.writing-item__year {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  padding-top: 0.15em;
}

.writing-item__body {}

.writing-item__title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 600;
  line-height: var(--leading-snug);
}

.writing-item__title a {
  text-decoration: none;
  color: var(--color-text);
}

.writing-item__title a:hover {
  color: var(--color-accent);
}

.writing-item__outlet {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: 0.15em;
}

.writing-item__description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

/* ---- BibTeX / References section ---- */
.references {
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.references h2 {
  margin-bottom: var(--space-lg);
}

#bibtex-rendered {
  font-size: var(--text-sm);
  line-height: 1.7;
}

#bibtex-rendered .ref-year-group {
  margin-bottom: var(--space-xl);
}

#bibtex-rendered .ref-year-label {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-md);
  display: block;
}

#bibtex-rendered ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

#bibtex-rendered li {
  padding-left: var(--space-xl);
  position: relative;
  color: var(--color-text);
}

#bibtex-rendered li::before {
  content: counter(ref-counter);
  counter-increment: ref-counter;
  position: absolute;
  left: 0;
  top: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  width: 1.5rem;
  text-align: right;
}

#bibtex-rendered ol {
  counter-reset: ref-counter;
}

#bibtex-rendered .ref-authors {
  color: var(--color-text);
}

#bibtex-rendered .ref-title {
  font-style: italic;
}

#bibtex-rendered .ref-venue {
  color: var(--color-text-muted);
}

#bibtex-rendered a {
  font-size: var(--text-sm);
  word-break: break-all;
}

#bibtex-rendered .ref-error {
  padding: var(--space-md);
  background-color: var(--color-surface);
  border-left: 3px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
}

/* ---- About page ---- */
.about-bio {
  max-width: var(--max-prose);
}

.about-bio p + p {
  margin-top: var(--space-md);
}

.about-headshot {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
}

.about-headshot-placeholder {
  width: 200px;
  height: 200px;
  border-radius: var(--radius-lg);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--space-md);
}

.affiliations-list {
  margin-top: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.affiliation-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-sm) var(--space-md);
  align-items: start;
}

.affiliation-item__icon {
  font-size: 1.1rem;
  padding-top: 0.1em;
}

.affiliation-item__name {
  font-weight: 600;
  font-size: var(--text-sm);
}

.affiliation-item__detail {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ---- Recognition / award callout ---- */
.recognition-callout {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-block: var(--space-xl);
  max-width: var(--max-prose);
}

.recognition-callout p {
  font-size: var(--text-md);
  font-family: var(--font-display);
  font-style: italic;
  line-height: 1.55;
  max-width: none;
}

.recognition-callout cite {
  display: block;
  font-style: normal;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-sm);
  font-family: var(--font-body);
}

/* ---- Contact form ---- */
.contact-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2xl);
  align-items: start;
}

.contact-info p {
  margin-bottom: var(--space-md);
  color: var(--color-text-muted);
}

.contact-form-wrapper {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.form-field label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.form-field .field-hint {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 0.625rem var(--space-md);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(45,106,79, 0.12);
}

.form-field textarea {
  min-height: 120px;
  resize: vertical;
  line-height: var(--leading-body);
}

.form-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6560' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
}

.form-status {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-top: var(--space-md);
  display: none;
}

.form-status.success {
  background-color: var(--color-accent-light);
  color: var(--color-accent-hover);
  border: 1px solid var(--color-accent);
  display: block;
}

.form-status.error {
  background-color: #fde8e8;
  color: #842029;
  border: 1px solid #f5c6cb;
  display: block;
}

/* ---- Index credibility / stats strip ---- */
.credibility-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-lg);
  padding-block: var(--space-xl);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.credibility-item {
  text-align: center;
}

.credibility-item__number {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-accent);
  display: block;
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.credibility-item__label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* ---- Two-column layout for larger contexts ---- */
.two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  align-items: start;
}

/* ---- Media embeds ---- */
.media-embed {
  position: relative;
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background-color: var(--color-surface);
}

/* 16:9 aspect ratio container */
.media-embed--video {
  aspect-ratio: 16 / 9;
}

.media-embed iframe,
.media-embed video {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

video, audio {
  border-radius: var(--radius-md);
}

audio {
  width: 100%;
}


/* --------------------------------------------------------------------------
   6. DARK MODE
   -------------------------------------------------------------------------- */

[data-theme="dark"] {
  --color-bg:          #141312;
  --color-surface:     #1e1c1a;
  --color-border:      #302e2b;
  --color-text:        #f0ede9;
  --color-text-muted:  #8a847d;
  --color-accent:      #52b788;   /* lighter green for dark bg contrast */
  --color-accent-hover:#74c69d;
  --color-accent-light:#1a3a29;   /* dark tint for tags */
}

[data-theme="dark"] .form-field input,
[data-theme="dark"] .form-field textarea,
[data-theme="dark"] .form-field select {
  background-color: var(--color-surface);
  color: var(--color-text);
}

[data-theme="dark"] .form-field input:focus,
[data-theme="dark"] .form-field textarea:focus,
[data-theme="dark"] .form-field select:focus {
  box-shadow: 0 0 0 3px rgba(82,183,136, 0.15);
}

[data-theme="dark"] .form-status.success {
  background-color: var(--color-accent-light);
  color: var(--color-accent-hover);
  border-color: var(--color-accent);
}


/* --------------------------------------------------------------------------
   7. UTILITIES
   -------------------------------------------------------------------------- */

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

.mt-sm  { margin-top: var(--space-sm);  }
.mt-md  { margin-top: var(--space-md);  }
.mt-lg  { margin-top: var(--space-lg);  }
.mt-xl  { margin-top: var(--space-xl);  }
.mt-2xl { margin-top: var(--space-2xl); }

.mb-sm  { margin-bottom: var(--space-sm);  }
.mb-md  { margin-bottom: var(--space-md);  }
.mb-lg  { margin-bottom: var(--space-lg);  }
.mb-xl  { margin-bottom: var(--space-xl);  }

.text-center { text-align: center; }
.text-right  { text-align: right;  }

.flex          { display: flex; }
.flex-wrap     { flex-wrap: wrap; }
.items-center  { align-items: center; }
.gap-sm        { gap: var(--space-sm); }
.gap-md        { gap: var(--space-md); }


/* --------------------------------------------------------------------------
   8. MEDIA QUERIES
   -------------------------------------------------------------------------- */

/* Mobile nav — collapsed state */
@media (max-width: 700px) {
  .nav-toggle {
    display: flex;
  }

  .site-nav__list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-sm) var(--space-lg) var(--space-md);
    gap: var(--space-xs);
    box-shadow: var(--shadow-md);
    z-index: 99;
  }

  .site-nav__list.is-open {
    display: flex;
  }

  .site-nav__list a {
    padding-block: var(--space-sm);
  }

  .site-header {
    position: relative; /* so the dropdown can be absolute inside */
  }

  .hero {
    padding-block: var(--space-2xl);
  }

  .hero__headline {
    font-size: var(--text-2xl);
  }

  .writing-item {
    grid-template-columns: 1fr;
  }

  .writing-item__year {
    font-size: var(--text-xs);
  }
}

/* Medium screens and up */
@media (min-width: 700px) {
  .two-col {
    grid-template-columns: 1fr 1fr;
  }

  .contact-layout {
    grid-template-columns: 1fr 1.4fr;
  }
}

/* Large screens: year in a narrow left column, body on right */
@media (min-width: 900px) {
  .project-item {
    grid-template-columns: 3.5rem 1fr;
    gap: var(--space-sm) var(--space-md);
    align-items: start;
  }

  .project-item__year {
    text-align: right;
    padding-top: 0.25em;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }
}


/* ==========================================================================
   ADDITIONS: Markdown content, media embeds, thumbnails, media grid,
   anchor links, BibTeX per-section
   ========================================================================== */

/* --------------------------------------------------------------------------
   MD-CONTENT: rendered markdown blocks
   Any <div class="md-content"> is parsed and rendered by content.js.
   -------------------------------------------------------------------------- */

.md-content {
  max-width: var(--max-prose);
}

.md-content h1 { font-size: var(--text-3xl); margin: var(--space-xl) 0 var(--space-md); }
.md-content h2 { font-size: var(--text-2xl); margin: var(--space-xl) 0 var(--space-md); }
.md-content h3 { font-size: var(--text-xl);  margin: var(--space-lg) 0 var(--space-sm); }
.md-content h4 { font-size: var(--text-lg);  margin: var(--space-lg) 0 var(--space-sm); }

.md-content p  { margin-bottom: var(--space-md); }
.md-content ul,
.md-content ol { padding-left: 1.4em; margin-bottom: var(--space-md); list-style: revert; }
.md-content li { margin-bottom: var(--space-xs); }
.md-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding-left: var(--space-lg);
  margin: var(--space-lg) 0;
  color: var(--color-text-muted);
  font-style: italic;
}
.md-content code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9em;
  background: var(--color-surface);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}
.md-content pre {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  overflow-x: auto;
  margin-bottom: var(--space-md);
}
.md-content pre code {
  background: none;
  padding: 0;
}
.md-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-xl) 0;
}
.md-content a {
  color: var(--color-accent);
}
.md-content strong { font-weight: 600; }
.md-content em     { font-style: italic; }

/* --------------------------------------------------------------------------
   SECTION ANCHOR LINKS
   A small # icon appears on hover next to any heading that has an id.
   content.js adds these automatically.
   -------------------------------------------------------------------------- */

.heading-anchor {
  display: inline-flex;
  align-items: center;
  margin-left: 0.4em;
  opacity: 0;
  font-size: 0.7em;
  color: var(--color-text-muted);
  text-decoration: none;
  vertical-align: middle;
  transition: opacity var(--transition-fast), color var(--transition-fast);
  user-select: none;
}

h1:hover .heading-anchor,
h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h1:focus-within .heading-anchor,
h2:focus-within .heading-anchor,
h3:focus-within .heading-anchor {
  opacity: 1;
}

.heading-anchor:hover {
  color: var(--color-accent);
}

.heading-anchor .anchor-copied {
  display: none;
  font-family: var(--font-body);
  font-size: 0.75rem;
  background: var(--color-accent);
  color: #fff;
  padding: 0.1em 0.5em;
  border-radius: var(--radius-sm);
  margin-left: 0.25em;
  pointer-events: none;
}

.heading-anchor.just-copied .anchor-copied {
  display: inline;
}

/* --------------------------------------------------------------------------
   VIDEO EMBEDS
   Responsive 16:9 container for YouTube, Vimeo, Internet Archive, etc.
   -------------------------------------------------------------------------- */

.embed-video {
  position: relative;
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  margin: var(--space-lg) 0;
}

/* Default size: full prose width at 16:9 */
.embed-video--default {
  max-width: var(--max-prose);
  aspect-ratio: 16 / 9;
}

/* Large: full container width */
.embed-video--large {
  max-width: 100%;
  aspect-ratio: 16 / 9;
}

/* Small: ~240px high (good for phone-friendly embeds) */
.embed-video--small {
  max-width: 426px;
  aspect-ratio: 16 / 9;
}

.embed-video iframe,
.embed-video video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* --------------------------------------------------------------------------
   AUDIO EMBEDS
   -------------------------------------------------------------------------- */

.embed-audio {
  margin: var(--space-lg) 0;
  max-width: var(--max-prose);
}

.embed-audio audio {
  width: 100%;
  border-radius: var(--radius-md);
}

.embed-audio iframe {
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
}

.embed-audio__label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
  display: block;
}

/* --------------------------------------------------------------------------
   THUMBNAIL IMAGE on BibTeX / project items
   Desktop: floated right of text. Mobile: full width above text.
   Standard proportion: 3:2 (150×100px equivalent, scales with container)
   -------------------------------------------------------------------------- */

.item-with-thumb {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  align-items: start;
}

.item-thumb {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  display: block;
}

/* Force-sized thumb (set by thumb=url|WxH in BibTeX custom field) */
.item-thumb--forced {
  aspect-ratio: unset;
  object-fit: contain;
}

@media (min-width: 600px) {
  .item-with-thumb {
    grid-template-columns: 1fr 160px;
    direction: ltr; /* text left, image right */
  }

  .item-thumb-col {
    order: 2; /* image on right */
  }

  .item-body-col {
    order: 1;
  }
}

/* --------------------------------------------------------------------------
   MEDIA GRID (Instagram-like) for home page
   -------------------------------------------------------------------------- */

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: var(--space-sm);
  margin: var(--space-xl) 0;
}

.media-grid__cell {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}

/* Image cells: fixed square aspect */
.media-grid__cell--image {
  aspect-ratio: 1 / 1;
}

.media-grid__cell--image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--transition-base);
}

.media-grid__cell--image:hover img {
  transform: scale(1.03);
}

/* Video cells: 16:9 in grid */
.media-grid__cell--video {
  aspect-ratio: 16 / 9;
}

.media-grid__cell--video iframe,
.media-grid__cell--video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: none;
  display: block;
}

/* Wide cell: spans 2 columns */
.media-grid__cell--wide {
  grid-column: span 2;
  aspect-ratio: 2 / 1;
}

@media (max-width: 500px) {
  .media-grid__cell--wide {
    grid-column: span 1;
    aspect-ratio: 1 / 1;
  }
}

/* Caption overlay on hover */
.media-grid__caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.65));
  color: #fff;
  font-size: var(--text-sm);
  padding: var(--space-md) var(--space-sm) var(--space-sm);
  transform: translateY(100%);
  transition: transform var(--transition-base);
}

.media-grid__cell:hover .media-grid__caption,
.media-grid__cell:focus-within .media-grid__caption {
  transform: translateY(0);
}

/* --------------------------------------------------------------------------
   BIBTEX PER-SECTION: each writing section can have its own BibTeX block
   The rendered output reuses the existing #bibtex-rendered styles but
   scoped under .bibtex-section-output so multiple can coexist on one page.
   -------------------------------------------------------------------------- */

.bibtex-section-output {
  font-size: var(--text-sm);
  line-height: 1.7;
  margin-top: var(--space-lg);
}

.bibtex-section-output .ref-year-group {
  margin-bottom: var(--space-xl);
}

.bibtex-section-output .ref-year-label {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: var(--space-md);
  display: block;
}

.bibtex-section-output ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  counter-reset: ref-counter;
}

.bibtex-section-output li {
  padding-left: var(--space-xl);
  position: relative;
}

.bibtex-section-output li::before {
  content: counter(ref-counter);
  counter-increment: ref-counter;
  position: absolute;
  left: 0; top: 0;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  width: 1.5rem;
  text-align: right;
}

/* Thumbnail inside a bibtex list item */
.ref-item-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
  align-items: start;
}

@media (min-width: 600px) {
  .ref-item-inner.has-thumb {
    grid-template-columns: 1fr 140px;
  }
}

.ref-thumb {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  order: 2;
}

.ref-thumb--forced {
  aspect-ratio: unset;
  object-fit: contain;
}

.ref-body { order: 1; }

.bibtex-section-output .ref-authors { color: var(--color-text); }
.bibtex-section-output .ref-title   { font-style: italic; }
.bibtex-section-output .ref-venue   { color: var(--color-text-muted); }
.bibtex-section-output a            { font-size: var(--text-sm); word-break: break-all; }
.bibtex-section-output .ref-error   {
  padding: var(--space-md);
  background: var(--color-surface);
  border-left: 3px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
}

/* Inline BibTeX input area — hidden in normal view, shown for devtools users */
.bibtex-input-block {
  display: none;
}

/* --------------------------------------------------------------------------
   MINI CONTACT SECTION (work, about, writing pages)
   A compact "Work together" form shown at the bottom of inner pages.
   -------------------------------------------------------------------------- */

.page-contact {
  /* kept for standalone use; when inside .site-footer__contact these are overridden */
  padding: var(--space-2xl) 0;
}

.page-contact__inner {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: var(--space-2xl);
  align-items: start;
  max-width: var(--max-content);
  margin-inline: auto;
  padding-inline: var(--space-lg);
}

@media (max-width: 700px) {
  .page-contact__inner { grid-template-columns: 1fr; }
}

.page-contact__heading {
  font-family: var(--font-display);
  font-style: italic;
  font-size: clamp(1.6rem, 3vw, 2.5rem);
  line-height: 1.1;
  margin-bottom: var(--space-md);
}

.page-contact__desc {
  font-family: var(--font-body);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.7;
  margin-bottom: var(--space-md);
  max-width: none;
}

.page-contact__email {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.page-contact__email a { color: var(--color-text-muted); text-decoration: underline; text-underline-offset: 3px; }

/* Mini form */
.page-contact__form .pcf-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

@media (max-width: 500px) {
  .page-contact__form .pcf-row { grid-template-columns: 1fr; }
}

.page-contact__form .pcf-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: var(--space-md);
}

.page-contact__form label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.page-contact__form input,
.page-contact__form textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 0;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition-fast);
}

.page-contact__form input:focus,
.page-contact__form textarea:focus {
  border-color: var(--color-accent);
}

.page-contact__form textarea {
  min-height: 90px;
  resize: vertical;
  line-height: var(--leading-body);
}

.pcf-submit-row { margin-top: var(--space-sm); }

.btn-ink {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text);
  border: 2px solid var(--color-border);
  padding: 0.65rem 1.75rem;
  cursor: pointer;
  background: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-ink:hover { background: var(--color-text); color: var(--color-bg); }

/* --------------------------------------------------------------------------
   WORK PAGE: Solo image and gallery
   Use <figure class="work-figure"> for a single image with optional caption.
   Use <div class="work-gallery"> with <figure> children for a grid.
   -------------------------------------------------------------------------- */

.work-figure {
  margin: var(--space-xl) 0;
  max-width: var(--max-prose);
}

.work-figure img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.work-figure figcaption {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  padding: var(--space-xs) var(--space-sm);
  margin-top: var(--space-xs);
}

.work-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: var(--space-sm);
  margin: var(--space-xl) 0;
}

.work-gallery figure {
  margin: 0;
}

.work-gallery img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  display: block;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: transform var(--transition-base);
}

.work-gallery figure:hover img {
  transform: scale(1.02);
}

.work-gallery figcaption {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  padding: var(--space-xs) 0;
}

/* Portrait image: taller crop (use .work-figure--portrait modifier) */
.work-figure--portrait img {
  max-width: 360px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
}

