/* Sekce API nápovědy - stejný grafický jazyk jako návody (help.css), jen komponenty navíc */

:root {
  --api-get: #08705f;
  --api-post: #145389;
  --api-put: #72520a;
  --api-delete: #a22536;
  --api-code-bg: #252122;
  --api-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}

/* ---------- rozložení ---------- */

.api-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 56px; align-items: start; padding-bottom: 24px; }
.api-content { min-width: 0; max-width: 860px; overflow-wrap: anywhere; }
.api-content h1 { margin: 12px 0 16px; overflow-wrap: anywhere; }
.api-content h2 { font-size: 1.5rem; margin: 2.4rem 0 .8rem; }
.api-content h3 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
.api-content > p, .api-content > ul { margin: 0 0 1rem; }
.api-content :not(pre) > code { background: var(--bg-soft); padding: .1em .35em; border-radius: 4px; font-size: .88em; overflow-wrap: anywhere; }
.api-content .prose > :last-child { margin-bottom: 0; }
.api-note { color: var(--muted); font-size: .9rem; font-style: italic; margin: 0 0 .6rem !important; }

/* ---------- štítek HTTP metody ---------- */

.api-method {
  display: inline-block;
  min-width: 52px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--api-get);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: .03em;
  text-align: center;
  white-space: nowrap;
  vertical-align: .1em;
}
.api-method--post { background: var(--api-post); }
.api-method--put { background: var(--api-put); }
.api-method--delete { background: var(--api-delete); }

/* ---------- levý sidebar (vzor: obsah návodu .toc) ---------- */

.api-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 20px);
  max-height: calc(100vh - var(--header-h) - 40px);
  overflow-y: auto;
  margin-top: 12px;
  padding-right: 6px;
  font-size: .9rem;
  line-height: 1.4;
}
.api-sidebar nav { display: flex; flex-direction: column; }
.api-sidebar a { color: var(--text); text-decoration: none; }
.api-sidebar a:hover { color: var(--brand-dark); }
.api-sidebar nav > a, .api-sidebar summary { display: block; padding: 6px 0 6px 12px; border-left: 2px solid var(--line); }
.api-sidebar nav > a[aria-current="page"] { border-left-color: var(--brand); color: var(--brand-dark); font-weight: 500; }
.api-sidebar details { margin: 0; }
.api-sidebar summary { list-style: none; cursor: pointer; position: relative; padding-right: 22px; }
.api-sidebar summary::-webkit-details-marker { display: none; }
.api-sidebar nav details > summary::after {
  content: '';
  position: absolute;
  right: 6px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -5px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .15s;
}
.api-sidebar nav details[open] > summary::after { transform: rotate(45deg); margin-top: -6px; }
.api-sidebar nav details[open] > summary { border-left-color: var(--brand); }
.api-sidebar nav details[open] > summary a { color: var(--ink); font-weight: 500; }
.api-sidebar strong {
  display: block;
  margin: 10px 0 2px;
  padding-left: 22px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.api-sidebar__endpoint {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 5px 4px 5px 22px;
  border-radius: 0 4px 4px 0;
  font-size: .85rem;
}
.api-sidebar__endpoint .api-method { min-width: 46px; font-size: .64rem; padding: 1px 5px; flex: none; }
.api-sidebar__endpoint:hover { background: var(--brand-lighter); }
.api-sidebar__endpoint[aria-current="page"] { background: var(--brand-light); color: var(--brand-dark); font-weight: 500; }
.api-sidebar__title { margin: 0 0 8px; padding-left: 14px; font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.api-nav-toggle, .api-nav-close, .api-nav-backdrop { display: none; }

/* ---------- přehled API (vzor: úvod nápovědy) ---------- */

.hero--api { padding-bottom: 48px; }
.api-base {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 12px;
  max-width: 100%;
  margin: 0 0 28px;
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: .85rem;
  color: var(--muted);
}
.api-base code { padding: 4px 12px; border-radius: 999px; background: var(--api-code-bg); color: #f3f1f1; font-family: var(--api-mono); font-size: .88rem; overflow-wrap: anywhere; }
.api-concepts .category-card__title { font-size: 1rem; }
.api-card__methods { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 10px; }
.api-card__methods .api-method { min-width: 0; font-size: .66rem; padding: 1px 7px; }

/* ---------- přehled a stránka skupiny ---------- */

.api-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin: 28px 0 0; }
.api-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.api-card:hover { border-color: var(--brand); box-shadow: var(--shadow); color: var(--text); transform: translateY(-1px); }
.api-card h2 { margin: 0; font-size: 1.08rem; font-weight: 500; color: var(--ink); }
.api-card p { margin: 0; font-size: .92rem; line-height: 1.5; }
.api-card span { margin-top: 8px; font-size: .8rem; color: var(--muted); }
.api-content .link-list { margin: 8px 0 0; }

/* ---------- řádek operace (metoda + cesta) ---------- */

.api-operation {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 28px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.api-operation .api-method { font-size: .78rem; min-width: 60px; padding: 3px 8px; }
.api-content .api-path { flex: 1; min-width: 0; margin: 0; background: transparent; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.api-content .api-path pre { flex: 1; min-width: 0; margin: 0; padding: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .95rem; }
.api-js .api-content .api-path pre { padding: 0; }
.api-content .api-path code { background: none; padding: 0; font-family: var(--api-mono); }
.api-js .api-content .api-path .api-copy {
  position: static;
  order: 2;
  flex: none;
  background: #fff;
  color: var(--brand-dark);
  border: 1px solid var(--line);
}
.api-js .api-content .api-path .api-copy:hover { border-color: var(--brand); background: #fff; color: var(--brand-dark); }

/* ---------- bloky kódu ---------- */

.api-code { position: relative; margin: 12px 0 16px; max-width: 100%; min-width: 0; border-radius: var(--radius); background: var(--api-code-bg); color: #f3f1f1; }
.api-code pre { margin: 0; padding: 18px 20px; overflow: auto; max-width: 100%; font-size: .85rem; line-height: 1.6; }
.api-code code { font-family: var(--api-mono); overflow-wrap: normal; }
.api-js .api-code pre { padding-top: 42px; }
.api-copy { display: none; }
.api-js .api-copy {
  display: block;
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 10px;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 4px;
  background: rgba(255, 255, 255, .08);
  color: #f3f1f1;
  font: inherit;
  font-size: .78rem;
  font-style: italic;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.api-js .api-copy:hover { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- záložky (vzor: pilulky podkategorií) ---------- */

.api-tab-buttons { display: none; }
.api-js .api-tab-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.api-tab-buttons button {
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.api-tab-buttons button:hover { border-color: var(--brand); }
.api-tab-buttons button[aria-selected="true"] { background: var(--brand-light); border-color: var(--brand-light); color: var(--brand-dark); font-weight: 500; }
/* Nadpis jazyka zdvojuje záložku; bez JS (všechny panely pod sebou) zůstává vidět. */
.api-js [data-api-tabs="language"] [data-api-panel] > h3 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[data-api-tabs="responses"] [data-api-panel] > h3 { font-size: 1.02rem; margin: 1.2rem 0 .2rem; }
[data-api-tabs="responses"] [data-api-panel] > p { margin: 0 0 .4rem; font-size: .92rem; }
[data-api-tabs="responses"] [data-api-panel] > p:first-of-type code { color: var(--muted); }

/* ---------- tabulky (vzor: .prose table) ---------- */

.api-content .table-wrap { overflow-x: auto; max-width: 100%; margin: 0 0 1.25rem; }
.api-table { border-collapse: collapse; width: 100%; font-size: .92rem; line-height: 1.5; overflow-wrap: normal; }
.api-table th, .api-table td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.api-table th { background: var(--bg-soft); color: var(--ink); font-weight: 500; white-space: nowrap; }
.api-table td:first-child code { white-space: nowrap; }
.api-table td code { overflow-wrap: anywhere; }
/* tabulka parametrů má pět sloupců; pod 700 px se posouvá uvnitř */
.api-content h3 + .table-wrap .api-table { min-width: 640px; }
/* seznam operací na stránce skupiny: řádky jako seznam, bez svislých čar */
.api-content > .table-wrap .api-table:has(a) th, .api-content > .table-wrap .api-table:has(a) td { border-left: 0; border-right: 0; }
.api-table td a { color: var(--ink); font-weight: 500; text-decoration: none; }
.api-table td a:hover { color: var(--brand-dark); text-decoration: underline; }
.api-table tbody tr:hover td { background: var(--brand-lighter); }

/* ---------- obsah koncepčních stránek ---------- */

.api-content > nav[aria-label] { margin: 0 0 24px; padding: 12px 16px; background: var(--bg-soft); border-radius: var(--radius); font-size: .92rem; }
.api-content > nav[aria-label] ul { list-style: none; margin: 0; padding: 0; }
.api-content > nav[aria-label] a { display: block; padding: 3px 0; text-decoration: none; color: var(--text); }
.api-content > nav[aria-label] a:hover { color: var(--brand-dark); }

/* ---------- responzivita (zlom 1000 px shodně s obsahem návodu) ---------- */

@media (max-width: 1000px) {
  .api-layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .api-content h1 { margin-top: 4px; }
  /* bez JS je menu pod obsahem, s JS vyjíždí zleva přes plovoucí tlačítko */
  .api-sidebar { order: 2; position: static; max-height: none; overflow: visible; margin: 40px 0 0; padding: 20px 0 0; border-top: 1px solid var(--line); }
  .api-js .api-sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(340px, 88vw);
    margin: 0;
    padding: 20px 16px 32px 20px;
    border: 0;
    background: #fff;
    box-shadow: 0 0 40px rgba(37, 33, 34, .22);
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform .22s ease, visibility 0s linear .22s;
  }
  .api-nav-open .api-sidebar { transform: none; visibility: visible; transition: transform .22s ease; }
  .api-js .api-sidebar__title { margin: 6px 0 14px; font-size: .8rem; }
  .api-js .api-nav-close {
    display: grid;
    place-items: center;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: var(--bg-soft);
    color: var(--ink);
    cursor: pointer;
  }
  .api-js .api-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(37, 33, 34, .4);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s;
  }
  .api-nav-open .api-nav-backdrop { opacity: 1; pointer-events: auto; }
  .api-nav-open body { overflow: hidden; }
  .api-js .api-nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    z-index: 30;
    left: 20px;
    bottom: 20px;
    padding: 11px 18px 11px 16px;
    border: 0;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font: inherit;
    font-size: .92rem;
    font-weight: 500;
    box-shadow: 0 6px 20px rgba(37, 33, 34, .28);
    cursor: pointer;
    transition: background .15s, transform .15s;
  }
  .api-js .api-nav-toggle:hover { background: var(--brand-dark); transform: translateY(-1px); }
  .api-js .api-nav-toggle .icon { width: 18px; height: 18px; }
}

@media (max-width: 560px) {
  .api-content h2 { font-size: 1.3rem; }
  .api-cards { grid-template-columns: minmax(0, 1fr); }
  .api-operation { flex-wrap: wrap; }
  .api-content .api-path pre { font-size: .88rem; }
  .api-code pre { padding-left: 14px; padding-right: 14px; }
}

@media print {
  .api-sidebar, .api-tab-buttons, .api-copy { display: none !important; }
  .api-layout { display: block; }
  .api-code { background: #fff; color: var(--ink); border: 1px solid var(--line); }
  [data-api-panel][hidden] { display: block !important; }
}
