/**
 * Documentation (SSR) styles — only the highlight.js GitHub theme (light + dark).
 * All layout/search/share/TOC styling uses Tailwind utilities + Alpine in the
 * template; the only thing that can't be expressed as utilities is the
 * third-party token palette below.
 *
 * Token colours are unlayered so they win over the @layer base prose rules.
 * The code box itself comes from .nem-docs-body pre (tailwind.config.css);
 * hljs background/padding are neutralised so there is a single box.
 */

/* ---- highlight.js: GitHub (light, default) ---- */
.hljs { color: #24292e; }
.hljs-doctag, .hljs-keyword, .hljs-meta .hljs-keyword, .hljs-template-tag, .hljs-template-variable, .hljs-type, .hljs-variable.language_ { color: #d73a49; }
.hljs-title, .hljs-title.class_, .hljs-title.class_.inherited__, .hljs-title.function_ { color: #6f42c1; }
.hljs-attr, .hljs-attribute, .hljs-literal, .hljs-meta, .hljs-number, .hljs-operator, .hljs-selector-attr, .hljs-selector-class, .hljs-selector-id, .hljs-variable { color: #005cc5; }
.hljs-meta .hljs-string, .hljs-regexp, .hljs-string { color: #032f62; }
.hljs-built_in, .hljs-symbol { color: #e36209; }
.hljs-code, .hljs-comment, .hljs-formula { color: #6a737d; }
.hljs-name, .hljs-quote, .hljs-selector-pseudo, .hljs-selector-tag { color: #22863a; }
.hljs-subst { color: #24292e; }
.hljs-section { color: #005cc5; font-weight: 700; }
.hljs-bullet { color: #735c0f; }
.hljs-emphasis { color: #24292e; font-style: italic; }
.hljs-strong { color: #24292e; font-weight: 700; }
.hljs-addition { color: #22863a; background-color: #f0fff4; }
.hljs-deletion { color: #b31d28; background-color: #ffeef0; }

/* ---- highlight.js: GitHub Dark (override under [data-theme="dark"]) ---- */
[data-theme="dark"] .hljs { color: #c9d1d9; }
[data-theme="dark"] .hljs-doctag, [data-theme="dark"] .hljs-keyword, [data-theme="dark"] .hljs-meta .hljs-keyword, [data-theme="dark"] .hljs-template-tag, [data-theme="dark"] .hljs-template-variable, [data-theme="dark"] .hljs-type, [data-theme="dark"] .hljs-variable.language_ { color: #ff7b72; }
[data-theme="dark"] .hljs-title, [data-theme="dark"] .hljs-title.class_, [data-theme="dark"] .hljs-title.class_.inherited__, [data-theme="dark"] .hljs-title.function_ { color: #d2a8ff; }
[data-theme="dark"] .hljs-attr, [data-theme="dark"] .hljs-attribute, [data-theme="dark"] .hljs-literal, [data-theme="dark"] .hljs-meta, [data-theme="dark"] .hljs-number, [data-theme="dark"] .hljs-operator, [data-theme="dark"] .hljs-selector-attr, [data-theme="dark"] .hljs-selector-class, [data-theme="dark"] .hljs-selector-id, [data-theme="dark"] .hljs-variable { color: #79c0ff; }
[data-theme="dark"] .hljs-meta .hljs-string, [data-theme="dark"] .hljs-regexp, [data-theme="dark"] .hljs-string { color: #a5d6ff; }
[data-theme="dark"] .hljs-built_in, [data-theme="dark"] .hljs-symbol { color: #ffa657; }
[data-theme="dark"] .hljs-code, [data-theme="dark"] .hljs-comment, [data-theme="dark"] .hljs-formula { color: #8b949e; }
[data-theme="dark"] .hljs-name, [data-theme="dark"] .hljs-quote, [data-theme="dark"] .hljs-selector-pseudo, [data-theme="dark"] .hljs-selector-tag { color: #7ee787; }
[data-theme="dark"] .hljs-subst { color: #c9d1d9; }
[data-theme="dark"] .hljs-section { color: #1f6feb; font-weight: 700; }
[data-theme="dark"] .hljs-bullet { color: #f2cc60; }
[data-theme="dark"] .hljs-emphasis { color: #c9d1d9; font-style: italic; }
[data-theme="dark"] .hljs-strong { color: #c9d1d9; font-weight: 700; }
[data-theme="dark"] .hljs-addition { color: #aff5b4; background-color: #033a16; }
[data-theme="dark"] .hljs-deletion { color: #ffdcd7; background-color: #67060c; }

/* Single code box: let .nem-docs-body pre own the background/border. */
.nem-docs-body pre code.hljs { background: transparent; padding: 0; }

/* Doc images open in a lightbox on click. */
.nem-docs-body img { cursor: zoom-in; }

/* Tall screenshots fold: shared css/imagefold.css (asset dependency). */
.nem-docs-body .nem-img-fold { margin: 16px 0; }

/* Hide x-cloak elements until Alpine initialises (collapsible tree, drawer, search, share). */
[x-cloak] { display: none !important; }

/**
 * Copy-to-clipboard buttons on code blocks.
 *
 * Injected by docs.js rather than rendered server-side, so these cannot be
 * Tailwind utilities: the template build is static and never scans class names
 * built in JavaScript. Colours reuse the theme's CSS variables so the button
 * follows light/dark without a second rule set.
 */
.nem-code-wrap { position: relative; }

.nem-code-wrap > pre { margin: 0; }

/* Keep the last column of code clear of the button. Without this a long
   single-line command (a curl call, a request URL) scrolls underneath it. */
.nem-code-wrap > pre { padding-right: 3.25rem; }

/* The wrapper replaces the <pre> in flow, so it inherits the block spacing. */
.nem-docs-body .nem-code-wrap { margin: 1.25rem 0; }

.nem-code-copy {
    position: absolute;
    top: .5rem;
    right: .5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--nxt-border, #e5e7eb);
    border-radius: .375rem;
    background: var(--nxt-surface, #fff);
    color: var(--nxt-text-secondary, #4b5563);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s ease, color .15s ease, border-color .15s ease;
}

.nem-code-copy svg { width: 18px; height: 18px; }

.nem-code-copy.is-done { color: #047857; }

[data-theme="dark"] .nem-code-copy.is-done { color: #6ee7b7; }

.nem-code-wrap:hover .nem-code-copy,
.nem-code-copy:focus-visible {
    opacity: 1;
}

.nem-code-copy:hover {
    color: var(--nxt-text, #111827);
    border-color: var(--nxt-text-secondary, #4b5563);
}

/* Touch devices have no hover, so the button must always be visible there. */
@media (hover: none) {
    .nem-code-copy { opacity: 1; }
}

/**
 * Tables.
 *
 * The way most docs sites handle wide tables (Docusaurus, GitHub, MDN): the
 * table is its own horizontal scroll box, and identifiers inside cells never
 * break mid-word. Previously inline code could wrap "anywhere", so the browser
 * squeezed the Field/Type columns down to a character or two ("intege|r").
 *
 * display:block is what lets overflow-x apply to a table. width:max-content
 * with max-width:100% keeps it full width when it fits; descriptions wrap,
 * and when the unbreakable columns alone are too wide the table scrolls.
 * Borders are horizontal only and the header is tinted, which reads better
 * than a full grid for parameter lists.
 */
.nem-docs-body table {
    display: block;
    width: max-content;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border: 1px solid var(--nxt-border, #e5e7eb);
    border-radius: var(--nxt-radius-md, 8px);
    border-collapse: separate;
    border-spacing: 0;
    font-size: .9375rem;
}

.nem-docs-body table th,
.nem-docs-body table td {
    border: 0;
    border-bottom: 1px solid var(--nxt-border, #e5e7eb);
    padding: 10px 14px;
    vertical-align: top;
}

.nem-docs-body table tr:last-child td { border-bottom: 0; }

.nem-docs-body table th {
    font-size: .8125rem;
    white-space: nowrap;
    background-color: rgba(0, 0, 0, .03);
}

[data-theme="dark"] .nem-docs-body table th { background-color: rgba(255, 255, 255, .05); }

/* Identifiers stay whole: wrap only where the code itself has a space. */
.nem-docs-body table code {
    overflow-wrap: normal;
    word-break: normal;
    font-size: .8125rem;
}

/* The first column names the thing (field, parameter, status): never wrap it. */
.nem-docs-body table td:first-child code { white-space: nowrap; }

/* The last column is usually prose. Without a floor, a phone squeezes it to a
   word per line (and out of view); with one, the table scrolls sideways and
   rows stay readable. Browsers ignore min-width on table cells, so an empty
   block of that width sets the column's minimum instead. */
.nem-docs-body table td:last-child:not(:first-child)::before,
.nem-docs-body table th:last-child:not(:first-child)::before {
    content: '';
    display: block;
    width: 15rem;
    height: 0;
}

/**
 * Long inline code must wrap.
 *
 * An operation path like `/v1/nextrestaurant/locations/{locationId}/menu` is a
 * single unbreakable token, so on a phone it pushes the whole page sideways.
 * Scoped to inline code outside tables only — tables scroll instead (above),
 * and code inside <pre> keeps its own horizontal scroll, because breaking a
 * command mid-token would make it wrong to copy.
 */
.nem-docs-body :not(pre) > code {
    overflow-wrap: anywhere;
}

.nem-docs-body table :not(pre) > code {
    overflow-wrap: normal;
}

/**
 * Code-sample tabs (cURL / PHP / JavaScript) built by docs.js on API pages.
 */
.nem-docs-body .nem-code-tabs { margin: 1.25rem 0; }

.nem-code-tabs-bar {
    display: flex;
    gap: .25rem;
    overflow-x: auto;
    border-bottom: 1px solid var(--nxt-border, #e5e7eb);
    margin-bottom: .5rem;
}

.nem-code-tab {
    padding: .4rem .75rem;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    background: transparent;
    color: var(--nxt-text-secondary, #4b5563);
    font-size: .8125rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.nem-code-tab:hover { color: var(--nxt-text, #111827); }

.nem-code-tab.is-active {
    color: var(--nxt-primary, #2563eb);
    border-bottom-color: var(--nxt-primary, #2563eb);
}

.nem-docs-body .nem-code-tabs > .nem-code-panel { margin: 0; }

/**
 * Checklist pages (_meta.json "checklist": true): checkbox list items.
 */
.nem-docs-body li.nem-check { list-style: none; margin-left: -1.25rem; }

.nem-docs-body li.nem-check > .nem-check-box,
.nem-docs-body li.nem-check > p > .nem-check-box {
    width: 1rem;
    height: 1rem;
    margin: 0 .5rem 0 0;
    vertical-align: -2px;
    accent-color: var(--nxt-primary, #2563eb);
    cursor: pointer;
}

.nem-check-progress {
    font-size: .8125rem;
    font-weight: 600;
    color: var(--nxt-text-secondary, #4b5563);
}
