/* Learning hub (Wizard Lab) */
.narrow { max-width: 820px; }
.block { padding-top: 56px; }
.block h2 { font-size: 1.7rem; margin-bottom: 4px; }
.lead { font-size: 1.12rem; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.language-bar { display: flex; justify-content: flex-end; padding-top: 18px; }
.language-switch { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 12px; }
.language-switch a { padding: 7px 14px; border-radius: 8px; color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.language-switch a[aria-current="page"] { background: var(--brand); color: var(--brand-ink); }
.language-switch a:hover { text-decoration: none; color: var(--text); }
.language-switch a:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

.learn-hero {
  position: relative; padding: 80px 0 56px; border-bottom: 1px solid var(--border);
}
.learn-hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); max-width: 860px; margin: 14px 0 18px; }
.learn-hero .lead { max-width: 680px; }
.learn-hero-grid { position: relative; display: grid; grid-template-columns: 1.3fr 1fr; gap: 48px; align-items: center; }
.terminal {
  background: #111; color: #f2efe9; border-radius: 16px; border: 2px solid #111; box-shadow: 8px 8px 0 var(--brand);
  overflow: hidden; transform: rotate(1.5deg);
}
.terminal-bar { display: flex; align-items: center; gap: 6px; padding: 10px 14px; background: #1c1b19; }
.terminal-bar span { width: 10px; height: 10px; border-radius: 50%; background: #3a3733; }
.terminal-bar span:first-child { background: var(--brand); }
.terminal-bar span:nth-child(2) { background: var(--yellow); }
.terminal-bar em { margin-left: auto; font-style: normal; font-family: var(--font-mono); font-size: 0.75rem; color: #8c857c; }
.terminal pre { margin: 0; padding: 18px 20px 22px; font-family: var(--font-mono); font-size: 0.86rem; line-height: 1.75; white-space: pre; overflow-x: auto; }
.t-prompt { color: var(--brand); } .t-ok { color: var(--yellow); } .t-muted { color: #8c857c; }
.t-cursor { display: inline-block; width: 8px; height: 1.05em; margin-left: 4px; vertical-align: -2px; background: var(--brand); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.page-hero {
  padding: 56px 0 36px; margin-bottom: 36px; border-bottom: 1px solid var(--border);
}
.page-hero h1 { font-size: clamp(2rem, 4.4vw, 3rem); margin: 12px 0 14px; }
.page-hero .eyebrow { color: var(--accent); }
.crumb { display: block; width: fit-content; font-size: 0.9rem; color: var(--muted); margin-bottom: 18px; }

/* Series cards */
.series-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 18px; margin-top: 24px; }
.series-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 26px; color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.series-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--series); }
.series-card:hover { transform: translate(-3px, -3px); box-shadow: 6px 6px 0 var(--text); border-color: var(--text); text-decoration: none; }
.series-card h3 { font-size: 1.3rem; margin: 0; }
.series-card p { margin: 0; font-size: 0.95rem; }
.series-level { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); }
.series-count { margin-top: auto; padding-top: 8px; font-weight: 600; font-size: 0.9rem; color: var(--accent); }
.series-card-cover { width: calc(100% + 52px); max-width: none; height: auto; margin: -26px -26px 8px; aspect-ratio: 3 / 2; object-fit: cover; }
.series-cover { width: 100%; height: auto; margin-top: 28px; border-radius: var(--radius); border: 1px solid var(--border); }

/* Article cards */
.article-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 20px; }
.article-list { display: grid; gap: 12px; }
.article-card {
  display: flex; flex-direction: column; gap: 6px; padding: 22px; color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--border); border-left: 3px solid var(--series); border-radius: var(--radius-sm);
}
.article-card { transition: transform 0.18s ease, box-shadow 0.18s ease; }
.article-card:hover { text-decoration: none; transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--text); border-color: var(--text); border-left-color: var(--series); }
.article-card h3 { font-size: 1.12rem; margin: 0; }
.article-card p { margin: 0; font-size: 0.93rem; }
.article-card-series { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.article-card-meta { font-size: 0.82rem; color: var(--muted); }
.filter {
  width: 100%; margin-top: 18px; padding: 14px 16px; font: inherit; color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 12px;
}
.filter:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.article-card.has-cover { padding-top: 0; overflow: hidden; }
.article-card-cover { width: calc(100% + 44px); max-width: none; margin: 0 -22px 10px -25px; aspect-ratio: 16 / 9; object-fit: cover; object-position: center top; }
.article-cover { width: 100%; height: auto; max-height: 640px; object-fit: contain; margin-top: 28px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-soft); }
/* Sinhala reads better a touch larger with looser leading. */
[lang="si"] .prose { font-size: 1.1rem; line-height: 1.95; }
[lang="si"] h1, [lang="si"] h3 { line-height: 1.35; letter-spacing: 0; }

/* Series page */
.series-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.series-list a {
  display: flex; gap: 16px; align-items: flex-start; padding: 18px 20px; color: var(--text);
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.series-list a:hover { border-color: var(--series); text-decoration: none; }
.series-list strong { display: block; }
.series-list .muted { font-size: 0.92rem; }
.series-num {
  flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 700; color: var(--brand-ink); background: var(--brand);
}
.empty h2 { font-size: 1.3rem; }

/* Article */
.article-share { margin-top: 24px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-soft); }
.share-label { margin: 0 0 10px; font-size: 0.88rem; font-weight: 600; color: var(--muted); }
.share-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.share-action { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev); color: var(--text); font: 600 0.85rem var(--font); cursor: pointer; }
.share-action:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.share-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.share-status { margin: 8px 0 0; font-size: 0.88rem; color: var(--accent); }
.share-status:empty { margin: 0; }
.share-link { margin-top: 8px; width: 100%; min-width: 0; padding: 10px; font: inherit; font-size: 0.85rem; color: var(--text); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; }
.article-share [hidden] { display: none; }
.article-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.9rem; margin: 0; }
.article-meta img { border-radius: 50%; width: 28px; height: 28px; object-fit: cover; }
.article-layout { max-width: 1076px; display: grid; grid-template-columns: minmax(0, 760px) 220px; gap: 56px; }
.toc { position: sticky; top: 88px; align-self: start; font-size: 0.88rem; }
.toc-title { font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; font-size: 0.72rem; color: var(--muted); }
.toc ul { list-style: none; padding: 0 0 0 12px; margin: 0; border-left: 1px solid var(--border); display: grid; gap: 6px; }
.toc a { color: var(--muted); }
.toc a:hover { color: var(--text); }
.toc .toc-sub { padding-left: 12px; }
.article-tags { margin-top: 40px; }
/* Line the article header and footer up with the text column, not the page centre. */
.article .narrow { max-width: 1076px; }
.article .narrow > * { max-width: 760px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 32px; }
.pager a {
  display: flex; flex-direction: column; gap: 4px; padding: 18px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-weight: 600; background: var(--bg-elev);
}
.pager a:hover { border-color: var(--series); text-decoration: none; }
.pager .muted { font-size: 0.82rem; font-weight: 500; }
.pager-next { text-align: right; grid-column: 2; }

/* Prose */
.prose { font-size: 1.06rem; line-height: 1.8; min-width: 0; }
.prose h2 { font-size: 1.6rem; margin: 2em 0 0.6em; scroll-margin-top: 84px; }
.prose h3 { font-size: 1.25rem; margin: 1.6em 0 0.5em; scroll-margin-top: 84px; }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: 3px; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin-bottom: 0.4em; }
.prose img { border-radius: var(--radius-sm); border: 1px solid var(--border); margin: 1.5em auto; }
.prose blockquote {
  margin: 1.5em 0; padding: 14px 20px; border-left: 4px solid var(--series, var(--accent));
  background: var(--bg-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.prose blockquote p:last-child { margin: 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1.5em 0; font-size: 0.95rem; display: block; overflow-x: auto; }
.prose th, .prose td { padding: 10px 12px; border: 1px solid var(--border); text-align: left; }
.prose th { background: var(--bg-soft); }
.prose table.defs thead { display: none; }
.prose table.defs td:first-child { white-space: nowrap; background: var(--bg-soft); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.5em 0; }
.prose code { font-family: var(--font-mono); font-size: 0.88em; }
.prose :not(pre) > code { padding: 2px 6px; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--border); }
.prose div.highlighter-rouge { position: relative; margin: 1.5em 0; }
.prose pre {
  margin: 0; padding: 18px 20px; overflow-x: auto; border-radius: 12px; line-height: 1.6;
  background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); font-size: 0.9rem;
}
.copy-btn {
  position: absolute; top: 8px; right: 8px; font: 500 0.75rem var(--font); padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--muted); cursor: pointer; opacity: 0; transition: opacity 0.15s ease;
}
.prose div.highlighter-rouge:hover .copy-btn, .copy-btn:focus { opacity: 1; }

/* Rouge syntax colours: light by default, dark under [data-theme="dark"] */
.highlight { --c-com: #6e7781; --c-kw: #cf222e; --c-type: #953800; --c-str: #0a3069; --c-num: #0550ae; --c-fn: #8250df; --c-attr: #0550ae; --c-op: #24292f; }
[data-theme="dark"] .highlight { --c-com: #8b949e; --c-kw: #ff7b72; --c-type: #ffa657; --c-str: #a5d6ff; --c-num: #79c0ff; --c-fn: #d2a8ff; --c-attr: #79c0ff; --c-op: #c9d1d9; }
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs, .highlight .sd { color: var(--c-com); font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kc, .highlight .ow { color: var(--c-kw); }
.highlight .kt, .highlight .nc, .highlight .nn { color: var(--c-type); }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sh, .highlight .si, .highlight .sa { color: var(--c-str); }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh { color: var(--c-num); }
.highlight .nf, .highlight .fm, .highlight .nb, .highlight .bp { color: var(--c-fn); }
.highlight .nd, .highlight .na, .highlight .nt { color: var(--c-attr); }
.highlight .o, .highlight .p { color: var(--c-op); }
.highlight .err, .highlight .gd { color: var(--c-kw); }
.highlight .gi { color: #1a7f37; }

@media (max-width: 1000px) {
  .learn-hero-grid { grid-template-columns: 1fr; }
  .terminal { transform: none; }
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 640px) {
  .learn-hero { padding: 48px 0 32px; }
  .share-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .share-action { min-width: 0; text-align: center; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { grid-column: 1; }
}
