/*
 * Kunkel Capital Blog Styles
 * Inherits brand variables and header/footer styles directly from index.php (matching).
 * Body, header, footer, container, btn-primary, btn-login: identical to main site.
 * Blog-specific selectors (.blog-*): unique to blog templates.
 */

:root {
  /* COLORS — match index.php :root */
  --bg-color: #ffffff;
  --bg-alt: #f8f9fa;
  --text-main: #050505;
  --text-secondary: #444444;
  --accent: #c2943e;
  --accent-dark: #9e762e;
  --border: #e0e0e0;

  /* UTILS */
  --container-width: 1200px;
  --font-display: 'Playfair Display', serif;
  --font-body: 'Inter', sans-serif;
  --shadow-soft: 0 20px 40px rgba(0,0,0,0.06);

  /* BLOG-SPECIFIC */
  --kc-content-width: 720px;
}

*, *::before, *::after { box-sizing: border-box; }

/* Native smooth scroll (honors prefers-reduced-motion automatically below). */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .blog-reading-progress { transition: none !important; }
}

/* Fixed reading progress — mirrors dashboard/analysis.php bar, routed for blog.
   Sits just under the site header (60px). */
.blog-reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  z-index: 9999;
  border-radius: 0 2px 2px 0;
  transition: width 80ms linear;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(194, 148, 62, 0.25);
}

body.blog-page {
  margin: 0;
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-main);
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 25px;
}

h1, h2, h3 { font-family: var(--font-display); color: var(--text-main); margin: 0; }
p { font-size: 1.1rem; color: var(--text-secondary); line-height: 1.6; font-weight: 400; }

/* ============= BUTTONS (match main site exactly) ============= */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 18px 40px;
  background: var(--text-main);
  color: #fff !important;
  text-decoration: none;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.9rem;
  border-radius: 4px;
  transition: all 0.3s cubic-bezier(0.215, 0.610, 0.355, 1.000);
  cursor: pointer;
  border: 1px solid var(--text-main);
  -webkit-appearance: none;
}
.btn-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(194, 148, 62, 0.3);
}
.btn-primary.gold {
  background: var(--accent);
  border-color: var(--accent);
}
.btn-primary.gold:hover {
  background: var(--accent-dark);
}

.btn-login {
  font-size: 0.85rem; font-weight: 600; text-decoration: none; color: #111;
  padding: 8px 20px; border: 1px solid #ddd; border-radius: 50px;
  transition: all 0.2s;
}
.btn-login:hover { border-color: #000; background: #000; color: #fff; }

/* ============= HEADER (match main site exactly) ============= */
/* IMPORTANT: scope to body > header (direct child only).
   Otherwise inner <header class="blog-index-hero"> / <header class="blog-post-header">
   inherit position:fixed and overlap the layout. */
body.blog-page > header {
  position: fixed; top: 0; left: 0; right: 0; padding: 20px 0;
  z-index: 1000; background: rgba(255,255,255,0.95);
  backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
  border-bottom: 1px solid rgba(0,0,0,0.05);
}
body.blog-page > header .header-inner { display: flex; justify-content: space-between; align-items: center; }
body.blog-page > header .brand img { height: 50px; width: auto; }
body.blog-page > header .brand-group { display: flex; align-items: center; gap: 14px; }

/* Inner article/section headers must remain in normal flow */
body.blog-page main header,
body.blog-page article header {
  position: static;
  padding: 0;
  background: transparent;
  border: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Push content below fixed page header */
body.blog-page main,
body.blog-page article.blog-post,
body.blog-page .blog-404 { padding-top: 110px; }

/* ============= FOOTER (match main site exactly) ============= */
footer {
  background: #f8f9fa; color: #222; padding: 100px 0 40px;
  text-align: center; border-top: 1px solid #e0e0e0;
  margin-top: 80px;
}
footer h2 { color: #111; margin-bottom: 20px; font-family: var(--font-display); font-size: 2.4rem; }
footer p { color: #555; }
.footer-links a { color: #555; text-decoration: none; margin: 0 15px; font-size: 0.9rem; font-weight: 500; transition: color 0.2s; }
.footer-links a:hover { color: var(--accent); }

/* ============= ETC: blog-specific tokens ============= */
.kc-eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent-dark);
  margin-bottom: 8px;
}
.meta-dot { margin: 0 8px; color: #888; }

/* ============= BLOG INDEX ============= */
.blog-index {
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 140px 25px 80px;  /* Top padding clears fixed header (~90px) + breathing room */
}
.blog-index-hero {
  text-align: center;
  margin-top: 40px;
  margin-bottom: 80px;
}
.blog-index-title {
  font-family: var(--font-display);
  font-size: clamp(40px, 5vw, 64px);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -1.5px;
  margin: 8px 0 16px;
}
.blog-index-title em {
  font-style: italic;
  color: var(--accent);
  font-weight: 700;
}
.blog-index-subtitle {
  font-size: 1.18rem;
  color: var(--text-secondary);
  margin: 0 auto 32px;
  max-width: 640px;
  line-height: 1.5;
}

/* Author strip — E-E-A-T + personal brand */
.blog-author-strip {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  margin: 8px 0 28px;
  text-align: left;
  max-width: 560px;
}
.blog-author-strip-photo {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #050505, #2a2a2a);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 1px;
  flex-shrink: 0;
}
.blog-author-strip-name {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.95rem;
}
.blog-author-strip-credential {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 2px;
}

/* Email signup — soft CTA above fold */
.blog-email-form {
  max-width: 580px;
  margin: 0 auto 36px;
  text-align: left;
}
.blog-email-form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 12px;
}
.blog-email-form input[type="email"] {
  flex: 1 1 260px;
  padding: 14px 18px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  color: var(--text-main);
  outline: none;
  transition: border-color .2s;
}
.blog-email-form input[type="email"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(194,148,62,0.15);
}
.blog-email-form button {
  flex: 0 0 auto;
  padding: 14px 28px;
  font-size: 0.85rem;
}
.blog-email-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
/* GDPR footnote — implicit consent via "By clicking" pattern (Art. 4(11)) */
.blog-email-form-mark {
  font-size: 0.85em;
  font-weight: 600;
  margin-left: 5px;
  vertical-align: super;
  line-height: 0;
  opacity: 1;
  position: relative;
  top: -0.2em;
}
.blog-email-form-footnote {
  margin: 0;
  padding: 0 4px;
  font-size: 0.72rem;
  line-height: 1.55;
  color: #888;
  text-align: center;
  letter-spacing: 0.01em;
}
.blog-email-form-footnote sup {
  font-size: 0.85em;
  margin-right: 2px;
  color: #aaa;
}
.blog-email-form-footnote a {
  color: #666;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(0,0,0,0.2);
  transition: color .15s, text-decoration-color .15s;
}
.blog-email-form-footnote a:hover {
  color: var(--accent-dark);
  text-decoration-color: var(--accent);
}
/* Success/Error message after submit */
.blog-email-form-message {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 0.88rem;
  font-weight: 500;
  text-align: center;
  display: none;
}
.blog-email-form-message-ok {
  display: block;
  background: rgba(34, 134, 58, 0.08);
  color: #166534;
  border: 1px solid rgba(34, 134, 58, 0.2);
}
.blog-email-form-message-err {
  display: block;
  background: rgba(190, 18, 60, 0.08);
  color: #be123c;
  border: 1px solid rgba(190, 18, 60, 0.2);
}

.blog-pillar-nav {
  display: inline-flex; flex-wrap: wrap; gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  max-width: 100%;
}
.blog-pillar-nav a {
  padding: 8px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary); text-decoration: none;
  white-space: nowrap;
}
.blog-pillar-nav a:hover { color: var(--text-main); }
.blog-pillar-nav a.active { background: var(--text-main); color: #fff; }

/* Mobile: switch to horizontal scroll to avoid ugly two-row pill-shape break */
@media (max-width: 640px) {
  .blog-pillar-nav {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;        /* Firefox */
    -ms-overflow-style: none;     /* IE/Edge */
    max-width: calc(100vw - 32px);
    border-radius: 999px;
    padding: 5px 6px;
    /* Soft fade at edges to indicate scrollability */
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
  }
  .blog-pillar-nav::-webkit-scrollbar { display: none; }  /* WebKit */
  .blog-pillar-nav a {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: 7px 14px;
    font-size: 12.5px;
  }
}

/* ============= GRID + CARDS ============= */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 32px;
}
.blog-grid-3 {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}
.blog-card {
  background: #fff;
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.blog-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
}
.blog-card-link {
  display: block; color: inherit !important; text-decoration: none !important;
}
/* Blog cover images are rendered at 1600x640 (5:2) by the Remotion pipeline,
   so match that ratio on cards to avoid cropping editorial copy in/out. */
.blog-card-image {
  aspect-ratio: 5 / 2;
  overflow: hidden;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.blog-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform .35s ease;
}
.blog-card:hover .blog-card-image img { transform: scale(1.03); }
.blog-card-body { padding: 20px 22px 22px; }
.blog-card-pillar {
  font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase;
  color: var(--accent-dark); margin-bottom: 8px;
}
.blog-card-title {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 600; line-height: 1.2;
  margin: 0 0 10px; color: var(--text-main);
}
.blog-card-excerpt {
  color: var(--text-secondary);
  font-size: 0.95rem; line-height: 1.55;
  margin: 0 0 14px;
}
.blog-card-meta { font-size: 0.82rem; color: #888; }

.blog-empty { text-align: center; padding: 60px 0; color: #888; }

/* Bridge CTA — sits above the standard site footer, blog-native tone */
.blog-bridge-cta {
  margin: 80px auto 40px;
  max-width: 720px;
  padding: 48px 40px;
  background: var(--bg-alt);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  text-align: center;
}
.blog-bridge-cta h3 {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 14px;
  letter-spacing: -0.5px;
}
.blog-bridge-cta p {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin: 0 auto 26px;
  max-width: 560px;
  line-height: 1.55;
}

.blog-pagination {
  margin-top: 50px;
  display: flex; align-items: center; justify-content: center;
  gap: 24px; font-size: 14px;
}
.blog-page-indicator { color: #888; }

/* ============= SINGLE POST ============= */
.blog-post {
  max-width: var(--kc-content-width);
  margin: 0 auto;
  padding: 110px 25px 60px;
}
.blog-breadcrumbs {
  font-size: 13px; color: #888; margin-bottom: 32px;
}
.blog-breadcrumbs a { color: var(--text-secondary); margin: 0 6px; text-decoration: none; }
.blog-breadcrumbs a:first-child { margin-left: 0; }
.blog-breadcrumbs a:hover { color: var(--accent-dark); }
.blog-breadcrumbs span { color: var(--border); }

.blog-post-header { margin-bottom: 32px; }
.blog-post-title {
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 56px);
  font-weight: 700; line-height: 1.06; letter-spacing: -1.5px;
  color: var(--text-main); margin: 8px 0 24px;
}
.blog-post-meta { font-size: 0.92rem; color: #888; }
.blog-post-meta a { color: var(--text-main); font-weight: 600; text-decoration: none; }
.blog-post-meta a:hover { color: var(--accent-dark); }
.blog-post-updated { color: var(--accent-dark); font-weight: 500; }

.blog-post-hero {
  margin: 0 calc(50% - 50vw) 40px;
  max-width: 100vw;
}
.blog-post-hero img {
  width: 100%; height: auto; max-width: 1000px;
  margin: 0 auto; display: block; border-radius: 6px;
}

.blog-post-body {
  font-size: 1.18rem; line-height: 1.65; color: var(--text-main);
}
.blog-post-body h2 {
  font-family: var(--font-display);
  font-size: 2rem; font-weight: 700; line-height: 1.15;
  margin: 50px 0 18px; letter-spacing: -0.8px;
}
.blog-post-body h3 {
  font-size: 1.35rem; font-weight: 600; margin: 36px 0 14px;
}
.blog-post-body p { margin: 0 0 22px; color: var(--text-main); font-size: 1.18rem; }
.blog-post-body a {
  color: var(--accent-dark); text-decoration: underline; text-underline-offset: 3px;
}
.blog-post-body strong { color: var(--text-main); }
.blog-post-body figure.blog-figure {
  margin: 36px calc(50% - 50vw); max-width: 100vw; text-align: center;
}
.blog-post-body figure.blog-figure img {
  max-width: 1000px; width: 100%; height: auto;
  display: block; margin: 0 auto; border-radius: 6px;
}
.blog-post-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 0 12px 24px; margin: 30px 0;
  color: var(--text-secondary); font-style: italic;
}
.blog-post-body ul, .blog-post-body ol { padding-left: 24px; margin: 0 0 22px; }
.blog-post-body li { margin-bottom: 8px; }
.blog-post-body code {
  background: var(--bg-alt); padding: 2px 6px;
  border-radius: 3px; font-size: 0.92em;
}

/* ============= IN-ARTICLE CTAs ============= */
.blog-cta {
  margin: 50px 0; padding: 32px;
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
}
.blog-cta h3 {
  font-family: var(--font-display);
  font-size: 1.6rem; margin: 8px 0 12px; color: var(--text-main);
}
.blog-cta p { font-size: 1rem; color: var(--text-secondary); margin: 0 0 20px; }

/* ============= AUTHOR BIO ============= */
.blog-author-bio {
  display: flex; gap: 20px;
  margin: 50px 0 30px; padding: 28px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.blog-author-photo {
  width: 80px; height: 80px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0;
}
.blog-author-photo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #050505, #2a2a2a);
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: 1.5px;
}
.blog-author-name {
  font-weight: 600; font-size: 1.1rem; color: var(--text-main);
}
.blog-author-job {
  font-size: 0.78rem; color: var(--accent-dark);
  margin: 2px 0 10px;
  font-weight: 600; letter-spacing: 1px; text-transform: uppercase;
}
.blog-author-bio-text {
  font-size: 0.95rem; color: var(--text-secondary);
  margin: 0 0 12px; line-height: 1.55;
}
.blog-author-links { display: flex; gap: 14px; font-size: 13px; }

.blog-post-disclosure {
  margin: 30px 0; font-size: 0.82rem; color: #888;
  text-align: center; font-style: italic;
}

/* ============= RELATED ============= */
.blog-related {
  margin-top: 60px; padding-top: 40px;
  border-top: 1px solid var(--border);
}
.blog-related h3 {
  font-family: var(--font-display);
  font-size: 1.5rem; margin: 0 0 24px;
}
.blog-related .blog-card-title { font-size: 1.05rem; }

/* ============= 404 ============= */
.blog-404 {
  max-width: 600px; margin: 0 auto;
  padding: 140px 25px 80px; text-align: center;
}
.blog-404 h1 {
  font-family: var(--font-display);
  font-size: 3rem; margin-bottom: 16px;
}

/* ============= MOBILE ============= */
@media (max-width: 768px) {
  body.blog-page main,
  body.blog-page article.blog-post,
  body.blog-page .blog-404 { padding-top: 90px; }
  .brand img { height: 40px; }
  .blog-post { padding: 90px 18px 60px; }
  .blog-post-body { font-size: 1.1rem; }
  .blog-post-body h2 { font-size: 1.65rem; margin: 36px 0 14px; }
  .blog-post-body h3 { font-size: 1.2rem; }
  .blog-author-bio { flex-direction: column; }
  footer { padding: 60px 0 40px; }
  footer h2 { font-size: 1.7rem; }
  .blog-author-strip { padding: 12px 16px; gap: 12px; }
  .blog-author-strip-photo { width: 40px; height: 40px; font-size: 0.82rem; }
  .blog-author-strip-credential { font-size: 0.78rem; }
  .blog-email-form { flex-direction: column; }
  .blog-email-form input[type="email"], .blog-email-form button { width: 100%; flex: none; }
  .blog-bridge-cta { padding: 32px 22px; margin: 60px auto 30px; }
  .blog-bridge-cta h3 { font-size: 1.5rem; }
  .blog-bridge-cta p { font-size: 0.95rem; }
}
