/* ════════════════════════════════════════════════════════════════════════
   AWS Knowledge — Article view, markdown, callouts, TOC, footer nav
   ════════════════════════════════════════════════════════════════════════ */

/* reading progress bar */
.read-progress { position: absolute; left: 0; top: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--mod), var(--amber)); z-index: 6; transition: width 0.1s linear; }

/* ── sticky breadcrumb bar ── */
.crumb-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 11px 30px; background: rgba(255,255,255,0.88);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-muted);
}
.crumb-back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; color: var(--text-secondary);
  background: var(--surface-3); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: var(--r-sm); transition: all var(--t); flex-shrink: 0;
}
.crumb-back:hover { color: var(--mod); border-color: var(--mod); background: var(--surface); }
.crumb-back svg { transition: transform var(--t); }
.crumb-back:hover svg { transform: translateX(-2px); }

.crumb-trail { display: flex; align-items: center; gap: 7px; min-width: 0; font-size: 12.5px; }
.crumb-mod { font-weight: 700; color: var(--mod); white-space: nowrap; }
.crumb-sep { color: var(--text-faint); }
.crumb-now { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }

.crumb-actions { margin-left: auto; display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--text-secondary);
  background: var(--surface-3); border: 1px solid var(--border);
  padding: 6px 11px; border-radius: var(--r-sm); transition: all var(--t); white-space: nowrap;
}
.icon-btn:hover { background: var(--surface); color: var(--text-primary); border-color: var(--border-strong); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn.bm.on { color: var(--amber-dark); background: var(--amber-light); border-color: var(--amber-line); }
.icon-btn.bm.on svg { fill: var(--amber); color: var(--amber); }
.icon-btn.read.on { color: #15803d; background: #e9f9ee; border-color: #bbf0c9; }
.crumb-nav { display: flex; gap: 3px; }
.crumb-nav .icon-btn { padding: 6px 9px; }

/* ── article layout ── */
.article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 236px;
  gap: 48px;
  max-width: calc(var(--read-width) + 284px);
  margin: 0 auto; padding: 38px 36px 96px;
  align-items: start;
}
.article.no-toc { grid-template-columns: minmax(0, 1fr); max-width: var(--read-width); }

.article-body { min-width: 0; font-size: calc(16px * var(--read-scale)); }

/* hero */
.art-hero { margin-bottom: 28px; }
.art-kicker {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  font-size: 11px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--mod); background: var(--mod-tint); padding: 4px 12px; border-radius: var(--r-pill);
  margin-bottom: 14px;
}
.art-kicker .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--mod); }

/* tier badge in article hero */
.art-kicker-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.art-kicker-row .art-kicker { margin-bottom: 0; }
.art-tier-badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  padding: 4px 10px; border-radius: var(--r-pill);
  border: 1px solid transparent;
}

/* ════════════════════════════════════════════════════════════════════════
   MARKDOWN
   ════════════════════════════════════════════════════════════════════════ */
.md h1 {
  font-size: calc(32px * var(--read-scale)); font-weight: 900; letter-spacing: -0.9px;
  color: var(--text-primary); line-height: 1.12; margin-bottom: 8px;
  padding-bottom: 16px; border-bottom: 1px solid var(--border); position: relative;
}
.md h1::after { content:""; position:absolute; left:0; bottom:-1px; width:56px; height:3px; background: var(--mod); border-radius: 2px; }

/* collapsible H2 sections */
.sect { border-bottom: 1px solid var(--border-muted); }
.sect:last-child { border-bottom: none; }
.sect-head {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 20px 0 16px; margin-top: 6px;
}
.sect-head h2 {
  font-size: calc(19px * var(--read-scale)); font-weight: 800; letter-spacing: -0.3px;
  color: var(--text-primary); flex: 1; line-height: 1.25;
}
.sect-chev {
  width: 24px; height: 24px; border-radius: 6px; flex-shrink: 0;
  display: grid; place-items: center; color: var(--mod); background: var(--mod-tint);
  transition: transform var(--t);
}
.sect[data-open="false"] .sect-chev { transform: rotate(-90deg); }
.sect-wrap { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.28s cubic-bezier(.4,0,.2,1); }
.sect[data-open="false"] .sect-wrap { grid-template-rows: 0fr; }
.sect-inner { overflow: hidden; padding-bottom: 6px; }

.md h3 {
  font-size: calc(15px * var(--read-scale)); font-weight: 800; color: var(--mod);
  letter-spacing: -0.1px; margin: 22px 0 9px;
  display: flex; align-items: center; gap: 9px;
}
.md h3::before { content:""; width: 3px; height: 14px; border-radius: 2px; background: var(--mod); flex-shrink: 0; }

.md p { font-size: 1em; color: var(--text-body); line-height: 1.82; margin-bottom: 14px; }
.md ul, .md ol { font-size: 1em; color: var(--text-body); line-height: 1.8; padding-left: 22px; margin-bottom: 14px; }
.md li { margin-bottom: 6px; padding-left: 3px; }
.md li::marker { color: var(--mod); }
.md ul li::marker { font-size: 0.9em; }
.md strong { color: var(--text-primary); font-weight: 800; }
.md em { color: var(--text-secondary); }
.md a {
  color: var(--amber-dark); font-weight: 700; text-decoration: none;
  border-bottom: 1.5px solid var(--amber-line); transition: border-color var(--t), background var(--t);
  padding-bottom: 1px;
}
.md a:hover { border-bottom-color: var(--amber); background: var(--amber-light); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

/* inline code */
.md :not(pre) > code {
  font-family: var(--mono); font-size: 0.84em;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 5px; padding: 1.5px 6px; color: var(--navy); white-space: nowrap;
}

/* code block */
.md pre {
  background: #14142b; border: 1px solid #26264a; border-radius: var(--r-md);
  padding: 16px 20px; overflow-x: auto; margin: 16px 0 20px; box-shadow: var(--sh-sm);
}
.md pre code { font-family: var(--mono); font-size: calc(13px * var(--read-scale)); color: #e6e8f2; line-height: 1.7; white-space: pre; }
.md pre::-webkit-scrollbar { height: 7px; }
.md pre::-webkit-scrollbar-thumb { background: #3a3a63; border-radius: 8px; }

/* ASCII diagram frame */
.diagram {
  margin: 18px 0 22px; border-radius: var(--r-md); overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--sh-sm);
}
.diagram-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 15px; background: var(--surface-3); border-bottom: 1px solid var(--border-muted);
  font-size: 10px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted);
}
.diagram-bar svg { color: var(--mod); }
.diagram pre {
  margin: 0; border: none; border-radius: 0; box-shadow: none;
  background: var(--surface-2);
  padding: 16px 20px;
}
.diagram pre code { color: #2a3142; font-size: calc(12.5px * var(--read-scale)); line-height: 1.75; font-weight: 500; }

/* tables */
.md .tbl-wrap { margin: 4px 0 22px; border-radius: var(--r-md); border: 1px solid var(--border); overflow: hidden; box-shadow: var(--sh-xs); }
.md table { width: 100%; border-collapse: collapse; font-size: calc(13.5px * var(--read-scale)); }
.md thead { background: var(--navy); }
.md th { color: #fff; font-weight: 700; text-align: left; padding: 11px 16px; font-size: calc(12px * var(--read-scale)); letter-spacing: 0.2px; }
.md td { padding: 11px 16px; border-bottom: 1px solid var(--border-muted); color: var(--text-body); vertical-align: top; line-height: 1.55; }
.md tbody tr:last-child td { border-bottom: none; }
.md tbody tr { transition: background var(--t); }
.md tbody tr:nth-child(even) { background: var(--surface-2); }
.md tbody tr:hover { background: var(--mod-tint); }
.md td strong { color: var(--mod); }

/* ════════════════════════════════════════════════════════════════════════
   CALLOUTS
   ════════════════════════════════════════════════════════════════════════ */
.callout {
  display: flex; gap: 13px; margin: 18px 0;
  padding: 14px 16px; border-radius: var(--r-md);
  border: 1px solid var(--co-bd); background: var(--co-bg);
  border-left: 4px solid var(--co-ac);
}
.callout-ico {
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  display: grid; place-items: center; color: #fff; background: var(--co-ac);
}
.callout-body { min-width: 0; flex: 1; }
.callout-kind { font-size: 10.5px; font-weight: 800; letter-spacing: 0.7px; text-transform: uppercase; color: var(--co-ac); margin-bottom: 3px; }
.callout-body p { margin: 0; font-size: calc(14px * var(--read-scale)); line-height: 1.65; color: var(--text-body); }
.callout-body p + p { margin-top: 7px; }

.callout.exam  { --co-ac:#e08600; --co-bg:#fff8ea; --co-bd:#ffe0a8; }
.callout.tip   { --co-ac:#0f9d58; --co-bg:#edfaf1; --co-bd:#c2ecd0; }
.callout.warn  { --co-ac:#d93a3f; --co-bg:#fdeded; --co-bd:#f6c9cb; }
.callout.note  { --co-ac:#3b6fd4; --co-bg:#eef4fd; --co-bd:#cadcf6; }

/* ── prev / next footer nav ── */
.art-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--border); }
.art-nav-card {
  display: flex; flex-direction: column; gap: 5px; padding: 14px 18px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); transition: all var(--t);
  cursor: pointer;
}
.art-nav-card:hover { border-color: var(--mod); box-shadow: var(--sh-sm); transform: translateY(-2px); }
.art-nav-card.next { text-align: right; align-items: flex-end; }
.art-nav-lbl { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; color: var(--text-muted); }
.art-nav-card:hover .art-nav-lbl { color: var(--mod); }
.art-nav-ttl { font-size: 14px; font-weight: 800; color: var(--text-primary); line-height: 1.3; }

/* ════════════════════════════════════════════════════════════════════════
   TOC RAIL
   ════════════════════════════════════════════════════════════════════════ */
.toc { position: sticky; top: 72px; align-self: start; }
.toc-card { border-left: 2px solid var(--border); padding-left: 2px; }
.toc-label { font-size: 10px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); padding: 0 0 10px 13px; }
.toc-link {
  display: block; width: 100%; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  padding: 5px 10px 5px 13px; border-left: 2px solid transparent; margin-left: -2px;
  line-height: 1.4; transition: color var(--t), border-color var(--t);
  cursor: pointer;
}
.toc-link:hover { color: var(--text-primary); }
.toc-link.active { color: var(--mod); border-left-color: var(--mod); font-weight: 800; }
.toc-foot { margin-top: 18px; padding: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); }
.toc-mini-btn {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  padding: 6px 10px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface-3);
  color: var(--text-secondary); transition: all var(--t); width: 100%; justify-content: center;
  cursor: pointer;
}
.toc-mini-btn + .toc-mini-btn { margin-top: 7px; }
.toc-mini-btn.read.on { color: #15803d; background: #e9f9ee; border-color: #bbf0c9; }
.toc-mini-btn.bm.on { color: var(--amber-dark); background: var(--amber-light); border-color: var(--amber-line); }
.toc-mini-btn.bm.on svg { fill: var(--amber); }
.toc-mini-btn:hover:not(.on) { border-color: var(--border-strong); }

.loading { color: var(--text-muted); font-size: 15px; padding: 60px 0; text-align: center; }

/* ════════════════════════════════════════════════════════════════════════
   PRACTICE QUESTIONS
   ════════════════════════════════════════════════════════════════════════ */
.quiz-section {
  margin: 40px 0 16px; border-top: 1px solid var(--border-muted); padding-top: 32px;
}
.quiz-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
}
.quiz-head-left {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 800; color: var(--text-primary); letter-spacing: .01em;
}
.quiz-score {
  font-size: 12.5px; font-weight: 800; color: var(--text-secondary);
  background: var(--surface-3); border: 1px solid var(--border);
  padding: 3px 10px; border-radius: 99px;
}
.quiz-cards { display: flex; flex-direction: column; gap: 16px; }

.qcard {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); overflow: hidden;
  transition: border-color var(--t);
}
.qcard.qcard-right { border-color: #22c55e; }
.qcard.qcard-wrong { border-color: #ef4444; }

.qcard-q {
  padding: 16px 18px 14px; font-size: 14px; font-weight: 600;
  color: var(--text-primary); line-height: 1.55; display: flex; gap: 8px; align-items: flex-start;
}
.qcard-num {
  flex-shrink: 0; font-size: 10.5px; font-weight: 800; color: var(--mod, var(--text-secondary));
  background: var(--surface-3); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 99px; margin-top: 2px;
}
.qcard-badge {
  flex-shrink: 0; font-size: 10.5px; font-weight: 800; color: #7c3aed;
  background: #f3f0ff; border: 1px solid #ddd6fe;
  padding: 2px 8px; border-radius: 99px; margin-top: 2px;
}

.qcard-options { padding: 0 14px 14px; display: flex; flex-direction: column; gap: 7px; }
.qcard-opt {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 10px 13px; border-radius: var(--r-md);
  border: 1.5px solid var(--border); background: var(--surface-3);
  cursor: pointer; text-align: left; transition: all var(--t);
  font-size: 13.5px; color: var(--text-primary);
}
.qcard-opt:hover:not(:disabled) { border-color: var(--mod, var(--border-strong)); background: var(--surface-2); }
.qcard-opt.sel { border-color: #818cf8; background: #eef2ff; }
.qcard-opt.correct { border-color: #22c55e; background: #f0fdf4; color: #15803d; }
.qcard-opt.wrong { border-color: #ef4444; background: #fef2f2; color: #b91c1c; }
.qcard-opt:disabled { cursor: default; }

.qcard-letter {
  flex-shrink: 0; width: 22px; height: 22px;
  border-radius: 50%; border: 1.5px solid currentColor;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 800; line-height: 1;
  color: var(--text-secondary);
}
.qcard-opt.correct .qcard-letter { color: #15803d; }
.qcard-opt.wrong .qcard-letter   { color: #b91c1c; }
.qcard-opt.sel .qcard-letter     { color: #4f46e5; }

.qcard-text { line-height: 1.45; }

.qcard-explain {
  margin: 0 14px 14px; padding: 12px 14px;
  font-size: 13px; line-height: 1.6; color: var(--text-secondary);
  background: var(--surface-2); border: 1px solid var(--border-muted);
  border-radius: var(--r-md);
}

/* ════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .article { grid-template-columns: minmax(0,1fr); max-width: var(--read-width); }
  .toc { display: none; }
}
@media (max-width: 820px) {
  .article { padding: 24px 18px 72px; }
  .crumb-bar { padding: 10px 16px; }
  .crumb-trail { display: none; }
  .art-nav { grid-template-columns: 1fr; }
  .art-nav-card.next { text-align: left; align-items: flex-start; }
}
