/* ============================================================
   OpenClaw PRD — Shared Stylesheet
   Top-nav layout (no sidebar)
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --accent:      #e74c3c;
  --accent-dark: #c0392b;
  --heading:     #2c3e50;
  --text:        #333;
  --text-light:  #666;
  --bg:          #fff;
  --bg-alt:      #f8f9fa;
  --border:      #e1e4e8;
  --max-w:       920px;
  --radius:      8px;
  --shadow:      0 2px 8px rgba(0,0,0,.08);
  --topnav-h:    56px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.75;
}

/* ============================================================
   TOP NAVIGATION BAR
   ============================================================ */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topnav-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.topnav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: calc(var(--max-w) + 120px);
  margin: 0 auto;
  padding: 0 24px;
  gap: 16px;
}

/* Logo / brand */
.topnav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}
.topnav-logo .logo-icon { font-size: 1.5rem; }
.topnav-logo .logo-text {
  font-size: .9rem;
  font-weight: 700;
  color: var(--heading);
  white-space: nowrap;
}

/* Nav links — desktop */
.topnav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.topnav-links a {
  display: block;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-light);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.topnav-links a:hover {
  background: var(--bg-alt);
  color: var(--heading);
}
.topnav-links a.active {
  background: rgba(231,76,60,.1);
  color: var(--accent);
  font-weight: 600;
}

/* Hamburger — hidden on desktop */
.topnav-burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  padding: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
}
.topnav-burger span {
  display: block;
  height: 2px;
  background: var(--heading);
  border-radius: 2px;
  transition: all .2s;
}

/* Mobile dropdown */
.topnav-dropdown {
  display: none;
  position: fixed;
  top: var(--topnav-h);
  left: 0;
  right: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  z-index: 99;
  padding: 8px 0 12px;
  max-height: calc(100vh - var(--topnav-h));
  overflow-y: auto;
}
.topnav-dropdown.open { display: block; }
.topnav-dropdown a {
  display: block;
  padding: 9px 24px;
  font-size: .88rem;
  color: var(--text);
  text-decoration: none;
  transition: background .15s;
}
.topnav-dropdown a:hover { background: var(--bg-alt); }
.topnav-dropdown a.active { color: var(--accent); font-weight: 600; }
.topnav-dropdown .sep {
  height: 1px;
  background: var(--border);
  margin: 6px 24px;
}

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
  font-size: .78rem;
  color: var(--text-light);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb a {
  color: var(--text-light);
  text-decoration: none;
  transition: color .15s;
}
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--border); }
.breadcrumb .current { color: var(--heading); font-weight: 500; }

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main {
  padding: calc(var(--topnav-h) + 40px) 48px 80px;
}
.content {
  max-width: var(--max-w);
  margin: 0 auto;
}

/* ============================================================
   PAGE HEADER  (chapter number + title)
   ============================================================ */
.page-header {
  padding: 36px 0 32px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 40px;
}
.page-header .chapter-num {
  display: inline-block;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--accent);
  margin-bottom: 10px;
}
.page-header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--heading);
  letter-spacing: -.02em;
  line-height: 1.25;
}
.page-header .page-sub {
  margin-top: 10px;
  font-size: .9rem;
  color: var(--text-light);
}

/* ============================================================
   PAGE NAVIGATION  (prev / next)
   ============================================================ */
.page-nav {
  display: flex;
  gap: 12px;
  margin-top: 60px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.page-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color .2s, box-shadow .2s, background .2s;
  min-width: 0;
}
.page-nav a:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(231,76,60,.1);
  background: rgba(231,76,60,.02);
}
.page-nav .nav-label {
  font-size: .72rem;
  color: var(--text-light);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.page-nav .nav-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.page-nav .prev { text-align: left; }
.page-nav .next { text-align: right; }
.page-nav .prev .nav-label::before { content: "← "; }
.page-nav .next .nav-label::after  { content: " →"; }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  text-align: center;
  padding: 48px 0 40px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 48px;
}
.hero .emoji  { font-size: 4rem; margin-bottom: 12px; }
.hero h1      { font-size: 2rem; color: var(--heading); font-weight: 800; letter-spacing: -.02em; }
.hero .sub    { color: var(--text-light); margin-top: 8px; font-size: .92rem; }
.hero .badges { margin-top: 16px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ---------- Badges ---------- */
.badge         { display: inline-block; padding: 4px 14px; border-radius: 20px; font-size: .78rem; font-weight: 600; }
.badge.red     { background: #fde8e8; color: var(--accent); }
.badge.blue    { background: #e8f0fe; color: #1a73e8; }
.badge.green   { background: #e6f4ea; color: #137333; }

/* ============================================================
   HEADINGS
   ============================================================ */
h2 { font-size: 1.55rem; color: var(--heading); font-weight: 800; margin: 56px 0 20px; padding-bottom: 10px; border-bottom: 3px solid var(--accent); scroll-margin-top: calc(var(--topnav-h) + 12px); }
h3 { font-size: 1.2rem;  color: var(--heading); font-weight: 700; margin: 36px 0 14px; scroll-margin-top: calc(var(--topnav-h) + 12px); }
h4 { font-size: 1.05rem; color: var(--heading); font-weight: 700; margin: 28px 0 10px; scroll-margin-top: calc(var(--topnav-h) + 12px); }
h5 { font-size: .95rem;  color: var(--text);    font-weight: 700; margin: 20px 0 8px; }
p  { margin: 8px 0 14px; }
strong { color: var(--heading); }

/* ============================================================
   TABLES
   ============================================================ */
table     { width: 100%; border-collapse: collapse; margin: 14px 0 22px; font-size: .88rem; }
thead th  { background: var(--accent); color: #fff; font-weight: 600; text-align: left; padding: 10px 14px; white-space: nowrap; }
tbody td  { padding: 9px 14px; border-bottom: 1px solid var(--border); }
tbody tr:nth-child(even) { background: var(--bg-alt); }
tbody tr:hover           { background: #fef7f6; }

/* ============================================================
   CARDS
   ============================================================ */
.cards    { display: grid; gap: 16px; margin: 16px 0 24px; }
.cards.c2 { grid-template-columns: repeat(2, 1fr); }
.cards.c3 { grid-template-columns: repeat(3, 1fr); }
.cards.c4 { grid-template-columns: repeat(4, 1fr); }
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.card:hover           { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.card .icon           { font-size: 1.6rem; margin-bottom: 8px; }
.card h5              { margin: 0 0 6px; font-size: .95rem; color: var(--heading); }
.card p               { margin: 0; font-size: .84rem; color: var(--text-light); line-height: 1.6; }
.card.accent-left     { border-left: 4px solid var(--accent); }
.card.accent-blue     { border-left: 4px solid #3498db; }
.card.accent-green    { border-left: 4px solid #27ae60; }
.card.accent-purple   { border-left: 4px solid #8e44ad; }

/* ============================================================
   USER STORIES & ACCEPTANCE
   ============================================================ */
.story {
  border-left: 3px solid var(--accent);
  padding: 6px 16px;
  margin: 8px 0;
  font-style: italic;
  color: var(--text-light);
  font-size: .88rem;
  background: var(--bg-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.accept    { margin: 12px 0 20px; padding: 0; }
.accept li { list-style: none; padding: 5px 0 5px 28px; position: relative; font-size: .86rem; color: var(--text); }
.accept li::before { content: "☐"; position: absolute; left: 0; top: 5px; font-size: 1rem; color: var(--accent); }

/* ============================================================
   CODE
   ============================================================ */
.code {
  background: #f6f8fa;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 18px;
  margin: 12px 0 18px;
  font-family: "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: .82rem;
  line-height: 1.7;
  overflow-x: auto;
  white-space: pre;
  color: var(--text);
}

/* ============================================================
   LISTS
   ============================================================ */
ul, ol    { margin: 8px 0 16px 20px; }
li        { margin: 4px 0; font-size: .9rem; }
.do-list, .dont-list { list-style: none; margin-left: 0; padding: 0; }
.do-list li::before   { content: "✅ "; font-style: normal; }
.dont-list li::before { content: "❌ "; font-style: normal; }

/* ============================================================
   PRIORITY BADGES
   ============================================================ */
.pri { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .72rem; font-weight: 700; vertical-align: middle; }
.p0  { background: #fde8e8; color: #c0392b; }
.p1  { background: #fef3e2; color: #e67e22; }
.p2  { background: #eee;    color: #999; }

/* ============================================================
   ARCHITECTURE DIAGRAM
   ============================================================ */
.arch-diagram  { margin: 24px 0; background: var(--bg-alt); border-radius: var(--radius); padding: 32px 24px; border: 1px solid var(--border); }
.arch-row      { display: flex; justify-content: center; gap: 16px; margin: 12px 0; flex-wrap: wrap; }
.arch-box      { background: var(--bg); border: 2px solid var(--border); border-radius: var(--radius); padding: 12px 20px; text-align: center; font-size: .82rem; font-weight: 600; color: var(--heading); min-width: 100px; box-shadow: var(--shadow); }
.arch-box.highlight { border-color: var(--accent); background: #fef7f6; }
.arch-box.gateway   { border-color: var(--accent); background: linear-gradient(135deg,#fef7f6,#fff); min-width: 320px; padding: 20px; }
.arch-box.agent     { border-color: #3498db;       background: linear-gradient(135deg,#ebf5fb,#fff); min-width: 320px; padding: 20px; }
.arch-arrow    { text-align: center; font-size: 1.4rem; color: var(--accent); margin: 4px 0; }
.arch-label    { text-align: center; font-size: .75rem; color: var(--text-light); }

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline { position: relative; padding-left: 28px; margin: 20px 0 30px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--accent); }
.timeline .event  { position: relative; padding: 8px 0 20px 20px; }
.timeline .event::before { content: ""; position: absolute; left: -24px; top: 12px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--accent); }
.timeline .date   { font-weight: 700; color: var(--accent); font-size: .85rem; }
.timeline .desc   { font-size: .88rem; color: var(--text); }

/* ============================================================
   USER JOURNEY
   ============================================================ */
.journey { display: flex; gap: 0; margin: 20px 0 30px; overflow-x: auto; }
.journey .stage { flex: 1; min-width: 160px; padding: 16px; text-align: center; position: relative; background: var(--bg-alt); border: 1px solid var(--border); }
.journey .stage:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.journey .stage:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }
.journey .stage .num    { display: inline-block; width: 28px; height: 28px; line-height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .78rem; font-weight: 700; margin-bottom: 6px; }
.journey .stage h5      { font-size: .82rem; margin: 4px 0 2px; }
.journey .stage .time   { font-size: .72rem; color: var(--text-light); }
.journey .stage .emotion{ font-size: .75rem; margin-top: 4px; }

/* ============================================================
   CALLOUT
   ============================================================ */
.callout {
  background: linear-gradient(135deg, #fef7f6, #fff);
  border: 1px solid var(--accent);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 20px;
  margin: 16px 0 24px;
}
.callout.blue          { background: linear-gradient(135deg,#ebf5fb,#fff); border-color: #3498db; }
.callout    h5         { color: var(--accent);  margin: 0 0 6px; }
.callout.blue h5       { color: #2980b9; }

/* ============================================================
   MODULE GRID
   ============================================================ */
.mod-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin: 20px 0 30px; }
.mod-card { border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; transition: all .2s; }
.mod-card:hover         { border-color: var(--accent); box-shadow: var(--shadow); }
.mod-card .mod-num      { font-size: .72rem; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.mod-card h5            { margin: 6px 0 8px; font-size: .9rem; }
.mod-card .features     { font-size: .76rem; color: var(--text-light); line-height: 1.6; }

/* ============================================================
   SECTION NOTE & FEATURE TAG
   ============================================================ */
.section-note { background: var(--bg-alt); border-radius: var(--radius); padding: 12px 18px; margin: 16px 0; font-size: .86rem; color: var(--text-light); border-left: 3px solid var(--accent); }
.ftag         { display: inline-block; background: var(--accent); color: #fff; padding: 1px 10px; border-radius: 12px; font-size: .75rem; font-weight: 600; margin-right: 6px; vertical-align: middle; }

/* ============================================================
   BACK TO TOP
   ============================================================ */
.back-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .3s;
  z-index: 100;
}
.back-top.show { opacity: 1; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  margin-top: 60px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .8rem;
  color: var(--text-light);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .topnav-links  { display: none; }
  .topnav-burger { display: flex; }
  .main          { padding: calc(var(--topnav-h) + 20px) 20px 60px; }
  .cards.c3, .cards.c4   { grid-template-columns: repeat(2,1fr); }
  .mod-grid              { grid-template-columns: repeat(2,1fr); }
  .journey               { flex-direction: column; }
  .journey .stage        { border-radius: var(--radius) !important; margin: 4px 0; }
  .page-nav              { flex-direction: column; }
}

@media (max-width: 600px) {
  .cards.c2, .cards.c3, .cards.c4 { grid-template-columns: 1fr; }
  .mod-grid   { grid-template-columns: 1fr; }
  .hero h1    { font-size: 1.5rem; }
  .page-header h1 { font-size: 1.5rem; }
  .topnav-logo .logo-text { display: none; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .topnav, .back-top, .page-nav, .breadcrumb { display: none !important; }
  .main { padding: 20px; }
  h2    { break-before: page; }
  table { font-size: .75rem; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
