/* ============================================================
   PSSCRIPT DOCUMENTATION
   Reuses the global theme variables defined in custom.css
   (--primary-color, --bg-color, --text-color, --box-bg-color,
    --btn-bg-color …) so the docs follow light / dark mode and
   the same dark-green / amber palette as the rest of the site.
   ============================================================ */

/* ── Layout ────────────────────────────────────────────────── */
.psd-layout {
    max-width: 1320px;
    margin: 0 auto;
    padding: 8px 20px 56px;
}

.psd-content {
    min-width: 0;            /* allow code blocks to scroll, not stretch */
    font-size: 0.96rem;
    line-height: 1.8;
}

.psd-content section {
    scroll-margin-top: 90px; /* anchor offset under the sticky navbar */
    margin-bottom: 34px;
}

/* ── Hero ──────────────────────────────────────────────────── */
.psd-hero {
    padding: 36px 16px 18px;
}

.psd-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.6;
    margin-bottom: 12px;
}

.psd-eyebrow-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--btn-bg-color);
}

.psd-hero h1 {
    font-weight: 400;
    margin-bottom: 12px;
}

.psd-hero-intro {
    font-size: 1.08rem;
    opacity: 0.82;
    max-width: 760px;
}

/* ── Sidebar navigation ────────────────────────────────────── */
.psd-sidebar {
    position: sticky;
    top: 84px;
    align-self: flex-start;
    background: var(--box-bg-color);
    border-radius: 12px;
    padding: 16px 14px;
}

.psd-sidebar-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.6;
    margin: 4px 8px 10px;
}

.psd-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.psd-nav-list li {
    margin-bottom: 2px;
}

.psd-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
    opacity: 0.85;
    transition: background-color 140ms ease, opacity 140ms ease;
}

.psd-nav-link i {
    width: 18px;
    text-align: center;
    opacity: 0.7;
}

.psd-nav-link:hover {
    opacity: 1;
    background: rgba(0, 44, 27, 0.08);
    color: var(--text-color);
}

.psd-nav-link.active {
    opacity: 1;
    color: #fff;
    background: var(--primary-color);
}

.psd-nav-link.active i {
    opacity: 1;
    color: #70dda4;
}

@media (prefers-color-scheme: dark) {
    .psd-nav-link:hover {
        background: rgba(255, 255, 255, 0.06);
    }
}

/* ── In-page table of contents ─────────────────────────────── */
.psd-toc {
    background: var(--box-bg-color);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 28px;
    font-size: 0.9rem;
}

.psd-toc p {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.6;
    margin: 0 0 8px;
    line-height: 1;
}

.psd-toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 2;
    column-gap: 22px;
}

.psd-toc a {
    color: var(--text-color);
    text-decoration: none;
    opacity: 0.85;
}

.psd-toc a:hover {
    opacity: 1;
    text-decoration: underline;
    color: var(--btn-bg-color);
}

/* ── Headings ──────────────────────────────────────────────── */
.psd-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.25);
}

.psd-content h3 {
    font-size: 1.12rem;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 8px;
}

.psd-content h3 code,
.psd-content h2 code {
    font-size: inherit;
}

.psd-lead {
    opacity: 0.82;
    margin-bottom: 18px;
}

/* ── Inline code ───────────────────────────────────────────── */
.psd-content code {
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.86em;
    background: rgba(0, 44, 27, 0.1);
    color: var(--btn-bg-color);
    padding: 1px 6px;
    border-radius: 5px;
    word-break: break-word;
}

@media (prefers-color-scheme: dark) {
    .psd-content code {
        background: rgba(255, 255, 255, 0.08);
        color: #ffb27a;
    }
}

/* ── Code blocks (extends .dev-code-block from custom.css) ──── */
.psd-code {
    background: var(--primary-color);
    color: #c8ffd4;
    border-radius: 10px;
    padding: 16px 18px;
    font-size: 0.84rem;
    line-height: 1.65;
    overflow-x: auto;
    margin: 8px 0 18px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    direction: ltr;
}

.psd-code pre {
    margin: 0;
    background: none;
    color: inherit;
    white-space: pre;
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
}

.psd-code code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

.psd-code-title {
    display: inline-block;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    opacity: 0.7;
    margin: 6px 0 -4px 2px;
    color: var(--text-color);
}

/* ── Reference cards ───────────────────────────────────────── */
.psd-card {
    background: var(--box-bg-color);
    border-radius: 12px;
    padding: 22px 22px 10px;
    margin-bottom: 18px;
}

.psd-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.psd-sys-icon {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: #70dda4;
    font-size: 1rem;
}

.psd-sys-name {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}

.psd-sys-name code {
    background: none;
    color: inherit;
    padding: 0;
}

.psd-sys-sub {
    font-size: 0.85rem;
    opacity: 0.7;
    margin: 0;
}

/* ── Method / signature list ───────────────────────────────── */
.psd-sig {
    display: block;
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.84rem;
    background: var(--primary-color);
    color: #c8ffd4;
    border-radius: 7px;
    padding: 7px 12px;
    margin-bottom: 6px;
    overflow-x: auto;
    white-space: nowrap;
}

.psd-sig .k { color: #ffb27a; }       /* object / keyword         */
.psd-sig .m { color: #c8ffd4; }       /* method name              */
.psd-sig .a { color: #9fd0ff; }       /* arguments                */

.psd-method-desc {
    font-size: 0.9rem;
    opacity: 0.82;
    margin: 0 0 16px;
    padding-left: 2px;
}

/* ── Tables ────────────────────────────────────────────────── */
.psd-table {
    width: 100%;
    font-size: 0.88rem;
    border-collapse: collapse;
    margin: 4px 0 20px;
}

.psd-table th,
.psd-table td {
    text-align: start;
    padding: 9px 12px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.22);
    vertical-align: top;
}

.psd-table th {
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    opacity: 0.7;
}

.psd-table td code {
    white-space: nowrap;
}

.psd-table tr:last-child td {
    border-bottom: none;
}

/* ── Pills / badges ────────────────────────────────────────── */
.psd-pill {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 2px 9px;
    border-radius: 20px;
    background: rgba(25, 135, 84, 0.16);
    color: #198754;
    white-space: nowrap;
}

.psd-pill.read   { background: rgba(13, 110, 253, 0.16); color: #0d6efd; }
.psd-pill.write  { background: rgba(253, 126, 20, 0.16); color: #fd7e14; }
.psd-pill.rw     { background: rgba(111, 66, 193, 0.16); color: #8a63d2; }

/* ── Callouts ──────────────────────────────────────────────── */
.psd-note {
    border-inline-start: 3px solid var(--btn-bg-color);
    background: var(--box-bg-color);
    border-radius: 0 8px 8px 0;
    padding: 12px 16px;
    margin: 14px 0 20px;
    font-size: 0.9rem;
}

.psd-note.tip   { border-inline-start-color: #198754; }
.psd-note.warn  { border-inline-start-color: #e0a800; }

.psd-note .psd-note-label {
    display: block;
    font-weight: 700;
    font-size: 0.74rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 3px;
}

/* ── Pipeline / step strip ─────────────────────────────────── */
.psd-pipeline {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 10px;
    margin: 18px 0 24px;
}

.psd-pipe-step {
    flex: 1 1 130px;
    background: var(--box-bg-color);
    border-radius: 10px;
    padding: 14px 14px;
    text-align: center;
    position: relative;
}

.psd-pipe-step .psd-pipe-stage {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    display: block;
    margin-bottom: 4px;
}

.psd-pipe-step .psd-pipe-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.psd-pipe-step .psd-pipe-arrow {
    position: absolute;
    inset-inline-end: -11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--btn-bg-color);
    font-size: 0.8rem;
    z-index: 2;
}

.psd-pipe-step:last-child .psd-pipe-arrow { display: none; }

[dir='rtl'] .psd-pipe-step .psd-pipe-arrow {
    transform: translateY(-50%) scaleX(-1);
}

/* ── Feature grid (overview) ───────────────────────────────── */
.psd-feature {
    background: var(--box-bg-color);
    border-radius: 12px;
    padding: 20px 20px;
    height: 100%;
}

.psd-feature-icon {
    font-size: 1.4rem;
    color: var(--btn-bg-color);
    margin-bottom: 10px;
}

.psd-feature h3 {
    font-size: 1.02rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.psd-feature p {
    font-size: 0.88rem;
    opacity: 0.8;
    margin: 0;
    line-height: 1.6;
}

/* ── Pager (prev / next at page bottom) ────────────────────── */
.psd-pager {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 36px;
    flex-wrap: wrap;
}

.psd-pager a {
    flex: 1 1 220px;
    background: var(--box-bg-color);
    border-radius: 10px;
    padding: 14px 18px;
    text-decoration: none;
    color: var(--text-color);
    transition: transform 140ms ease, box-shadow 140ms ease;
}

.psd-pager a:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.6rem 1.4rem rgba(0, 0, 0, 0.12);
    color: var(--text-color);
}

.psd-pager a.next { text-align: end; }

.psd-pager .psd-pager-dir {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    opacity: 0.6;
}

.psd-pager .psd-pager-title {
    font-weight: 700;
    font-size: 0.98rem;
    margin-top: 2px;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 991.98px) {
    .psd-sidebar {
        position: static;
        top: auto;
        margin-bottom: 22px;
    }
    .psd-toc ul { columns: 1; }
}

@media (max-width: 575.98px) {
    .psd-layout { padding: 4px 12px 40px; }
    .psd-hero { padding-top: 24px; }
    .psd-sig { font-size: 0.78rem; }
}
