/* ===== CSS Variables ===== */
:root {
  --color-bg: #ffffff;
  --color-bg-alt: #f3f6f8;
  --color-text: #111111;
  --color-text-secondary: #555555;
  --color-accent: #2E5A52;
  --color-border: #e0e5e9;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Source Sans 3', sans-serif;
  --max-width: 1200px;
  --content-width: 680px;
  --gutter: 1.5rem;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}
img, picture, svg, video { max-width: 100%; height: auto; display: block; }
a { color: var(--color-text); text-decoration: underline; text-underline-offset: 0.2em; text-decoration-color: var(--color-accent); }
a:hover { text-decoration-thickness: 2px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* ===== Skip link ===== */
.skip-link {
  position: absolute; top: -40px; left: 0; background: var(--color-accent); color: #fff;
  padding: 0.5rem 1rem; z-index: 100; font-family: var(--font-display); font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 0; }

/* ===== Reading progress ===== */
.reading-progress { position: fixed; top: 0; left: 0; height: 3px; background: var(--color-accent); z-index: 200; width: 0%; }

/* ===== Masthead ===== */
.masthead {
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0;
  background: rgba(255,255,255,0.96); backdrop-filter: blur(6px); z-index: 50;
}
.masthead-inner {
  max-width: var(--max-width); margin: 0 auto; padding: 1rem var(--gutter);
  display: flex; align-items: center; justify-content: space-between;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; text-decoration: none; }
.brand-mark { color: var(--color-text); width: 28px; height: 28px; }
.brand-wordmark { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; letter-spacing: 0.04em; color: var(--color-text); }

.menu-toggle {
  display: block; background: none; border: none; cursor: pointer; padding: 0.4rem;
}
.menu-toggle-bar {
  display: block; width: 26px; height: 2px; background: var(--color-text); margin: 6px 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.menu-toggle.is-open .menu-toggle-bar:first-child { transform: translateY(4px) rotate(45deg); }
.menu-toggle.is-open .menu-toggle-bar:last-child { transform: translateY(-4px) rotate(-45deg); }

.menu-list {
  list-style: none; position: absolute; top: 100%; right: var(--gutter); left: var(--gutter);
  background: var(--color-bg); border: 1px solid var(--color-border); padding: 1rem;
  display: none; flex-direction: column; gap: 0.8rem;
}
.menu-list.is-open { display: flex; }
.menu-list a { font-family: var(--font-display); font-weight: 500; font-size: 0.95rem; text-decoration: none; }
.menu-list a:hover { color: var(--color-accent); }

@media (min-width: 800px) {
  .menu-toggle { display: none; }
  .menu-list { position: static; display: flex !important; flex-direction: row; gap: 1.5rem; border: none; padding: 0; background: transparent; }
}

/* ===== Breadcrumbs ===== */
.breadcrumbs { font-size: 0.82rem; color: var(--color-text-secondary); padding: 1.2rem var(--gutter) 0; max-width: var(--max-width); margin: 0 auto; }
.breadcrumbs a { color: var(--color-text-secondary); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }

/* ===== Layout helpers ===== */
.section-inner { max-width: var(--max-width); margin: 0 auto; padding: 3rem var(--gutter); }
.section-alt { background: var(--color-bg-alt); }
.section-title { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 1.5rem; color: var(--color-text-secondary); }
.section-number { color: var(--color-accent); margin-right: 0.5rem; }
.section-label { font-family: var(--font-display); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-accent); display: block; margin-bottom: 0.6rem; }

/* ===== Images ===== */
.image-wrap { position: relative; overflow: hidden; background: var(--color-bg-alt); }
.image-wrap img { width: 100%; height: 100%; object-fit: cover; }
.aspect-16-9 { aspect-ratio: 16 / 9; }
.aspect-3-4 { aspect-ratio: 3 / 4; }
.aspect-4-3 { aspect-ratio: 4 / 3; }

/* ===== Home: Hero ===== */
.hero { padding: 2.5rem 0 1rem; }
.hero-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--gutter); }
.hero h1 { font-family: var(--font-display); font-size: clamp(1.8rem, 5vw, 3rem); font-weight: 700; line-height: 1.15; margin-bottom: 1rem; max-width: 900px; }
.hero .meta { font-size: 0.9rem; color: var(--color-text-secondary); margin-bottom: 1.5rem; display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.hero .meta a { color: var(--color-text-secondary); text-decoration: none; }
.hero .meta a:hover { color: var(--color-accent); }
.hero .meta .author { font-weight: 600; color: var(--color-text); }
.hero .meta time { font-variant-numeric: tabular-nums; }
.hero-image { margin: 0 0 1.5rem; }
.lead { font-size: 1.15rem; line-height: 1.6; max-width: 700px; margin-bottom: 1.2rem; color: var(--color-text); }
.read-more { font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; text-decoration: none; color: var(--color-accent); }
.read-more:hover { text-decoration: underline; }

/* ===== Home: Recent posts ===== */
.recent-posts { padding-top: 2rem; }
.post-grid { display: grid; gap: 2rem; }
@media (min-width: 700px) { .post-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .post-grid { grid-template-columns: repeat(3, 1fr); } }

.post-card { display: flex; flex-direction: column; gap: 0.6rem; }
.post-card .image-wrap { margin-bottom: 0.4rem; }
.post-card h3 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; line-height: 1.25; }
.post-card h3 a { text-decoration: none; }
.post-card h3 a:hover { text-decoration: underline; text-decoration-color: var(--color-accent); }
.post-card .meta { font-size: 0.82rem; color: var(--color-text-secondary); }

/* ===== Home: Featured post ===== */
.feature-post { padding: 3rem 0; }
.feature-layout { display: grid; gap: 2rem; align-items: center; }
@media (min-width: 800px) { .feature-layout { grid-template-columns: 1.2fr 1fr; } }
.feature-content h2 { font-family: var(--font-display); font-size: clamp(1.4rem, 3vw, 2rem); font-weight: 700; margin-bottom: 0.8rem; line-height: 1.2; }
.feature-content p { color: var(--color-text-secondary); margin-bottom: 1rem; }

/* ===== Home: Categories ===== */
.categories { padding: 2.5rem 0; }
.category-list { list-style: none; display: grid; gap: 0.6rem; }
@media (min-width: 700px) { .category-list { grid-template-columns: repeat(2, 1fr); } }
.category-list li { border-bottom: 1px solid var(--color-border); padding: 0.9rem 0; }
.category-list a { font-family: var(--font-display); font-size: 1.1rem; font-weight: 500; text-decoration: none; display: flex; align-items: baseline; gap: 0.8rem; }
.category-list a:hover { color: var(--color-accent); }
.cat-num { font-size: 0.85rem; font-weight: 700; color: var(--color-accent); font-variant-numeric: tabular-nums; letter-spacing: 0.05em; }

/* ===== Home: Newsletter ===== */
.newsletter { padding: 3rem 0; border-top: 1px solid var(--color-border); }
.newsletter h2 { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; margin-bottom: 0.4rem; }
.newsletter > .section-inner > p { color: var(--color-text-secondary); margin-bottom: 1.2rem; max-width: 600px; }
.newsletter-form { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.newsletter-form input[type="email"] {
  flex: 1 1 240px; padding: 0.65rem 0.9rem; border: 1px solid var(--color-border);
  font-family: var(--font-body); font-size: 1rem;
}
.newsletter-form button {
  padding: 0.65rem 1.4rem; background: var(--color-accent); color: #fff; border: none;
  font-family: var(--font-display); font-weight: 600; cursor: pointer;
}
.newsletter-form button:hover { background: #244a43; }

/* ===== Article ===== */
.article-header { max-width: var(--content-width); margin: 0 auto; padding: 2rem var(--gutter) 1rem; }
.article-header h1 { font-family: var(--font-display); font-size: clamp(1.7rem, 4.5vw, 2.6rem); font-weight: 700; line-height: 1.15; margin-bottom: 1rem; }
.article-meta { font-size: 0.9rem; color: var(--color-text-secondary); display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; margin-bottom: 1.5rem; }
.article-meta .author-name { font-weight: 600; color: var(--color-text); }
.article-meta time { font-variant-numeric: tabular-nums; }

.hero-image { max-width: var(--max-width); margin: 0 auto 2rem; padding: 0 var(--gutter); }

.article-body-wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--gutter); display: grid; gap: 2.5rem; }
@media (min-width: 1000px) { .article-body-wrap { grid-template-columns: 1fr 260px; } }

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

/* Gutenberg content resets */
.article-content .wp-block-image { margin: 0 0 1.5rem; }
.article-content .wp-block-image img { width: 100%; height: auto; object-fit: cover; }
.article-content > .entry-content > p:first-child,
.article-content > p:first-of-type { font-size: 1.15rem; line-height: 1.6; margin-bottom: 1.5rem; }
.article-content p { margin-bottom: 1.2rem; }
.article-content h2 { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; margin: 2.2rem 0 0.9rem; line-height: 1.25; }
.article-content h3 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; margin: 1.8rem 0 0.6rem; }
.article-content ul, .article-content ol { margin: 0 0 1.2rem 1.4rem; }
.article-content li { margin-bottom: 0.4rem; }
.article-content strong { font-weight: 700; }
.article-content figure { margin: 1.5rem 0; }
.article-content figcaption { font-size: 0.85rem; color: var(--color-text-secondary); margin-top: 0.4rem; }
.article-content table { width: 100%; border-collapse: collapse; margin: 1.5rem 0; }
.article-content th, .article-content td { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--color-border); text-align: left; }
.article-content th { font-family: var(--font-display); font-weight: 600; background: var(--color-bg-alt); }

/* Block style: Highlights */
.is-style-highlights {
  background: var(--color-bg-alt);
  border-left: 3px solid var(--color-accent);
  padding: 1.2rem 1.4rem;
  margin: 0 0 1.8rem;
}
.is-style-highlights > *:first-child { margin-top: 0; }
.is-style-highlights > *:last-child { margin-bottom: 0; }
.is-style-highlights h2, .is-style-highlights h3, .is-style-highlights h4 {
  font-family: var(--font-display); font-size: 0.9rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 0.7rem; color: var(--color-text-secondary);
}
.is-style-highlights ul { list-style: none; margin: 0; padding: 0; }
.is-style-highlights li { padding: 0.35rem 0 0.35rem 1.2rem; position: relative; margin: 0; }
.is-style-highlights li::before {
  content: ''; position: absolute; left: 0; top: 0.85rem;
  width: 6px; height: 6px; background: var(--color-accent);
}

/* Block style: Pull quote */
.is-style-pull,
.wp-block-quote.is-style-pull,
.wp-block-pullquote.is-style-pull {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 500;
  line-height: 1.4; color: var(--color-accent);
  border-top: 2px solid var(--color-accent); border-bottom: 2px solid var(--color-accent);
  padding: 1.2rem 0; margin: 2rem 0;
}
.is-style-pull cite,
.wp-block-quote.is-style-pull cite,
.wp-block-pullquote.is-style-pull cite {
  display: block; margin-top: 0.6rem; font-size: 0.85rem; font-style: normal;
  color: var(--color-text-secondary); font-family: var(--font-body);
}

/* Block style: Disclaimer */
.is-style-disclaimer {
  background: #fff8e6; border-left: 3px solid #d4a017;
  padding: 0.9rem 1.1rem; margin: 2rem 0;
  font-size: 0.9rem; color: #5a4a1a;
}
.is-style-disclaimer strong { font-weight: 700; }

/* Chart / data figure */
.data-figure { margin: 2rem 0; }
.data-figure h3 {
  font-family: var(--font-display); font-size: 0.9rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--color-text-secondary); margin-bottom: 0.8rem;
}
.chart {
  display: flex; align-items: flex-end; gap: 1.2rem;
  height: 220px; padding: 1rem 0; border-bottom: 2px solid var(--color-border);
}
.chart-bar { flex: 1; background: var(--color-accent); position: relative; transition: height 0.8s ease; }
.chart-bar:nth-child(2) { background: #4a7c72; }
.chart-bar:nth-child(3) { background: #6a9a8e; }
.chart-bar:nth-child(4) { background: #8ab8aa; }
.chart-label { position: absolute; bottom: -1.6rem; left: 0; right: 0; text-align: center; font-size: 0.75rem; color: var(--color-text-secondary); font-family: var(--font-display); }
.chart-value { position: absolute; top: -1.4rem; left: 0; right: 0; text-align: center; font-size: 0.8rem; font-weight: 600; color: var(--color-text); font-family: var(--font-display); }

/* Author box */
.author-box { display: flex; gap: 1rem; align-items: flex-start; border-top: 1px solid var(--color-border); padding-top: 1.5rem; margin-top: 2.5rem; }
.author-avatar { width: 56px; height: 56px; border-radius: 0; flex-shrink: 0; }
.author-info { font-size: 0.95rem; }
.author-info .name { font-weight: 700; }
.author-info .bio { margin-top: 0.3rem; color: var(--color-text-secondary); font-size: 0.9rem; }

/* Related posts */
.related-posts { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--color-border); }
.related-posts h2 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }
.related-list { list-style: none; padding: 0; }
.related-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--color-border); }
.related-list a { text-decoration: none; font-weight: 600; }
.related-list a:hover { text-decoration: underline; }
.related-list .meta { font-size: 0.82rem; color: var(--color-text-secondary); display: block; margin-top: 0.15rem; }

/* TOC */
.toc { display: none; }
@media (min-width: 1000px) {
  .toc { display: block; position: sticky; top: 5rem; align-self: start; }
  .toc h2 { font-family: var(--font-display); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-text-secondary); margin-bottom: 0.8rem; }
  .toc ol { list-style: none; padding: 0; margin: 0; }
  .toc li { margin: 0.3rem 0; }
  .toc a { display: block; font-size: 0.88rem; text-decoration: none; color: var(--color-text-secondary); padding: 0.25rem 0; border-left: 2px solid transparent; padding-left: 0.7rem; }
  .toc a.active { color: var(--color-accent); border-left-color: var(--color-accent); font-weight: 600; }
  .toc a:hover { color: var(--color-text); }
}

/* ===== Archive ===== */
.page-header { max-width: var(--max-width); margin: 0 auto; padding: 2.5rem var(--gutter) 1rem; }
.page-header h1 { font-family: var(--font-display); font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700; line-height: 1.15; margin-bottom: 0.4rem; }
.page-header .subtitle { color: var(--color-text-secondary); font-size: 1rem; }

.filters { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--gutter) 1.5rem; }
.filter-list { list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.filter-list a {
  display: inline-block; padding: 0.4rem 0.9rem; border: 1px solid var(--color-border);
  font-family: var(--font-display); font-size: 0.85rem; font-weight: 500;
  text-decoration: none; color: var(--color-text-secondary);
}
.filter-list a:hover, .filter-list a.active { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

.results-bar {
  max-width: var(--max-width); margin: 0 auto; padding: 0.8rem var(--gutter);
  border-top: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border);
  font-size: 0.9rem; color: var(--color-text-secondary); display: flex; justify-content: space-between; align-items: center;
}
.results-bar strong { color: var(--color-text); font-weight: 600; }

.archive-list { max-width: var(--max-width); margin: 0 auto; padding: 1.5rem var(--gutter); list-style: none; }
.archive-item { display: grid; gap: 1rem; padding: 1.2rem 0; border-bottom: 1px solid var(--color-border); align-items: start; }
@media (min-width: 700px) { .archive-item { grid-template-columns: 160px 1fr; } }
.archive-item .item-num { font-family: var(--font-display); font-size: 0.75rem; font-weight: 700; color: var(--color-accent); letter-spacing: 0.05em; margin-bottom: 0.2rem; }
.archive-item h2 { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; line-height: 1.25; margin-bottom: 0.3rem; }
.archive-item h2 a { text-decoration: none; }
.archive-item h2 a:hover { text-decoration: underline; text-decoration-color: var(--color-accent); }
.archive-item .meta { font-size: 0.82rem; color: var(--color-text-secondary); margin-bottom: 0.4rem; }
.archive-item p { font-size: 0.95rem; color: var(--color-text-secondary); line-height: 1.5; }
.archive-thumb { aspect-ratio: 4 / 3; background: var(--color-bg-alt); overflow: hidden; }
.archive-thumb img { width: 100%; height: 100%; object-fit: cover; }

.pagination { max-width: var(--max-width); margin: 0 auto; padding: 1.5rem var(--gutter) 3rem; display: flex; gap: 0.4rem; list-style: none; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; height: 40px; padding: 0 0.6rem;
  border: 1px solid var(--color-border); font-family: var(--font-display); font-size: 0.9rem; font-weight: 500; text-decoration: none;
}
.pagination a:hover { background: var(--color-bg-alt); }
.pagination .current { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

/* ===== 404 ===== */
.error-main { max-width: var(--max-width); margin: 0 auto; padding: 4rem var(--gutter); }
.error-code { font-family: var(--font-display); font-size: clamp(4rem, 12vw, 8rem); font-weight: 700; line-height: 1; color: var(--color-accent); letter-spacing: -0.02em; margin-bottom: 0.5rem; }
.error-numbering { font-family: var(--font-display); font-size: 0.8rem; font-weight: 600; color: var(--color-accent); letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 1.5rem; }
.error-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; margin-bottom: 0.6rem; }
.error-desc { color: var(--color-text-secondary); max-width: 520px; margin-bottom: 2rem; }

.search-box { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 2.5rem; max-width: 480px; }
.search-box input[type="search"] { flex: 1 1 240px; padding: 0.65rem 0.9rem; border: 1px solid var(--color-border); font-family: var(--font-body); font-size: 1rem; }
.search-box button { padding: 0.65rem 1.4rem; background: var(--color-accent); color: #fff; border: none; font-family: var(--font-display); font-weight: 600; cursor: pointer; }
.search-box button:hover { background: #244a43; }

.back-home { display: inline-block; padding: 0.6rem 1.2rem; border: 1px solid var(--color-text); font-family: var(--font-display); font-weight: 600; text-decoration: none; margin-bottom: 2.5rem; }
.back-home:hover { background: var(--color-text); color: #fff; }

.rubrics h2 { font-family: var(--font-display); font-size: 0.9rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-secondary); margin-bottom: 0.8rem; }
.rubrics ol { list-style: none; display: grid; gap: 0.5rem; }
@media (min-width: 600px) { .rubrics ol { grid-template-columns: repeat(2, 1fr); } }
.rubrics a { font-family: var(--font-display); font-size: 1rem; font-weight: 500; text-decoration: none; display: flex; align-items: baseline; gap: 0.6rem; }
.rubrics a:hover { color: var(--color-accent); }
.rubrics .cat-num { font-size: 0.8rem; font-weight: 700; color: var(--color-accent); font-variant-numeric: tabular-nums; }

/* ===== Footer ===== */
.site-footer { background: var(--color-text); color: #adb5bd; padding: 2.5rem 0 2rem; margin-top: 3rem; }
.footer-inner { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--gutter); }
.brand-footer { color: #fff; margin-bottom: 1.2rem; }
.brand-footer .brand-wordmark { color: #fff; }
.site-footer nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.site-footer nav a { color: #adb5bd; text-decoration: none; font-size: 0.9rem; }
.site-footer nav a:hover { color: #fff; }
.copyright { font-size: 0.85rem; color: #6c757d; }

/* ===== Utilities ===== */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity 0.6s ease, transform 0.6s ease; }
.reveal.is-visible { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  html { scroll-behavior: auto; }
  .chart-bar { transition: none; }
}
