/* ============================================================
   blog.css — Interactive article page styles
   Loaded on top of styles.css for individual article pages
   ============================================================ */

/* ============ READING PROGRESS BAR ============ */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: var(--gradient-gold);
  width: 0%;
  z-index: 1001;
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 10px rgba(201, 168, 76, 0.4);
}

/* ============ ARTICLE LAYOUT ============ */
.blog-page {
  padding-top: 80px;
}

.blog-layout {
  display: grid;
  /* minmax(0, 1fr), not 1fr: a plain 1fr resolves its minimum to the
     column's min-content, so a wide code block stretches the whole
     layout past the viewport instead of scrolling inside its own box. */
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 3rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
  align-items: start;
}

/* ============ PARALLAX HERO ============ */
.blog-hero {
  position: relative;
  width: 100%;
  height: 50vh;
  min-height: 360px;
  max-height: 500px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.blog-hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
  will-change: transform;
}

.blog-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(5, 5, 5, 1) 0%,
    rgba(5, 5, 5, 0.85) 30%,
    rgba(5, 5, 5, 0.3) 70%,
    rgba(5, 5, 5, 0.1) 100%
  );
  z-index: 1;
}

.blog-hero-content {
  position: relative;
  z-index: 2;
  padding: 3rem 2rem;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.blog-meta-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.blog-category-badge {
  padding: 4px 12px;
  border-radius: 50px;
  background: rgba(201, 168, 76, 0.15);
  border: 1px solid var(--border-gold);
  color: var(--gold-primary);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.blog-read-time {
  color: var(--text-muted);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 5px;
}

.blog-hero-title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--gold-light) 60%, var(--gold-primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.blog-hero-subtitle {
  color: var(--text-secondary);
  font-size: clamp(0.9rem, 1.5vw, 1.05rem);
  line-height: 1.7;
  max-width: 600px;
  margin-bottom: 1.5rem;
}

.blog-author-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.blog-author-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border-gold);
  object-fit: cover;
}

.blog-author-info {
  display: flex;
  flex-direction: column;
}

.blog-author-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.blog-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============ STICKY TABLE OF CONTENTS ============ */
.blog-toc {
  position: sticky;
  top: 100px;
  padding: 1.5rem 0;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: none;
}

.blog-toc::-webkit-scrollbar { display: none; }

.toc-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold-primary);
  margin-bottom: 1rem;
  display: block;
}

.toc-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toc-link {
  display: block;
  padding: 6px 12px;
  border-left: 2px solid var(--border-subtle);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  transition: all 0.3s ease;
}

.toc-link:hover {
  color: var(--text-secondary);
  border-left-color: var(--text-secondary);
}

.toc-link.active {
  color: var(--gold-primary);
  border-left-color: var(--gold-primary);
  background: var(--gold-glow);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.toc-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 1.5rem;
  padding: 6px 12px;
  border-radius: 50px;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 500;
  transition: var(--transition);
}

.toc-back:hover {
  border-color: var(--border-gold);
  color: var(--gold-primary);
  background: var(--gold-glow);
}

/* ============ ARTICLE CONTENT ============ */
.blog-content {
  max-width: 65ch;
  padding: 3rem 0 4rem;
}

.blog-content h2 {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 3vw, 1.8rem);
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 3rem;
  margin-bottom: 1.2rem;
  line-height: 1.2;
  position: relative;
}

.blog-content h2::before {
  content: '';
  position: absolute;
  left: -1.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  background: var(--gradient-gold);
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.blog-content h2:hover::before {
  opacity: 1;
}

.blog-content h3 {
  font-family: var(--font-heading);
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  font-weight: 600;
  color: var(--gold-light);
  margin-top: 2rem;
  margin-bottom: 0.8rem;
  line-height: 1.3;
}

.blog-content p {
  color: var(--text-secondary);
  font-size: clamp(0.88rem, 1.2vw, 0.95rem);
  line-height: 1.8;
  margin-bottom: 1.5rem;
}

.blog-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.blog-content a {
  color: var(--gold-primary);
  text-decoration: none;
  border-bottom: 1px solid rgba(201, 168, 76, 0.3);
  transition: var(--transition);
}

.blog-content a:hover {
  border-bottom-color: var(--gold-primary);
}

/* ============ ANIMATED HIGHLIGHT ============ */
.highlight {
  background: linear-gradient(120deg, rgba(201, 168, 76, 0.25) 0%, rgba(201, 168, 76, 0.25) 100%);
  background-repeat: no-repeat;
  background-size: 0% 100%;
  transition: background-size 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  padding: 1px 4px;
  border-radius: 3px;
  cursor: pointer;
}

.highlight:hover {
  background-size: 100% 100%;
}

/* ============ TOOLTIP ============ */
.tooltip-term {
  position: relative;
  color: var(--gold-primary);
  border-bottom: 1px dashed rgba(201, 168, 76, 0.4);
  cursor: help;
}

.tooltip-term::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: rgba(15, 15, 15, 0.95);
  border: 1px solid var(--border-gold);
  color: var(--gold-light);
  font-size: 0.72rem;
  font-weight: 400;
  font-family: var(--font-body);
  line-height: 1.5;
  white-space: normal;
  width: max-content;
  /* Never wider than the viewport allows, so a shown tooltip stays readable
     on a phone. */
  max-width: min(280px, calc(100vw - 2.5rem));
  /* display:none, not just opacity:0 — an invisible-but-laid-out tooltip
     still contributes scrollable overflow. A term that wrapped across two
     lines pushed the page 10px past a 375px viewport. `allow-discrete`
     keeps the fade in browsers that support it; older ones just snap. */
  display: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, display 0.3s allow-discrete;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 50;
}

.tooltip-term:hover::after,
.tooltip-term:focus-visible::after {
  display: block;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@starting-style {
  .tooltip-term:hover::after,
  .tooltip-term:focus-visible::after {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }
}

/* On a phone a 280px bubble centred on an inline term runs off the edge —
   several were clipped past the left margin and unreadable. Anchor
   positioning would solve it, but GSAP puts a transform on the surrounding
   paragraph, so a fixed-position bubble would resolve against that instead
   of the viewport. Drop the bubble entirely below ~700px and let the
   definition open in flow underneath the term, where it always fits. */
@media (max-width: 700px) {
  .tooltip-term::after {
    position: static;
    transform: none;
    width: auto;
    max-width: 100%;
    margin: 6px 0;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .tooltip-term:hover::after,
  .tooltip-term:focus-visible::after {
    transform: none;
  }

  @starting-style {
    .tooltip-term:hover::after,
    .tooltip-term:focus-visible::after {
      opacity: 0;
      transform: none;
    }
  }
}

/* ============ BLOCKQUOTE ============ */
.blog-content blockquote {
  margin: 2rem 0;
  padding: 1.5rem 2rem;
  border-left: 3px solid var(--gold-primary);
  background: rgba(201, 168, 76, 0.04);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.blog-content blockquote p {
  color: var(--gold-light);
  font-size: 1rem;
  font-style: italic;
  line-height: 1.7;
  margin-bottom: 0;
}

.blog-content blockquote cite {
  display: block;
  margin-top: 0.8rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: normal;
}

/* ============ CODE BLOCKS ============ */
.blog-content code {
  background: rgba(201, 168, 76, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--gold-light);
  font-family: var(--font-body);
}

.blog-content pre {
  margin: 2rem 0;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  overflow-x: auto;
  position: relative;
}

.blog-content pre code {
  background: transparent;
  padding: 0;
  font-size: 0.82rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-glow);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.75rem;
}

.code-copy-btn:hover {
  border-color: var(--border-gold);
  color: var(--gold-primary);
}

.code-copy-btn.copied {
  color: var(--gold-primary);
  border-color: var(--gold-primary);
}

/* ============ INTERACTIVE BOX ============ */
.interactive-box {
  margin: 2rem 0;
  padding: 1.5rem 2rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  transition: var(--transition);
}

.interactive-box:hover {
  border-color: var(--border-gold);
  box-shadow: var(--shadow-gold);
  transform: translateY(-2px);
}

.interactive-box h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  margin-top: 0;
}

.interactive-box p {
  margin-bottom: 0;
}

/* ============ EXPANDABLE DEEP DIVE ============ */
.deep-dive {
  margin: 2rem 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  overflow: hidden;
  transition: var(--transition);
}

.deep-dive[open] {
  border-color: var(--border-gold);
  box-shadow: 0 0 30px rgba(201, 168, 76, 0.06);
}

.deep-dive summary {
  padding: 1rem 1.5rem;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gold-light);
  display: flex;
  align-items: center;
  gap: 10px;
  list-style: none;
  transition: var(--transition);
}

.deep-dive summary::-webkit-details-marker { display: none; }

.deep-dive summary::before {
  content: '▸';
  color: var(--gold-primary);
  font-size: 0.8rem;
  transition: transform 0.3s ease;
}

.deep-dive[open] summary::before {
  transform: rotate(90deg);
}

.deep-dive summary:hover {
  background: rgba(201, 168, 76, 0.04);
}

.deep-dive-content {
  padding: 0 1.5rem 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.deep-dive-content p {
  margin-top: 1rem;
}

/* ============ IMAGE FIGURE ============ */
.blog-figure {
  margin: 2.5rem 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

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

.blog-figure figcaption {
  padding: 0.8rem 1.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
}

/* ============ DIVIDER ============ */
.blog-divider {
  border: none;
  height: 1px;
  background: var(--border-subtle);
  margin: 3rem 0;
  position: relative;
}

.blog-divider::after {
  content: '◆';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-primary);
  padding: 0 12px;
  color: var(--gold-dark);
  font-size: 0.6rem;
}

/* ============ ARTICLE FOOTER ============ */
.blog-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-subtle);
}

.blog-footer-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.blog-tag {
  padding: 4px 14px;
  border-radius: 50px;
  background: var(--gold-glow);
  border: 1px solid var(--border-subtle);
  color: var(--gold-light);
  font-size: 0.7rem;
  font-weight: 500;
}

.blog-back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: 50px;
  border: 1px solid var(--border-gold);
  color: var(--gold-primary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  transition: var(--transition);
}

.blog-back-link:hover {
  background: var(--gold-glow);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(201, 168, 76, 0.12);
}

/* ============ GSAP INITIAL STATE ============ */
.gsap-reveal {
  opacity: 0;
  visibility: hidden;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .blog-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .blog-toc {
    position: relative;
    top: auto;
    max-height: none;
    padding: 1.5rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin: 1rem 2rem;
  }

  .blog-content {
    padding: 2rem 2rem 4rem;
    max-width: 100%;
  }

  .blog-content h2::before {
    display: none;
  }

  .blog-hero {
    min-height: 280px;
  }
}

@media (max-width: 600px) {
  .blog-hero-content {
    padding: 2rem 1.2rem;
  }

  .blog-content {
    padding: 1.5rem 1.2rem 3rem;
  }

  .blog-toc {
    margin: 0.5rem 1rem;
    padding: 1rem 1.2rem;
  }

  .blog-content blockquote {
    padding: 1rem 1.2rem;
  }
}
