/* ==========================================================================
   Post Layout — Substack-inspired, reader-friendly
   ========================================================================== */

/* -- Reading font -------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400&display=swap');

/* -- Article container --------------------------------------------------- */
.post {
  --post-width: 680px;
  --post-wide: 800px;
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-tertiary: #999;
  --border-light: #e8e8e8;
  --bg-highlight: #faf9f7;
  --accent: #006747;
  --accent-light: #e8f5f0;
  max-width: 100%;
  padding-bottom: 4rem;
}

/* -- Header -------------------------------------------------------------- */
.post-header {
  padding: 4rem 1.5rem 0;
  text-align: center;
}

.post-header__inner {
  max-width: var(--post-width);
  margin: 0 auto;
}

.post-category {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  padding: 0.3em 0.9em;
  border-radius: 100px;
  margin-bottom: 1.25rem;
}

.post-title {
  font-family: 'Source Serif 4', 'Lora', Georgia, serif;
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  margin: 0 0 1rem;
  letter-spacing: -0.02em;
}

.post-subtitle {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0 0 2rem;
  font-weight: 400;
}

/* -- Author / meta ------------------------------------------------------- */
.post-meta {
  display: flex;
  justify-content: center;
  padding-top: 1.5rem;
}

.post-author {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.post-author__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.post-author__info {
  text-align: left;
}

.post-author__name {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.post-meta__details {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin-top: 0.15rem;
}

.post-meta__sep {
  margin: 0 0.4em;
}

/* -- Hero image ---------------------------------------------------------- */
.post-hero {
  max-width: var(--post-wide);
  margin: 2.5rem auto 0;
  padding: 0 1.5rem;
}

.post-hero img {
  width: 100%;
  border-radius: 8px;
  object-fit: cover;
}

.post-hero figcaption {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  text-align: center;
  margin-top: 0.75rem;
}

/* -- Video trigger button ------------------------------------------------ */
.post-video-trigger {
  max-width: var(--post-width);
  margin: 2rem auto 0;
  padding: 0 1.5rem;
}

.post-video-btn {
  position: relative;
  display: block;
  width: 100%;
  border: none;
  padding: 0;
  cursor: pointer;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
  transition: box-shadow 0.3s, transform 0.3s;
}

.post-video-btn:hover {
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  transform: translateY(-2px);
}

.post-video-btn__thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
}

.post-video-btn__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: linear-gradient(0deg, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.15) 50%, rgba(0,0,0,0.3) 100%);
  transition: background 0.3s;
}

.post-video-btn:hover .post-video-btn__overlay {
  background: linear-gradient(0deg, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0.2) 50%, rgba(0,0,0,0.35) 100%);
}

.post-video-btn__play {
  transition: transform 0.3s;
}

.post-video-btn:hover .post-video-btn__play {
  transform: scale(1.1);
}

.post-video-btn__play svg circle {
  transition: fill 0.3s;
}

.post-video-btn:hover .post-video-btn__play svg circle {
  fill: rgba(0,103,71,0.85);
}

.post-video-btn__label {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.03em;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

/* -- Cinematic video modal ---------------------------------------------- */
.video-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.video-modal[aria-hidden="false"] {
  display: flex;
}

.video-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: modalFadeIn 0.3s ease;
}

.video-modal__content {
  position: relative;
  width: 90vw;
  max-width: 960px;
  z-index: 1;
  animation: modalSlideUp 0.4s cubic-bezier(0.16,1,0.3,1);
}

.video-modal__close {
  position: absolute;
  top: -48px;
  right: 0;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  transition: color 0.2s;
}

.video-modal__close:hover {
  color: #fff;
}

.video-modal__player {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.video-modal__player iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* -- Override fade-in for post pages (scripts can block observer) --------- */
.post .fade-in {
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
}

/* -- Body content -------------------------------------------------------- */
.post-body {
  max-width: var(--post-width);
  margin: 2.5rem auto 0;
  padding: 0 1.5rem;
  font-family: 'Lora', Georgia, serif;
  font-size: 1.15rem;
  line-height: 1.8;
  color: var(--text-primary);
}

/* Interactive figures */
.post-body .interactive-figure {
  margin: 2rem -1.5rem;
}

@media (max-width: 768px) {
  .post-body .interactive-figure {
    margin: 1.5rem -1rem;
  }
}

/* Headings inside body */
.post-body h2 {
  font-family: 'Source Serif 4', 'Lora', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 3rem 0 1rem;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.post-body h3 {
  font-family: 'Source Serif 4', 'Lora', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 2.5rem 0 0.75rem;
  line-height: 1.35;
}

.post-body h4 {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 2rem 0 0.5rem;
  letter-spacing: 0.01em;
}

/* Math (KaTeX) */
.post-body .katex-display {
  margin: 2rem 0;
}

.post-body .katex-display > .katex {
  font-size: 1.15em;
}

.post-body .katex {
  font-size: 1.05em;
}

/* Paragraphs */
.post-body p {
  margin: 0 0 1.5rem;
}

/* Bold & italic */
.post-body strong {
  font-weight: 600;
  color: var(--text-primary);
}

.post-body em {
  font-style: italic;
}

/* Links */
.post-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(0, 103, 71, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.2s;
}

.post-body a:hover {
  text-decoration-color: var(--accent);
}

/* Blockquotes — Substack accent bar style */
.post-body blockquote {
  margin: 2rem 0;
  padding: 0.25rem 0 0.25rem 1.5rem;
  border-left: 3px solid var(--accent);
  font-style: italic;
  color: var(--text-secondary);
}

.post-body blockquote p {
  margin-bottom: 0.5rem;
}

.post-body blockquote p:last-child {
  margin-bottom: 0;
}

/* Horizontal rules — elegant divider */
.post-body hr {
  border: none;
  text-align: center;
  margin: 3rem 0;
}

.post-body hr::before {
  content: "* * *";
  display: block;
  font-family: 'Lora', Georgia, serif;
  font-size: 1.25rem;
  letter-spacing: 0.5em;
  color: var(--text-tertiary);
}

/* Lists */
.post-body ul,
.post-body ol {
  margin: 0 0 1.5rem;
  padding-left: 1.5rem;
}

.post-body li {
  margin-bottom: 0.5rem;
}

.post-body li::marker {
  color: var(--accent);
}

/* Code (exclude KaTeX) */
.post-body code:not(.katex-mathml *):not(.katex *) {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.88em;
  background: var(--bg-highlight);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: #c0392b;
}

/* Reset any inherited styles inside KaTeX */
.post-body .katex-display,
.post-body .katex {
  background: none;
  padding: 0;
  border: none;
  color: var(--text-primary);
}

.post-body pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 2rem 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.post-body pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Images inside body */
.post-body img {
  max-width: 100%;
  border-radius: 6px;
  margin: 1.5rem 0;
}

/* -- Footer -------------------------------------------------------------- */
.post-footer {
  max-width: var(--post-width);
  margin: 3rem auto 0;
  padding: 0 1.5rem;
}

/* Tags */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.post-tag {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-highlight);
  padding: 0.35em 0.85em;
  border-radius: 100px;
  border: 1px solid var(--border-light);
}

/* Share */
.post-share {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 0;
}

.post-share__label {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.post-share__buttons {
  display: flex;
  gap: 1rem;
}

.post-share__buttons a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-highlight);
  color: var(--text-secondary);
  font-size: 1rem;
  transition: all 0.2s;
  text-decoration: none;
}

.post-share__buttons a:hover {
  background: var(--accent);
  color: #fff;
}

/* Back link */
.post-nav {
  padding: 2rem 0;
}

.post-nav__back {
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: gap 0.2s;
}

.post-nav__back:hover {
  gap: 0.75rem;
}

/* ==========================================================================
   Blog index page
   ========================================================================== */

.blog-list {
  max-width: 720px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.blog-card {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border-light, #e8e8e8);
}

.blog-card:first-child {
  padding-top: 0;
}

.blog-card__category {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #006747;
  margin-bottom: 0.5rem;
}

.blog-card__title {
  font-family: 'Source Serif 4', 'Lora', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 0.5rem;
  letter-spacing: -0.01em;
}

.blog-card__title a {
  color: #1a1a1a;
  text-decoration: none;
  transition: color 0.2s;
}

.blog-card__title a:hover {
  color: #006747;
}

.blog-card__excerpt {
  font-family: 'Lora', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.65;
  color: #6b6b6b;
  margin: 0 0 0.75rem;
}

.blog-card__meta {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: #999;
}

.blog-card__meta span + span::before {
  content: "\00b7";
  margin: 0 0.4em;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .post-header {
    padding: 2.5rem 1.25rem 0;
  }

  .post-body {
    font-size: 1.08rem;
    padding: 0 1.25rem;
  }

  .post-body h2 {
    font-size: 1.4rem;
  }

  .post-body h3 {
    font-size: 1.2rem;
  }

  .post-footer {
    padding: 0 1.25rem;
  }

  .post-hero {
    padding: 0 1rem;
  }

  .post-share {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .post-header {
    padding: 2rem 1rem 0;
  }

  .post-body {
    font-size: 1.02rem;
    padding: 0 1rem;
    line-height: 1.75;
  }

  .post-footer {
    padding: 0 1rem;
  }
}
