/*
 * Greenheart Documentation
 * Style tokens taken from greenheartexchange.org (GreenheartStarfront theme):
 *   Headings  Sanchez, light, #363637
 *   Body      Lato 17px / 1.56, #6d6e70
 *   Links     #00a9e0
 *   Brand     green #00843D, lime #8AC53F
 */

:root {
  --gh-green: #00843d;
  --gh-green-dark: #006b31;
  --gh-lime: #8ac53f;
  --gh-lime-dark: #7ab82b;
  --gh-blue: #0080c5;
  --gh-link: #00a9e0;
  --gh-coral: #ff7276;
  --gh-gold: #fcc04c;
  --gh-violet: #8986ca;

  --text: #6d6e70;
  --heading: #363637;
  --muted: #a7a8a9;
  --border: #e9eaea;
  --surface: #ffffff;
  --surface-alt: #f9f9f9;
  --code-bg: #f2f2f2;

  --font-heading: "Sanchez", Georgia, serif;
  --font-body: "Lato", Georgia, serif;

  --sidebar-w: 300px;
  --header-h: 68px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 24px); }

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font: 17px/1.56 var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { color: var(--heading); line-height: 1.2; margin: 0; }
h1, h2, h3 { font-family: var(--font-heading); font-weight: 400; }
h1 { font-size: 48px; letter-spacing: -.5px; line-height: 1.08; }
h2 { font-size: 36px; letter-spacing: -.4px; }
h3 { font-size: 26px; letter-spacing: -.4px; line-height: 1.14; }
h4 { font-size: 20px; font-weight: 700; }

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

code {
  background: var(--code-bg);
  border-radius: 4px;
  color: var(--heading);
  font-size: .88em;
  padding: .1em .35em;
}

/* ---------- Header ---------- */

.site-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 16px;
  height: var(--header-h);
  left: 0;
  padding: 0 24px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 30;
}

.site-header .brand { align-items: center; display: flex; gap: 14px; }
.site-header .brand img { display: block; height: 40px; width: auto; }
.site-header .brand span {
  border-left: 1px solid var(--border);
  color: var(--heading);
  font-family: var(--font-heading);
  font-size: 20px;
  padding-left: 14px;
}

.menu-toggle {
  align-items: center;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--heading);
  cursor: pointer;
  display: inline-flex;
  height: 40px;
  justify-content: center;
  width: 40px;
}
.menu-toggle:hover { border-color: var(--gh-green); color: var(--gh-green); }
.menu-toggle svg { height: 20px; width: 20px; }

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--surface-alt);
  border-right: 1px solid var(--border);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: 24px 0 48px;
  position: fixed;
  top: var(--header-h);
  transition: transform .25s ease;
  width: var(--sidebar-w);
  z-index: 20;
}

.sidebar-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  margin: 0 24px 12px;
  text-transform: uppercase;
}

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

.toc-section { border-bottom: 1px solid var(--border); }
.toc-section:first-child { border-top: 1px solid var(--border); }

.toc-row { align-items: stretch; display: flex; }

.toc-row > a {
  color: var(--heading);
  flex: 1;
  font-size: 16px;
  font-weight: 700;
  padding: 12px 8px 12px 24px;
}

.toc-expand {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 0 18px;
}
.toc-expand:hover { color: var(--gh-green); }
.toc-expand svg { height: 14px; transition: transform .2s ease; width: 14px; }
.toc-section.open .toc-expand svg { transform: rotate(90deg); }

.toc-sub { display: none; padding-bottom: 10px !important; }
.toc-section.open .toc-sub { display: block; }

.toc-sub a {
  border-left: 3px solid transparent;
  color: var(--text);
  display: block;
  font-size: 15px;
  line-height: 1.4;
  padding: 6px 16px 6px 37px;
}

.toc a:hover { color: var(--gh-green); text-decoration: none; }
.toc a.active { color: var(--gh-green); }
.toc-sub a.active { background: #fff; border-left-color: var(--gh-lime); font-weight: 700; }

/* ---------- Main ---------- */

.content {
  margin-left: var(--sidebar-w);
  padding: calc(var(--header-h) + 48px) 64px 96px;
  transition: margin-left .25s ease;
}

.manual { max-width: 820px; }

.manual-hero {
  border-bottom: 4px solid var(--gh-lime);
  margin-bottom: 56px;
  padding-bottom: 32px;
}
.manual-hero .eyebrow {
  color: var(--gh-green);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .1em;
  margin: 0 0 12px;
  text-transform: uppercase;
}
.manual-hero p.lede { color: var(--text); font-size: 20px; font-weight: 300; margin: 16px 0 0; }

.doc-section { margin-bottom: 72px; }
.doc-section > h2 {
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  padding-bottom: 14px;
}
.doc-section > h2 .num { color: var(--gh-lime); margin-right: 10px; }

.doc-sub { margin: 40px 0 0; }
.doc-sub > h3 { margin-bottom: 14px; }

.manual p { margin: 0 0 16px; }
.manual ul, .manual ol { margin: 0 0 16px; padding-left: 24px; }
.manual li { margin-bottom: 6px; }
.manual strong { color: var(--heading); }

.callout {
  background: var(--surface-alt);
  border-left: 4px solid var(--gh-green);
  border-radius: 0 6px 6px 0;
  margin: 24px 0;
  padding: 16px 20px;
}
.callout p:last-child { margin-bottom: 0; }
.callout .callout-title { color: var(--heading); display: block; font-weight: 700; margin-bottom: 4px; }
.callout.tip { border-left-color: var(--gh-lime); }
.callout.warning { border-left-color: var(--gh-gold); }

.placeholder {
  border: 1px dashed var(--muted);
  border-radius: 6px;
  color: var(--muted);
  font-style: italic;
  margin: 16px 0;
  padding: 12px 16px;
}

.back-to-top { display: inline-block; font-size: 14px; margin-top: 24px; }

.sr-only {
  clip: rect(0 0 0 0);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* ---------- Site badges & filter ---------- */

.site-badge {
  border-radius: 999px;
  display: inline-block;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1;
  padding: 5px 9px;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: nowrap;
}
.site-badge.exchange { background: #e3f2e9; color: var(--gh-green-dark); }
.site-badge.org      { background: #e1eff8; color: #005a8c; }
.site-badge.travel   { background: #ecebf6; color: #4f4b9a; }
.site-badge.all      { background: var(--code-bg); color: var(--text); }

.badges { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 12px; vertical-align: middle; }

.site-filter {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 14px;
  gap: 8px;
  margin-left: auto;
}
.site-filter select {
  appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23363637' stroke-width='2'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E") no-repeat right 10px center / 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--heading);
  cursor: pointer;
  font: 700 15px var(--font-body);
  height: 40px;
  padding: 0 34px 0 12px;
}
.site-filter select:hover,
.site-filter select:focus { border-color: var(--gh-green); outline: none; }

:root[data-site="exchange"] [data-sites]:not([data-sites~="exchange"]),
:root[data-site="org"] [data-sites]:not([data-sites~="org"]),
:root[data-site="travel"] [data-sites]:not([data-sites~="travel"]) { display: none !important; }

/* ---------- Tables ---------- */

.table-scroll { margin: 0 0 16px; overflow-x: auto; }

.data-table { border-collapse: collapse; font-size: 15px; margin: 0; min-width: 520px; width: 100%; }
.matrix { min-width: 0; }
.data-table th,
.data-table td { border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; vertical-align: top; }
.data-table thead th {
  border-bottom: 2px solid var(--gh-lime);
  color: var(--heading);
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.data-table .site-shot { padding-right: 20px; width: 175px; }
.site-shot a { display: block; }
.site-shot img {
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
  display: block;
  height: auto;
  max-height: 350px;
  object-fit: cover;
  object-position: top;
  transition: border-color .15s ease, box-shadow .15s ease;
  width: 175px;
}
.site-shot a:hover img { border-color: var(--gh-lime); box-shadow: 0 4px 14px rgba(0, 0, 0, .12); }

.matrix td,
.matrix thead th { text-align: center; }
.matrix td:first-child,
.matrix thead th:first-child { text-align: left; }
.matrix td { padding: 7px 12px; }
.matrix .yes { color: var(--gh-green); font-weight: 700; }
.matrix .no { color: var(--muted); }
.matrix .group-row th {
  background: var(--surface-alt);
  color: var(--heading);
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
}
:root[data-site="exchange"] .matrix .col-exchange,
:root[data-site="org"] .matrix .col-org,
:root[data-site="travel"] .matrix .col-travel { background: #f4f9ec; }

/* ---------- Content type & block entries ---------- */

.type-entry,
.block-entry {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 0 0 16px;
  padding: 18px 20px;
}
.type-entry h4,
.block-entry h4 { margin-bottom: 8px; }
.type-entry h5 { font-size: 16px; margin: 18px 0 6px; }
.type-entry p:last-child,
.block-entry p:last-child { margin-bottom: 0; }
.is-target { border-color: var(--gh-lime); box-shadow: 0 0 0 3px rgba(138, 197, 63, .25); }

.type-entry dl {
  display: grid;
  font-size: 15px;
  gap: 4px 16px;
  grid-template-columns: max-content 1fr;
  margin: 12px 0 0;
}
.type-entry dt { color: var(--heading); font-weight: 700; }
.type-entry dd { margin: 0; }
.type-entry .placeholder { margin-bottom: 0; }

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  margin-top: 96px;
  padding-top: 24px;
}

/* ---------- Collapsed state (desktop) ---------- */

body.nav-collapsed .sidebar { transform: translateX(-100%); }
body.nav-collapsed .content { margin-left: 0; }

.scrim { display: none; }

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

@media (max-width: 960px) {
  :root { --header-h: 60px; }

  h1 { font-size: 36px; }
  h2 { font-size: 28px; }
  h3 { font-size: 22px; }

  .site-header { padding: 0 16px; }
  .site-header .brand img { height: 32px; }
  .site-header { gap: 10px; }
  .site-header .brand span { display: none; }
  .site-filter > span { display: none; }

  .type-entry dl { grid-template-columns: 1fr; }
  .type-entry dd { margin-bottom: 6px; }

  .sidebar { transform: translateX(-100%); width: min(86vw, var(--sidebar-w)); }
  .content { margin-left: 0; padding: calc(var(--header-h) + 32px) 16px 64px; }

  body.nav-open .sidebar { box-shadow: 4px 0 24px rgba(0, 0, 0, .08); transform: none; }
  body.nav-open .scrim {
    background: rgba(54, 54, 55, .35);
    display: block;
    inset: var(--header-h) 0 0 0;
    position: fixed;
    z-index: 15;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .sidebar, .content, .toc-expand svg { transition: none; }
}

.inline-dl { display: flex; flex-wrap: wrap; font-size: 15px; gap: 4px 12px; margin: 0; }
.inline-dl dt { color: var(--heading); font-weight: 700; }
.inline-dl dd { margin: 0; }

/* ---------- Handle-anchor target ---------- */

.doc-sub.is-target { animation: target-flash 2.4s ease-out; border-radius: 8px; }
@keyframes target-flash {
  0%, 30% { background: #f4f9ec; box-shadow: 0 0 0 12px #f4f9ec; }
  100% { background: transparent; box-shadow: 0 0 0 12px transparent; }
}

/* ---------- Previous / next page ---------- */

.pager {
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-top: 48px;
  padding-top: 24px;
}
.pager a {
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--heading);
  flex: 1;
  font-weight: 700;
  max-width: 50%;
  padding: 12px 16px;
}
.pager a:hover { border-color: var(--gh-green); color: var(--gh-green); text-decoration: none; }
.pager span { color: var(--muted); display: block; font-size: 13px; font-weight: 400; }
.pager-next { margin-left: auto; text-align: right; }

/* ---------- Embed mode (?embed=1) ---------- */

.embed-bar { display: none; }

:root.embed { --header-h: 36px; }
:root.embed .site-header,
:root.embed .sidebar,
:root.embed .scrim,
:root.embed .manual-hero,
:root.embed .back-to-top,
:root.embed .pager,
:root.embed .site-footer { display: none !important; }
:root.embed .content { margin-left: 0; padding: calc(var(--header-h) + 16px) 20px 40px; }
:root.embed .manual { max-width: none; padding-bottom: 60vh; } /* lets entries near the end scroll to the top */
:root.embed .embed-bar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  font-size: 14px;
  font-weight: 700;
  gap: 16px;
  height: var(--header-h);
  left: 0;
  padding: 0 20px;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 30;
}
.embed-open { margin-left: auto; white-space: nowrap; }
.embed-back {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--heading);
  cursor: pointer;
  font: inherit;
  max-width: 60%;
  overflow: hidden;
  padding: 3px 10px;
  text-overflow: ellipsis;
  transition: opacity .2s;
  white-space: nowrap;
}
.embed-back:hover { border-color: var(--gh-lime); }
.embed-back:focus-visible { outline: 2px solid var(--gh-link); outline-offset: 2px; }
.embed-back.is-onscreen { opacity: .5; }
.embed-back[hidden] { display: none; }
.embed-missing {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gh-gold);
  border-radius: 4px;
  color: var(--heading);
  margin: 0 0 24px;
  padding: 12px 16px;
}
.embed-missing p { margin: 0; }
:root.embed h2 { font-size: 28px; }
:root.embed h3 { font-size: 22px; }
:root.embed .doc-section { margin-bottom: 48px; }

.faq-list { margin: 0 0 16px; }
.faq-list dt { color: var(--heading); font-weight: 700; margin-top: 14px; }
.faq-list dd { margin: 4px 0 0; }
