/* dawn-lang.dawnop.com — 精致极简、零 JS。
   签名：冷调「拂晓天际」渐变（靛蓝→violet→品红，黎明前的天空），
   等宽 eyebrow 展示语言自己的词汇，Hero 编辑器窗口 + GitHub Light 代码高亮。 */

:root {
  --accent: #7c3aed;
  --accent-hover: #6d28d9;
  --dawn-1: #4f46e5;   /* 靛蓝：将退的夜 */
  --dawn-2: #7c3aed;   /* violet：微光 */
  --dawn-3: #db2777;   /* 品红：地平线 */
  --dawn-grad: linear-gradient(90deg, var(--dawn-1) 0%, var(--dawn-2) 50%, var(--dawn-3) 100%);

  --text: #1f2328;
  --muted: #57606a;
  --faint: #8b949e;
  --border: #d0d7de;
  --border-soft: #e9ecf1;
  --code-bg: #f6f8fa;
  --code-bg-soft: #fafbfc;
  --output-bg: #fbfcfd;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;

  --max: 46rem;      /* 阅读宽度 */
  --max-wide: 64rem; /* 首页 */
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  /* 预留滚动条槽位：短页（如 Playground）与长页切换时不再左右漂移 */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  line-height: 1.75;
  font-size: 16px;
  /* 全站顶部的拂晓渐变细线 */
  border-top: 3px solid transparent;
  border-image: var(--dawn-grad) 1;
}

/* ---- 页头导航 ---- */

.site-header {
  border-bottom: 1px solid var(--border-soft);
}

.site-header nav {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 0.95rem 1.25rem;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1.15rem;
  flex-wrap: wrap;
}

.site-header .brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--accent);
  text-decoration: none;
}

.brand-logo {
  height: 1.25em;
  width: 1.25em;
  vertical-align: -0.28em;
  margin-right: 0.35rem;
}

.site-header a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  position: relative;
  transition: color 0.15s ease;
}

.site-header a:hover { color: var(--text); }

.site-header a.active {
  color: var(--text);
  /* deliberately no font-weight bump: bolding an active item widens its text,
     and the nav is center-justified, so the whole row (and page) would shift on
     navigation. Colour + the gradient underline mark the active item instead. */
}

.site-header a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.5rem;
  height: 2px;
  border-radius: 2px;
  background: var(--dawn-grad);
}

/* The other language. Only the front page has a twin, so this appears on two
   pages out of 38 — set apart from the nav items with a hairline border so it
   does not read as a seventh section of the site. */
.site-header a.lang {
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.12rem 0.6rem;
  font-size: 0.85rem;
}

.site-header a.lang:hover { border-color: var(--muted); }

/* ---- 正文（阅读页） ---- */

main.content {
  max-width: var(--max);
  margin: 0 auto;
  padding: 2.75rem 1.25rem 3.5rem;
}

h1 { font-size: 1.75rem; line-height: 1.35; margin: 0 0 1.25rem; }
h2 { font-size: 1.32rem; line-height: 1.4;  margin: 2.5rem 0 0.75rem; }
h3 { font-size: 1.08rem; line-height: 1.4;  margin: 1.75rem 0 0.5rem; }

h1, h2, h3 { font-weight: 680; letter-spacing: -0.015em; }

p { margin: 0.85rem 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

hr {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 2.5rem 0;
}

ul, ol { padding-left: 1.5rem; margin: 0.85rem 0; }
li { margin: 0.3rem 0; }

blockquote {
  margin: 1.15rem 0;
  padding: 0.35rem 1.1rem;
  border-left: 3px solid transparent;
  border-image: var(--dawn-grad) 1;
  color: var(--muted);
  background: var(--code-bg-soft);
}

/* ---- 首页 Hero ---- */

main.home {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 4rem 1.25rem 3.5rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 31rem);
  gap: 3.5rem;
  align-items: center;
}

.hero-copy .eyebrow {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: var(--faint);
  margin: 0 0 1.1rem;
}

.wordmark {
  font-size: clamp(3.2rem, 8vw, 4.6rem);
  font-weight: 820;
  letter-spacing: -0.045em;
  line-height: 1;
  margin: 0 0 1.4rem;
  position: relative;
  display: inline-block;
}

/* 地平线：一道向右淡出的渐变线，晨光在天际铺开 */
.wordmark::after {
  content: "";
  position: absolute;
  left: 0.06em;
  bottom: -0.18em;
  width: 2.6em;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--dawn-1), var(--dawn-2), var(--dawn-3), transparent);
}

.lede {
  font-size: 1.16rem;
  line-height: 1.65;
  color: var(--text);
  max-width: 33rem;
  margin: 0 0 1.9rem;
}

.cta-row {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

/* ---- 按钮 ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.62rem 1.2rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.96rem;
  line-height: 1;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease,
    border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #6d28d9 0%, #7c3aed 55%, #9333ea 100%);
  box-shadow: 0 1px 2px rgba(76, 29, 149, 0.28);
}

.btn-primary:hover {
  color: #fff;
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(91, 33, 182, 0.28);
}

.btn-ghost {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  color: var(--accent);
  text-decoration: none;
  border-color: var(--accent);
}

/* ---- 首页特性区 ---- */

.features {
  max-width: var(--max-wide);
  margin: 4.5rem auto 0;
  padding: 2.75rem 1.25rem 0;
  border-top: 1px solid var(--border-soft);
}

.features > h2 {
  margin: 0 0 1.75rem;
  font-size: 1.25rem;
}

.feature-list {
  display: flex;
  flex-direction: column;
}

.feature {
  display: grid;
  grid-template-columns: minmax(0, 21rem) minmax(0, 1fr);
  gap: 2.75rem;
  align-items: center;
  padding: 2.5rem 0;
  border-top: 1px solid var(--border-soft);
}

.feature:first-child { border-top: 0; padding-top: 0.5rem; }

.feature-text h3 {
  margin: 0 0 0.55rem;
  font-size: 1.18rem;
}

.feature-text p {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.7;
}

.feature-code pre {
  margin: 0;
}

/* 卡片的输出块贴在源码下面，中间只留一道缝 */
.feature-code pre + pre {
  margin-top: 0.65rem;
}

.features > p {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 0.95rem;
}

@media (max-width: 52rem) {
  .feature {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 2rem 0;
  }
}

/* ---- 代码 ---- */

code, pre, kbd { font-family: var(--mono); }

code {
  font-size: 0.875em;
  background: var(--code-bg);
  border-radius: 5px;
  padding: 0.15em 0.4em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  line-height: 1.6;
  margin: 1.25rem 0;
}

pre code {
  background: none;
  padding: 0;
  font-size: 0.86rem;
}

/* 输出块：右上角角标。这张样式表两棵语言树共用，所以角标的文字得跟着页面语言走：
   默认写英文（站点默认语言，<html lang="en">），中文树由下面那条 lang 限定的规则覆盖。
   site/src/gen/assets.dawn 会盯着这里——CSS 注入的文字绕过了 #172 的双语外壳。 */
pre.output {
  position: relative;
  background: var(--output-bg);
  border-style: dashed;
}

pre.output::before {
  content: "Output";
  position: absolute;
  top: 0.5rem;
  right: 0.85rem;
  font-size: 0.72rem;
  color: var(--faint);
  font-family: var(--mono);
}

html[lang="zh-CN"] pre.output::before {
  content: "输出";
}

/* 教程里的 dawn 代码块：底下挂一条去 Playground 的链接，href 的 #fragment 就是
   这段代码本身（UTF-8 的 base64），编辑器读 location.hash 预填。整块看起来是一扇
   窗：代码块下边角拉平，链接接上去当窗沿。
   标签文字在 markup 里（html/play.dawn 按 Lang 选），不用 content:——那条路绕过
   双语外壳，正是 gen/assets.dawn 盯着的那个 bug。 */
.playable {
  margin: 1.25rem 0;
}

.playable pre.dawn {
  margin: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

a.play-open {
  display: block;
  padding: 0.4rem 1.15rem 0.45rem;
  border: 1px solid var(--border-soft);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: var(--code-bg-soft);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--faint);
  text-align: right;
}

a.play-open:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Hero 编辑器窗口 */
.code-window {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 13px;
  overflow: hidden;
  background: var(--code-bg);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05),
    0 14px 40px rgba(91, 33, 182, 0.09);
}

.code-window__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  background: var(--code-bg-soft);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.code-window__bar .fname { color: var(--muted); }
.code-window__bar .run { color: var(--accent); }

.code-window pre.dawn {
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 1.1rem 1.25rem 1.2rem;
}

/* 窗口里的输出：还是同一扇窗，只用一道虚线分开 */
.code-window pre.output {
  margin: 0;
  border: 0;
  border-top: 1px dashed var(--border);
  border-radius: 0;
  padding: 1rem 1.25rem;
}

/* 高亮（GitHub Light / 蓝紫调）：k 关键字 t 类型 f 定义名 s 字符串 i 插值 n 数字 c 注释 */
.k { color: #cf222e; }
.t { color: #9333ea; }
.f { color: #7c3aed; }
.s { color: #0a3069; }
.i { color: #0550ae; }
.n { color: #0550ae; }
.c { color: #6e7781; }

/* ---- 表格 ---- */

table {
  border-collapse: collapse;
  margin: 1.25rem 0;
  width: 100%;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}

th, td {
  border: 1px solid var(--border-soft);
  padding: 0.45rem 0.8rem;
  text-align: left;
  vertical-align: top;
}

th { background: var(--code-bg); font-weight: 640; }

/* ---- 教程目录（序号已在标题文本内，去掉列表标记） ---- */

.chapter-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  border-top: 1px solid var(--border-soft);
}

.chapter-list li {
  margin: 0;
  border-bottom: 1px solid var(--border-soft);
}

.chapter-list a {
  display: block;
  padding: 0.75rem 0.25rem;
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s ease, padding-left 0.15s ease;
}

.chapter-list a:hover {
  color: var(--accent);
  padding-left: 0.6rem;
  text-decoration: none;
}

/* ---- 教程上一章 / 下一章 ---- */

.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.35rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.95rem;
}

.chapter-nav .next { margin-left: auto; text-align: right; }

/* ---- 规范页：侧栏 TOC（宽屏两栏，窄屏收顶部） ---- */

.with-toc {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 2.75rem 1.25rem 3.5rem;
  display: grid;
  grid-template-columns: 14rem minmax(0, 1fr);
  gap: 3rem;
}

.with-toc > article.doc { min-width: 0; }

.with-toc > .toc {
  font-size: 0.88rem;
  line-height: 1.6;
}

.with-toc > .toc > nav {
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding-right: 0.5rem;
}

.toc .toc-title {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 0.6rem;
}

.toc ul { list-style: none; padding-left: 0; margin: 0; }
.toc ul ul { padding-left: 1rem; }
.toc a { color: var(--muted); display: block; padding: 0.14rem 0; }
.toc a:hover { color: var(--accent); text-decoration: none; }

@media (max-width: 60rem) {
  .with-toc { display: block; }
  .with-toc > .toc > nav { position: static; max-height: none; }
  .with-toc > .toc { margin-bottom: 2rem; }
}

/* ---- 标准库参考页 ---- */

/* 一条一个条目：限定拼写当标题、签名、文档。161 条挨在一起，所以间距按「一屏能
   扫多少」定，而不是按正文段落定。 */
.api-group {
  font-family: var(--mono);
  margin-top: 2.25rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border-soft);
}

.api-item {
  margin: 1.35rem 0;
  padding-left: 0.9rem;
  border-left: 2px solid var(--border-soft);
}

.api-item:target { border-left-color: var(--accent); }

.api-name {
  font-family: var(--mono);
  font-size: 0.95rem;
  margin: 0 0 0.4rem;
}

.api-name a { color: var(--text); }
.api-name a:hover { color: var(--accent); text-decoration: none; }

.api-item pre.api-sig {
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 7px;
  line-height: 1.5;
}

.api-doc > :first-child { margin-top: 0; }
.api-doc > :last-child { margin-bottom: 0; }
.api-doc p { margin: 0.45rem 0; }
.api-doc { color: var(--muted); }
.api-doc code { color: var(--text); }

.api-impls {
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---- 页脚 ---- */

footer.site-footer {
  border-top: 1px solid var(--border-soft);
  margin-top: 3rem;
}

footer.site-footer .inner {
  max-width: var(--max-wide);
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}

footer.site-footer a { color: var(--muted); text-decoration: underline; }
footer.site-footer a:hover { color: var(--accent); }

/* ---- 无障碍与响应式 ---- */

a:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (max-width: 56rem) {
  .hero { grid-template-columns: 1fr; gap: 2.5rem; }
  main.home { padding-top: 3rem; }
}

@media (max-width: 40rem) {
  .features > ul { grid-template-columns: 1fr; gap: 0; }
  .cta-row .btn { flex: 1; justify-content: center; }
}

/* 入场：一次克制的淡入上浮 */
@media (prefers-reduced-motion: no-preference) {
  .hero-copy, .code-window {
    animation: rise 0.5s ease both;
  }
  .code-window { animation-delay: 0.08s; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

/* ---- 浏览器 demo（/tea.html）：两个 wasm reactor 的挂载框 ----
   .counter/.todo/.row 这些类名不是这里起的，是 guest 的 view 画出来的，
   所以选择器要跟着 examples/projects/ 下那两个应用走。 */

.tea-frame {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin: 1rem 0 0.75rem;
  background: var(--code-bg-soft);
}

.tea-note { color: var(--muted); font-size: 0.9rem; }
.tea-error { margin: 0.75rem 0 0; min-height: 1.4rem; font-size: 0.9rem; color: #b42318; }

/* demo 下面折叠起来的源码：内容是 gen/pages 从 examples/projects 下读出来的，
   代码块本身走 pre.dawn，这里只管折叠这一层的间距和指针。 */
.tea-src { margin: 0.25rem 0 2rem; }
.tea-src summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
}
.tea-src summary:hover { color: var(--accent); }
.tea-src pre.dawn { margin-top: 0.75rem; }

.tea-demo .tea-frame h1 { font-size: 1rem; font-weight: 600; margin: 0 0 0.75rem; }
.tea-demo .tea-frame button {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: inherit;
  cursor: pointer;
}
.tea-demo .tea-frame button:hover { border-color: var(--accent); color: var(--accent); }

/* 计数器 */
.counter.below-zero .count { color: #b42318; }
.count { font-size: 2.2rem; margin: 0 0 0.5rem; font-variant-numeric: tabular-nums; }
.bar { display: flex; gap: 3px; min-height: 12px; margin-bottom: 1rem; flex-wrap: wrap; }
.tick { width: 10px; height: 12px; background: var(--accent); opacity: 0.55; border-radius: 2px; }
.counter .row { display: flex; gap: 0.5rem; }

/* 待办列表 */
.compose { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.field {
  flex: 1;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-family: var(--mono);
  font-size: 0.9rem;
  background: #fff;
  color: inherit;
}
.field:focus { outline: none; border-color: var(--accent); }
.filters { display: flex; gap: 0.4rem; margin-bottom: 0.75rem; }
.filter.on { font-weight: 600; border-color: var(--accent); color: var(--accent); }
.list { list-style: none; margin: 0 0 0.75rem; padding: 0; }
.todo .row { display: flex; gap: 0.5rem; align-items: center; padding: 0.15rem 0; }
.todo .row.done .title { opacity: 0.5; text-decoration: line-through; }
.todo .row .title { flex: 1; cursor: pointer; }
.todo .row.editing .draft {
  flex: 1;
  font: inherit;
  font-family: var(--mono);
  font-size: 0.9rem;
  background: transparent;
  color: inherit;
  border: none;
  border-bottom: 1px solid var(--accent);
}
.todo .row.editing .draft:focus { outline: none; }
.status { margin: 0; font-size: 0.9rem; color: var(--muted); }

/* ---- 搜索面板 ---- */
/* 页头按钮 + 一个懒挂载的 wasm reactor（examples/projects/tea_dom_search）。
   面板内部的一切由 guest 画，这里只负责壳与状态类；没有一条 content: 规则，
   面板里的每个字都跟着页面语言从 guest 出来（gen/assets.dawn 的三条规矩）。 */

.site-header .search-open {
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 0.12rem 0.6rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
}

.site-header .search-open:hover { border-color: var(--muted); color: var(--text); }

.site-header .search-open kbd {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--faint);
}

/* 面板本体。`hidden` 是页面脚本的开关，空树是 guest 的：两个都成立时面板不占位。 */
.search-host {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(31, 35, 40, 0.35);
  padding: 8vh 1rem 1rem;
  overflow-y: auto;
}

.search-host[hidden] { display: none; }

.search-panel {
  max-width: 42rem;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(31, 35, 40, 0.18);
  padding: 0.75rem;
}

/* Escape 之后 guest 交回的空树。没有子节点，所以只要不给它内边距就不留痕。 */
.search-panel.is-closed { display: none; }

.search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 1rem;
  color: inherit;
  background: #fff;
}

.search-input:focus { outline: none; border-color: var(--accent); }

.search-results {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  max-height: 60vh;
  overflow-y: auto;
}

.search-group + .search-group { margin-top: 0.6rem; }

.search-group-name {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.search-group-rows { list-style: none; margin: 0; padding: 0; }

.search-row a {
  display: block;
  padding: 0.3rem 0.45rem;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
}

.search-row.is-selected a { background: var(--code-bg); }

.search-title { font-family: var(--mono); font-size: 0.9rem; }

.search-detail {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--faint);
  margin-left: 0.5rem;
}

.search-note {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
}

.search-status, .search-scope {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.search-none { list-style: none; }

/* Enter 留下的那一条指令。页面脚本读到它就跳走，所以读者永远看不见它。 */
.search-goto { display: none; }
