/* encre — base layout system
 * Cherry-picked from Ghost Casper's gh-canvas grid.
 * Three named columns: full / wide / main
 */

/* === GRID SYSTEM === */
.article-canvas {
  --gap: max(4vmin, 20px);
  --main: min(var(--content-width, 720px), 100% - var(--gap) * 2);
  --wide: minmax(0, calc((var(--container-max, 1200px) - var(--content-width, 720px)) / 2));
  --full: minmax(var(--gap), 1fr);
  display: grid;
  grid-template-columns:
    [full-start] var(--full)
    [wide-start] var(--wide)
    [main-start] var(--main) [main-end]
    var(--wide) [wide-end]
    var(--full) [full-end];
}

.article-canvas > * {
  grid-column: main-start / main-end;
}

.width-wide {
  grid-column: wide-start / wide-end;
}

.width-full {
  grid-column: full-start / full-end;
}

/* === TYPOGRAPHY === */
body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--fg);
  background: var(--bg);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  letter-spacing: var(--tracking-display);
  line-height: var(--leading-tight);
  color: var(--fg);
}

.article-title {
  font-size: clamp(var(--text-2xl), 5vw, var(--text-3xl));
  margin: 0 0 var(--space-4);
}

.article-subtitle {
  font-size: var(--text-lg);
  color: var(--fg-2);
  margin: 0 0 var(--space-8);
}

h2 { font-size: var(--text-xl); margin: 2.5em 0 0.8em; }
h3 { font-size: var(--text-lg); margin: 2em 0 0.6em; }

p {
  margin: 0 0 max(2.4vmin, 18px);
  color: var(--fg-2);
}

/* === BLOCKS === */

/* Image */
.block-image {
  margin: max(4vmin, 28px) 0;
}

.block-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
}

.block-image figcaption {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: var(--space-3);
  text-align: center;
}

/* Pullquote */
.block-pullquote {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  line-height: 1.4;
  color: var(--fg);
  border-left: 3px solid var(--accent);
  padding: var(--space-4) 0 var(--space-4) var(--space-6);
  margin: max(4vmin, 28px) 0;
}

/* Blockquote (original language) */
.block-quote {
  border-left: 3px solid var(--border);
  padding: var(--space-4) var(--space-6);
  margin: max(3vmin, 20px) 0;
  background: var(--surface);
  border-radius: var(--radius-sm);
}

.block-quote .quote-original {
  font-style: italic;
  color: var(--fg-2);
  margin-bottom: var(--space-3);
}

.block-quote .quote-source {
  font-size: var(--text-sm);
  color: var(--muted);
}

/* Horizontal rule */
.block-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: max(4.8vmin, 32px) 0;
}

/* Series nav */
.block-series-nav {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  margin: max(4vmin, 28px) 0;
}

.block-series-nav h4 {
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 var(--space-4);
}

.block-series-nav a {
  display: block;
  padding: var(--space-2) 0;
  color: var(--accent);
  text-decoration: none;
  font-size: var(--text-sm);
}

.block-series-nav a:hover {
  text-decoration: underline;
}

/* Hero */
.block-hero {
  position: relative;
  margin-bottom: max(6vmin, 40px);
}

/* Data Card */
.block-data-card {
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  margin: max(4vmin, 28px) 0;
}

.block-data-card .data-card-number {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}

.block-data-card .data-card-unit {
  font-size: var(--text-lg);
}

.block-data-card .data-card-label {
  font-size: var(--text-base);
  color: var(--muted);
  margin-top: var(--space-2);
}

.block-data-card .data-card-source {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: var(--space-3);
}

/* Timeline */
.block-timeline {
  list-style: none;
  padding: 0;
  margin: max(4vmin, 28px) 0;
  border-left: 2px solid var(--accent);
}

.block-timeline li {
  position: relative;
  padding: var(--space-3) 0 var(--space-3) var(--space-6);
}

.block-timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.block-timeline .timeline-year {
  font-weight: 700;
  margin-right: var(--space-3);
}

.block-timeline .timeline-text {
  color: var(--fg-2);
}

.block-hero img {
  width: 100%;
  height: auto;
  display: block;
}

/* Meta */
.article-meta {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: var(--space-8);
}

.article-meta .meta-category {
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* === RESPONSIVE — 5 breakpoints ===
 * phone-s:  ≤390px  (6" iPhone 14 / Pixel 7)
 * phone-l:  ≤430px  (6.9" iPhone 16 Pro Max / S25 Ultra)
 * tablet:   ≤820px  (iPad Air / iPad 10th)
 * desktop:  ≤1920px (Full HD)
 * ultra:    >1920px (4K+)
 */

/* phone-s: 6" — tightest spacing */
@media (max-width: 390px) {
  :root {
    --text-base: 16px;
    --text-lg: 18px;
    --text-xl: 24px;
    --text-2xl: 32px;
    --text-3xl: 44px;
    --content-width: 100%;
  }
  .article-canvas { --gap: 16px; }
  .article-title { font-size: var(--text-2xl); }
  .block-pullquote { font-size: var(--text-lg); padding-left: var(--space-4); }
  .width-wide { grid-column: full-start / full-end; }
}

/* phone-l: 6.9" */
@media (min-width: 391px) and (max-width: 430px) {
  :root {
    --text-base: 16px;
    --text-lg: 19px;
    --text-xl: 25px;
    --text-2xl: 34px;
    --text-3xl: 48px;
    --content-width: 100%;
  }
  .article-canvas { --gap: 18px; }
  .article-title { font-size: var(--text-2xl); }
  .block-pullquote { font-size: var(--text-lg); }
  .width-wide { grid-column: full-start / full-end; }
}

/* tablet: iPad */
@media (min-width: 431px) and (max-width: 820px) {
  :root {
    --text-base: 17px;
    --text-lg: 20px;
    --text-xl: 26px;
    --text-2xl: 38px;
    --text-3xl: 54px;
    --content-width: 85%;
  }
  .article-canvas { --gap: 24px; }
  .article-title { font-size: var(--text-2xl); }
}

/* desktop: Full HD — default values from theme tokens apply */
/* (no override needed, 720px content width is the base) */

/* ultra: 4K+ */
@media (min-width: 1921px) {
  :root {
    --text-base: 20px;
    --text-lg: 24px;
    --text-xl: 34px;
    --text-2xl: 52px;
    --text-3xl: 76px;
    --text-4xl: 108px;
    --content-width: 800px;
    --container-max: 1400px;
  }
  .article-canvas { --gap: max(5vmin, 40px); }
  .block-image img { border-radius: var(--radius-md); }
}

/* === DARK MODE === */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1a1a;
    --surface: #242424;
    --surface-warm: #2a2420;
    --fg: #e8e4e0;
    --fg-2: #b8b0a8;
    --muted: #8a8078;
    --border: #3a3530;
    --border-soft: #2e2a26;
  }
}
