/* ============================================================
   GUIDE ARTICLE STYLES
   Extends liverdecoded.css (style-v2.css) for individual
   guide/article pages rendered from markdown via Hugo.

   Drop in: /static/css/guide-article.css
   Requires: /static/css/liverdecoded.css loaded first
   ============================================================ */


/* ── Article Hero variant ──────────────────────────────── */
.ld-hero--article {
  padding: 48px 24px 44px;
}
.ld-hero--article .ld-hero__title {
  font-size: clamp(1.7rem, 3.8vw, 2.6rem);
  max-width: 740px;
}
.ld-hero--article .ld-hero__subtitle {
  font-size: .97rem;
  max-width: 640px;
  margin-bottom: 20px;
}

/* Hero tag pills */
.ld-hero__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.ld-hero__tag {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 4px;
  background: rgba(255,255,255,.12);
  color: var(--color-amber-lt);
  text-decoration: none;
  transition: background .2s;
}
.ld-hero__tag:hover {
  background: rgba(255,255,255,.2);
}

/* Article meta line */
.ld-hero__article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 4px;
}
.ld-hero__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  color: rgba(255,255,255,.65);
}
.ld-hero__meta-item svg {
  opacity: .7;
  flex-shrink: 0;
}


/* ── Hero image ────────────────────────────────────────── */
.ld-article__hero-img {
  margin: 0 0 36px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.ld-article__hero-img img {
  width: 100%;
  height: auto;
  display: block;
}


/* ============================================================
   ARTICLE PROSE — styles for Hugo-rendered markdown
   Scoped under .ld-article so they don't bleed into the
   sidebar, hero, or footer.
   ============================================================ */

.ld-article {
  font-family: var(--font-sans);
  font-size: 1.02rem;
  line-height: 1.8;
  color: var(--color-ink-mid);
  max-width: 100%;
  min-width: 0;
}


/* ── Headings ──────────────────────────────────────────── */
.ld-article h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--color-forest-dk);
  letter-spacing: -.3px;
  line-height: 1.25;
  margin: 52px 0 16px;
  padding-top: 28px;
  border-top: 1px solid var(--color-rule);
  scroll-margin-top: 80px;          /* offset for sticky nav */
}
.ld-article h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.ld-article h3 {
  font-family: var(--font-serif);
  font-size: 1.22rem;
  font-weight: 600;
  color: var(--color-ink);
  line-height: 1.3;
  margin: 36px 0 12px;
  scroll-margin-top: 80px;
}

.ld-article h4 {
  font-family: var(--font-sans);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--color-forest);
  margin: 28px 0 10px;
  scroll-margin-top: 80px;
}

.ld-article h5,
.ld-article h6 {
  font-family: var(--font-sans);
  font-size: .92rem;
  font-weight: 700;
  color: var(--color-ink);
  margin: 20px 0 8px;
  scroll-margin-top: 80px;
}


/* ── Paragraph & inline ────────────────────────────────── */
.ld-article p {
  margin-bottom: 1.15em;
}
.ld-article p:last-child {
  margin-bottom: 0;
}

.ld-article strong {
  font-weight: 600;
  color: var(--color-ink);
}
.ld-article em {
  font-style: italic;
}
.ld-article a {
  color: var(--color-forest);
  text-decoration: underline;
  text-decoration-color: var(--color-forest-lt);
  text-underline-offset: 2px;
  transition: color .2s, text-decoration-color .2s;
}
.ld-article a:hover {
  color: var(--color-amber);
  text-decoration-color: var(--color-amber);
}

.ld-article mark {
  background: var(--color-amber-pale);
  padding: 1px 4px;
  border-radius: 3px;
}

.ld-article sup {
  font-size: .72em;
  line-height: 0;
}


/* ── Lists ─────────────────────────────────────────────── */
.ld-article ul,
.ld-article ol {
  margin: 0 0 1.3em 1.4em;
  padding: 0;
}
.ld-article ul { list-style: disc; }
.ld-article ol { list-style: decimal; }
.ld-article li {
  margin-bottom: .45em;
  line-height: 1.7;
}
.ld-article li > ul,
.ld-article li > ol {
  margin-top: .45em;
  margin-bottom: .3em;
}
.ld-article li::marker {
  color: var(--color-forest-lt);
}


/* ── Horizontal rule ───────────────────────────────────── */
.ld-article hr {
  border: none;
  border-top: 1px solid var(--color-rule);
  margin: 40px 0;
}


/* ── Blockquote ────────────────────────────────────────── */
.ld-article blockquote {
  background: var(--color-teal-mist);
  border-left: 4px solid var(--color-forest);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 20px 24px;
  margin: 28px 0;
  font-size: .95rem;
  color: var(--color-ink-mid);
  line-height: 1.75;
}
.ld-article blockquote p:last-child {
  margin-bottom: 0;
}
.ld-article blockquote strong {
  color: var(--color-forest-dk);
}


/* ── Inline code ───────────────────────────────────────── */
.ld-article code {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  font-size: .88em;
  background: var(--color-cream-dk);
  border: 1px solid var(--color-rule);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--color-forest-dk);
  word-break: break-word;
}


/* ── Code blocks (fenced) ──────────────────────────────── */
.ld-article pre {
  background: var(--color-forest-dk);
  color: #e0ece8;
  border-radius: var(--radius-md);
  padding: 24px;
  margin: 28px 0;
  overflow-x: auto;
  font-size: .87rem;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}
.ld-article pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
  word-break: normal;
}


/* ── Tables ────────────────────────────────────────────── */
.ld-article table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  background: #fff;
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 28px 0;
  box-shadow: var(--shadow-sm);
  display: block;
  overflow-x: auto;
}
.ld-article thead th {
  background: var(--color-forest);
  color: #fff;
  text-align: left;
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .8rem;
  letter-spacing: .3px;
  white-space: nowrap;
}
.ld-article tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--color-rule);
  vertical-align: top;
  line-height: 1.5;
  color: var(--color-ink-mid);
}
.ld-article tbody tr:last-child td {
  border-bottom: none;
}
.ld-article tbody tr:nth-child(even) td {
  background: var(--color-cream);
}
.ld-article tbody td strong {
  color: var(--color-ink);
}


/* ── Images within article ─────────────────────────────── */
.ld-article img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 24px 0;
  box-shadow: var(--shadow-sm);
}
.ld-article figure {
  margin: 28px 0;
}
.ld-article figcaption {
  font-size: .8rem;
  color: var(--color-ink-soft);
  text-align: center;
  margin-top: 8px;
  line-height: 1.5;
}


/* ── Definition lists ──────────────────────────────────── */
.ld-article dl {
  margin: 24px 0;
}
.ld-article dt {
  font-weight: 700;
  color: var(--color-ink);
  margin-top: 16px;
}
.ld-article dd {
  margin-left: 1.4em;
  margin-bottom: 8px;
  color: var(--color-ink-mid);
}


/* ── Footnotes (Hugo default class) ────────────────────── */
.ld-article .footnotes {
  border-top: 1px solid var(--color-rule);
  margin-top: 48px;
  padding-top: 24px;
  font-size: .85rem;
  color: var(--color-ink-soft);
}
.ld-article .footnotes hr {
  display: none;
}


/* ============================================================
   SIDEBAR TOC — override Hugo's default TableOfContents
   Hugo generates <nav id="TableOfContents"><ul><li>…</li></ul></nav>
   We restyle it to match the ld-toc widget pattern.
   ============================================================ */

/* ── Scrollable TOC container ──────────────────────────── */
/* The sidebar is sticky (top: 80px). We give the TOC widget
   body a viewport-relative max-height so it scrolls on its
   own when the heading list is long, while Quick Links and
   eBooks widgets remain accessible below it.                */

#toc-widget .ld-widget__body {
  max-height: calc(100vh - 260px);
  /* 260px ≈ sticky-top(80) + widget-head(46) + gap for
     widgets below + breathing room. Adjust if layout changes. */
  overflow-y: auto;
  overscroll-behavior: contain;     /* don't scroll parent */
  position: relative;
}

/* Subtle fade at the bottom when content overflows */
#toc-widget .ld-widget__body::after {
  content: '';
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  display: block;
  height: 28px;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, #fff 90%);
  margin-top: -28px;              /* overlap the last line */
  opacity: 1;
  transition: opacity .2s;
}

/* Hide fade when scrolled to the very bottom (JS toggles this) */
#toc-widget .ld-widget__body.scrolled-end::after {
  opacity: 0;
}

/* Custom scrollbar — thin, on-brand, unobtrusive */
#toc-widget .ld-widget__body::-webkit-scrollbar {
  width: 5px;
}
#toc-widget .ld-widget__body::-webkit-scrollbar-track {
  background: transparent;
}
#toc-widget .ld-widget__body::-webkit-scrollbar-thumb {
  background: var(--color-rule);
  border-radius: 4px;
}
#toc-widget .ld-widget__body::-webkit-scrollbar-thumb:hover {
  background: var(--color-ink-soft);
}

/* Firefox */
#toc-widget .ld-widget__body {
  scrollbar-width: thin;
  scrollbar-color: var(--color-rule) transparent;
}


.ld-toc-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Top-level items */
.ld-toc-nav > ul > li {
  border-bottom: 1px solid var(--color-rule);
}
.ld-toc-nav > ul > li:last-child {
  border-bottom: none;
}
.ld-toc-nav > ul > li > a {
  display: block;
  padding: 9px 0;
  font-size: .83rem;
  font-weight: 500;
  color: var(--color-forest);
  text-decoration: none;
  line-height: 1.4;
  transition: color .2s;
}
.ld-toc-nav > ul > li > a:hover {
  color: var(--color-amber);
}

/* Active state */
.ld-toc-nav > ul > li.active > a {
  color: var(--color-amber);
  font-weight: 600;
}

/* Nested items (h3 sub-headings) */
.ld-toc-nav ul ul {
  padding-left: 14px;
  border-left: 2px solid var(--color-rule);
  margin: 2px 0 6px;
}
.ld-toc-nav ul ul li a {
  display: block;
  padding: 4px 0;
  font-size: .78rem;
  color: var(--color-ink-soft);
  text-decoration: none;
  line-height: 1.4;
  transition: color .2s;
}
.ld-toc-nav ul ul li a:hover {
  color: var(--color-amber);
}
.ld-toc-nav ul ul li.active > a {
  color: var(--color-amber);
  font-weight: 600;
}

/* Collapse deeper nesting (h4+) for cleanliness */
.ld-toc-nav ul ul ul {
  display: none;
}


/* ============================================================
   ARTICLE TAGS FOOTER
   ============================================================ */

.ld-article__tags-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 40px 0 0;
  padding-top: 24px;
  border-top: 1px solid var(--color-rule);
}
.ld-article__tags-label {
  font-size: .8rem;
  font-weight: 700;
  color: var(--color-ink-soft);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.ld-article__tag {
  display: inline-block;
  font-size: .78rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 4px;
  background: var(--color-teal-mist);
  color: var(--color-forest);
  text-decoration: none;
  transition: background .2s, color .2s;
}
.ld-article__tag:hover {
  background: var(--color-forest);
  color: #fff;
}


/* ============================================================
   HAMBURGER MENU (mobile)
   ============================================================ */

.ld-nav__hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
}
.ld-nav__hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform .3s, opacity .2s;
}
.ld-nav__hamburger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.ld-nav__hamburger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.ld-nav__hamburger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}


/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Mobile TOC toggle (shows above article on small screens) */
.ld-mobile-toc {
  display: none;
}

@media (max-width: 820px) {
  .ld-aside {
    display: none;
  }

  /* Show a mobile TOC above the article instead */
  .ld-mobile-toc {
    display: block;
    margin-bottom: 32px;
  }
  .ld-mobile-toc__toggle {
    width: 100%;
    background: #fff;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    font-family: var(--font-sans);
    font-size: .88rem;
    font-weight: 600;
    color: var(--color-forest-dk);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background .2s;
  }
  .ld-mobile-toc__toggle:hover {
    background: var(--color-cream);
  }
  .ld-mobile-toc__toggle::after {
    content: '+';
    font-size: 1.2rem;
    font-weight: 300;
    color: var(--color-forest-lt);
    transition: transform .3s;
  }
  .ld-mobile-toc.open .ld-mobile-toc__toggle::after {
    transform: rotate(45deg);
  }
  .ld-mobile-toc__body {
    max-height: 0;
    overflow: hidden;
    transition: max-height .4s ease;
    background: #fff;
    border: 1px solid var(--color-rule);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  }
  .ld-mobile-toc.open .ld-mobile-toc__body {
    max-height: 600px;
    padding: 12px 18px 16px;
  }

  .ld-hero--article {
    padding: 36px 24px 32px;
  }
  .ld-hero--article .ld-hero__title {
    font-size: clamp(1.5rem, 5vw, 2rem);
  }
}

@media (max-width: 560px) {
  .ld-nav__links { display: none; }
  .ld-nav__hamburger { display: flex; }

  /* Mobile nav dropdown */
  .ld-nav__links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--color-forest-dk);
    border-bottom: 3px solid var(--color-amber);
    padding: 12px 24px 20px;
    gap: 4px;
    z-index: 99;
  }
  .ld-nav__links.open li { width: 100%; }
  .ld-nav__links.open a {
    display: block;
    padding: 10px 12px;
  }

  .ld-article h2 {
    font-size: 1.35rem;
  }
  .ld-article h3 {
    font-size: 1.1rem;
  }

  .ld-cta-block {
    padding: 28px 20px;
  }
  .ld-btn--ghost {
    margin-left: 0;
    margin-top: 12px;
  }

  .footer__top {
    grid-template-columns: 1fr;
    gap: 28px;
  }
}


/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  .ld-nav,
  .ld-breadcrumb,
  .ld-aside,
  .newsletter,
  footer,
  .ld-cta-block,
  .ld-mobile-toc,
  .ld-article__tags-footer {
    display: none !important;
  }
  .ld-layout {
    grid-template-columns: 1fr;
  }
  .ld-hero--article {
    background: none;
    color: #000;
    padding: 24px 0;
  }
  .ld-hero--article .ld-hero__title {
    color: #000;
    font-size: 1.8rem;
  }
  .ld-hero--article .ld-hero__subtitle {
    color: #333;
  }
  .ld-article a {
    color: #000;
    text-decoration: underline;
  }
  .ld-article a::after {
    content: " (" attr(href) ")";
    font-size: .75em;
    color: #666;
  }
}
