/** 
 * article-only.css — Article-specific styles (TOC, hero, content, takeaways)
 * Mobile-first: base → 480px tablet → 1024px desktop
 * Shared styles (header, theme, footer) are in shared.css
 */

/* ===== Article Container ===== */
.article {
  padding: 16px 0;
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ===== TOC (Mobile: hidden, expandable) ===== */
.toc {
  position: relative;
  margin-bottom: 20px;
}

.toc-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s ease;
  min-height: 44px;
}
.toc-toggle:hover { background: var(--bg-code); }
.toc-toggle:active { transform: scale(0.98); }

.toc-panel {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 12px 16px;
  margin-top: -4px;
}

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

.toc.open .toc-toggle {
  border-radius: 8px 8px 0 0;
  border-bottom-color: transparent;
}

.toc-header {
  display: none;
}

.toc a {
  display: block;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  transition: color 0.2s ease;
}
.toc a:last-child { border-bottom: none; }
.toc a:hover { color: var(--accent); }

.toc-l1 { font-weight: 600; }
.toc-l2 { padding-left: 16px; font-size: 0.85rem; }
.toc-l3 { padding-left: 32px; font-size: 0.8rem; }

/* ===== Hero Banner ===== */
.hero {
  position: relative;
  width: 100%;
  height: 220px;
  border-radius: 8px;
  margin-bottom: 20px;
  overflow: hidden;
}

.hero-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.hero-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
  background: linear-gradient(to top, rgba(15,23,42,0.95) 0%, rgba(15,23,42,0.6) 50%, transparent 100%);
  padding: 16px;
}

[data-theme="light"] .hero-overlay {
  background: linear-gradient(to top, rgba(30,41,59,0.95) 0%, rgba(30,41,59,0.6) 50%, transparent 100%);
}

/* Hero date pill for better readability */
.hero-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
  display: inline-block;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 10px;
  border-radius: 6px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.hero-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.3;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Dashboard rows — distinct visual blocks per status item */
.dashboard-row {
  display: block;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-left: 4px solid var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.dashboard-threat { border-left-color: #ef4444; background: rgba(239, 68, 68, 0.08); }
.dashboard-watch  { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.08); }
.dashboard-good   { border-left-color: #22c55e; background: rgba(34, 197, 94, 0.08); }
.dashboard-risk   { border-left-color: #ef4444; background: rgba(239, 68, 68, 0.08); }

[data-theme="light"] .dashboard-row {
  background: rgba(0, 0, 0, 0.04);
}
[data-theme="light"] .dashboard-threat { background: rgba(239, 68, 68, 0.06); }
[data-theme="light"] .dashboard-watch  { background: rgba(245, 158, 11, 0.06); }
[data-theme="light"] .dashboard-good   { background: rgba(34, 197, 94, 0.06); }
[data-theme="light"] .dashboard-risk   { background: rgba(239, 68, 68, 0.06); }

/* Type badge on hero needs better contrast */
.hero-overlay .type-badge {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  margin-top: 8px;
}

[data-theme="light"] .hero-overlay .type-badge {
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
}

/* ===== Content ===== */
.content {
  overflow-wrap: break-word;
  word-break: break-word;
}

.content h1 {
  font-size: 1.5rem;
  margin-top: 28px;
  margin-bottom: 14px;
  scroll-margin-top: 80px;
  color: var(--text-heading);
}

.content h2 {
  font-size: 1.25rem;
  margin-top: 24px;
  margin-bottom: 10px;
  scroll-margin-top: 80px;
  color: var(--text-heading);
}

.content h3 {
  font-size: 1.1rem;
  margin-top: 20px;
  margin-bottom: 8px;
  color: var(--text-heading);
}

.content p {
  margin-bottom: 12px;
}

.content .table-scroll {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 14px 0;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.content .table-scroll table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  background: var(--bg-card);
  font-size: 0.9rem;
  min-width: min-content;
}

.content th,
.content td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  word-break: normal;
  overflow-wrap: normal;
  font-size: 0.8rem;
  min-width: 80px;
}

.content th {
  background: var(--bg-code);
  font-weight: 600;
  color: var(--text-heading);
  font-size: 0.85rem;
}

.content tr:hover { background: var(--bg-code); }

.content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
  margin: 14px 0;
  color: var(--text-muted);
}

/* Prevent inline code overflow */
.content code {
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: 'SF Mono', Monaco, monospace;
  word-break: break-all;
}

.content pre {
  background: var(--bg-code);
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 14px 0;
  font-size: 0.85rem;
  max-width: 100%;
}

.content pre code { background: none; padding: 0; }

/* Ensure all content children respect container width */
.content > * {
  max-width: 100%;
  box-sizing: border-box;
}

.content ul,
.content ol {
  margin: 10px 0;
  padding-left: 20px;
}

.content li {
  margin-bottom: 5px;
}

.content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 14px 0;
}

.content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 24px 0;
}

/* ===== Takeaways Card ===== */
.takeaways-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.takeaways-card h3 {
  font-size: 1rem;
  margin-bottom: 10px;
  color: var(--text-heading);
}

.takeaways-card ul {
  margin: 0;
  padding-left: 18px;
}

.takeaways-card li {
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ===== Back to Top ===== */
.back-to-top {
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease, background 0.2s ease, transform 0.2s ease;
  z-index: 50;
  font-size: 1rem;
}
.back-to-top.visible { opacity: 1; }
.back-to-top:hover { background: var(--bg-code); color: var(--text-primary); }
.back-to-top:active { transform: scale(0.9); }

/* ===== Tablet (480px+) ===== */
@media (min-width: 480px) {
  .article {
    padding: 24px 20px;
  }
  
  .hero {
    height: 260px;
    border-radius: 10px;
    padding: 20px;
  }
  .hero-overlay { padding: 20px; margin: -20px; }
  .hero-title { font-size: 1.7rem; }
  
  .content h1 { font-size: 1.7rem; }
  .content h2 { font-size: 1.35rem; }
  .content h3 { font-size: 1.15rem; }
  .content table { font-size: 0.95rem; }
  .content th, .content td { padding: 12px 14px; }
  
  .takeaways-card { padding: 20px; }
  .takeaways-card h3 { font-size: 1.1rem; }
  .takeaways-card li { font-size: 0.95rem; }
  
  .back-to-top {
    width: 44px;
    height: 44px;
    bottom: 20px;
    right: 20px;
  }
}

/* ===== Desktop (1024px+) ===== */
@media (min-width: 1024px) {
  .article {
    padding: 32px;
    max-width: 900px;
    margin: 0 auto;
  }
  
  /* TOC becomes fixed sidebar */
  .toc {
    position: fixed;
    top: 84px;
    left: 20px;
    width: 240px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 16px;
    z-index: 90;
    margin-bottom: 0;
  }
  
  .toc-toggle {
    display: none;
  }
  
  .toc-panel {
    display: block;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
  }
  
  .toc-header {
    display: block;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 12px;
    font-size: 0.9rem;
  }
  
  .toc a {
    padding: 6px 0;
    font-size: 0.85rem;
    border-bottom: none;
  }
  
  .toc-l2 { padding-left: 12px; }
  .toc-l3 { padding-left: 24px; }
  
  .hero {
    height: 320px;
    border-radius: 12px;
    padding: 28px;
    margin-bottom: 28px;
  }
  .hero-overlay { padding: 28px; margin: -28px; }
  .hero-title { font-size: 2rem; }
  .hero-date { font-size: 0.85rem; }
  
  .content h1 { font-size: 2rem; }
  .content h2 { font-size: 1.5rem; }
  .content h3 { font-size: 1.25rem; }
  
  .takeaways-card {
    padding: 24px;
    margin-bottom: 28px;
  }
}

/* ===== Extra Large (1400px+) ===== */
@media (min-width: 1400px) {
  .toc {
    left: calc(50% - 700px);
  }
}

/* ===== Reading Time ===== */
.reading-time {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== Article Navigation (Prev/Next) ===== */
.article-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.article-nav a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-nav a:hover { color: var(--accent-hover); text-decoration: underline; }

.nav-prev span, .nav-next span {
  display: inline;
}

/* ===== Related Articles ===== */
.related {
  margin-top: 32px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.related h3 {
  font-size: 1rem;
  margin-bottom: 14px;
  color: var(--text-heading);
}

.related-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.related-link {
  display: block;
  padding: 10px 14px;
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.related-link:hover {
  background: var(--bg-primary);
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== Tablet (480px+) ===== */
@media (min-width: 480px) {
  .related { padding: 24px; }
  .related h3 { font-size: 1.1rem; }
  .related-grid { flex-direction: row; flex-wrap: wrap; }
  .related-link { flex: 1 1 calc(50% - 5px); }
  .article-nav a { font-size: 0.95rem; }
}

/* ===== Desktop (1024px+) ===== */
@media (min-width: 1024px) {
  .related { margin-top: 40px; padding: 28px; }
  .related h3 { font-size: 1.15rem; margin-bottom: 16px; }
  .related-link { flex: 1 1 calc(33.333% - 7px); }
  .article-nav { margin-top: 40px; padding-top: 28px; }
  .article-nav a { font-size: 1rem; }
}

/* ===== Print Styles ===== */
@media print {
  .site-header,
  .toc,
  .toc-toggle,
  .back-to-top,
  .drawer,
  .drawer-overlay,
  .search-overlay,
  .progress-bar,
  .article-nav,
  .related,
  .heading-copy,
  footer {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  .article {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .content h1,
  .content h2,
  .content h3,
  .content h4,
  .content h5,
  .content h6 {
    color: #000 !important;
    scroll-margin-top: 0 !important;
  }

  .content a {
    color: #000 !important;
    text-decoration: underline !important;
  }

  .content a::after {
    content: ' (' attr(href) ')';
    font-size: 0.8em;
    opacity: 0.7;
  }

  .content code,
  .content pre {
    background: #f0f0f0 !important;
    border-color: #ddd !important;
    color: #000 !important;
  }

  .content blockquote {
    border-color: #999 !important;
    color: #333 !important;
  }

  .content table {
    border-color: #999 !important;
  }

  .content th,
  .content td {
    border-color: #999 !important;
  }

  .takeaways-card {
    background: #f5f5f5 !important;
    border-color: #ccc !important;
  }

  .takeaways-card h3 {
    color: #000 !important;
  }

  .takeaways-card li {
    color: #333 !important;
  }

  .hero {
    height: auto !important;
    border-radius: 0 !important;
    background: none !important;
    padding: 0 !important;
    margin-bottom: 16px !important;
  }

  .hero-image {
    display: none !important;
  }

  .hero-overlay {
    background: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .hero-title {
    color: #000 !important;
    font-size: 1.5rem !important;
  }

  .hero-date {
    color: #666 !important;
  }
}
