/* ==========================================================================
   Docs page — reference layout
   ========================================================================== */

.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60; }
.read-progress i { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left; background: linear-gradient(90deg, var(--heat-2), var(--heat), var(--cool)); }

/* ---------- status chips ---------- */
.st { display: inline-block; font-style: normal; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; line-height: 1; padding: 5px 9px; border-radius: 100px; border: 1px solid var(--line-2); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.st.principle { color: var(--cool); border-color: rgba(91, 227, 207, .4); }
.st.proposed { color: var(--heat-2); border-color: rgba(255, 179, 92, .45); }
.st.open { color: var(--warn); border-color: rgba(255, 93, 108, .45); }
.st.illus { color: var(--text-2); }

/* ---------- masthead ---------- */
.d-hero { position: relative; padding: 156px 0 64px; overflow: hidden; border-bottom: 1px solid var(--line); }
.d-hero-glow { position: absolute; right: -200px; top: -320px; width: 1000px; height: 760px; background: radial-gradient(closest-side, rgba(255, 122, 61, .12), rgba(91, 227, 207, .05) 60%, transparent); pointer-events: none; }
.d-hero .container { position: relative; }
.d-hero h1 { font-size: clamp(44px, 6.4vw, 92px); line-height: 1; max-width: 16ch; }
.d-hero h1 em { background: linear-gradient(100deg, var(--heat-2) 0%, var(--heat) 40%, var(--cool) 100%); -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: .06em; }
.d-dek { margin: 28px 0 0; max-width: 62ch; font-size: clamp(18px, 1.5vw, 21px); color: var(--text-2); }
.d-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 26px; margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.d-legend-k { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.d-legend .st { margin-right: 8px; }

/* ---------- layout ---------- */
.d-layout { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 80px; padding-top: 64px; padding-bottom: 120px; }
.d-side-inner { position: sticky; top: 100px; max-height: calc(100vh - 130px); overflow-y: auto; padding-right: 8px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.d-side-inner > summary { list-style: none; cursor: default; pointer-events: none; font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 16px; }
.d-side-inner > summary::-webkit-details-marker { display: none; }
.d-toc, .d-toc ul { list-style: none; margin: 0; padding: 0; }
.d-toc { border-left: 1px solid var(--line-2); }
.d-toc > li > a { display: grid; grid-template-columns: 30px 1fr; gap: 2px; padding: 8px 0 8px 16px; margin-left: -1px; border-left: 1px solid transparent; font-size: 14px; line-height: 1.35; color: var(--muted); transition: color .2s, border-color .2s; }
.d-toc > li > a span { font-family: var(--font-mono); font-size: 11px; padding-top: 2px; color: var(--dim); transition: color .2s; }
.d-toc a:hover { color: var(--text-2); }
.d-toc > li.active > a { color: var(--text); border-left-color: var(--heat); }
.d-toc > li.active > a span { color: var(--heat-2); }
.d-toc ul { display: none; padding: 2px 0 10px 48px; }
.d-toc li.active ul { display: grid; gap: 7px; }
.d-toc ul a { font-size: 13px; line-height: 1.35; color: var(--muted); }
.d-toc ul a.on { color: var(--cool-2); }

/* ---------- content ---------- */
.d-content { max-width: 800px; min-width: 0; }
.d-sec { padding-bottom: 80px; scroll-margin-top: 96px; }
.d-sec + .d-sec { padding-top: 72px; border-top: 1px solid var(--line); }
.d-h { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 18px; margin-bottom: 28px; }
.d-n { font-family: var(--font-mono); font-size: 12px; letter-spacing: .14em; color: var(--heat); }
.d-h h2 { margin: 0; flex: 1 1 auto; font-family: var(--font-display); font-weight: 400; font-size: clamp(36px, 4vw, 56px); line-height: 1.02; letter-spacing: -0.01em; }
.d-h h2 em { color: var(--ivory); }
.d-content h3 { margin: 56px 0 16px; font-size: 22px; font-weight: 500; letter-spacing: -0.01em; line-height: 1.25; scroll-margin-top: 96px; }
.d-content h3 .st { margin-left: 8px; }
.d-content h4 { margin: 0 0 8px; font-size: 18px; font-weight: 500; }
.d-content p, .d-content li { font-size: 17px; line-height: 1.68; color: var(--text-2); }
.d-content p { margin: 0 0 1.1em; }
.d-content p b, .d-content li b, .d-content strong { color: var(--text); font-weight: 500; }
.d-content a { color: var(--cool-2); border-bottom: 1px solid rgba(154, 242, 228, .3); transition: border-color .2s, color .2s; }
.d-content a:hover { color: var(--text); border-color: var(--text-2); }
.d-content ul, .d-content ol { margin: 0 0 1.3em; padding-left: 22px; }
.d-content li { margin-bottom: .45em; }
.d-content li::marker { color: var(--dim); }
.d-lead { font-family: var(--font-display); font-size: clamp(24px, 2.4vw, 31px) !important; line-height: 1.22 !important; color: var(--ivory) !important; margin-bottom: 1em !important; }
.d-small { font-size: 14px !important; color: var(--muted) !important; }
.d-content code { font-family: var(--font-mono); font-size: .9em; color: var(--ivory); }
.d-content .mono { font-family: var(--font-mono); font-size: 14px; color: var(--text); }

/* tables */
.d-table-wrap { margin: 28px 0 32px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg-1); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.d-table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 15px; }
.d-table th, .d-table td { padding: 15px 20px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); font-weight: 400; line-height: 1.5; }
.d-table tr:last-child th, .d-table tr:last-child td { border-bottom: 0; }
.d-table thead th { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--heat-2); background: rgba(255, 255, 255, .015); }
.d-table tbody th { color: var(--text); white-space: nowrap; }
.d-table tbody th a { border: 0; color: var(--text); }
.d-table td { color: var(--text-2); }
.d-compare td.no { color: var(--muted); }
.d-compare td.yes { color: var(--text); }
.d-compare td.yes::before, .d-compare td.no::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 9px; vertical-align: 1px; }
.d-compare td.yes::before { background: var(--cool); box-shadow: 0 0 10px var(--cool); }
.d-compare td.no::before { box-shadow: inset 0 0 0 1px var(--warn); }
.d-compare tr.us th, .d-compare tr.us td { background: rgba(91, 227, 207, .06); }
.d-compare tr.us th { font-family: var(--font-display); font-size: 20px; }
.d-num td:nth-child(2) { font-family: var(--font-mono); color: var(--text); text-align: right; width: 90px; }
.d-num thead th:nth-child(2) { text-align: right; }
.d-num tr.total th, .d-num tr.total td { background: rgba(255, 255, 255, .02); color: var(--ivory); }

/* callouts */
.d-note, .d-formula { margin: 28px 0 32px; padding: 22px 26px; border-left: 2px solid var(--line-3); border-radius: 0 14px 14px 0; background: var(--bg-1); }
.d-note p:last-child, .d-formula p:last-child { margin-bottom: 0; }
.d-note-k { display: block; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.d-note.key { border-left-color: var(--cool); background: rgba(91, 227, 207, .05); } .d-note.key .d-note-k { color: var(--cool); }
.d-note.illus { border-left-color: var(--heat); background: rgba(255, 122, 61, .05); } .d-note.illus .d-note-k { color: var(--heat-2); }
.d-note.warn { border-left-color: var(--warn); background: rgba(255, 93, 108, .05); } .d-note.warn .d-note-k { color: var(--warn); }
.d-formula { border-left-color: var(--ivory); }
.d-formula code { font-size: 17px; }

/* small grids */
.d-paths { list-style: none; padding: 0 !important; display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.d-paths li { display: grid; grid-template-columns: 220px 1fr; gap: 20px; margin: 0; padding: 16px 20px; background: var(--bg); font-size: 15px !important; }
.d-grid4, .d-grid3 { display: grid; gap: 1px; margin: 28px 0 32px; background: var(--line); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.d-grid4 { grid-template-columns: repeat(4, 1fr); } .d-grid3 { grid-template-columns: repeat(3, 1fr); }
.d-grid4 > div, .d-grid3 > div { background: var(--bg); padding: 22px 20px; }
.d-grid4 span, .d-grid3 span { display: block; font-family: var(--font-display); font-size: 24px; line-height: 1.1; color: var(--text); margin-bottom: 10px; }
.d-grid4 p, .d-grid3 p { margin: 0; font-size: 14px; line-height: 1.55; }
.d-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 28px 0 32px; }
.d-box { padding: 22px 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg-1); }
.d-box > span { display: block; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 14px; }
.d-box.used > span { color: var(--cool); } .d-box.never > span { color: var(--heat-2); }
.d-box ul { margin: 0; padding-left: 18px; } .d-box li { font-size: 15px; }

/* numbered rules */
.d-rules { list-style: none; padding: 0 !important; counter-reset: r; margin: 24px 0 32px !important; border-top: 1px solid var(--line); }
.d-rules li { counter-increment: r; display: grid; grid-template-columns: 44px 1fr; column-gap: 12px; margin: 0; padding: 18px 0; border-bottom: 1px solid var(--line); }
.d-rules li::before { content: counter(r); grid-row: 1 / span 2; font-family: var(--font-display); font-size: 34px; line-height: .9; color: transparent; -webkit-text-stroke: 1px var(--heat); }
.d-rules li b { font-size: 17px; }
.d-rules li span { grid-column: 2; font-size: 16px; line-height: 1.6; color: var(--text-2); }

/* figures */
.d-fig { margin: 36px 0 40px; padding: 30px 26px 20px; border: 1px solid var(--line); border-radius: 18px; background: radial-gradient(120% 120% at 0% 0%, rgba(255, 255, 255, .025), transparent 60%), var(--bg-1); }
.d-fig svg { width: 100%; height: auto; overflow: visible; }
.d-fig .svg-text { font-size: 11.5px; }
.d-fig figcaption { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.5; color: var(--muted); }
.d-fig figcaption span { font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--heat-2); margin-right: 10px; }

/* steps, open questions */
.d-steps, .d-open { list-style: none; padding: 0 !important; margin: 28px 0 32px !important; display: grid; gap: 12px; }
.d-steps li, .d-open li { margin: 0; padding: 24px 26px; border: 1px solid var(--line); border-radius: 16px; background: var(--bg-1); }
.d-steps li p, .d-open li p { margin: 0; font-size: 16px; }
.d-step-k { display: block; font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--heat); margin-bottom: 10px; }
.d-steps h4 { font-family: var(--font-display); font-weight: 400; font-size: 26px; line-height: 1.15; margin-bottom: 10px; }
.d-open { counter-reset: o; }
.d-open li { counter-increment: o; border-color: rgba(255, 93, 108, .22); position: relative; padding-left: 64px; }
.d-open li::before { content: counter(o); position: absolute; left: 24px; top: 22px; font-family: var(--font-mono); font-size: 13px; color: var(--warn); }

/* faq */
.d-faq { border-top: 1px solid var(--line); }
.d-faq details { border-bottom: 1px solid var(--line); }
.d-faq summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 20px 0; font-size: 18px; color: var(--text); transition: color .2s; }
.d-faq summary::-webkit-details-marker { display: none; }
.d-faq summary::after { content: "+"; flex: none; font-family: var(--font-mono); font-size: 20px; color: var(--heat-2); transition: transform .3s var(--ease); }
.d-faq details[open] summary::after { transform: rotate(45deg); }
.d-faq summary:hover { color: var(--ivory); }
.d-faq details p { margin: 0 0 22px; max-width: 68ch; }

/* glossary */
.d-gloss { margin: 0; border-top: 1px solid var(--line); }
.d-gloss > div { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.d-gloss dt { font-size: 16px; font-weight: 500; color: var(--text); }
.d-gloss dd { margin: 0; font-size: 16px; line-height: 1.6; color: var(--text-2); }

/* end */
.d-end { margin-top: 40px; padding-top: 72px; border-top: 1px solid var(--line); }
.d-end .display { font-size: clamp(34px, 4.4vw, 60px); margin: 0 0 36px; max-width: 16ch; }
.d-end-links { display: flex; gap: 14px; flex-wrap: wrap; }
.d-end-links a { border-bottom: 0; }
.d-end-links .btn-primary { color: #0a0a0a; }
.d-end-links .btn-ghost { color: var(--text); border: 1px solid var(--line-3); }

/* ---------- responsive ---------- */
@media (max-width: 1040px) {
  .d-layout { grid-template-columns: 1fr; gap: 0; padding-top: 28px; }
  .d-side { margin-bottom: 40px; }
  .d-side-inner { position: static; max-height: none; overflow: visible; padding: 0; border: 1px solid var(--line-2); border-radius: 14px; background: var(--bg-1); }
  .d-side-inner > summary { pointer-events: auto; cursor: pointer; margin: 0; padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; color: var(--text); }
  .d-side-inner > summary::after { content: "+"; font-size: 18px; color: var(--heat-2); }
  .d-side-inner[open] > summary::after { content: "–"; }
  .d-toc { border-left: 0; padding: 0 12px 14px; }
  .d-toc ul { display: none !important; }
  .d-content { max-width: none; }
}
@media (max-width: 640px) {
  .d-hero { padding: 120px 0 44px; }
  .d-legend { gap: 10px 0; flex-direction: column; align-items: flex-start; }
  .d-sec { padding-bottom: 56px; }
  .d-sec + .d-sec { padding-top: 52px; }
  .d-content p, .d-content li { font-size: 16px; }
  .d-content h3 { margin-top: 44px; font-size: 20px; }
  .d-paths li, .d-gloss > div { grid-template-columns: 1fr; gap: 4px; }
  .d-grid4 { grid-template-columns: 1fr 1fr; } .d-grid3, .d-two { grid-template-columns: 1fr; }
  .d-fig { padding: 20px 14px 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .d-fig svg { min-width: 600px; }
  .d-fig figcaption { position: sticky; left: 0; max-width: calc(100vw - 64px); }
  .d-steps li, .d-note, .d-formula { padding: 20px; }
  .d-open li { padding: 20px 20px 20px 52px; } .d-open li::before { left: 20px; top: 20px; }
  .d-rules li { grid-template-columns: 34px 1fr; }
  .d-table th, .d-table td { padding: 13px 16px; }
  .d-table tbody th { white-space: normal; }
  .d-faq summary { font-size: 17px; }
}
@media print {
  .nav, .d-side, .read-progress, footer .foot-word { display: none; }
  .d-layout { grid-template-columns: 1fr; }
}
