/* ============================================================
   TinyOS Genesis v0.1 — site styles
   Pure static. No build tool, no CDN, no external assets.
   Visuals: CSS gradients + the inline SVG logo in index.html.
   ============================================================ */

:root {
  --bg:        #0a0e16;
  --bg-2:      #0e1422;
  --panel:     #121a2b;
  --panel-2:   #162034;
  --line:      #223049;
  --text:      #e7eefb;
  --muted:     #9fb0cc;
  --accent:    #4dd0e1;   /* cyan */
  --accent-2:  #7c8cff;   /* indigo */
  --good:      #7ee787;   /* green */
  --warn:      #ffd166;
  --old-bar:   #3a4a63;
  --radius:    14px;
  --maxw:      1080px;
  --font: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
          "Source Han Sans SC", "Noto Sans CJK SC", system-ui,
          -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", "Fira Code", "Sarasa Mono SC",
          Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  line-height: 1.65;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(124,140,255,0.18), transparent 60%),
    radial-gradient(1000px 500px at -10% 10%, rgba(77,208,225,0.14), transparent 55%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- Accessibility: skip link + focus ---------- */
.skip-link {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #04121a;
  padding: 10px 16px; border-radius: 0 0 10px 0; z-index: 100; font-weight: 700;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
  background: rgba(10,14,22,0.72);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; }
.brand:hover { text-decoration: none; }
.brand-logo { color: var(--accent); flex: none; }
.brand-name { letter-spacing: .3px; }

.site-nav { display: flex; gap: 4px 14px; margin-left: auto; flex-wrap: wrap; }
.site-nav a { color: var(--muted); font-size: 14px; padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.site-nav a:hover { color: var(--text); text-decoration: none; background: rgba(255,255,255,.04); }
.site-nav a[aria-current="page"] {
  color: var(--text); background: rgba(77,208,225,.12);
  border: 1px solid rgba(77,208,225,.35);
}

.lang-toggle {
  margin-left: 6px;
  background: transparent; color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-weight: 700; cursor: pointer; font-family: var(--font);
}
.lang-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Hero ---------- */
.hero { padding: 64px 0 48px; }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 36px; align-items: center; }
.kicker {
  display: inline-block; color: var(--accent); font-weight: 700;
  letter-spacing: .4px; font-size: 14px; margin: 0 0 12px;
  padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: rgba(77,208,225,0.08);
}
.hero h1 {
  font-size: clamp(34px, 6vw, 60px); line-height: 1.05; margin: 0 0 16px;
  letter-spacing: -.5px;
  background: linear-gradient(90deg, #fff 0%, var(--accent) 55%, var(--accent-2) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.badge {
  display: inline-block; font-size: 14px; vertical-align: middle;
  margin-left: 8px; padding: 3px 10px; border-radius: 999px;
  background: var(--good); color: #06210d; font-weight: 800;
  -webkit-text-fill-color: #06210d;
}
.lede { color: var(--muted); font-size: 17px; max-width: 56ch; margin: 0 0 24px; }

.cta-row { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 26px; }
.btn {
  display: inline-block; padding: 12px 22px; border-radius: 10px;
  font-weight: 700; border: 1px solid transparent; cursor: pointer;
}
.btn-primary {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  color: #04121a;
}
.btn-primary:hover { text-decoration: none; filter: brightness(1.08); }
.btn-ghost { border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

.hero-facts { display: flex; gap: 22px; flex-wrap: wrap; list-style: none; padding: 0; margin: 0; }
.hero-facts li { display: flex; flex-direction: column; }
.hero-facts strong { font-size: 22px; color: var(--text); }
.hero-facts span { font-size: 13px; color: var(--muted); }

.hero-art { display: flex; justify-content: center; }
.art-frame {
  width: 100%; max-width: 360px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(160deg, #0c1424, #0a0f1c);
  box-shadow: 0 20px 50px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.02);
  padding: 18px;
}
.art-term {
  font-family: var(--mono); font-size: 13px; color: var(--accent);
  margin: 0; white-space: pre; line-height: 1.7;
}
.art-cursor { color: var(--good); animation: blink 1.1s steps(1) infinite; }

/* ---------- Generic sections ---------- */
.section { padding: 56px 0; border-top: 1px solid var(--line); }
.section h2 {
  font-size: clamp(24px, 4vw, 34px); margin: 0 0 6px; letter-spacing: -.3px;
}
.section-lead { color: var(--muted); max-width: 70ch; margin: 0 0 28px; }

/* ---------- Size chart ---------- */
.chart { display: grid; gap: 18px; }
.chart-row {
  display: grid; grid-template-columns: minmax(160px, 240px) 1fr auto;
  gap: 16px; align-items: center;
}
.chart-label { font-weight: 600; font-size: 14px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar {
  position: relative; min-height: 30px; border-radius: 8px;
  display: flex; align-items: center; padding: 0 12px;
  font-family: var(--mono); font-size: 13px; color: #04121a; font-weight: 700;
  overflow: hidden;
}
.bar-old { background: linear-gradient(90deg, #2c3a52, #3a4a63); color: #cdd9ec; }
.bar-new { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.bar-val { position: relative; z-index: 1; white-space: nowrap; }
.bar-tag {
  display: inline-block; margin-left: 8px; font-size: 11px; font-weight: 600;
  opacity: .8; padding: 1px 6px; border-radius: 6px; background: rgba(0,0,0,.2);
}
.chart-delta {
  font-weight: 800; font-size: 14px; color: var(--good);
  white-space: nowrap; text-align: right; min-width: 120px;
}
.chart-note { color: var(--muted); font-size: 13px; margin-top: 8px; }

/* ---------- Terminal demo ---------- */
.section-term { background: linear-gradient(180deg, rgba(124,140,255,0.04), transparent); }
.term {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: #060a12; box-shadow: 0 18px 40px rgba(0,0,0,.4);
}
.term-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: #0b1220; border-bottom: 1px solid var(--line);
}
.term-bar .dot { width: 11px; height: 11px; border-radius: 50%; background: #2a3650; }
.term-bar .dot:nth-child(1) { background: #ff5f57; }
.term-bar .dot:nth-child(2) { background: #febc2e; }
.term-bar .dot:nth-child(3) { background: #28c840; }
.term-title { margin-left: 8px; color: var(--muted); font-size: 13px; font-family: var(--mono); }
.term-body {
  margin: 0; padding: 18px; font-family: var(--mono); font-size: 14px;
  line-height: 1.6; color: #c8f7ff; white-space: pre-wrap; word-break: break-word;
  min-height: 320px;
}
.term-body:focus { outline: 3px solid var(--accent); outline-offset: -3px; }

.callout {
  margin-top: 22px; padding: 16px 18px; border-left: 4px solid var(--accent);
  background: rgba(77,208,225,0.07); border-radius: 0 10px 10px 0;
}
.callout h3 { margin: 0 0 6px; font-size: 16px; }
.callout p { margin: 0; color: var(--muted); }

/* ---------- Cards (matrix + stack) ---------- */
.matrix, .stack { list-style: none; padding: 0; margin: 0; display: grid; gap: 16px; }
.matrix { grid-template-columns: repeat(3, 1fr); }
.stack  { grid-template-columns: repeat(2, 1fr); }
.card {
  background: linear-gradient(160deg, rgba(255,255,255,0.03), rgba(255,255,255,0));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
}
.card h3 { margin: 0 0 8px; font-size: 18px; color: #fff; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }
.card code {
  font-family: var(--mono); font-size: 12.5px; color: var(--accent);
  background: rgba(77,208,225,0.1); padding: 2px 6px; border-radius: 6px;
  display: inline-block; margin-bottom: 8px; word-break: break-word;
}
.card-wide { grid-column: 1 / -1; }

/* ---------- Architecture flow ---------- */
.arch {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; align-items: stretch; gap: 10px; justify-content: center;
}
.arch-node {
  flex: 1 1 150px; min-width: 140px;
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  background: linear-gradient(160deg, #121a2b, #0d1422);
  display: flex; flex-direction: column; gap: 4px;
}
.arch-node-userspace { border-color: var(--accent-2); box-shadow: 0 0 0 1px rgba(124,140,255,.3) inset; }
.arch-tag { font-weight: 800; font-size: 15px; color: #fff; }
.arch-detail { font-size: 13px; color: var(--muted); font-family: var(--mono); }
.arch-arrow { align-self: center; color: var(--accent); font-size: 22px; font-weight: 800; }

/* ---------- Code block ---------- */
.code-block {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: auto;
  background: #060a12;
}
.code-block pre { margin: 0; padding: 18px; font-family: var(--mono); font-size: 14px; color: #c8f7ff; white-space: pre; }

/* ---------- Roadmap ---------- */
.roadmap { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.roadmap-col { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; background: rgba(255,255,255,0.02); }
.done-head { color: var(--good); margin: 0 0 12px; font-size: 17px; }
.plan-head { color: var(--warn); margin: 0 0 12px; font-size: 17px; }
.done-list, .plan-list { margin: 0; padding-left: 20px; color: var(--muted); }
.done-list li, .plan-list li { margin: 6px 0; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0; margin-top: 20px; }
.footer-inner { display: flex; flex-direction: column; gap: 4px; }
.footer-meta { color: var(--muted); font-size: 13px; margin: 0; }

/* ---------- Animations ---------- */
@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { order: -1; }
  .matrix { grid-template-columns: repeat(2, 1fr); }
  .stack  { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .header-inner { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; }
  .site-nav { width: 100%; margin-left: 0; }
  .matrix { grid-template-columns: 1fr; }
  .roadmap { grid-template-columns: 1fr; }
  .chart-row { grid-template-columns: 1fr; }
  .chart-delta { text-align: left; }
  .hero { padding: 40px 0 32px; }
  .section { padding: 40px 0; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .art-cursor { animation: none; }
  * { transition: none !important; }
}

/* ---------- In-page section TOC (index hub) ---------- */
.section-toc {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 14px 0 4px; margin: 0;
}
.section-toc a {
  font-size: 13px; color: var(--muted);
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px;
}
.section-toc a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

/* ---------- Card link (product intro hub) ---------- */
.card-link { display: inline-block; margin-top: 6px; color: var(--accent); font-weight: 700; }
.card-link:hover { text-decoration: none; color: var(--accent-2); }

/* ---------- Sub-page head + placeholder ---------- */
.page-head { padding: 52px 0 6px; }
.page-head h1 {
  font-size: clamp(28px, 5vw, 44px); margin: 0 0 10px; letter-spacing: -.4px;
  background: linear-gradient(90deg, #fff 0%, var(--accent) 60%, var(--accent-2) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-fill-color: transparent;
}
.page-head .lede { color: var(--muted); max-width: 64ch; margin: 0; }

.placeholder {
  margin: 10px 0 0; padding: 48px 24px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--radius);
  background: rgba(255,255,255,.02);
}
.placeholder-icon { color: var(--accent); margin-bottom: 12px; }
.placeholder h2 { font-size: 22px; margin: 0 0 8px; color: #fff; }
.placeholder p { color: var(--muted); max-width: 56ch; margin: 0 auto; }

.footer-links { margin: 8px 0 0; font-size: 13px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); }

/* ============================================================
   Package catalogue (pkgcat) — packages.html only
   ============================================================ */

.pkgcat { margin-top: 8px; }

.pkg-grid {
  list-style: none; padding: 0; margin: 0 0 20px;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.pkg-card {
  display: flex; flex-direction: column; gap: 10px;
  width: 100%; text-align: left; cursor: pointer;
  padding: 16px 18px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text);
  font: inherit;
  transition: border-color .16s ease, transform .16s ease, background .16s ease;
}
.pkg-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.pkg-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.pkg-card.is-open { border-color: var(--accent); background: var(--panel-2); }

.pkg-card-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pkg-name {
  font-family: var(--mono); font-size: 17px; font-weight: 700; color: #fff;
}
.pkg-state {
  font-size: 12px; font-weight: 700; white-space: nowrap;
  padding: 2px 9px; border-radius: 999px;
  border: 1px solid currentColor;
}
.pkg-ready   .pkg-state { color: var(--good); }
.pkg-index   .pkg-state { color: var(--accent); }
.pkg-planned .pkg-state { color: var(--warn); }

.pkg-desc { color: var(--muted); font-size: 14px; line-height: 1.6; }
.pkg-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: auto; padding-top: 4px;
  font-size: 13px; color: var(--accent); font-weight: 600;
}
.pkg-dots { color: var(--muted); }

/* ---- detail panel ---- */
.pkg-detail {
  margin: 4px 0 8px; padding: 22px 24px;
  background: var(--panel); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}
.pkg-detail[hidden] { display: none; }

.pkg-detail-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; margin-bottom: 16px;
}
.pkg-detail-head > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pkg-detail-name {
  font-family: var(--mono); font-size: 20px; font-weight: 700; color: #fff;
}
.pkg-close {
  flex: none; width: 32px; height: 32px; line-height: 1;
  font-size: 22px; cursor: pointer; color: var(--muted);
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  transition: color .16s ease, border-color .16s ease;
}
.pkg-close:hover { color: #fff; border-color: var(--accent); }
.pkg-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.pkg-facts { width: 100%; border-collapse: collapse; margin: 0 0 18px; font-size: 14px; }
.pkg-facts th, .pkg-facts td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.pkg-facts th { color: var(--muted); font-weight: 600; width: 34%; }
.pkg-facts td { color: var(--text); }
.pkg-facts code { font-family: var(--mono); font-size: 13px; color: #c8f7ff; }
.pkg-sha { word-break: break-all; }
.pkg-flag {
  font-size: 11px; font-weight: 700; color: var(--warn);
  border: 1px solid currentColor; border-radius: 999px; padding: 1px 7px;
}

/* ---- tabs ---- */
.pkg-tabs { display: flex; gap: 8px; margin: 0 0 14px; flex-wrap: wrap; }
.pkg-tab {
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  padding: 7px 15px; color: var(--muted);
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  transition: color .16s ease, border-color .16s ease, background .16s ease;
}
.pkg-tab:hover { color: var(--text); border-color: var(--accent); }
.pkg-tab.is-on {
  color: var(--bg); background: var(--accent); border-color: var(--accent);
}
.pkg-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.pkg-tabpanel { display: none; }
.pkg-tabpanel.is-on { display: block; }
.pkg-tabpanel p { color: var(--muted); line-height: 1.75; margin: 0 0 12px; }

.pkg-files-note { font-size: 13px; color: var(--accent); font-weight: 600; }
.pkg-files { width: 100%; border-collapse: collapse; font-size: 13px; }
.pkg-files th, .pkg-files td {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--line); vertical-align: top;
}
.pkg-files thead th { color: #fff; background: rgba(255,255,255,.03); }
.pkg-files tbody th { font-weight: 500; }
.pkg-files tbody th code { font-family: var(--mono); color: var(--accent); font-size: 12px; }
.pkg-files .num { text-align: right; font-family: var(--mono); color: var(--text); white-space: nowrap; }
.pkg-files td:last-child { color: var(--muted); }

@media (max-width: 640px) {
  .pkg-facts th { width: auto; }
  .pkg-facts tr { display: block; padding: 6px 0; border-bottom: 1px solid var(--line); }
  .pkg-facts th, .pkg-facts td { display: block; border: 0; padding: 2px 0; }
  .pkg-files, .pkg-files tbody, .pkg-files tr, .pkg-files td, .pkg-files th { display: block; }
  .pkg-files thead { display: none; }
  .pkg-files tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  .pkg-files .num { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .pkg-card { transition: none; }
  .pkg-card:hover { transform: none; }
}
