/* Learn pages (built by learn/build.ts). Same tokens as src/styles/global.css. */
@font-face { font-family: Vazirmatn; src: url(/learn/fonts/vazir-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(/learn/fonts/vazir-700.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(/learn/fonts/vazir-900.woff2) format('woff2'); font-weight: 800 900; font-display: swap; }
@font-face { font-family: Inter; src: url(/learn/fonts/inter-400.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Inter; src: url(/learn/fonts/inter-700.woff2) format('woff2'); font-weight: 600 700; font-display: swap; }
@font-face { font-family: Inter; src: url(/learn/fonts/inter-800.woff2) format('woff2'); font-weight: 800 900; font-display: swap; }

:root, :root[data-theme='dark'] {
  --bg: #030d09; --bg2: #071711; --surface: rgba(255, 255, 255, 0.04); --solid: #0a1c15;
  --line: rgba(255, 255, 255, 0.09); --line2: rgba(22, 199, 132, 0.42);
  --text: #ecfff6; --body: #cfe6dc; --muted: #8aa99b; --primary: #16c784; --onprimary: #02130c;
  --glow: rgba(22, 199, 132, 0.5); --grid: rgba(22, 199, 132, 0.08); --soft: rgba(22, 199, 132, 0.12);
  --blob1: rgba(22, 199, 132, 0.22); --blob2: rgba(20, 140, 190, 0.16); --nav: rgba(3, 13, 9, 0.8);
  --warn: #fbbf24; --warnsoft: rgba(251, 191, 36, 0.1);
  color-scheme: dark;
}
:root[data-theme='light'] {
  --bg: #f4fbf8; --bg2: #e9f6f0; --surface: rgba(255, 255, 255, 0.78); --solid: #ffffff;
  --line: rgba(11, 59, 44, 0.1); --line2: rgba(14, 159, 110, 0.45);
  --text: #0b2a20; --body: #23463a; --muted: #4a7464; --primary: #0a7f57; --onprimary: #ffffff;
  --glow: rgba(14, 159, 110, 0.32); --grid: rgba(14, 159, 110, 0.09); --soft: rgba(14, 159, 110, 0.1);
  --blob1: rgba(22, 199, 132, 0.18); --blob2: rgba(56, 189, 248, 0.12); --nav: rgba(244, 251, 248, 0.88);
  --warn: #92400e; --warnsoft: rgba(245, 158, 11, 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 90px; }
body {
  background: var(--bg); color: var(--text); min-height: 100dvh;
  font-family: Vazirmatn, Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased;
}
html[lang='en'] body { font-family: Inter, system-ui, sans-serif; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
::selection { background: var(--soft); }
.en { font-family: Inter, sans-serif; direction: ltr; unicode-bidi: isolate; }
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; direction: ltr; unicode-bidi: isolate; }
.gtext { background: linear-gradient(100deg, #16c784 0%, #8bffd3 45%, #16c784 90%); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme='light'] .gtext { background: linear-gradient(100deg, #0a7f57, #0e9f6e 50%, #0a7f57); -webkit-background-clip: text; background-clip: text; }
.eyebrow { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; letter-spacing: 0.14em; color: var(--primary); direction: ltr; unicode-bidi: isolate; }
html[dir='rtl'] .eyebrow { direction: rtl; letter-spacing: 0.04em; }

/* Background */
.bgfx { position: fixed; inset: 0; pointer-events: none; z-index: -1; overflow: hidden; }
.gridbg {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse 70% 50% at 50% 0%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 50% at 50% 0%, #000 20%, transparent 75%);
}
.blob { position: absolute; border-radius: 50%; filter: blur(90px); }
.b1 { width: 560px; height: 560px; inset-inline-start: -180px; top: -120px; background: var(--blob1); }
.b2 { width: 480px; height: 480px; inset-inline-end: -180px; top: 120px; background: var(--blob2); }

/* Buttons */
.btn, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 50px; padding: 0 22px;
  border-radius: 15px; font-size: 15px; font-weight: 800; white-space: nowrap; cursor: pointer;
}
.btn { background: var(--primary); color: var(--onprimary); border: 0; box-shadow: 0 12px 34px -8px var(--glow), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
.btn:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface); border: 1px solid var(--line); color: var(--text); font-weight: 600; }
.btn-ghost:hover { border-color: var(--line2); }
.btn-sm { height: 42px; padding: 0 16px; font-size: 14px; border-radius: 13px; }
.icon-btn {
  min-width: 42px; height: 42px; padding: 0 12px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 14px; font-weight: 600;
}
.icon-btn:hover { border-color: var(--line2); }

/* Header */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px;
  padding: 14px max(20px, calc((100vw - 1180px) / 2)); background: var(--nav);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.wm { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.top-nav { display: flex; gap: 22px; font-size: 15px; color: var(--muted); }
.top-nav a:hover { color: var(--text); }
.top-actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }

/* Layout */
.wrap { width: min(1180px, 100% - 40px); margin: 0 auto; padding: 28px 0 80px; }
.crumbs { display: flex; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 26px; }
.crumbs a:hover { color: var(--primary); }

/* Article */
.art { max-width: 780px; margin: 0 auto; }
.art-head { display: flex; flex-direction: column; gap: 14px; margin-bottom: 26px; }
h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.35; margin: 0; font-weight: 900; letter-spacing: -0.01em; }
html[lang='en'] h1 { line-height: 1.15; letter-spacing: -0.025em; }
.lead { font-size: 18px; line-height: 2; color: var(--muted); margin: 0; }
html[lang='en'] .lead { line-height: 1.7; }
.meta { font-size: 13px; color: var(--muted); margin: 0; }

.toc { border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 18px 22px; margin: 0 0 34px; }
.toc summary { cursor: pointer; font-weight: 800; color: var(--primary); }
.toc ol { margin: 14px 0 0; padding-inline-start: 22px; display: grid; gap: 8px; font-size: 15px; color: var(--body); }
.toc a:hover { color: var(--primary); }

.prose { font-size: 17px; line-height: 2.1; color: var(--body); }
html[lang='en'] .prose { line-height: 1.8; }
.prose h2 { font-size: 27px; line-height: 1.5; color: var(--text); margin: 52px 0 14px; font-weight: 900; }
.prose h2::before { content: ''; display: block; width: 36px; height: 4px; border-radius: 4px; background: var(--primary); margin-bottom: 16px; box-shadow: 0 0 18px var(--glow); }
.prose h3 { font-size: 20px; color: var(--text); margin: 34px 0 8px; font-weight: 800; }
.prose p { margin: 0 0 18px; }
.prose a { color: var(--primary); border-bottom: 1px solid var(--line2); }
.prose a:hover { border-bottom-color: var(--primary); }
.prose strong { color: var(--text); }
.prose ul, .prose ol { padding-inline-start: 24px; margin: 0 0 20px; }
.prose li { margin-bottom: 8px; }
.prose li::marker { color: var(--primary); }
.prose code { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.82em; padding: 2px 7px; border-radius: 7px; background: var(--soft); color: var(--text); direction: ltr; unicode-bidi: isolate; word-break: break-all; }
.prose blockquote { margin: 26px 0; padding: 16px 20px; border-radius: 18px; background: var(--soft); border: 1px solid var(--line2); color: var(--text); }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 40px 0; }
.tbl { overflow-x: auto; margin: 0 0 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.8; min-width: 520px; }
.prose th, .prose td { padding: 12px 16px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { color: var(--text); background: var(--soft); font-weight: 800; }
.prose tr:last-child td { border-bottom: 0; }

/* Call to action */
.cta {
  position: relative; overflow: hidden; margin: 48px 0 0; padding: 32px; border-radius: 26px;
  border: 1px solid var(--line2); background: var(--surface); display: flex; flex-direction: column; gap: 12px;
}
.cta-inline { margin: 34px 0; padding: 24px; }
.cta-glow { position: absolute; width: 360px; height: 220px; inset-inline-end: -80px; top: -110px; border-radius: 50%; filter: blur(70px); background: var(--blob1); pointer-events: none; }
.cta > * { position: relative; }
.cta b { font-size: 22px; font-weight: 900; color: var(--text); }
.cta p { margin: 0; color: var(--muted); line-height: 1.9; font-size: 15px; }
.cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.prose .cta a { border: 0; color: inherit; }
.prose .cta .btn { color: var(--onprimary); }

/* Cards */
.hub-head { display: flex; flex-direction: column; gap: 16px; max-width: 760px; margin: 20px 0 40px; }
.more { margin-top: 72px; }
.more h2 { font-size: 26px; margin: 0 0 20px; font-weight: 900; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 20px; }
.card { border: 1px solid var(--line); background: var(--surface); border-radius: 24px; overflow: hidden; }
.post { display: flex; flex-direction: column; transition: transform 0.2s ease, border-color 0.2s ease; }
.post:hover { transform: translateY(-3px); border-color: var(--line2); }
.thumb { height: 150px; position: relative; }
.thumb .mono { position: absolute; bottom: 14px; left: 16px; font-size: 22px; font-weight: 600; color: #fff; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35); }
.post-body { padding: 20px 22px 24px; display: flex; flex-direction: column; gap: 8px; }
.post-body b { font-size: 18px; line-height: 1.7; }
html[lang='en'] .post-body b { line-height: 1.4; }
.post-body p { margin: 0; font-size: 14px; line-height: 1.9; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Footer */
.foot { border-top: 1px solid var(--line); padding: 36px 20px 48px; }
.foot-in { width: min(1180px, 100%); margin: 0 auto; display: flex; flex-direction: column; gap: 10px; color: var(--muted); font-size: 14px; }
.foot p { margin: 0; }
.foot nav { display: flex; gap: 18px; flex-wrap: wrap; }
.foot nav a:hover { color: var(--primary); }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  .top { gap: 12px; padding: 12px 16px; }
  .top .wm { display: none; }
  .top-nav { font-size: 14px; }
  .wrap { width: calc(100% - 32px); }
  .prose { font-size: 16px; }
  .prose h2 { font-size: 23px; }
  .cta { padding: 24px 20px; }
}
@media (max-width: 380px) { .top .btn-sm { padding: 0 12px; font-size: 13px; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .post { transition: none; } }
:root[data-theme='light'] .thumb .mono { color: #0b2a20; text-shadow: none; }
.prose td code { white-space: nowrap; }

/* Tutorials: pictures, topics, pager, channel box */
.thumb-img { height: auto; aspect-ratio: 16 / 9; overflow: hidden; background: var(--bg2); }
.thumb-img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; }
.post:hover .thumb-img img { transform: scale(1.03); }
.hero-img { display: block; width: 100%; height: auto; border-radius: 24px; border: 1px solid var(--line); margin: 8px 0 28px; box-shadow: 0 30px 80px -40px var(--glow); }
.topics { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 44px; }
.topic { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 700; text-decoration: none; transition: border-color 0.2s ease, background 0.2s ease; }
.topic:hover, .topic.on { border-color: var(--acc, var(--primary)); background: color-mix(in srgb, var(--acc, var(--primary)) 14%, transparent); }
.topic small { font-size: 12px; color: var(--muted); font-weight: 600; }
.topic-sec { margin: 0 0 56px; scroll-margin-top: 90px; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0 0 20px; }
.sec-head h2 { margin: 0; font-size: 24px; font-weight: 900; display: flex; gap: 10px; align-items: center; }
.see-all { color: var(--primary); font-weight: 700; font-size: 14px; text-decoration: none; white-space: nowrap; }
.see-all:hover { text-decoration: underline; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 40px 0 0; }
.pg { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--text); transition: border-color 0.2s ease; }
.pg:hover { border-color: var(--line2); }
.pg b { font-size: 16px; line-height: 1.7; }
.pg.next { text-align: end; }
.chan { display: flex; align-items: center; gap: 16px; margin: 28px 0 0; padding: 18px 22px; border-radius: 22px; border: 1px solid var(--line); background: linear-gradient(120deg, rgba(56, 189, 248, 0.1), transparent 60%), var(--surface); }
.chan-ic { font-size: 28px; }
.chan div { flex: 1; }
.chan b { font-size: 16px; }
.chan p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
@media (max-width: 640px) {
  .pager { grid-template-columns: 1fr; }
  .chan { flex-wrap: wrap; }
  .sec-head h2 { font-size: 20px; }
}
