/* ============================================================
 * ApplyCH Blog — Swiss-modernist long-form layout
 * Pairs with /css/redesign.css (tokens, nav, footer, buttons)
 * ============================================================ */

/* ---- 1. Listing hero ---- */
.blog-hero {
  padding-block: 64px 40px;
}
@media (max-width: 768px) {
  .blog-hero { padding-block: 48px 32px; }
}
.blog-hero .eyebrow { margin-bottom: 22px; }
.blog-hero h1 {
  font-size: clamp(40px, 5vw, 60px);
  margin-bottom: 0;
}
.blog-hero .lede {
  margin-top: 0;
  font-size: 18px;
  color: var(--ink-2);
  max-width: 640px;
  line-height: 1.55;
}

/* ---- 2. Listing grid ---- */
.blog-listing {
  padding-block: 16px 96px;
}
.blog-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px 20px;
}
@media (max-width: 968px) { .blog-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .blog-grid { grid-template-columns: 1fr; gap: 28px; } }

.post-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: #FFFFFF;
  overflow: hidden;
  transition: border-color 200ms var(--ease), transform 200ms var(--ease), box-shadow 200ms var(--ease);
}
.post-card:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 14px 28px -12px rgba(0,0,0,0.10);
}

.post-card-cover {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-alt);
}
.post-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 400ms var(--ease);
}
.post-card:hover .post-card-cover img { transform: scale(1.03); }

.post-card-body {
  padding: 22px 22px 24px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}
.post-card-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.post-card-meta span { color: var(--muted); }
.post-card-title {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-bottom: 10px;
  text-wrap: balance;
}
.post-card-title a { color: var(--ink); text-decoration: none; }
.post-card-title a:hover { color: var(--accent); }
.post-card-excerpt {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.55;
  margin-bottom: 14px;
  flex-grow: 1;
}
.post-card-link {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
}
.post-card-link a { color: var(--accent); }

/* First card spans the full width on desktop, larger image */
.post-card-feat {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: stretch;
}
.post-card-feat .post-card-cover {
  flex: 0 0 50%;
  aspect-ratio: auto;
  height: auto;
  align-self: stretch;
}
.post-card-feat .post-card-cover img { aspect-ratio: 16 / 10; }
.post-card-feat .post-card-body { padding: 36px 36px 36px; justify-content: center; }
.post-card-feat .post-card-title { font-size: clamp(24px, 2.6vw, 32px); }
.post-card-feat .post-card-excerpt { font-size: 16px; max-width: 56ch; }
@media (max-width: 880px) {
  .post-card-feat { flex-direction: column; }
  .post-card-feat .post-card-cover { flex-basis: auto; aspect-ratio: 16 / 9; }
  .post-card-feat .post-card-cover img { aspect-ratio: 16 / 9; }
  .post-card-feat .post-card-body { padding: 24px 22px 26px; }
  .post-card-feat .post-card-title { font-size: 24px; }
}

.blog-empty {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  padding: 80px 0;
}

/* ---- 3. Post header ---- */
.post-header {
  padding-block: 56px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-alt);
}
@media (max-width: 768px) { .post-header { padding-block: 36px 22px; } }

.post-eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 18px;
}
.post-eyebrow a { color: var(--muted); text-decoration: none; }
.post-eyebrow a:hover { color: var(--ink); }

.post-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(32px, 4.4vw, 52px);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 18px;
  max-width: 22ch;
  text-wrap: balance;
}

.post-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0;
}
.post-meta time { color: var(--ink-2); }
.post-meta-sep { margin: 0 6px; color: var(--line); }
#post-readtime:empty + .post-meta-readtime-sep,
.post-meta-readtime-sep:has(+ #post-readtime:empty) { display: none; }

/* ---- 4. Article body ---- */
.post-body-wrap {
  display: grid;
  grid-template-columns: 1fr;
  padding-block: 56px 64px;
}
@media (max-width: 768px) { .post-body-wrap { padding-block: 36px 48px; } }

.post-body {
  max-width: 68ch;
  margin: 0 auto;
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
  hyphens: auto;
  /* Pre-allocate space so the JS-fetched article body doesn't cause CLS.
   * Most blog posts render at 150–250vh of content; reserving 200vh
   * means subsequent sections (related, final-CTA, footer) don't shift
   * down when the fetch finishes for posts shorter than that. */
  min-height: 200vh;
}
.post-loading {
  font-family: var(--font-mono);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 40px 0;
}

/* Long-form prose */
.post-body > *:first-child { margin-top: 0; }
.post-body > *:last-child  { margin-bottom: 0; }

.post-body p {
  margin: 0 0 22px;
  font-size: 17px;
  color: var(--ink);
  line-height: 1.7;
}

/* Lead paragraph — slightly larger than body for visual entry. */
.post-body > p:first-of-type {
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: 28px;
}

.post-body h2 {
  font-family: var(--font-display);
  font-size: clamp(24px, 2.6vw, 32px);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 56px 0 16px;
  color: var(--ink);
  text-wrap: balance;
}
.post-body h2:first-child { margin-top: 0; }

.post-body h3 {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 36px 0 12px;
  color: var(--ink);
}

.post-body h4 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  margin: 28px 0 10px;
}

.post-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.post-body a:hover {
  color: var(--accent-deep);
  text-decoration-thickness: 2px;
}

.post-body ul,
.post-body ol {
  margin: 0 0 22px;
  padding-left: 22px;
}
.post-body li {
  margin-bottom: 8px;
  line-height: 1.65;
}
.post-body ul li::marker { color: var(--accent); }

.post-body blockquote {
  margin: 32px 0;
  padding: 8px 0 8px 24px;
  border-left: 3px solid var(--accent);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.4;
  color: var(--ink);
  font-style: italic;
}
.post-body blockquote p { font-size: inherit; line-height: inherit; margin: 0; color: inherit; }

.post-body code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--ink);
}
.post-body pre {
  background: var(--bg-dark);
  color: #F4F0E8;
  padding: 18px 20px;
  border-radius: var(--r-card);
  margin: 28px 0;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
}
.post-body pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
}

.post-body img,
.post-body video {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-card);
  margin: 28px 0;
  border: 1px solid var(--line);
  display: block;
}
.post-body figure {
  margin: 28px 0;
}
.post-body figure img { margin: 0; }
.post-body figcaption {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 10px;
}

.post-body hr {
  border: 0;
  height: 1px;
  background: var(--line);
  margin: 40px 0;
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 28px 0;
  font-size: 15px;
}
.post-body th, .post-body td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.post-body th {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

/* ---- 5. Mid-post CTA ---- */
.post-cta {
  max-width: 68ch;
  margin: 40px auto;
  padding: 28px 28px 30px;
  background: var(--bg-dark);
  color: #FFFFFF;
  border-radius: var(--r-card);
  position: relative;
  overflow: hidden;
}
.post-cta::before {
  content: '';
  position: absolute;
  top: 0; left: 24px; right: 24px;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
}
.post-cta-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #FF5468;
  margin: 6px 0 12px;
}
.post-cta h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 0 0 12px;
  color: #FFFFFF;
  text-wrap: balance;
}
.post-cta p {
  font-size: 15px;
  color: rgba(255,255,255,0.78);
  line-height: 1.6;
  margin: 0 0 18px;
}
/* Buttons inside the post body should ignore body link styles. */
.post-cta .btn,
.post-body .btn,
.post-body a.btn {
  text-decoration: none;
}
.post-cta .btn-red {
  background: var(--accent);
  color: #FFFFFF;
}
.post-cta .btn-red:hover { background: var(--accent-deep); color: #FFFFFF; text-decoration: none; }

/* ---- 6. Back link below content ---- */
.post-back {
  max-width: 68ch;
  margin: 40px auto 0;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}
.post-back a { color: var(--ink-2); text-decoration: none; }
.post-back a:hover { color: var(--ink); }

/* ---- 7. Related posts ---- */
.post-related {
  background: var(--bg-alt);
  border-block: 1px solid var(--line);
  padding-block: 64px;
}
@media (max-width: 768px) { .post-related { padding-block: 48px; } }
.post-related-head { margin-bottom: 32px; max-width: 720px; }
.post-related-head .eyebrow { margin-bottom: 12px; }
.post-related-head h2 {
  font-family: var(--font-display);
  font-size: clamp(28px, 3.6vw, 40px);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.post-related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 880px) { .post-related-grid { grid-template-columns: 1fr; } }

.related-card {
  display: block;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: #FFFFFF;
  text-decoration: none;
  color: inherit;
  transition: border-color 200ms var(--ease), transform 200ms var(--ease);
}
.related-card:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
  color: inherit;
}
.related-card-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}
.related-card-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-bottom: 10px;
  color: var(--ink);
}
.related-card-excerpt {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.55;
  margin-bottom: 14px;
}
.related-card-link {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
}

/* ---- 8. Final CTA strip on post pages ---- */
.post-final-cta {
  padding-block: 96px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.post-final-cta::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 700px; height: 700px;
  background: radial-gradient(circle, rgba(220,0,24,0.04), transparent 60%);
  pointer-events: none;
}
.post-final-cta-inner { position: relative; }
.post-final-cta h2 {
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 64px);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin: 0 0 16px;
}
.post-final-cta p {
  font-size: 16px;
  color: var(--muted);
  margin: 0 0 28px;
}
@media (max-width: 768px) { .post-final-cta { padding-block: 64px; } }

/* ============================================================
 * Legal pages (privacy, terms) — long-form with sticky TOC
 * ============================================================ */
.legal {
  padding-block: 56px 96px;
}
@media (max-width: 768px) { .legal { padding-block: 36px 64px; } }

.legal-head {
  max-width: 920px;
  margin: 0 auto 32px;
}
.legal-head .eyebrow { margin-bottom: 18px; }
.legal-head h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(36px, 4.6vw, 56px);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 16px;
  text-wrap: balance;
}
.legal-updated {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.legal-en-only {
  max-width: 1040px;
  margin: 0 auto 28px;
  padding: 12px 16px;
  border: 1px solid var(--accent);
  border-radius: var(--r-card);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
  font-size: 14px;
  color: var(--ink-2);
  text-align: center;
}
.legal-en-only a { color: var(--accent); font-weight: 500; }
.legal-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 56px;
  max-width: 1040px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 880px) { .legal-grid { grid-template-columns: 1fr; gap: 32px; } }

.legal-toc {
  position: sticky;
  top: 96px;
  align-self: start;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
}
@media (max-width: 880px) { .legal-toc { position: static; } }
.legal-toc h2 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
  font-weight: 500;
  border-top: 1px solid var(--ink);
  padding-top: 14px;
}
.legal-toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: toc;
}
.legal-toc li {
  margin-bottom: 8px;
  counter-increment: toc;
  display: flex;
  gap: 8px;
}
.legal-toc li::before {
  content: counter(toc, decimal-leading-zero);
  color: var(--muted);
  flex-shrink: 0;
}
.legal-toc a {
  color: var(--ink-2);
  text-decoration: none;
  line-height: 1.45;
}
.legal-toc a:hover { color: var(--accent); }

.legal-body {
  max-width: 70ch;
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  hyphens: auto;
}
.legal-body > .legal-intro {
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  margin: 0 0 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.legal-body h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(20px, 2.2vw, 24px);
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 44px 0 14px;
  scroll-margin-top: 96px; /* account for sticky nav */
  text-wrap: balance;
}
.legal-body h2:first-of-type { margin-top: 0; }
.legal-body h2 a.anchor {
  color: var(--line);
  text-decoration: none;
  margin-left: 10px;
  font-family: var(--font-mono);
  font-size: 0.6em;
  font-weight: 400;
  opacity: 0;
  transition: opacity 150ms var(--ease);
}
.legal-body h2:hover a.anchor { opacity: 1; }
.legal-body h2 a.anchor:hover { color: var(--accent); }
.legal-body p { margin: 0 0 16px; color: var(--ink-2); }
.legal-body ul, .legal-body ol { margin: 0 0 18px; padding-left: 22px; }
.legal-body li { margin-bottom: 6px; line-height: 1.6; color: var(--ink-2); }
.legal-body li ul { margin: 6px 0 8px; }
.legal-body strong { color: var(--ink); }
.legal-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.legal-body a:hover { color: var(--accent-deep); text-decoration-thickness: 2px; }
.legal-body code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 4px;
}
.legal-contact-card {
  margin-top: 32px;
  padding: 22px 24px;
  background: var(--bg-alt);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
}
.legal-contact-card p { margin: 0 0 8px; color: var(--ink-2); font-size: 15px; }
.legal-contact-card p:last-child { margin: 0; }
.legal-contact-card .legal-email {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
}

/* ============================================================
 * Contact page
 * ============================================================ */
.contact-hero {
  padding-block: 64px 32px;
}
@media (max-width: 768px) { .contact-hero { padding-block: 48px 24px; } }
.contact-hero .eyebrow { margin-bottom: 20px; }
.contact-hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(40px, 5vw, 60px);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 16px;
  text-wrap: balance;
}
.contact-hero .lede {
  font-size: 18px;
  color: var(--ink-2);
  max-width: 580px;
  margin: 0;
  line-height: 1.55;
}

.contact-section {
  padding-block: 24px 96px;
}
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: 32px;
  max-width: 1040px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 880px) { .contact-grid { grid-template-columns: 1fr; gap: 24px; } }

.contact-main {
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 36px 36px 40px;
  position: relative;
}
.contact-main::before {
  content: '';
  position: absolute;
  top: 0; left: 32px; right: 32px;
  height: 3px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
}
.contact-main p:first-of-type {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 8px 0 14px;
}
.contact-main h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(24px, 2.6vw, 30px);
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  text-wrap: balance;
}
.contact-main p {
  font-size: 16px;
  color: var(--ink-2);
  line-height: 1.6;
  margin: 0 0 20px;
}
.contact-email {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 17px;
  color: var(--ink);
  background: var(--bg-alt);
  border: 1px solid var(--line);
  padding: 12px 18px;
  border-radius: var(--r-pill);
  text-decoration: none;
  font-weight: 500;
  transition: border-color 150ms var(--ease), background 150ms var(--ease);
}
.contact-email:hover {
  border-color: var(--ink);
  color: var(--accent);
}
.contact-email-icon {
  width: 16px; height: 16px;
  color: var(--accent);
  flex-shrink: 0;
}
.contact-fineprint {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--muted);
}
.contact-fineprint strong { color: var(--ink); font-weight: 600; }

.contact-aside {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.contact-aside-card {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 24px;
  background: var(--bg-alt);
}
.contact-aside-card .eyebrow {
  display: block;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}
.contact-aside-card h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  margin: 0 0 8px;
  letter-spacing: -0.005em;
}
.contact-aside-card p {
  font-size: 14px;
  color: var(--ink-2);
  margin: 0 0 12px;
  line-height: 1.55;
}
.contact-aside-card a {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}
.contact-aside-card a:hover { color: var(--accent-deep); }

/* ---- 9. Active nav state ---- */
.nav-list a.is-current {
  color: var(--ink);
  position: relative;
}
.nav-list a.is-current::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -22px;
  height: 1px;
  background: var(--accent);
}
@media (max-width: 880px) {
  .nav-list a.is-current::after { display: none; }
}
