/* ═══════════════════════════════════════════════════════════
   Browser Understanding — Ink & Paper Design System
   
   Design: Analog-Digital Hybrid editorial aesthetic
   Fonts:  Fraunces (display), Literata (body), Space Grotesk (UI)
   Colors: Warm paper, charcoal ink, burnt sienna accent, teal secondary
   
   To customise: edit the CSS variables in :root below.
   ═══════════════════════════════════════════════════════════ */

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

:root {
  /* Paper & Ink */
  --paper:        #F7F3ED;
  --paper-alt:    #EDE8DF;
  --ink:          #2D2A26;
  --ink-light:    #6B6560;
  --ink-faint:    #9E9890;

  /* Accents */
  --sienna:       #C75B39;
  --sienna-light: #D4795E;
  --teal:         #2A8C82;
  --teal-light:   #3DADA2;

  /* Borders & Rules */
  --rule:         #D9D3CA;
  --rule-light:   #E8E3DB;

  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'Literata', Georgia, serif;
  --font-ui:      'Space Grotesk', 'Segoe UI', sans-serif;

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

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

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(199, 91, 57, 0.18);
  color: var(--ink);
}

img { max-width: 100%; height: auto; display: block; }
a   { color: var(--sienna); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--sienna-light); }


/* ── Reading Progress Bar ── */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  background: var(--sienna);
  z-index: 200;
  width: 0%;
  transition: width 60ms linear;
  pointer-events: none;
}


/* ── Site Header ── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  font-family: var(--font-ui);
  transition: background 0.3s, box-shadow 0.3s, height 0.3s;
  height: 64px;
}
.site-header.scrolled {
  background: rgba(247, 243, 237, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 1px 0 var(--rule);
  height: 56px;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
.site-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.site-logo .logo-mark {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--sienna);
  letter-spacing: -0.02em;
}
.site-logo .logo-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  transition: opacity 0.3s;
}
.site-header.scrolled .logo-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.header-nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-light);
  text-decoration: none;
}
.header-nav a:hover { color: var(--sienna); }

@media (min-width: 640px) {
  .header-inner { padding: 0 1.5rem; }
}
@media (min-width: 1024px) {
  .header-inner { padding: 0 2rem; }
}


/* ── Layout ── */
.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.content-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}
@media (min-width: 640px) {
  .content-wrapper { padding: 0 1.5rem; }
}
@media (min-width: 1024px) {
  .content-wrapper { padding: 0 2rem; }
}

/* Two-column layout for article + sidebar */
.article-layout {
  display: flex;
  gap: 3rem;
}
.article-main {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.article-sidebar {
  display: none;
  width: 220px;
  flex-shrink: 0;
}
@media (min-width: 1200px) {
  .article-main { margin: 0; }
  .article-sidebar { display: block; }
  .article-layout { gap: 4rem; }
}


/* ── Hero (Article page) ── */
.hero {
  padding-top: 6rem;
  padding-bottom: 2rem;
}
.hero-meta {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 1.5rem;
}
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 1.5rem;
}
.hero-title .accent { color: var(--sienna); }
.hero-subtitle {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--ink-light);
  line-height: 1.6;
  max-width: 600px;
  margin-bottom: 2rem;
}
.hero-info {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.hero-info .dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--ink-faint);
  opacity: 0.5;
}
.hero-image {
  margin-top: 2.5rem;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 1rem;
}
@media (min-width: 640px) {
  .hero { padding-top: 7rem; padding-bottom: 3rem; }
  .hero-image { padding: 0 1.5rem; }
}


/* ── Article Body Typography ── */
.article-body p {
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.85;
  color: #3D3832;
  margin-bottom: 1.5rem;
}
.article-body p:first-child::first-letter {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 700;
  float: left;
  line-height: 0.85;
  margin-right: 0.15em;
  margin-top: 0.05em;
  color: var(--sienna);
}
.article-body strong { font-weight: 600; color: var(--ink); }
.article-body em { font-style: italic; }
.article-body a {
  color: var(--sienna);
  text-decoration: underline;
  text-decoration-color: rgba(199, 91, 57, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s;
}
.article-body a:hover {
  text-decoration-color: var(--sienna);
}


/* ── Section ── */
.article-section {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.article-section.visible {
  opacity: 1;
  transform: translateY(0);
}
.section-rule {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 3rem 0;
}
.section-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (min-width: 640px) {
  .section-header { gap: 1.5rem; }
}
.section-number {
  font-family: var(--font-ui);
  font-weight: 300;
  font-size: 3.5rem;
  color: var(--rule);
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
}
.section-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 1.875rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  padding-top: 0.6rem;
}


/* ── Figures ── */
.article-figure {
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
  background: #FAF8F4;
  margin: 2.5rem 0;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.article-figure.visible {
  opacity: 1;
  transform: translateY(0);
}
.article-figure img {
  width: 100%;
  height: auto;
}
.article-figure figcaption {
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  color: var(--ink-light);
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--rule-light);
  line-height: 1.5;
}
.article-figure figcaption .fig-label {
  font-weight: 600;
  color: var(--sienna);
}


/* ── Pull Quote ── */
.pull-quote {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.4rem;
  line-height: 1.5;
  color: var(--sienna);
  border-left: 3px solid var(--sienna);
  padding-left: 1.5rem;
  margin: 2.5rem 0;
}


/* ── Table of Contents (sidebar) ── */
.toc {
  position: sticky;
  top: 6rem;
  font-family: var(--font-ui);
}
.toc-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--ink-light);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 1rem;
}
.toc ul { list-style: none; }
.toc li { margin-bottom: 0.125rem; }
.toc a {
  display: block;
  padding: 0.375rem 0 0.375rem 0.75rem;
  font-size: 0.8125rem;
  color: rgba(107, 101, 96, 0.7);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.2s;
}
.toc a:hover {
  color: var(--ink-light);
  border-left-color: var(--rule);
}
.toc a.active {
  color: var(--sienna);
  font-weight: 500;
  border-left-color: var(--sienna);
}
.toc .toc-num {
  font-size: 0.6875rem;
  opacity: 0.5;
  margin-right: 0.375rem;
}


/* ── Closing ── */
.article-closing {
  margin-top: 4rem;
  margin-bottom: 2rem;
}
.article-closing p {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.125rem;
  color: var(--ink-light);
  line-height: 1.7;
  margin-top: 2rem;
}


/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: 5rem;
  padding: 3rem 0;
  font-family: var(--font-ui);
}
.footer-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
@media (min-width: 640px) {
  .footer-inner {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0 1.5rem;
  }
}
.footer-refs-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--ink-light);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.75rem;
}
.footer-refs ul { list-style: none; }
.footer-refs li { margin-bottom: 0.375rem; }
.footer-refs a {
  font-size: 0.875rem;
  color: rgba(107, 101, 96, 0.8);
  text-decoration: none;
}
.footer-refs a:hover { color: var(--sienna); }
.footer-brand { text-align: right; }
.footer-brand .logo-mark {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--sienna);
}
.footer-brand .logo-sub {
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin-top: 0.25rem;
}
.footer-bottom {
  max-width: 720px;
  margin: 2.5rem auto 0;
  padding: 1.5rem 1rem 0;
  border-top: 1px solid rgba(217, 211, 202, 0.5);
  text-align: center;
  font-size: 0.75rem;
  color: rgba(158, 152, 144, 0.7);
}


/* ── Index Page ── */
.index-hero {
  padding-top: 7rem;
  padding-bottom: 4rem;
  max-width: 860px;
  margin: 0 auto;
  padding-left: 1rem;
  padding-right: 1rem;
}
@media (min-width: 640px) {
  .index-hero { padding-top: 8rem; padding-left: 1.5rem; padding-right: 1.5rem; }
}
.index-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5vw, 3.25rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
  margin-bottom: 1rem;
}
.index-subtitle {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.125rem;
  color: var(--ink-light);
  line-height: 1.6;
  max-width: 520px;
}
.essays-label {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-bottom: 1.5rem;
}
.essays-list {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1rem 4rem;
}
@media (min-width: 640px) {
  .essays-list { padding: 0 1.5rem 4rem; }
}

/* Article card */
.article-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.article-card:hover {
  border-color: rgba(199, 91, 57, 0.4);
  box-shadow: 0 2px 20px -4px rgba(199, 91, 57, 0.1);
}
.article-card-image {
  overflow: hidden;
}
.article-card-image img {
  width: 100%;
  height: auto;
  transition: transform 0.5s;
}
.article-card:hover .article-card-image img {
  transform: scale(1.02);
}
.article-card-body {
  padding: 1.5rem;
}
@media (min-width: 640px) {
  .article-card-body { padding: 2rem; }
}
.article-card-tags {
  font-family: var(--font-ui);
  font-size: 0.6875rem;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.article-card-tags .dot {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--ink-faint);
  opacity: 0.5;
}
.article-card h2 {
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 3vw, 1.75rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  margin-bottom: 0.75rem;
  transition: color 0.3s;
}
.article-card:hover h2 { color: var(--sienna); }
.article-card .card-subtitle {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1rem;
  color: var(--ink-light);
  line-height: 1.6;
}
.article-card .read-link {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--sienna);
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.3s;
}
.article-card:hover .read-link { opacity: 1; }
.read-link svg {
  transition: transform 0.3s;
}
.article-card:hover .read-link svg {
  transform: translateX(4px);
}

/* Coming soon placeholder */
.coming-soon {
  margin-top: 3rem;
  text-align: center;
  padding: 3rem;
  border: 1px dashed var(--rule);
  border-radius: 3px;
}
.coming-soon p {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  color: rgba(158, 152, 144, 0.6);
}


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