/* ============================================================================
   api-styles.css - the extra styling for the achocodes free REST API guide
   (api/api-docs.php, served at achocodes.com/api)
   ----------------------------------------------------------------------------
   EVERY visual token here comes from achocodesstyles.css, which
   universal_header.php loads BEFORE this file: the light and dark palettes,
   the two site fonts (Reddit Sans for UI, "codingfont" Source Code Pro for
   code), the card shadows and the border colors. So this page follows the
   site theme automatically - including the [hidden] display rule - and
   there are no hard-coded colors except the status-code badge greens and
   reds, which are defined once per theme further down.

   Sections:
     1. Page frame            - the centered docs column
     2. Quick facts           - the six-fact grid under the intro
     3. Guide prose           - body copy, inline code, notes
     4. Status code badges    - the 200 / 400 / 404 ... chips
     5. Quick navigation      - the category jump links
     6. Endpoint cards        - the heart of the page: method badge, the
                               big gently-colored endpoint path, params
                               and the gold Run button
     7. Result panels         - status / url / timing meta row, Copy JSON
                               button and the Prism-highlighted output
     8. Dark theme            - the few overrides the dark palette needs
     9. Small screens         - everything stacks neatly on mobile
   ============================================================================ */

/* ============================================================================
   1. PAGE FRAME - one centered reading column inside the site container
   ============================================================================ */
.api-docs {
  max-width: 960px;
  margin: 0 auto;
}

/* Section rhythm: every guide block (How it works, Premier League, ...)
   gets the same comfortable spacing; the in-page anchors sit above the
   sticky navbar when a quicknav link is followed. */
.api-guide-section {
  margin-top: 46px;
  scroll-margin-top: 130px;
}

/* ============================================================================
   2. QUICK FACTS - a grid of six small panels right under the intro
   ============================================================================ */
.api-quickfacts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 26px 0 8px;
}

.api-fact {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Small-caps label above each value, in the site's wide-tracked style */
.api-fact-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

.api-fact-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-body);
}

/* Mono variant used for the base URL and the ?pretty=0 switch */
.api-fact-mono {
  font-family: var(--font-code);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

/* ============================================================================
   3. GUIDE PROSE - body copy, subheadings, inline code and the data note
   ============================================================================ */
.api-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-body);
  margin: 14px 0;
  line-height: 1.65;
}

.api-subhead {
  font-family: var(--font-ui);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-strong);
  margin: 26px 0 6px;
}

/* The short label next to a status badge ("the request worked") */
.api-text-inline {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  align-self: center;
}

/* Inline code inside a sentence - inset background, mono font, rounded */
.api-inline-code {
  font-family: var(--font-code);
  font-size: 0.85em;
  font-weight: 500;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 1px 7px;
  overflow-wrap: anywhere;
}

/* The sample envelope/error blocks in "How the API works" reuse the site
   pre > code styles completely; .api-sample only shrinks the bottom gap
   between the two example blocks a little. */
.api-sample {
  margin-bottom: 14px;
}

/* The honest note about the CSV data being illustrative */
.api-note {
  margin-top: 24px;
  padding: 14px 18px;
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-left: 5px solid var(--brand-gold);
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ============================================================================
   4. STATUS CODE BADGES - outline chips, one row per code + description
   ============================================================================ */
.api-codes {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 14px;
  margin: 14px 0;
}

.api-code {
  font-family: var(--font-code);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 7px;
  border: 1.5px solid currentColor;
  white-space: nowrap;
  justify-self: start;
  align-self: center;
}

/* Green for success, red for client errors, gold for the rate limit.
   The border is currentColor, so only the text color is set here. */
.api-code.ok {
  color: #2e9e4f;
}

.api-code.err {
  color: #c0392b;
}

.api-code.rate {
  color: #b7950b;
}

/* ============================================================================
   5. QUICK NAVIGATION - jump links to every category section
   ============================================================================ */
.api-quicknav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 30px 0 6px;
}

.api-quicknav a {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--link-color);
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 6px 14px;
  text-decoration: none;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.api-quicknav a:hover {
  background: var(--bg-inset);
  border-color: var(--border-strong);
}

/* ============================================================================
   6. ENDPOINT CARDS - one card per endpoint
   ============================================================================ */
.api-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 22px 20px 36px;
  margin: 24px 0;
  box-shadow: var(--shadow-card);
}

.api-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

/* GET method badge - the brand gold with dark text, rounded */
.api-method {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  background: var(--brand-gold);
  color: #17130f;
  border-radius: 7px;
  padding: 4px 10px;
}

/* THE BIG GENTLY-COLORED ENDPOINT PATH - the signature look of this page.
   Monospace, big (about 2.2rem on wide screens, clamped for narrow ones),
   weight 500, and a soft translucent ink that stays quiet on both themes.
   The {n} / {slug} parameters are bolded in the markup. */
.api-path {
  font-family: var(--font-code);
  font-size: clamp(1.25rem, 2.4vw, 2.2rem);
  font-weight: 500;
  color: rgba(11, 28, 58, 0.42);
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
}

.api-path b {
  font-weight: 700;
  color: rgba(11, 28, 58, 0.6);
}

/* One-line description under the path */
.api-desc {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  margin: 4px 0 12px;
  line-height: 1.55;
}

/* The row of parameter inputs + the Run button */
.api-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
}

/* Small-caps label wrapping a number/text input */
.api-param-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

/* The parameter input itself - mono font, inset background, soft border */
.api-param {
  font-family: var(--font-code);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-body);
  background: var(--bg-inset);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 7px 10px;
  width: 110px;
  outline: none;
  transition: border-color 0.2s ease;
}

.api-param:focus {
  border-color: var(--brand-gold);
}

/* THE RUN BUTTON - the brand gold, dark text, bold, with a lift on hover */
.api-run {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 700;
  background: var(--brand-gold);
  color: #17130f;
  border: none;
  border-radius: 9px;
  padding: 9px 20px;
  margin-bottom: -20px;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease;
}

.api-run:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(255, 210, 19, 0.45);
}

.api-run:active {
  transform: translateY(0);
}

/* While a request is in flight the button says "Running..." and waits */
.api-run:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

/* ============================================================================
   7. RESULT PANELS - meta row + Prism-highlighted JSON output
   ============================================================================ */

/* The whole panel is hidden via the [hidden] attribute until the first run;
   the site's global [hidden] display rule guarantees it stays hidden. */
.api-result {
  margin-top: 14px;
  border-top: 1px dashed var(--border-strong);
  padding-top: 12px;
}

/* Status badge + request url + timing + Copy JSON, one tidy row */
.api-result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

/* The HTTP status of the last run - the JS sets one of three classes:
   ok (2xx), err (4xx and 5xx) or rate (429, the gold badge). */
.api-status {
  font-family: var(--font-code);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 7px;
  border: 1.5px solid currentColor;
}

.api-status.ok {
  color: #2e9e4f;
}
.api-status.err {
  color: #c0392b;
}
.api-status.rate {
  color: #b7950b;
}

.api-url {
  font-family: var(--font-code);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.api-time {
  font-family: var(--font-code);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: auto;
}

/* Ghost Copy JSON button, pinned to the right; enabled once a response
   has been stored on the element via its data-json attribute. */
.api-copy {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--link-color);
  background: transparent;
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  padding: 4px 12px;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.api-copy:hover:not(:disabled) {
  background: var(--bg-inset);
  border-color: var(--border-strong);
}

.api-copy:disabled {
  opacity: 0.45;
  cursor: default;
}

/* The response output - the site's pre > code styles already give the
   codingfont, the gold-blue left bar and the code background; this only
   caps the height so a 100-row response stays scrollable inside the card. */
.api-output {
  margin: 0 0 6px;
  max-height: 420px;
}

.api-output > code {
  display: block;
  min-height: 40px;
}

/* ============================================================================
   8. DARK THEME - only what the translucent inks need
   ============================================================================
   Almost everything switches itself via the CSS variables defined in the
   dark palette of achocodesstyles.css. Only the big gentle endpoint path
   uses a fixed rgba() ink, so it gets its own light-tinted variant here. */
html[data-theme="dark"] .api-path {
  color: rgba(216, 228, 245, 0.55);
}

html[data-theme="dark"] .api-path b {
  color: rgba(216, 228, 245, 0.78);
}

/* Lighter green/red/gold badges readable on navy */
html[data-theme="dark"] .api-code.ok {
  color: #5fc47e;
}
html[data-theme="dark"] .api-code.err {
  color: #e8695a;
}
html[data-theme="dark"] .api-code.rate {
  color: #f2c94c;
}

html[data-theme="dark"] .api-status.ok {
  color: #5fc47e;
}
html[data-theme="dark"] .api-status.err {
  color: #e8695a;
}
html[data-theme="dark"] .api-status.rate {
  color: #f2c94c;
}

/* ============================================================================
   9. SMALL SCREENS - the facts grid and the meta row stack vertically
   ============================================================================ */
@media (max-width: 760px) {
  .api-quickfacts {
    grid-template-columns: 1fr 1fr;
  }

  .api-codes {
    grid-template-columns: 1fr;
  }

  .api-codes .api-text-inline {
    margin-top: -4px;
  }

  .api-card-head {
    flex-wrap: wrap;
    gap: 8px;
  }

  .api-time {
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .api-quickfacts {
    grid-template-columns: 1fr;
  }

  .api-controls {
    align-items: stretch;
  }

  .api-param-label {
    justify-content: space-between;
  }
}
