/* ── Blog: a light, editorial counterpart to the dark calculator ──
 * Loaded after styles.css. Every token the shared stylesheet defines on :root
 * is re-declared on body.blog, so shared pieces inherit the paper theme.
 */

body.blog {
  --bg: #f7f3ec;
  --paper: #fffdfa;
  --card: #fffdfa;
  --card-raised: #f2ece1;
  --text: #17211f;
  --text-secondary: #5d6660;
  --text-muted: #8b9088;
  --border: #e5ddcf;
  --rule-soft: #eee7db;

  --accent: #0f766e;
  --accent-deep: #0b4f4a;
  --accent-soft: #e6f0ed;
  --ochre: #9a6b12;
  --ochre-soft: #f7efdc;

  --radius: 16px;
  --radius-sm: 12px;
  --shadow-soft: 0 1px 2px rgba(31, 26, 16, 0.04), 0 14px 34px -22px rgba(31, 26, 16, 0.4);
  --shadow-lift: 0 2px 4px rgba(31, 26, 16, 0.05), 0 22px 44px -24px rgba(31, 26, 16, 0.45);

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-prose: "Newsreader", Georgia, "Times New Roman", serif;
  --font-ui: "DM Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;

  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-synthesis-weight: none;
}

body.blog ::selection { background: #cfe6df; color: var(--accent-deep); }

/* Fraunces is requested with its SOFT and WONK axes already pinned, so the
 * headings get the softer, slightly wonky cut without any extra declaration. */
body.blog h1,
body.blog h2,
body.blog h3 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* Paper grain: warm washes plus a faint tessellation, far softer than the app's. */
body.blog .geo-bg {
  opacity: 1;
  background:
    radial-gradient(ellipse 70% 50% at 50% -10%, rgba(15, 118, 110, 0.07), transparent 70%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(154, 107, 18, 0.06), transparent 70%),
    repeating-conic-gradient(from 30deg at 50% 50%, transparent 0deg 30deg, rgba(23, 33, 31, 0.012) 30deg 60deg);
  background-size: 100% 100%, 100% 100%, 92px 92px;
}

/* ── Ornament: an eight-point star on a hairline ── */
.ornament {
  position: relative;
  height: 1.25rem;
  margin: 2.25rem 0;
}

.ornament::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 50%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border) 25%, var(--border) 75%, transparent);
}

.ornament::after {
  content: "";
  position: absolute;
  inset-inline-start: 50%;
  top: 50%;
  width: 15px;
  height: 15px;
  translate: -50% -50%;
  background: var(--accent);
  opacity: 0.55;
  box-shadow: 0 0 0 7px var(--bg);
  clip-path: polygon(
    50% 0%, 58.4% 29.7%, 85.4% 14.6%, 70.3% 41.6%,
    100% 50%, 70.3% 58.4%, 85.4% 85.4%, 58.4% 70.3%,
    50% 100%, 41.6% 70.3%, 14.6% 85.4%, 29.7% 58.4%,
    0% 50%, 29.7% 41.6%, 14.6% 14.6%, 41.6% 29.7%
  );
}

/* ── Masthead ── */
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(247, 243, 236, 0.86);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule-soft);
}

.site-nav {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0.85rem clamp(1.1rem, 4vw, 2.5rem);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-nav .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  min-width: 0;
}

.site-nav .brand img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(31, 26, 16, 0.18);
}

.site-nav .nav-links {
  margin-inline-start: auto;
  display: flex;
  gap: 1.35rem;
}

.site-nav .nav-links a {
  position: relative;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding-block: 0.35rem;
  transition: color 0.18s ease;
}

.site-nav .nav-links a::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
  scale: 0 1;
  transition: scale 0.22s ease;
}

.site-nav .nav-links a:hover { color: var(--accent-deep); }
.site-nav .nav-links a:hover::after,
.site-nav .nav-links a.active::after { scale: 1 1; }
.site-nav .nav-links a.active { color: var(--accent-deep); }

/* ── Page frame ── */
body.blog main.blog-main {
  display: block;
  width: 100%;
  max-width: 62rem;
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 4rem) clamp(1.1rem, 4vw, 2.5rem) clamp(2.5rem, 6vw, 4.5rem);
}

.eyebrow {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
}

/* ── Index ── */
.blog-intro {
  max-width: 34rem;
  margin: 0 auto clamp(1.5rem, 4vw, 2.5rem);
  text-align: center;
}

.blog-intro h1 {
  font-size: clamp(2.1rem, 6vw, 3.25rem);
  line-height: 1.04;
  letter-spacing: -0.03em;
  margin: 0.7rem 0 0;
}

.blog-intro .standfirst {
  font-family: var(--font-prose);
  font-size: 1.1rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-top: 1rem;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr));
  gap: clamp(1.25rem, 3vw, 2rem);
}

.post-card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow-soft);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 90ms);
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lift);
  border-color: #cbdfd9;
}

.post-card-frame {
  position: relative;
  overflow: hidden;
  background: var(--card-raised);
}

.post-card img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  transition: scale 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.post-card:hover img { scale: 1.04; }

.post-card-frame .tag {
  position: absolute;
  inset-block-start: 0.75rem;
  inset-inline-start: 0.75rem;
  background: rgba(255, 253, 250, 0.94);
  color: var(--accent-deep);
  box-shadow: 0 2px 10px rgba(31, 26, 16, 0.18);
}

.tag {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.post-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.35rem 1.4rem 1.5rem;
  flex: 1;
}

.post-card h2 {
  font-size: 1.28rem;
  line-height: 1.22;
  letter-spacing: -0.02em;
}

.post-card p {
  font-family: var(--font-prose);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.post-card .post-meta { margin-top: auto; padding-top: 0.5rem; }

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--text-muted);
}

.post-meta > * + *::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  vertical-align: 0.2em;
  margin-inline-end: 0.75rem;
}

/* ── Article ── */
.post {
  max-width: 41rem;
  margin: 0 auto;
}

.post-header { text-align: center; }

.post-header h1 {
  font-size: clamp(2rem, 5.6vw, 3.1rem);
  line-height: 1.06;
  letter-spacing: -0.03em;
  margin: 0.85rem 0 0;
  text-wrap: balance;
}

.post-header .post-lede {
  font-family: var(--font-prose);
  font-size: 1.15rem;
  line-height: 1.65;
  color: var(--text-secondary);
  margin-top: 1rem;
}

.post-header .post-meta {
  justify-content: center;
  margin-top: 1.4rem;
}

/* The photo breaks a little wider than the text column. */
.post-hero {
  position: relative;
  margin: clamp(2rem, 5vw, 3rem) calc(-1 * clamp(0rem, 4vw, 2.5rem)) 0;
}

.post-hero img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--card-raised);
  box-shadow: var(--shadow-soft);
}

.photo-credit {
  margin-top: 0.6rem;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: end;
}

.photo-credit a { color: inherit; text-decoration-color: var(--border); }
.photo-credit a:hover { color: var(--accent); }

/* The short, self-contained answer search engines and assistants quote. */
.post-answer {
  margin-top: clamp(2rem, 5vw, 3rem);
  padding: 1.6rem 1.75rem;
  background: linear-gradient(160deg, var(--accent-soft), #f4faf8);
  border: 1px solid #cfe3dd;
  border-radius: var(--radius);
}

.post-answer h2 {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

.post-answer h2::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-inline-end: 0.5rem;
  background: var(--accent);
  clip-path: polygon(
    50% 0%, 58.4% 29.7%, 85.4% 14.6%, 70.3% 41.6%,
    100% 50%, 70.3% 58.4%, 85.4% 85.4%, 58.4% 70.3%,
    50% 100%, 41.6% 70.3%, 14.6% 85.4%, 29.7% 58.4%,
    0% 50%, 29.7% 41.6%, 14.6% 14.6%, 41.6% 29.7%
  );
}

.post-answer p {
  font-family: var(--font-prose);
  font-size: 1.16rem;
  line-height: 1.62;
  color: var(--accent-deep);
}

.post-body {
  font-family: var(--font-prose);
  font-size: 1.15rem;
  line-height: 1.75;
  padding-top: clamp(1.75rem, 4vw, 2.5rem);
}

.post-body > * + * { margin-top: 1.4rem; }

.post-body > p:first-of-type::first-letter {
  float: inline-start;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 3.6em;
  line-height: 0.82;
  margin: 0.06em 0.09em 0 0;
  color: var(--accent);
}

.post-body h2 {
  font-size: clamp(1.45rem, 3.6vw, 1.8rem);
  line-height: 1.2;
  margin-top: 3.2rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--border);
}

.post-body h3 {
  font-size: 1.2rem;
  line-height: 1.3;
  margin-top: 2.2rem;
}

.post-body h2 + *, .post-body h3 + * { margin-top: 0.85rem; }

.post-body ul, .post-body ol { padding-inline-start: 1.3rem; }
.post-body li + li { margin-top: 0.55rem; }
.post-body li::marker { color: var(--accent); }

.post-body a {
  color: var(--accent-deep);
  text-decoration: underline;
  text-decoration-color: rgba(15, 118, 110, 0.35);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.18s ease;
}

.post-body a:hover { text-decoration-color: var(--accent); }
.post-body strong { font-weight: 600; color: #101816; }

.post-body blockquote {
  margin: 2.2rem 0;
  padding: 0.4rem 0 0.4rem 1.6rem;
  border-inline-start: 2px solid var(--ochre);
  font-size: 1.22rem;
  line-height: 1.62;
  font-style: italic;
  color: #4a3a17;
}

.post-body blockquote p + p { margin-top: 0.8rem; }

.post-body .table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
}

.post-body table {
  border-collapse: collapse;
  width: 100%;
  font-family: var(--font-ui);
  font-size: 0.92rem;
  line-height: 1.5;
}

.post-body th, .post-body td {
  text-align: start;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
}

.post-body th {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-deep);
  background: var(--accent-soft);
  border-bottom-color: #cfe3dd;
}

.post-body tr:last-child td { border-bottom: 0; }

.post-body img { border-radius: var(--radius-sm); max-width: 100%; height: auto; }

.post-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: var(--card-raised);
  padding: 0.12em 0.38em;
  border-radius: 5px;
}

/* ── Calls to action ── */
.cta-box {
  position: relative;
  overflow: hidden;
  margin: 2.6rem 0;
  padding: 1.6rem 1.75rem;
  border-radius: var(--radius);
  background: linear-gradient(140deg, #0f766e, #0b4f4a 70%);
  color: #f3fbf9;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.1rem;
  box-shadow: 0 18px 40px -26px rgba(11, 79, 74, 0.9);
}

.cta-box::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-conic-gradient(from 30deg at 50% 50%, transparent 0deg 30deg, rgba(255, 255, 255, 0.05) 30deg 60deg);
  background-size: 56px 56px;
  pointer-events: none;
}

.cta-box p {
  position: relative;
  flex: 1 1 15rem;
  margin: 0;
  font-family: var(--font-prose);
  font-size: 1rem;
  line-height: 1.55;
  color: rgba(243, 251, 249, 0.82);
}

.cta-box strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.28rem;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: #fff;
  margin-bottom: 0.35rem;
}

.cta-box a {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.3rem;
  background: #fffdfa;
  color: var(--accent-deep);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 999px;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cta-box a:hover { transform: translateY(-2px); box-shadow: 0 10px 22px -12px rgba(0, 0, 0, 0.7); }
.cta-box a span { transition: translate 0.2s ease; }
.cta-box a:hover span { translate: 3px 0; }

/* ── FAQ ── */
.post-faq { margin-top: clamp(2.5rem, 6vw, 3.5rem); }

.post-refs { margin-top: clamp(2rem, 5vw, 3rem); padding-top: 1.25rem; border-top: 1px solid var(--rule-soft); }
.post-refs h2 { font-size: 1.05rem; margin-bottom: 0.6rem; }
.post-refs ol { padding-inline-start: 1.3rem; font-size: 0.9rem; line-height: 1.55; color: var(--text-secondary); }
.post-refs li + li { margin-top: 0.4rem; }
.post-refs a { color: var(--accent); }
.post-refs .ref-note { color: var(--text-muted); }

.post-faq h2 {
  font-size: clamp(1.45rem, 3.6vw, 1.8rem);
  margin-bottom: 1.2rem;
}

.post-faq details {
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
}

.post-faq details:first-of-type { border-top: 1px solid var(--border); }

.post-faq summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0.25rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.08rem;
  line-height: 1.35;
  cursor: pointer;
  list-style: none;
}

.post-faq summary::-webkit-details-marker { display: none; }
.post-faq summary:hover { color: var(--accent-deep); }

.post-faq summary::after {
  content: "+";
  flex: 0 0 auto;
  font-family: var(--font-ui);
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--accent);
  transition: rotate 0.2s ease;
}

.post-faq details[open] summary::after { content: "−"; }

.post-faq .faq-answer {
  padding: 0 0.25rem 1.3rem;
  font-family: var(--font-prose);
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 36rem;
}

.post-faq .faq-answer > * + * { margin-top: 0.8rem; }
.post-faq .faq-answer a { color: var(--accent-deep); text-underline-offset: 0.16em; }

.post-disclaimer {
  margin-top: clamp(2.5rem, 6vw, 3.5rem);
  padding: 1.1rem 1.25rem;
  background: var(--ochre-soft);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  line-height: 1.6;
  color: #6b5417;
}

/* ── Related ── */
.related { margin-top: clamp(2.5rem, 6vw, 4rem); }

.related > h2 {
  text-align: center;
  font-size: 1.35rem;
  margin-bottom: 1.5rem;
}

.related .post-grid { max-width: 41rem; margin: 0 auto; }

/* One teaser at the foot of an article reads better lying down. */
@media (min-width: 38rem) {
  .related .post-card { flex-direction: row; }
  .related .post-card-frame { flex: 0 0 42%; }
  .related .post-card img { position: absolute; inset: 0; width: 100%; height: 100%; aspect-ratio: auto; }
  .related .post-card-body { padding: 1.5rem 1.6rem; }
  .related .post-card h2 { font-size: 1.18rem; }
}

/* ── Footer ── */
.blog-footer {
  max-width: 62rem;
  margin: 0 auto;
  padding: 2.5rem clamp(1.1rem, 4vw, 2.5rem) 3rem;
  border-top: 1px solid var(--rule-soft);
  text-align: center;
}

.blog-footer .footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
}

.blog-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

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

.blog-footer p {
  margin-top: 0.9rem;
  font-family: var(--font-prose);
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-muted);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 560px) {
  .post-body { font-size: 1.08rem; }
  .post-answer, .cta-box { padding: 1.25rem 1.2rem; }
  .post-hero { margin-inline: 0; }
  .site-nav .brand span { display: none; }
  .cta-box a { width: 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  body.blog *, body.blog *::before, body.blog *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
