/* ============================================================
   ABAP Cheat Sheets — shared styles
   Light + dark modes, system fonts, SAP-ish gold accent.
   ============================================================ */

:root {
  --bg: #f7f7f5;
  --bg-elev: #ffffff;
  --bg-soft: #efefe9;
  --border: #e3e3dc;
  --border-strong: #cdcdc3;
  --text: #1d1d1b;
  --text-soft: #5a5a52;
  --text-muted: #8a8a7e;
  --accent: #d99500;
  --accent-strong: #b87b00;
  --accent-soft: #fff4d6;
  --code-bg: #f3f1eb;
  --code-text: #2a2a26;
  --link: #1858a0;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04), 0 1px 1px rgba(0,0,0,.03);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, "SF Mono", "Menlo", "Consolas", "JetBrains Mono", monospace;
}

html[data-theme="dark"] {
  --bg: #161614;
  --bg-elev: #1f1f1c;
  --bg-soft: #26262200;
  --border: #2e2e2a;
  --border-strong: #3d3d38;
  --text: #ececea;
  --text-soft: #b0b0a8;
  --text-muted: #7d7d75;
  --accent: #fcb913;
  --accent-strong: #ffcd4d;
  --accent-soft: #2c2616;
  --code-bg: #14140f;
  --code-text: #e8e6dd;
  --link: #6ab2ff;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  max-width: 1500px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: #1d1d1b;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -.5px;
}

.brand-sub {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
  margin-left: 4px;
}

.topbar nav {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}

.topbar nav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-soft);
  font-size: 13.5px;
  font-weight: 500;
}
.topbar nav a:hover {
  background: var(--bg-soft);
  text-decoration: none;
  color: var(--text);
}
.topbar nav a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.topbar-spacer { flex: 1; }

.search {
  position: relative;
  flex: 0 1 360px;
}
.search input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color .15s;
}
.search input:focus { border-color: var(--accent); }
.search::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
}
.search::after {
  content: "";
  position: absolute;
  left: 21px;
  top: 22px;
  width: 6px;
  height: 2px;
  background: var(--text-muted);
  transform: rotate(45deg);
  border-radius: 1px;
}

.theme-toggle {
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-soft);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 14px;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }

/* ---------- Page layouts ---------- */

.page {
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px 24px 80px;
}

.hero {
  margin: 16px 0 32px;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.5px;
}
.hero p {
  margin: 0;
  color: var(--text-soft);
  font-size: 15px;
  max-width: 720px;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
}
.hero-stats span strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Category section + cards ---------- */

.category {
  margin-bottom: 36px;
}
.category-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.category-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .2px;
  text-transform: uppercase;
}
.category-head .count {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform .12s ease, border-color .12s, box-shadow .12s;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity .15s;
}
.card:hover {
  text-decoration: none;
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.card:hover::before { opacity: 1; }

.card-num {
  font: 600 11px/1 var(--mono);
  color: var(--accent-strong);
  letter-spacing: .5px;
}
.card-title {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -.1px;
  color: var(--text);
}
.card-summary {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
  flex: 1;
}
.card-meta {
  margin-top: auto;
  font: 500 11.5px/1 var(--mono);
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  padding-top: 6px;
}

.empty {
  display: none;
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty.show { display: block; }

/* ---------- Sidebar (all.html, viewer.html) ---------- */

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  max-width: 1500px;
  margin: 0 auto;
  min-height: calc(100vh - 53px);
}

.sidebar {
  position: sticky;
  top: 53px;
  align-self: start;
  height: calc(100vh - 53px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 18px 0 60px;
  background: var(--bg);
}

.sidebar h3 {
  margin: 18px 18px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sidebar h3:first-child { margin-top: 4px; }

.sidebar ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar li a {
  display: block;
  padding: 5px 18px 5px 22px;
  color: var(--text-soft);
  font-size: 13.5px;
  border-left: 2px solid transparent;
  text-decoration: none;
  transition: color .1s, background .1s, border-color .1s;
}
.sidebar li a:hover {
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
}
.sidebar li a.active {
  color: var(--accent-strong);
  border-left-color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

/* ---------- Main content area ---------- */

.content {
  padding: 28px 40px 80px;
  min-width: 0;
  max-width: 980px;
}

.topic-section {
  border-bottom: 1px solid var(--border);
  padding-bottom: 32px;
  margin-bottom: 40px;
}
.topic-section:last-child { border-bottom: 0; }

.topic-section .topic-header {
  margin-bottom: 18px;
}

.topic-tag {
  display: inline-block;
  font: 600 10px/1 var(--mono);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* Markdown rendered content */

.md h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: -.4px;
}
.md h2 {
  font-size: 19px;
  font-weight: 700;
  margin: 28px 0 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 80px;
}
.md h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 22px 0 8px;
  scroll-margin-top: 80px;
}
.md h4 {
  font-size: 14.5px;
  font-weight: 700;
  margin: 18px 0 6px;
  color: var(--text-soft);
}
.md p {
  margin: 0 0 12px;
}
.md ul, .md ol {
  margin: 0 0 12px;
  padding-left: 22px;
}
.md li { margin: 3px 0; }
.md blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.md blockquote p:last-child { margin-bottom: 0; }

.md blockquote.alert .alert-label {
  font: 700 11px/1 var(--mono);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 6px;
  color: var(--accent-strong);
}
.md blockquote.alert-note         { border-left-color: #2c7be5; }
.md blockquote.alert-note .alert-label { color: #2c7be5; }
.md blockquote.alert-tip          { border-left-color: #28a745; }
.md blockquote.alert-tip .alert-label { color: #28a745; }
.md blockquote.alert-important    { border-left-color: #8e44ad; }
.md blockquote.alert-important .alert-label { color: #8e44ad; }
.md blockquote.alert-warning      { border-left-color: #d97706; }
.md blockquote.alert-warning .alert-label { color: #d97706; }
.md blockquote.alert-caution      { border-left-color: #d63333; }
.md blockquote.alert-caution .alert-label { color: #d63333; }
html[data-theme="dark"] .md blockquote.alert-note      .alert-label { color: #6ab2ff; }
html[data-theme="dark"] .md blockquote.alert-note      { border-left-color: #6ab2ff; }
html[data-theme="dark"] .md blockquote.alert-tip       .alert-label { color: #7dd5a3; }
html[data-theme="dark"] .md blockquote.alert-tip       { border-left-color: #7dd5a3; }
html[data-theme="dark"] .md blockquote.alert-important .alert-label { color: #c693e6; }
html[data-theme="dark"] .md blockquote.alert-important { border-left-color: #c693e6; }
html[data-theme="dark"] .md blockquote.alert-warning   .alert-label { color: #ffb84d; }
html[data-theme="dark"] .md blockquote.alert-warning   { border-left-color: #ffb84d; }
html[data-theme="dark"] .md blockquote.alert-caution   .alert-label { color: #f47272; }
html[data-theme="dark"] .md blockquote.alert-caution   { border-left-color: #f47272; }

.md code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1px 5px;
  border-radius: 4px;
}

.md pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0 14px;
  font-size: 12.5px;
  line-height: 1.45;
  position: relative;
}
.md pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 12.5px;
  color: var(--code-text);
}

.md pre .copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font: 500 10.5px/1 var(--mono);
  letter-spacing: .4px;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  text-transform: uppercase;
}
.md pre:hover .copy-btn { opacity: 1; }
.md pre .copy-btn:hover { color: var(--text); border-color: var(--accent); }
.md pre .copy-btn.copied { color: var(--accent-strong); border-color: var(--accent); }

.md table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 13px;
  width: 100%;
  overflow-x: auto;
  display: block;
}
.md table thead {
  background: var(--bg-soft);
}
.md table th, .md table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.md table th {
  font-weight: 600;
}

.md img {
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.md hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 22px 0;
}

.md details {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin: 10px 0 14px;
  padding: 8px 14px;
}
.md details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  padding: 4px 0;
  list-style: none;
}
.md details > summary::-webkit-details-marker { display: none; }
.md details > summary::before {
  content: "▸ ";
  color: var(--accent);
  font-size: 11px;
  display: inline-block;
  width: 14px;
  transition: transform .15s;
}
.md details[open] > summary::before {
  content: "▾ ";
}

/* ---------- ABAP keyword highlighter ---------- */

.abap-kw { color: #0a558c; font-weight: 600; }
html[data-theme="dark"] .abap-kw { color: #82baf2; }
.abap-str { color: #9b4422; }
html[data-theme="dark"] .abap-str { color: #f0a772; }
.abap-num { color: #1f7a4d; }
html[data-theme="dark"] .abap-num { color: #7dd5a3; }
.abap-com { color: #7a7e6f; font-style: italic; }
html[data-theme="dark"] .abap-com { color: #6f7468; }
.abap-op { color: var(--accent-strong); }

/* ---------- Search hit highlights ---------- */

mark.hit {
  background: var(--accent);
  color: #1d1d1b;
  padding: 0 2px;
  border-radius: 2px;
}

.topic-section.hidden, .card.hidden { display: none; }
.category.hidden { display: none; }

/* ---------- Examples page ---------- */

.examples-toc {
  position: sticky;
  top: 53px;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 0 10px;
  margin: -28px -24px 28px;
  padding-left: 24px;
  padding-right: 24px;
}
.examples-toc-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 1500px;
  margin: 0 auto;
}
.examples-toc a {
  font: 500 12.5px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-soft);
  text-decoration: none;
  transition: all .12s;
}
.examples-toc a:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  text-decoration: none;
}
.examples-toc a .n {
  font: 600 11px/1 var(--mono);
  color: var(--text-muted);
  margin-left: 4px;
}

.example-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  overflow: hidden;
  transition: border-color .12s;
}
.example-card:hover { border-color: var(--border-strong); }

.example-head {
  padding: 14px 18px 8px;
  border-bottom: 1px solid var(--border);
}
.example-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.1px;
  margin: 0 0 4px;
  color: var(--text);
}
.example-desc {
  font-size: 13px;
  color: var(--text-soft);
  margin: 4px 0 0;
}

.example-files {
  padding: 14px 18px 16px;
}
.example-file {
  margin: 0;
}
.example-file + .example-file { margin-top: 14px; }
.example-file-name {
  display: inline-block;
  font: 600 11px/1 var(--mono);
  letter-spacing: .4px;
  text-transform: uppercase;
  padding: 4px 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 4px;
  margin-bottom: 6px;
}
.example-file pre {
  margin: 0;
}

.example-card.hidden { display: none; }

/* Mobile tweaks for examples toc */
@media (max-width: 880px) {
  .examples-toc {
    position: static;
    margin: 0 -18px 18px;
    padding: 10px 18px;
  }
}

/* ---------- Back-to-top + footer ---------- */

.to-top {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #1d1d1b;
  border: none;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: none;
  z-index: 30;
}
.to-top.show { display: grid; place-items: center; }

.footer {
  margin-top: 36px;
  padding: 18px 0;
  color: var(--text-muted);
  font-size: 12.5px;
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ---------- Mobile ---------- */

@media (max-width: 880px) {
  .shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  .content { padding: 24px 18px 60px; }
  .topbar nav { display: none; }
  .search { flex: 1; }
}
