/* ============================================================
   hedglen.org — Shared Stylesheet
   Warm Literary Design
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */

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

:root {
  --bg:       #f2ead6;
  --bg-alt:   #e7decb;
  --text:     #1a1714;
  --muted:    #7a6e66;
  --accent:   #b84c00;
  --border:   #d4caae;
  --toggle-track: #e7decb;
  --toggle-track-hover: #ddd2bb;
  --toggle-thumb: #f2ead6;
  --toggle-thumb-border: #9b8f82;
  --serif:    'Lora', Georgia, 'Times New Roman', serif;
  --sans:     'Inter', system-ui, -apple-system, sans-serif;
  --max:      700px;
  --max-wide: 900px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:       #1a1714;
  --bg-alt:   #252220;
  --text:     #f8f4ee;
  --muted:    #b8aea6;
  --accent:   #ff7733;
  --border:   #3a3632;
  --toggle-track: #252220;
  --toggle-track-hover: #2f2b27;
  --toggle-thumb: #1a1714;
  --toggle-thumb-border: #b8aea6;
  color-scheme: dark;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ── Typography ───────────────────────────────────────────── */

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 { font-size: 2.75rem; margin-bottom: 0.4em; }
h2 { font-size: 1.35rem; margin-bottom: 0.35em; }
h3 { font-size: 1.05rem; margin-bottom: 0.25em; }

p {
  margin-bottom: 1.2em;
  max-width: var(--max);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s;
}

a:hover { opacity: 0.7; }

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

em { font-style: italic; }
strong { font-weight: 600; }

code {
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', monospace;
  font-size: 0.9em;
}

/* ── Navigation ───────────────────────────────────────────── */

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
}

.wordmark {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.wordmark:hover { opacity: 0.6; color: var(--text); }

.site-nav {
  display: flex;
  gap: 28px;
  list-style: none;
}

.site-nav a {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--accent);
  opacity: 1;
}

/* ── Theme Toggle ─────────────────────────────────────── */

.theme-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  margin-left: 24px;
  border-radius: 12px;
}

.toggle-track {
  display: block;
  width: 40px;
  height: 22px;
  background: var(--toggle-track);
  border: 1px solid var(--toggle-thumb-border);
  border-radius: 11px;
  position: relative;
  transition: background 0.2s, border-color 0.2s;
}

.theme-toggle:hover .toggle-track {
  background: var(--toggle-track-hover);
}

.toggle-thumb {
  display: block;
  width: 18px;
  height: 18px;
  background: var(--toggle-thumb);
  border: 1px solid var(--toggle-thumb-border);
  border-radius: 50%;
  position: absolute;
  top: 1px;
  left: 1px;
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
}

[data-theme="dark"] .toggle-thumb {
  transform: translateX(18px);
}

/* ── Page Layout ──────────────────────────────────────── */

.page {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 72px 24px 120px;
}

.page-narrow {
  max-width: var(--max);
  margin: 0 auto;
  padding: 72px 24px 120px;
}

/* ── Page Header ──────────────────────────────────────────── */

.page-kicker {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
  display: block;
}

.page-tagline {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--muted);
  margin-bottom: 48px;
  display: block;
}

.page-intro {
  font-size: 1.05rem;
  line-height: 1.8;
  margin-bottom: 56px;
  max-width: var(--max);
}

/* ── Section Headings ─────────────────────────────────────── */

.section-label {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 24px;
  display: block;
  border-top: 1px solid var(--border);
  padding-top: 32px;
  margin-top: 56px;
}

.section-label.first-section {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
}

/* ── Cards ────────────────────────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 48px;
}

.card {
  background: var(--bg);
  padding: 28px 32px;
  transition: background 0.15s;
}

.card:hover {
  background: var(--bg-alt);
}

.card h2 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.card p {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 0;
  max-width: 100%;
  line-height: 1.65;
}

.card-link {
  display: inline-block;
  margin-top: 14px;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--accent);
}

/* Writing card variant — more editorial */
.writing-card {
  background: var(--bg);
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 20px;
  transition: background 0.15s;
}

.writing-card:hover { background: var(--bg-alt); }

.writing-card .meta {
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  display: block;
}

.writing-card h2 {
  font-size: 1.3rem;
  margin-bottom: 10px;
}

.writing-card h2 a {
  color: var(--text);
}

.writing-card h2 a:hover { opacity: 0.6; color: var(--text); }

.writing-card p {
  font-style: italic;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 0;
  max-width: 100%;
}

/* ── Hero (Home page) ─────────────────────────────────────── */

.hero {
  padding: 80px 0 64px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 64px;
}

.hero h1 {
  font-size: 3.2rem;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.hero .hero-sub {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--muted);
  margin-bottom: 32px;
}

.hero p {
  font-size: 1.05rem;
  line-height: 1.85;
  max-width: 620px;
}

/* ── Featured Piece ───────────────────────────────────────── */

.featured {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 36px 40px;
  margin-bottom: 48px;
}

.featured .featured-label {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
  display: block;
}

.featured h2 {
  font-size: 1.6rem;
  margin-bottom: 12px;
}

.featured h2 a { color: var(--text); }
.featured h2 a:hover { opacity: 0.65; color: var(--text); }

.featured p {
  font-style: italic;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
  max-width: 560px;
  margin-bottom: 20px;
}

.featured .read-link {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--accent);
}

/* ── Reading Page (Essay/Piece) ───────────────────────────── */

.essay-header {
  padding: 64px 0 48px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 64px;
}

.essay-header h1 {
  font-size: 3rem;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.essay-header .essay-meta {
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.content-note {
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.88rem;
  line-height: 1.65;
  margin-bottom: 56px;
  padding: 18px 22px;
}

.content-note p {
  margin: 0;
  max-width: 100%;
}

.essay-body {
  font-size: 1.08rem;
  line-height: 1.85;
}

.essay-body p {
  margin-bottom: 1.4em;
  max-width: 100%;
  text-indent: 2em;
}

.essay-body p:first-of-type,
.essay-body p.no-indent {
  text-indent: 0;
}

.essay-section {
  margin-top: 72px;
  margin-bottom: 40px;
}

.essay-section-title {
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin-bottom: 48px;
  position: relative;
}

.essay-section-title::before,
.essay-section-title::after {
  content: '—';
  margin: 0 16px;
  color: var(--border);
}

.essay-footer {
  margin-top: 72px;
  padding-top: 40px;
  border-top: 1px solid var(--border);
}

.essay-footer p {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  text-indent: 0;
  max-width: 100%;
  margin-bottom: 4px;
}

.essay-back-link {
  margin-top: 16px;
}

/* ── About page ───────────────────────────────────────────── */

.about-body::after {
  clear: both;
  content: '';
  display: block;
}

.about-portrait {
  float: right;
  margin: 6px 0 28px 36px;
  width: min(42%, 280px);
}

.about-portrait img {
  aspect-ratio: 4 / 5;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: block;
  height: auto;
  object-fit: cover;
  width: 100%;
}

.about-body p {
  font-size: 1.05rem;
  line-height: 1.85;
  margin-bottom: 1.4em;
  max-width: 640px;
}

.military-credentials {
  margin-bottom: 48px;
}

.military-credentials .section-label {
  margin-top: 52px;
}

.credentials-intro {
  color: var(--muted);
  font-style: italic;
}

.credential-grid {
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 1px;
  margin-top: 20px;
  overflow: hidden;
}

.credential-card {
  background: var(--bg);
  padding: 26px 30px;
}

.credential-card h2 {
  font-size: 1.05rem;
  margin-bottom: 14px;
}

.credential-card ul {
  display: grid;
  gap: 10px;
  list-style: none;
}

.credential-card li {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.55;
}

.credential-card strong {
  color: var(--text);
}

.contact-section {
  scroll-margin-top: 120px;
}

/* ── Projects portfolio page ─────────────────────────────── */

.portfolio-page {
  max-width: 980px;
}

.portfolio-hero {
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 40px;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.7fr);
  margin-bottom: 48px;
  padding-bottom: 48px;
}

.portfolio-hero h1 {
  font-size: 3.05rem;
  margin-bottom: 16px;
}

.portfolio-hero .page-tagline {
  margin-bottom: 28px;
  max-width: 620px;
}

.portfolio-hero .page-intro {
  margin-bottom: 0;
  max-width: 650px;
}

.portfolio-summary {
  align-self: end;
  border-left: 1px solid var(--border);
  display: grid;
  gap: 18px;
  padding-left: 28px;
}

.summary-item {
  display: grid;
  gap: 2px;
}

.summary-value {
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1.1;
}

.summary-label {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.best-work {
  margin-bottom: 64px;
}

.best-work-heading {
  margin-bottom: 24px;
}

.best-work-heading h2 {
  font-family: var(--sans);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.best-work-heading p {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 0;
  max-width: 620px;
}

.best-work-grid {
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
}

.best-work-card {
  background: var(--bg);
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 420px;
  padding: 34px 38px;
  transition: background 0.15s;
}

.best-work-card:hover {
  background: var(--bg-alt);
}

.best-work-label,
.project-eyebrow,
.project-facts dt {
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.best-work-card h3 {
  font-size: 1.85rem;
  margin: 10px 0 14px;
}

.best-work-card p {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.7;
  margin-bottom: 0;
  max-width: 100%;
}

.best-work-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 22px;
}

.portfolio-link {
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.best-work-facts {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 14px;
  margin: 28px 0 0;
  padding-top: 18px;
}

.best-work-facts div {
  display: grid;
  gap: 3px;
}

.best-work-facts dt {
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.best-work-facts dd {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0;
}

.portfolio-section {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 24px;
  grid-template-columns: 190px minmax(0, 1fr);
  padding: 44px 0;
}

.portfolio-section-heading {
  align-self: start;
  position: sticky;
  top: 96px;
}

.portfolio-section-heading h2 {
  font-family: var(--sans);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.portfolio-section-heading p {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.55;
  margin-bottom: 0;
}

.project-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.project-row {
  background: var(--bg);
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.45fr);
  padding: 28px 30px;
  transition: background 0.15s;
}

.project-row + .project-row {
  border-top: 1px solid var(--border);
}

.project-row:hover {
  background: var(--bg-alt);
}

.project-row h3 {
  font-size: 1.24rem;
  margin: 6px 0 10px;
}

.project-row p {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.65;
  margin-bottom: 0;
  max-width: 610px;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  list-style: none;
  margin-top: 16px;
}

.project-meta li {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.project-meta li::before {
  color: var(--border);
  content: "/";
  margin-right: 12px;
}

.project-meta li:first-child::before {
  content: "";
  margin-right: 0;
}

.project-facts {
  display: grid;
  gap: 14px;
  margin: 0;
}

.project-facts div {
  display: grid;
  gap: 3px;
}

.project-facts dd {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 0;
}

.project-status {
  color: var(--text);
}

.project-action-row {
  margin-top: 18px;
}

/* ── Footer ───────────────────────────────────────────────── */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  margin-top: auto;
}

.site-footer-inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-footer p {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
  max-width: none;
}

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

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

/* ── Utility ──────────────────────────────────────────────── */

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px 0;
}

.note {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 48px;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 820px) {
  .portfolio-hero,
  .best-work-grid,
  .portfolio-section,
  .project-row {
    grid-template-columns: 1fr;
  }

  .portfolio-summary {
    border-left: 0;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 24px;
  }

  .portfolio-section-heading {
    position: static;
  }
}

@media (max-width: 640px) {
  html { font-size: 17px; }

  h1 { font-size: 2.1rem; }
  .hero h1 { font-size: 2.4rem; }
  .essay-header h1 { font-size: 2.2rem; }
  .portfolio-hero h1 { font-size: 2.25rem; }

  .site-header-inner { 
    flex-direction: row; 
    flex-wrap: wrap;
    gap: 16px; 
  }
  
  .site-nav { 
    gap: 20px; 
    flex-wrap: wrap; 
    order: 3;
    width: 100%;
  }
  
  .theme-toggle {
    margin-left: auto;
  }

  .page, .page-narrow { padding: 48px 20px 80px; }
  .featured { padding: 28px 24px; }
  .card { padding: 24px 20px; }
  .credential-card { padding: 24px 20px; }
  .best-work-card,
  .project-row { padding: 26px 22px; }
  .best-work-card { min-height: auto; }
  .portfolio-section { padding: 36px 0; }
  .essay-header { padding: 48px 0 36px; }
  .about-portrait {
    float: none;
    margin: 0 0 32px;
    width: min(100%, 320px);
  }

  .site-footer-inner { flex-direction: column; gap: 8px; }
}

/* ── Print ────────────────────────────────────────────────── */

@media print {
  @page {
    margin: 0.75in;
  }

  :root,
  [data-theme="dark"] {
    --bg: #ffffff;
    --bg-alt: #ffffff;
    --text: #000000;
    --muted: #444444;
    --accent: #000000;
    --border: #cccccc;
    color-scheme: light;
  }

  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  html {
    font-size: 12pt;
    scroll-behavior: auto;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    line-height: 1.5;
    transition: none;
  }

  .site-header,
  .site-footer,
  .theme-toggle,
  .content-note,
  .essay-footer,
  .about-portrait {
    display: none !important;
  }

  .page,
  .page-narrow {
    margin: 0;
    max-width: none;
    padding: 0;
  }

  .essay-header {
    border-bottom: 1px solid #cccccc;
    margin-bottom: 0.35in;
    padding: 0 0 0.22in;
  }

  .essay-header .page-kicker {
    display: none;
  }

  .essay-header h1 {
    font-size: 28pt;
    letter-spacing: 0;
    margin-bottom: 0.12in;
  }

  .essay-header .essay-meta,
  .page-kicker,
  .page-tagline,
  .section-label,
  .essay-section-title,
  .note {
    color: #444444 !important;
  }

  .essay-body {
    font-size: 12pt;
    line-height: 1.55;
  }

  .essay-body p {
    margin-bottom: 0.12in;
    max-width: none;
    orphans: 3;
    text-indent: 0.22in;
    widows: 3;
  }

  .essay-body p:first-of-type,
  .essay-body p.no-indent {
    text-indent: 0;
  }

  .essay-section {
    break-inside: auto;
    margin: 0.45in 0 0;
  }

  .essay-section:first-child {
    margin-top: 0;
  }

  .essay-section-title {
    break-after: avoid;
    font-size: 9pt;
    letter-spacing: 0.12em;
    margin-bottom: 0.22in;
    page-break-after: avoid;
  }

  .essay-section-title::before,
  .essay-section-title::after {
    content: '';
    margin: 0;
  }

  a {
    color: #000000 !important;
    text-decoration: none;
  }

  .card-grid,
  .card,
  .featured,
  .writing-card {
    background: #ffffff;
    border: 1px solid #cccccc;
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
