/* ============================================================
   PRODAO DOCS SHELL — docs-layout.css
   Shared by docs.html and brand-story.html (GitBook-style layout).
   Load AFTER styles/base.css. Controller: js/docs-page.js.
   ============================================================ */

body {
  margin: 0;
  background: radial-gradient(60% 70% at 100% 0%, var(--accent-glow), var(--accent-dim) 30%, transparent 68%), var(--bg-primary);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-sans); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overflow-x: hidden; min-height: 100vh;
}

/* ============================================================
   TOP NAV — logo / search / ask
   ============================================================ */
.dnav {
  position: sticky; top: 0; z-index: 100; height: 84px;
  background: rgba(19,19,19,0.86);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
}
.dnav-inner {
  max-width: var(--container-max); margin: 0 auto; height: 100%;
  display: grid; grid-template-columns: 280px 1fr; align-items: center;
}
.dnav-brand { display: flex; align-items: center; padding-left: 28px; }
.dnav-brand img { height: 26px; width: auto; }
.dnav-tools { display: flex; align-items: center; gap: 12px; padding: 0 28px 0 8px; max-width: 760px; }
.dnav-search {
  flex: 1; display: flex; align-items: center; gap: 10px;
  background: var(--bg-secondary); border: 1px solid var(--border-subtle);
  border-radius: 999px; padding: 9px 16px; transition: border-color .2s, box-shadow .2s;
}
.dnav-search:focus-within { border-color: var(--border-accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.dnav-search svg { width: 17px; height: 17px; color: var(--text-muted); flex: none; }
.dnav-search input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; color: var(--text-primary); font-family: var(--font-sans); font-size: 14px; }
.dnav-search input::placeholder { color: var(--text-muted); }
.kbd { display: inline-flex; align-items: center; gap: 2px; font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); }
.kbd kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 5px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); font: inherit; }

/* ============================================================
   LAYOUT — sidebar + content
   ============================================================ */
.dwrap { max-width: var(--container-max); margin: 0 auto; display: grid; grid-template-columns: 280px 1fr; align-items: start; }
.dside {
  position: sticky; top: 84px; align-self: start;
  height: calc(100vh - 84px); overflow-y: auto;
  padding: 28px 20px 48px 28px; scrollbar-width: thin;
}
.dside::-webkit-scrollbar { width: 6px; }
.dside::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 99px; }
.dside-group { font-size: 22px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); padding: 0 12px; margin: 24px 0 8px; cursor: pointer; user-select: none; transition: color .16s; display: flex; align-items: center; gap: 7px; }
.dside-group:first-child { margin-top: 0; }
.dside-group:hover { color: var(--text-primary); }
.dside-group:hover svg { color: var(--text-primary); }
.dside-caret { margin-left: auto; width: 16px !important; height: 16px !important; color: var(--text-muted); transition: transform .28s var(--ease-out), color .16s; }
.dside-group:hover .dside-caret { color: var(--text-primary); }
.dside-group.is-collapsed .dside-caret { transform: rotate(-90deg); }
.dside-children { margin: 2px 0 4px; padding-left: 13px; border-left: 1px solid var(--border-subtle); overflow: hidden; transition: max-height .32s var(--ease-out), opacity .22s ease; }
.dside-children.is-collapsed { opacity: 0; }
.dside-link {
  display: block; position: relative; font-size: 14px; color: var(--text-secondary);
  padding: 8px 12px; border-radius: 8px; cursor: pointer; line-height: 1.35;
  transition: color .16s, background .16s;
}
.dside-link:hover { color: var(--text-primary); background: var(--bg-secondary); }
.dside-link.is-active { color: var(--accent); font-weight: 700; }
.dside-link.is-active::before { content: ""; position: absolute; left: -28px; top: 4px; bottom: 4px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
/* child links sit under a folder heading: indented + a vertical tree guide */
.dside-link--child { font-size: 13.5px; }
.dside-link--child.is-active::before { left: -14px; }
.dside-group svg { width: 26px; height: 26px; color: var(--text-secondary); flex: none; }

/* content */
.dmain { min-width: 0; padding: 0; }
.dmain-bg { background: none; }
.dmain-inner { width: 100%; margin: 0 auto; padding: 48px 24px 96px; }
.dmain-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.dmain-head h1 { font-size: 32px; font-weight: 800; letter-spacing: -0.01em; text-transform: uppercase; }
.dmain-meta { display: flex; align-items: center; gap: 22px; flex: none; padding-top: 4px; }
.helpful { display: flex; align-items: center; gap: 10px; }
.helpful-label { font-size: 12.5px; color: var(--text-secondary); }
.helpful-faces { display: flex; gap: 6px; }
.face { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; background: var(--bg-secondary); border: 1px solid var(--border-subtle); color: var(--text-secondary); transition: border-color .16s, color .16s, background .16s; padding: 0; }
.face:hover { color: var(--text-primary); border-color: var(--border-warm); }
.face svg { width: 18px; height: 18px; }
.face.is-on { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* article body */
.darticle { margin-top: 36px; }
.darticle .lead { font-size: 17px; color: var(--text-primary); line-height: 1.55; }
.darticle p { color: var(--text-secondary); margin: 16px 0; line-height: 1.7; }
.darticle p.lead { color: var(--text-primary); }
.darticle h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); margin: 36px 0 4px; letter-spacing: -0.01em; }
.darticle h3 { font-size: 16.5px; font-weight: 700; color: var(--text-primary); margin: 28px 0 2px; letter-spacing: -0.005em; }
.darticle h4 { font-size: 14px; font-weight: 700; color: var(--text-secondary); margin: 22px 0 0; letter-spacing: .005em; }
.darticle em { color: var(--text-secondary); font-style: italic; }
.doc-formula {
  font-family: var(--font-mono); font-size: 16px; color: var(--text-primary);
  background: var(--bg-secondary); border: 1px solid var(--border-accent);
  border-left: 3px solid var(--accent); border-radius: 12px;
  padding: 18px 22px; margin: 22px 0; text-align: center; letter-spacing: .01em;
}
.doc-formula strong { color: var(--accent); font-weight: 700; }
.darticle ul, .darticle ol { color: var(--text-secondary); line-height: 1.7; padding-left: 22px; margin: 14px 0; }
.darticle li { margin: 7px 0; }
.darticle strong { color: var(--text-primary); font-weight: 700; }
.darticle a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--border-accent); }
.darticle a:hover { border-bottom-color: var(--accent); }
.darticle code { font-family: var(--font-mono); font-size: 0.88em; background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-radius: 6px; padding: 2px 6px; color: var(--text-primary); }
.darticle pre.doc-diagram { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; color: var(--text-secondary); background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 20px 22px; margin: 20px 0; overflow-x: auto; white-space: pre; tab-size: 2; }
.darticle pre.doc-code { font-family: var(--font-mono); font-size: 13px; line-height: 1.6; color: var(--text-primary); background: var(--bg-secondary); border: 1px solid var(--border-subtle); border-left: 3px solid var(--accent); border-radius: 12px; padding: 16px 20px; margin: 16px 0; overflow-x: auto; white-space: pre; tab-size: 2; }
.darticle img.doc-figure { display: block; width: 100%; max-width: 620px; height: auto; margin: 20px auto; border-radius: 14px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 18px 0; font-size: 14px; }
.doc-table th, .doc-table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }
.doc-table thead th { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-muted); }
.doc-table tbody th { color: var(--text-secondary); font-weight: 600; width: 220px; }
.doc-table td { color: var(--text-primary); }
.doc-table code { background: transparent; border: 0; padding: 0; }
.doc-gloss { margin: 8px 0; }
.doc-gloss dt { color: var(--text-primary); font-weight: 700; margin-top: 18px; }
.doc-gloss dd { color: var(--text-secondary); margin: 4px 0 0; line-height: 1.65; }

/* prev / next cards */
.docs-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 56px; padding-top: 22px; border-top: 1px solid var(--border-subtle); }
.docs-foot-copy { color: var(--text-muted); font-size: 13px; }
.dnext { display: flex; gap: 16px; margin-top: 56px; }
.dnext-card {
  flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px; border: 1px solid var(--border-subtle); border-radius: 14px;
  background: var(--bg-secondary); cursor: pointer;
  transition: border-color .18s, background .18s, transform .15s;
}
.dnext-card:hover { border-color: var(--border-accent); background: var(--bg-elevated); }
.dnext-card:active { transform: scale(0.99); }
.dnext-card.prev { text-align: right; flex-direction: row; justify-content: space-between; }
.dnext-card.is-empty { visibility: hidden; }
.dnext-k { font-size: 12px; color: var(--text-muted); }
.dnext-t { font-size: 15.5px; font-weight: 700; color: var(--text-primary); margin-top: 3px; }
.dnext-card svg { width: 20px; height: 20px; color: var(--text-secondary); flex: none; }

/* ---- entrance reveal (shared idiom) ---- */
.js-anim .reveal { opacity: 0; transform: translateY(14px); transition: opacity .45s var(--ease-out), transform .45s var(--ease-out); }
.js-anim .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .js-anim .reveal { opacity: 1; transform: none; } }


/* ---- mobile ---- */
.dside-toggle { display: none; }
@media (max-width: 900px) {
  .dnav-inner { grid-template-columns: auto 1fr; }
  .dnav-brand { padding-left: 16px; }
  .dnav-tools { padding-right: 16px; }
  .kbd { display: none; }
  .dwrap { grid-template-columns: 1fr; }
  .dside {
    position: fixed; top: 64px; left: 0; width: 280px; z-index: 90;
    background: var(--bg-primary); border-right: 1px solid var(--border-subtle);
    transform: translateX(-100%); transition: transform .3s var(--ease-out);
  }
  .dside.is-open { transform: translateX(0); }
  .dside-link.is-active::before { left: 0; }
  .dside-link--child.is-active::before { left: 0; }
  .dside { top: 84px; }
  .dside-toggle { top: 84px; }
  .dmain-inner { padding: 32px 24px 80px; }
  .dmain-head { flex-direction: column; }
  .dside-toggle {
    display: inline-flex; align-items: center; gap: 8px; position: sticky; top: 64px; z-index: 80;
    width: 100%; padding: 12px 16px; background: var(--bg-secondary); border: 0; border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary); font-family: var(--font-sans); font-size: 13px; font-weight: 600; cursor: pointer;
  }
  .dside-toggle svg { width: 16px; height: 16px; }
}
