/* === PANDACK ARTICLE PAGE === */

/* --- Article + TOC sidebar layout (Obsidian-style) --- */
.article-with-toc {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 32px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 30px 32px;
  align-items: start;
  box-sizing: border-box;
}

.article-with-toc .article-layout {
  padding: 0;
  margin: 0;
  max-width: 100%;
  min-width: 0;
}

.article-content {
  min-width: 0;
  max-width: 780px;
  width: 100%;
}

.article-toc {
  position: relative;
}

.toc-sticky {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  max-height: calc(100vh - var(--header-h) - 40px);
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.toc-title {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--magenta);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.toc-nav {
  display: block;
}

.toc-nav a {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
  padding: 4px 0 4px 10px;
  border-left: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  line-height: 1.4;
  word-wrap: break-word;
}

.toc-nav a:hover {
  color: var(--cyan);
}

.toc-nav a.active {
  color: var(--cyan);
  border-left-color: var(--cyan);
  background: rgba(0, 229, 255, 0.05);
}

.toc-nav a.toc-h3 {
  padding-left: 22px;
  font-size: 11px;
}

.toc-nav a.toc-h4 {
  padding-left: 34px;
  font-size: 11px;
  opacity: 0.85;
}

.article-layout {
  position: relative;
}

.article-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.article-h-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 12px;
  line-height: 1.3;
}

.article-h-meta {
  display: flex;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  flex-wrap: wrap;
}

/* Mobile floating TOC toggle — hidden on desktop (Part 3.4) */
.toc-mobile-toggle {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 16px;
  width: 48px;
  height: 48px;
  background: var(--bg-card);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 90;
  transition: var(--transition);
}

.toc-mobile-toggle:hover {
  background: var(--cyan-05);
}

/* Mobile TOC overlay panel */
.toc-panel {
  display: none;
  position: fixed;
  right: 16px;
  bottom: 150px;
  width: calc(100vw - 32px);
  max-width: 320px;
  max-height: 50vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  z-index: 95;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.toc-panel.active {
  display: block;
}

/* Hide the right TOC column when there is not enough horizontal room
 * (left sidebar + content + TOC would overflow below ~1200px).
 */
@media (max-width: 1199px) {
  .toc-mobile-toggle {
    display: flex;
  }
  .article-with-toc {
    grid-template-columns: 1fr;
  }
  .article-toc {
    display: none;
  }
}

.toc-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.toc-panel__close {
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  transition: var(--transition);
}

.toc-panel__close:hover {
  color: var(--cyan);
}

.toc-panel__nav {
  padding: 12px 16px;
}

.toc-panel__nav a {
  display: block;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-dim);
  transition: var(--transition);
  border-left: 2px solid transparent;
  padding-left: 10px;
}

.toc-panel__nav a:hover,
.toc-panel__nav a.active {
  color: var(--cyan);
  border-left-color: var(--cyan);
}

.toc-panel__nav a.toc-h3 {
  padding-left: 24px;
  font-size: 12px;
}

.toc-panel__nav a.toc-h4 {
  padding-left: 38px;
  font-size: 11px;
}

/* Article body */
.article-body h2 {
  font-size: 22px;
  color: var(--cyan);
  margin: 32px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.article-body h3 {
  font-size: 18px;
  color: var(--green);
  margin: 24px 0 10px;
  font-weight: 600;
}

.article-body h4 {
  font-size: 16px;
  color: var(--yellow);
  margin: 20px 0 8px;
  font-weight: 600;
}

.article-body p {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 16px;
}

.article-body a {
  color: var(--cyan);
  border-bottom: 1px solid rgba(0, 229, 255, 0.3);
  transition: var(--transition);
}

.article-body a:hover {
  border-bottom-color: var(--cyan);
}

.article-body strong {
  color: var(--text-bright);
  font-weight: 600;
}

.article-body ul,
.article-body ol {
  margin: 12px 0 16px 20px;
}

.article-body ul {
  list-style: disc;
}

.article-body ol {
  list-style: decimal;
}

.article-body li {
  margin-bottom: 6px;
  line-height: 1.7;
  font-size: 15px;
}

.article-body code {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--green);
  border-radius: 3px;
}

.article-body pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 16px 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--green);
  line-height: 1.7;
}

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

/* Tables */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13px;
  display: block;
  overflow-x: auto;
}

.article-body th {
  background: var(--bg-elev);
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 2px solid rgba(0, 229, 255, 0.3);
  white-space: nowrap;
}

.article-body td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.article-body tr:last-child td {
  border-bottom: none;
}

/* Images */
.article-body img {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin: 16px 0;
}

/* Blockquote */
.article-body blockquote {
  border-left: 3px solid var(--cyan);
  padding: 12px 20px;
  margin: 16px 0;
  color: var(--text-dim);
  font-style: italic;
  background: var(--cyan-05);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Fiche meta panel */
.fiche-meta-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 32px;
}

.fiche-meta-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.fiche-meta-row:last-child {
  border-bottom: none;
}

.fiche-meta-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  min-width: 140px;
  flex-shrink: 0;
  padding-top: 2px;
}

/* Mobile */
@media (max-width: 767px) {
  .article-with-toc {
    padding: 20px 16px;
    gap: 0;
  }

  .article-h-title {
    font-size: 24px;
  }

  .article-body h2 {
    font-size: 18px;
  }

  .article-body h3 {
    font-size: 16px;
  }

  .article-body p,
  .article-body li {
    font-size: 14px;
  }

  .article-body pre,
  .article-body code {
    font-size: 12px;
  }

  .fiche-meta-row {
    flex-direction: column;
    gap: 4px;
  }

  .fiche-meta-label {
    min-width: 0;
  }
}

/* Tablet: keep single column but a bit more breathing room */
@media (min-width: 768px) and (max-width: 1023px) {
  .article-with-toc {
    grid-template-columns: 1fr;
    padding: 24px 24px;
  }
}

/* Meta code/link helper styles (Part 13 polish) */
.fiche-meta-code {
  font-family: var(--font-mono);
  color: var(--green);
  font-size: 13px;
  padding: 1px 6px;
}

.fiche-meta-link {
  color: var(--cyan);
}

/* Post navigation (Part 13.4) */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 40px 0 20px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.post-nav__link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: var(--transition);
  min-height: 68px;
}

.post-nav__link:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
}

.post-nav__link--empty {
  background: transparent;
  border-color: transparent;
  min-height: 0;
}

.post-nav__link--next {
  text-align: right;
  align-items: flex-end;
}

.post-nav__dir {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.post-nav__title {
  font-size: 13px;
  color: var(--text-bright);
  font-weight: 500;
  line-height: 1.4;
}

@media (max-width: 767px) {
  .post-nav {
    grid-template-columns: 1fr;
  }
  .post-nav__link--next {
    text-align: left;
    align-items: flex-start;
  }
}
