/* Echo RSS Feed Post Generator — documentation styles
   Self-contained: no webfonts, no CDN. Works from file:// and from a web server. */

/* ---------- tokens ---------- */

:root {
  --bg:            #fbfaf8;
  --bg-elev:       #ffffff;
  --bg-subtle:     #f3f1ed;
  --bg-code:       #f6f4f1;

  --text:          #1b1a17;
  --text-muted:    #5f5a52;
  --text-faint:    #8b857b;

  --border:        #e4e0d9;
  --border-strong: #cdc7bd;

  --accent:        #b04716;
  --accent-hover:  #8a3610;
  --accent-tint:   #fbefe8;
  --accent-line:   #e0a381;

  --ok:            #2f6f43;
  --ok-tint:       #eef5f0;
  --warn:          #8a5a00;
  --warn-tint:     #fbf3e2;
  --stop:          #a13228;
  --stop-tint:     #fbeeec;

  --measure: 46rem;
  --sidebar: 16.5rem;
  --toc: 14rem;
  --top: 3.5rem;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #191816;
    --bg-elev:       #1f1e1b;
    --bg-subtle:     #242220;
    --bg-code:       #201f1c;

    --text:          #e9e6e0;
    --text-muted:    #a29c93;
    --text-faint:    #7b756b;

    --border:        #302e2a;
    --border-strong: #443f39;

    --accent:        #e8834f;
    --accent-hover:  #f19b6d;
    --accent-tint:   #2b1d14;
    --accent-line:   #6d422a;

    --ok:            #74b98c;
    --ok-tint:       #17241b;
    --warn:          #d9a441;
    --warn-tint:     #2a2213;
    --stop:          #e08a80;
    --stop-tint:     #2b1917;
  }
}

:root[data-theme="dark"] {
  --bg:            #191816;
  --bg-elev:       #1f1e1b;
  --bg-subtle:     #242220;
  --bg-code:       #201f1c;

  --text:          #e9e6e0;
  --text-muted:    #a29c93;
  --text-faint:    #7b756b;

  --border:        #302e2a;
  --border-strong: #443f39;

  --accent:        #e8834f;
  --accent-hover:  #f19b6d;
  --accent-tint:   #2b1d14;
  --accent-line:   #6d422a;

  --ok:            #74b98c;
  --ok-tint:       #17241b;
  --warn:          #d9a441;
  --warn-tint:     #2a2213;
  --stop:          #e08a80;
  --stop-tint:     #2b1917;
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--top) + 1rem); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--bg-elev); color: var(--text);
  padding: .6rem 1rem; border: 1px solid var(--border-strong); border-radius: 4px;
  z-index: 100;
}
.skip:focus { left: 1rem; top: .6rem; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--top);
  display: flex; align-items: center; gap: .85rem;
  padding: 0 1.1rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: baseline; gap: .5rem; min-width: 0; }
.brand a { color: var(--text); font-weight: 620; letter-spacing: -.012em; white-space: nowrap; }
.brand a:hover { text-decoration: none; color: var(--accent); }
.brand .sub { color: var(--text-faint); font-size: .78rem; white-space: nowrap; }
@media (max-width: 34rem) { .brand .sub { display: none; } }

.badge {
  display: inline-block;
  font: 500 .69rem/1.5 var(--mono);
  padding: .07rem .38rem;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  color: var(--text-muted);
  white-space: nowrap;
}

.topbar .spacer { flex: 1; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--bg-elev); color: var(--text-muted);
  cursor: pointer; padding: 0;
}
.iconbtn:hover { color: var(--text); border-color: var(--border-strong); }
.iconbtn svg { width: 1rem; height: 1rem; }

#navtoggle { display: none; }
@media (max-width: 60rem) { #navtoggle { display: inline-flex; } }

/* ---------- search ---------- */

.search { position: relative; width: 15rem; max-width: 38vw; }
.search input {
  width: 100%;
  font: inherit; font-size: .82rem;
  padding: .34rem .55rem .34rem 1.85rem;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 4px;
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus { border-color: var(--accent-line); outline: none; }
.search .mag {
  position: absolute; left: .5rem; top: 50%; transform: translateY(-50%);
  width: .85rem; height: .85rem; color: var(--text-faint); pointer-events: none;
}
.search kbd {
  position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
  font: 500 .68rem/1 var(--mono);
  color: var(--text-faint);
  border: 1px solid var(--border); border-radius: 3px;
  padding: .16rem .3rem; background: var(--bg-subtle);
}
.search input:focus ~ kbd, .search input:not(:placeholder-shown) ~ kbd { display: none; }

.results {
  position: absolute; top: calc(100% + .4rem); left: 0; right: 0;
  max-height: 60vh; overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong); border-radius: 5px;
  box-shadow: 0 8px 28px rgba(0,0,0,.13);
  padding: .25rem;
  width: 24rem; max-width: 80vw;
}
.results:empty { display: none; }
.results a {
  display: block; padding: .4rem .55rem; border-radius: 3px;
  color: var(--text); font-size: .84rem; line-height: 1.35;
}
.results a:hover, .results a.on { background: var(--accent-tint); text-decoration: none; }
.results a .where { display: block; color: var(--text-faint); font-size: .74rem; }
.results .none { padding: .55rem; color: var(--text-faint); font-size: .84rem; }

/* Narrow screens: collapse to a magnifier, expand on focus. */
@media (max-width: 46rem) {
  .search { width: 2.1rem; transition: width .18s ease; }
  .search kbd { display: none; }
  .search input { padding-left: 1.9rem; padding-right: .3rem; }
  .search:focus-within { width: min(14rem, 54vw); }
  .results { left: auto; right: 0; width: min(20rem, 88vw); }
}
@media (prefers-reduced-motion: reduce) { .search { transition: none; } }

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr) var(--toc);
  gap: 0;
  max-width: 82rem;
  margin: 0 auto;
}
@media (max-width: 76rem) { .shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); } .toc { display: none; } }
@media (max-width: 60rem) { .shell { grid-template-columns: minmax(0, 1fr); } }

/* ---------- sidebar ---------- */

.sidebar {
  position: sticky; top: var(--top);
  height: calc(100vh - var(--top));
  overflow-y: auto;
  padding: 1.6rem 1rem 3rem 1.1rem;
  border-right: 1px solid var(--border);
}
.sidebar h2 {
  margin: 1.5rem 0 .4rem;
  font-size: .7rem; font-weight: 620; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-faint);
}
.sidebar h2:first-child { margin-top: 0; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li { margin: 0; }
.sidebar a {
  display: block;
  padding: .3rem .6rem;
  margin-left: -.6rem;
  border-radius: 4px;
  color: var(--text-muted);
  font-size: .865rem;
  border-left: 2px solid transparent;
}
.sidebar a:hover { color: var(--text); background: var(--bg-subtle); text-decoration: none; }
.sidebar a[aria-current="page"] {
  color: var(--accent); font-weight: 560;
  background: var(--accent-tint);
  border-left-color: var(--accent);
  border-radius: 0 4px 4px 0;
}

@media (max-width: 60rem) {
  .sidebar {
    position: fixed; top: var(--top); left: 0; bottom: 0;
    width: min(19rem, 84vw);
    background: var(--bg-elev);
    z-index: 35;
    transform: translateX(-102%);
    transition: transform .18s ease;
    box-shadow: 0 0 30px rgba(0,0,0,.16);
  }
  body.nav-open .sidebar { transform: none; }
  .scrim {
    position: fixed; inset: var(--top) 0 0 0; z-index: 34;
    background: rgba(0,0,0,.34); border: 0; padding: 0;
    opacity: 0; pointer-events: none; transition: opacity .18s ease;
  }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) { .sidebar, .scrim { transition: none; } }
@media (min-width: 60.01rem) { .scrim { display: none; } }

/* ---------- main ---------- */

main { padding: 2.4rem 2.5rem 5rem; min-width: 0; }
@media (max-width: 46rem) { main { padding: 1.75rem 1.15rem 4rem; } }

.prose { max-width: var(--measure); }

.eyebrow {
  font-size: .7rem; font-weight: 620; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 .5rem;
}

.prose h1 {
  font-size: 2.1rem; line-height: 1.16; letter-spacing: -.023em; font-weight: 660;
  margin: 0 0 .55rem;
}
.lede { font-size: 1.04rem; color: var(--text-muted); margin: 0 0 2rem; line-height: 1.6; }

.prose h2 {
  font-size: 1.32rem; letter-spacing: -.014em; font-weight: 620; line-height: 1.3;
  margin: 2.9rem 0 .85rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--border);
}
.prose h3 {
  font-size: 1.03rem; font-weight: 620; letter-spacing: -.008em;
  margin: 2rem 0 .6rem;
}
.prose h4 {
  font-size: .875rem; font-weight: 620; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
  margin: 1.6rem 0 .5rem;
}

.anchor {
  float: left; margin-left: -1.15rem; width: 1.15rem;
  color: var(--text-faint); opacity: 0; font-weight: 400;
  text-decoration: none;
}
h2:hover .anchor, h3:hover .anchor, .anchor:focus { opacity: 1; }
@media (max-width: 60rem) { .anchor { display: none; } }

.prose p { margin: 0 0 1.05rem; }
.prose ul, .prose ol { margin: 0 0 1.05rem; padding-left: 1.35rem; }
.prose li { margin: .32rem 0; }
.prose li > ul, .prose li > ol { margin: .32rem 0; }

.prose strong { font-weight: 620; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.5rem 0; }

/* ---------- code ---------- */

code {
  font-family: var(--mono);
  font-size: .855em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .09em .34em;
  word-break: break-word;
}

pre {
  margin: 0 0 1.25rem;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .85rem 1rem;
  overflow-x: auto;
  position: relative;
}
pre code {
  background: none; border: 0; padding: 0;
  font-size: .82rem; line-height: 1.6;
  white-space: pre;
  word-break: normal;
}

.copy {
  position: absolute; top: .4rem; right: .4rem;
  font: 500 .7rem/1 var(--sans);
  color: var(--text-muted);
  background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 3px;
  padding: .28rem .45rem;
  cursor: pointer; opacity: 0; transition: opacity .12s ease;
}
pre:hover .copy, .copy:focus { opacity: 1; }
.copy:hover { color: var(--text); border-color: var(--border-strong); }
@media (prefers-reduced-motion: reduce) { .copy { transition: none; } }

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.35rem;
  border: 1px solid var(--border);
  border-radius: 5px;
}
table { border-collapse: collapse; width: 100%; font-size: .865rem; }
th, td {
  text-align: left; vertical-align: top;
  padding: .55rem .8rem;
  border-bottom: 1px solid var(--border);
}
thead th {
  background: var(--bg-subtle);
  font-weight: 620; font-size: .78rem;
  letter-spacing: .02em;
  color: var(--text-muted);
  white-space: nowrap;
}
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody th { font-weight: 560; }
td code, th code { white-space: nowrap; }

/* ---------- callouts ---------- */

.note {
  margin: 0 0 1.35rem;
  padding: .8rem 1rem;
  border-left: 3px solid var(--border-strong);
  background: var(--bg-subtle);
  border-radius: 0 4px 4px 0;
  font-size: .89rem;
}
.note > :last-child { margin-bottom: 0; }
.note .label {
  display: block;
  font-size: .68rem; font-weight: 660; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .28rem;
}
.note.tip   { border-left-color: var(--ok);   background: var(--ok-tint); }
.note.tip .label { color: var(--ok); }
.note.warn  { border-left-color: var(--warn); background: var(--warn-tint); }
.note.warn .label { color: var(--warn); }
.note.stop  { border-left-color: var(--stop); background: var(--stop-tint); }
.note.stop .label { color: var(--stop); }

/* ---------- steps ---------- */

.steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 1.35rem; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding-left: 2.4rem;
  margin: 0 0 1.5rem;
}
.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: -.05rem;
  width: 1.65rem; height: 1.65rem;
  display: grid; place-items: center;
  font: 620 .78rem/1 var(--sans);
  color: var(--accent);
  background: var(--accent-tint);
  border: 1px solid var(--accent-line);
  border-radius: 50%;
}
.steps > li > :last-child { margin-bottom: 0; }
.steps h3 { margin-top: 0; }

/* ---------- cards ---------- */

.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: .75rem; margin: 0 0 1.5rem; padding: 0; list-style: none;
}
.cards li { margin: 0; }
.cards a {
  display: block; height: 100%;
  padding: .85rem 1rem;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg-elev);
  color: var(--text);
}
.cards a:hover { border-color: var(--accent-line); text-decoration: none; }
.cards .t { display: block; font-weight: 620; font-size: .93rem; margin-bottom: .18rem; }
.cards .d { display: block; color: var(--text-muted); font-size: .83rem; line-height: 1.5; }

/* ---------- misc ---------- */

.cta {
  display: inline-block;
  padding: .5rem .95rem;
  background: var(--accent); color: #fff;
  border-radius: 4px; font-weight: 560; font-size: .9rem;
}
.cta:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
:root[data-theme="dark"] .cta, :root:not([data-theme="light"]) .cta { color: #1b1207; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .cta { color: #fff; } }

.meta {
  font-size: .8rem; color: var(--text-faint);
  border-top: 1px solid var(--border);
  padding-top: 1rem; margin-top: 3rem;
}

/* ---------- pager ---------- */

.pager {
  display: flex; gap: .75rem; flex-wrap: wrap;
  max-width: var(--measure);
  margin-top: 3.5rem; padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.pager a {
  flex: 1 1 12rem;
  padding: .7rem .9rem;
  border: 1px solid var(--border); border-radius: 5px;
  color: var(--text);
}
.pager a:hover { border-color: var(--accent-line); text-decoration: none; }
.pager .dir { display: block; font-size: .72rem; color: var(--text-faint); letter-spacing: .05em; text-transform: uppercase; margin-bottom: .12rem; }
.pager .t { font-weight: 560; font-size: .9rem; color: var(--accent); }
.pager .next { text-align: right; }

/* ---------- right-hand contents ---------- */

.toc {
  position: sticky; top: var(--top);
  height: calc(100vh - var(--top));
  overflow-y: auto;
  padding: 2.6rem 1.2rem 3rem .5rem;
  font-size: .82rem;
}
.toc .title {
  font-size: .69rem; font-weight: 620; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-faint); margin: 0 0 .5rem;
}
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc li { margin: 0; }
.toc a {
  display: block; padding: .22rem 0 .22rem .7rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-muted); line-height: 1.4;
}
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.on { color: var(--accent); border-left-color: var(--accent); }
.toc .lvl3 a { padding-left: 1.5rem; font-size: .79rem; }

/* ---------- print ---------- */

@media print {
  .topbar, .sidebar, .toc, .pager, .scrim, .copy, .anchor { display: none !important; }
  .shell { display: block; max-width: none; }
  main { padding: 0; }
  .prose { max-width: none; }
  body { font-size: 11pt; background: #fff; color: #000; }
  a { color: #000; text-decoration: underline; }
  .prose h2 { page-break-after: avoid; }
  pre, .table-wrap, .note { page-break-inside: avoid; }
}
