/* ==========================================================================
   Cheat sheet pages — loaded after ../styles.css, which supplies the
   design tokens (--ink, --teal, --cream, fonts) and the nav/footer rules.
   ========================================================================== */

:root {
    --code-bg: #0d1620;
    --code-bar: #16212d;
    --code-text: #e6ebf0;
    --code-muted: #8b98a6;
    --code-accent: #5fb3f2;
    --mono: ui-monospace, 'Cascadia Code', 'JetBrains Mono', 'SF Mono', Consolas, 'Liberation Mono', monospace;
}

html {
    scroll-padding-top: 88px;
}

/* ==========================================================================
   Page header
   ========================================================================== */
.doc-hero {
    padding: 60px 24px 40px;
    background: var(--sand);
    border-bottom: 1px solid var(--border);
}

.doc-hero-inner {
    max-width: 1180px;
    margin: 0 auto;
}

.crumbs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--ink-soft);
    margin-bottom: 18px;
}

.crumbs a {
    color: var(--teal);
    text-decoration: none;
    font-weight: 600;
}

.crumbs a:hover {
    text-decoration: underline;
}

.crumbs span[aria-hidden] {
    opacity: 0.5;
}

.doc-title {
    font-family: var(--font-display);
    font-size: clamp(1.9rem, 4.2vw, 2.9rem);
    font-weight: 600;
    line-height: 1.12;
    letter-spacing: -0.015em;
    max-width: 22ch;
}

.doc-lead {
    margin-top: 16px;
    max-width: 65ch;
    font-size: 1.05rem;
    color: var(--ink-soft);
}

.doc-meta {
    margin-top: 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.doc-meta .chip {
    background: var(--teal-soft);
    color: var(--teal-deep);
}

.doc-meta .chip-alt {
    background: var(--amber-soft);
    color: var(--amber-ink);
}

/* ==========================================================================
   Layout: sticky table of contents + article
   ========================================================================== */
.doc-shell {
    max-width: 1180px;
    margin: 0 auto;
    padding: 48px 24px 96px;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 56px;
    align-items: start;
}

.doc-toc {
    position: sticky;
    top: 96px;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    padding-right: 8px;
    font-size: 0.9rem;
}

.doc-toc h2 {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--coral);
    margin-bottom: 14px;
}

.doc-toc ol {
    list-style: none;
    border-left: 2px solid var(--border);
}

.doc-toc a {
    display: block;
    padding: 6px 0 6px 16px;
    margin-left: -2px;
    border-left: 2px solid transparent;
    color: var(--ink-soft);
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.doc-toc a:hover {
    color: var(--teal-deep);
}

.doc-toc a.is-active {
    color: var(--teal-deep);
    border-left-color: var(--teal);
    font-weight: 600;
}

/* ==========================================================================
   Article typography
   ========================================================================== */
.doc-body {
    min-width: 0;
    font-size: 1.02rem;
}

.doc-body > section + section {
    margin-top: 8px;
}

.doc-body h2 {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 2.6vw, 1.85rem);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    margin: 64px 0 20px;
    padding-top: 26px;
    border-top: 1px solid var(--border);
}

.doc-body > section:first-child > h2:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.doc-body h3 {
    font-size: 1.16rem;
    font-weight: 700;
    margin: 40px 0 14px;
}

.doc-body h4 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--teal-deep);
    margin: 30px 0 12px;
}

.doc-body p {
    color: var(--ink-soft);
    margin-bottom: 18px;
}

.doc-body strong {
    color: var(--ink);
    font-weight: 700;
}

.doc-body a {
    color: var(--teal);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

.doc-body a:hover {
    color: var(--coral-ink);
}

.doc-body ul,
.doc-body ol {
    margin: 0 0 18px 22px;
    color: var(--ink-soft);
}

.doc-body li {
    margin-bottom: 8px;
}

.doc-body li > ul,
.doc-body li > ol {
    margin-top: 8px;
    margin-bottom: 0;
}

.doc-body li::marker {
    color: var(--teal);
}

.doc-body hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 40px 0;
}

/* Anchor affordance on headings */
.doc-body h2,
.doc-body h3 {
    scroll-margin-top: 92px;
}

.anchor {
    margin-left: 10px;
    font-size: 0.8em;
    color: var(--border);
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.2s ease, color 0.2s ease;
}

h2:hover > .anchor,
h3:hover > .anchor,
.anchor:focus-visible {
    opacity: 1;
    color: var(--teal);
}

/* Inline code */
.doc-body :not(pre) > code {
    font-family: var(--mono);
    font-size: 0.86em;
    background: var(--teal-soft);
    color: var(--teal-deep);
    padding: 0.12em 0.4em;
    border-radius: 5px;
    word-break: break-word;
}

.doc-body td > code,
.doc-body th > code {
    white-space: nowrap;
}

/* Callout — the markdown blockquote */
.note {
    border-left: 3px solid var(--teal);
    background: var(--teal-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 16px 20px;
    margin: 24px 0;
}

.note > :last-child {
    margin-bottom: 0;
}

.note--warn {
    border-left-color: var(--coral);
    background: var(--coral-soft);
}

.note--warn p {
    color: var(--coral-ink);
}

.note--warn strong,
.note--warn code {
    color: var(--coral-ink);
}

.note--warn :not(pre) > code {
    background: rgba(164, 86, 28, 0.14);
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap {
    margin: 24px 0;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    -webkit-overflow-scrolling: touch;
}

.doc-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.94rem;
}

.doc-body th {
    text-align: left;
    font-weight: 700;
    color: var(--ink);
    background: var(--sand);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.doc-body td {
    padding: 12px 16px;
    color: var(--ink-soft);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.doc-body tbody tr:last-child td {
    border-bottom: 0;
}

.doc-body tbody tr:hover td {
    background: rgba(220, 229, 237, 0.4);
}

/* ==========================================================================
   Code blocks
   ========================================================================== */
.codeblock {
    margin: 24px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--code-bg);
    border: 1px solid var(--code-bar);
    box-shadow: var(--shadow);
}

.codeblock__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 7px 8px 7px 16px;
    background: var(--code-bar);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.codeblock__lang {
    font: 600 0.7rem/1 var(--mono);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--code-muted);
}

.codeblock__copy {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 11px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: transparent;
    color: var(--code-text);
    font: 600 0.75rem/1 var(--font-body);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.codeblock__copy:hover {
    background: rgba(255, 255, 255, 0.09);
}

.codeblock__copy:focus-visible {
    outline: 2px solid var(--code-accent);
    outline-offset: 2px;
}

.codeblock__copy[data-state='done'] {
    color: var(--code-accent);
    border-color: var(--code-accent);
}

.codeblock__copy[data-state='fail'] {
    color: #e4854f;
    border-color: #e4854f;
}

.codeblock__copy svg {
    width: 13px;
    height: 13px;
    flex: none;
}

.codeblock__copy .icon-done {
    display: none;
}

.codeblock__copy[data-state='done'] .icon-copy {
    display: none;
}

.codeblock__copy[data-state='done'] .icon-done {
    display: block;
}

/* Never wrap: a soft-wrapped PowerShell backtick continuation is a broken
   command once pasted, and the reader cannot tell it was the page's fault. */
.codeblock pre {
    margin: 0;
    padding: 16px 18px 18px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.codeblock pre code {
    display: block;
    font-family: var(--mono);
    font-size: 0.84rem;
    line-height: 1.65;
    color: var(--code-text);
    white-space: pre;
    background: none;
    padding: 0;
    tab-size: 2;
}

.codeblock pre::-webkit-scrollbar {
    height: 9px;
}

.codeblock pre::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 999px;
}

/* ==========================================================================
   highlight.js tokens, tuned to the site palette
   ========================================================================== */
.hljs-comment,
.hljs-quote {
    color: var(--code-muted);
    font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-section,
.hljs-doctag,
.hljs-type {
    color: #e88a5a;
}

.hljs-string,
.hljs-regexp,
.hljs-addition {
    color: #8fcf9a;
}

.hljs-number,
.hljs-symbol,
.hljs-bullet,
.hljs-meta {
    color: #d9b76a;
}

.hljs-built_in,
.hljs-title,
.hljs-title.function_,
.hljs-name,
.hljs-selector-id,
.hljs-selector-class {
    color: var(--code-accent);
}

.hljs-attr,
.hljs-attribute,
.hljs-property,
.hljs-template-variable,
.hljs-variable {
    color: #8fc6e8;
}

.hljs-params,
.hljs-punctuation,
.hljs-operator {
    color: #c3cedb;
}

.hljs-deletion {
    color: #e4854f;
}

.hljs-emphasis {
    font-style: italic;
}

.hljs-strong {
    font-weight: 700;
}

.hljs-link {
    text-decoration: underline;
}

/* ==========================================================================
   Footer navigation between sheets
   ========================================================================== */
.doc-next {
    margin-top: 72px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.doc-next a {
    display: block;
    padding: 20px 22px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    text-decoration: none;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.doc-next a:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: transparent;
}

.doc-next .doc-next__label {
    display: block;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--coral);
    margin-bottom: 6px;
}

.doc-next .doc-next__title {
    display: block;
    color: var(--ink);
    font-weight: 700;
    line-height: 1.35;
}

/* ==========================================================================
   Back to top
   ========================================================================== */
.to-top {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 40;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: var(--teal);
    color: #fff;
    cursor: pointer;
    box-shadow: var(--shadow-hover);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease, background 0.25s ease;
}

.to-top.is-visible {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.to-top:hover {
    background: var(--teal-deep);
}

.to-top svg {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
    .doc-shell {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
        padding-top: 32px;
    }

    .doc-toc {
        position: static;
        max-height: none;
        overflow: visible;
        margin-bottom: 40px;
        padding: 20px 22px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
    }

    .doc-toc ol {
        columns: 2;
        column-gap: 28px;
    }
}

@media (max-width: 640px) {
    .doc-hero {
        padding: 40px 20px 32px;
    }

    .doc-shell {
        padding: 28px 20px 72px;
    }

    .doc-toc ol {
        columns: 1;
    }

    .doc-body {
        font-size: 0.98rem;
    }

    .codeblock pre code {
        font-size: 0.79rem;
    }

    .to-top {
        right: 14px;
        bottom: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .codeblock__copy,
    .sheet-card,
    .doc-next a,
    .to-top {
        transition: none;
    }
}
