/* MaxLTV docs shell.
   Design tokens, base typography and buttons come from the marketing
   stylesheet (https://maxltv.ai/styles.css), loaded first. This file only
   adds the docs chrome: header, sidebar, article column and doc components. */

.docs-skip {
    position: absolute;
    left: -9999px;
}

.docs-skip:focus {
    left: 1rem;
    top: 1rem;
    z-index: 100;
    padding: 0.5rem 0.875rem;
    background: var(--foreground);
    color: var(--background);
    border-radius: 6px;
}

/* Header */
.docs-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--background);
    border-bottom: 1px solid var(--border);
}

.docs-header__inner {
    max-width: 87.5rem;
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.docs-header__brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    color: var(--foreground);
}

.docs-header__brand img {
    height: 28px;
    width: auto;
    display: block;
}

.docs-header__label {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted-foreground);
    border-left: 1px solid var(--border);
    padding-left: 0.625rem;
}

.docs-header__spacer {
    flex: 1;
}

.docs-header__links {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    font-size: 0.9375rem;
}

.docs-header__links a {
    color: var(--muted-foreground);
    text-decoration: none;
    white-space: nowrap;
}

@media (max-width: 480px) {
    .docs-header__inner {
        padding: 0.75rem 1rem;
        gap: 0.625rem;
    }

    .docs-header__links {
        gap: 0.75rem;
        font-size: 0.8125rem;
    }
}

.docs-header__links a:hover {
    color: var(--foreground);
}

/* Header search */
.docs-search {
    position: relative;
    width: 17rem;
}

.docs-search__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.docs-search__icon {
    position: absolute;
    left: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted-foreground);
    pointer-events: none;
}

.docs-search__input {
    width: 100%;
    height: 2.25rem;
    padding: 0 2.25rem 0 2rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--secondary);
    color: var(--foreground);
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    -webkit-appearance: none;
    appearance: none;
}

.docs-search__input::placeholder {
    color: var(--muted-foreground);
}

.docs-search__input::-webkit-search-cancel-button {
    display: none;
}

.docs-search__input:focus {
    outline: none;
    background: var(--background);
    border-color: var(--foreground);
}

.docs-search__key {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    min-width: 1.25rem;
    padding: 0.0625rem 0.3125rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--background);
    color: var(--muted-foreground);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    line-height: 1.4;
    text-align: center;
    pointer-events: none;
}

.docs-search__input:focus ~ .docs-search__key,
.docs-search__input:not(:placeholder-shown) ~ .docs-search__key {
    display: none;
}

.docs-search__panel {
    position: absolute;
    top: calc(100% + 0.375rem);
    right: 0;
    width: min(32rem, calc(100vw - 2rem));
    max-height: min(28rem, calc(100vh - 6rem));
    overflow-y: auto;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.docs-search__panel[hidden] {
    display: none;
}

.docs-search__results {
    list-style: none;
    margin: 0;
    padding: 0.375rem;
}

.docs-search__results:empty {
    display: none;
}

/* Doubled class beats the marketing stylesheet's a:not(.btn-primary):not(.btn-secondary) */
.docs-search__result.docs-search__result a {
    display: block;
    padding: 0.625rem 0.75rem;
    border-radius: 6px;
    color: var(--foreground);
    text-decoration: none;
}

.docs-search__result.docs-search__result a:hover {
    color: var(--foreground);
}

.docs-search__result[aria-selected="true"] a,
.docs-search__result a:hover {
    background: var(--secondary);
}

.docs-search__meta {
    display: block;
    margin-bottom: 0.125rem;
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted-foreground);
}

.docs-search__title {
    display: block;
    font-weight: 600;
    font-size: 0.9375rem;
    line-height: 1.4;
}

.docs-search__section {
    font-weight: 400;
    color: var(--muted-foreground);
}

.docs-search__snippet {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--gray-700);
}

.docs-search__snippet mark,
.docs-search__title mark {
    background: rgb(127 255 0 / 0.35);
    color: inherit;
    border-radius: 2px;
}

.docs-search__status {
    margin: 0;
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.docs-search__status:empty {
    display: none;
}

.docs-search__results:not(:empty) + .docs-search__status {
    border-top: 1px solid var(--border);
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

/* Below 720px the search box drops to its own full-width row under the header */
@media (max-width: 719px) {
    .docs-header__inner {
        flex-wrap: wrap;
    }

    .docs-search {
        order: 10;
        width: 100%;
    }

    .docs-search__key {
        display: none;
    }

    .docs-search__panel {
        left: 0;
        right: 0;
        width: auto;
    }
}

/* Sidebar toggle, mobile only */
.docs-nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    cursor: pointer;
}

@media (min-width: 900px) {
    .docs-nav-toggle {
        display: none;
    }
}

/* Layout */
.docs-layout {
    max-width: 87.5rem;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2.5rem;
}

@media (min-width: 900px) {
    .docs-layout {
        grid-template-columns: 16rem minmax(0, 1fr);
        gap: 3rem;
    }
}

/* Sidebar */
.docs-sidebar {
    display: none;
    padding: 2rem 0;
}

.docs-sidebar.is-open {
    display: block;
}

@media (min-width: 900px) {
    .docs-sidebar {
        display: block;
        position: sticky;
        top: 3.75rem;
        align-self: start;
        max-height: calc(100vh - 4.5rem);
        overflow-y: auto;
        border-right: 1px solid var(--border);
        padding-right: 1.25rem;
    }
}

.docs-sidebar__group {
    margin-bottom: 1.5rem;
}

.docs-sidebar__title {
    margin: 0 0 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted-foreground);
}

.docs-sidebar__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.125rem;
}

.docs-sidebar__list a {
    display: block;
    padding: 0.3125rem 0.625rem;
    margin-left: -0.625rem;
    border-radius: 4px;
    color: var(--gray-700);
    font-size: 0.9375rem;
    text-decoration: none;
    line-height: 1.5;
}

.docs-sidebar__list a:hover {
    background: var(--secondary);
    color: var(--foreground);
}

.docs-sidebar__list a[aria-current="page"] {
    background: var(--secondary);
    color: var(--foreground);
    font-weight: 600;
}

/* Article column */
.docs-main {
    padding: 2.5rem 0 5rem;
    min-width: 0;
}

.docs-article {
    max-width: 46rem;
}

.docs-breadcrumb {
    margin: 0 0 0.75rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.docs-breadcrumb a {
    color: var(--muted-foreground);
}

.docs-article h1 {
    margin: 0 0 0.75rem;
    font-family: var(--font-display);
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.docs-lede {
    margin: 0 0 2rem;
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--gray-700);
}

.docs-article h2 {
    margin: 2.75rem 0 1rem;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.docs-article h3 {
    margin: 2rem 0 0.75rem;
    font-family: var(--font-sans);
    font-size: 1.125rem;
    font-weight: 700;
}

.docs-article h4 {
    margin: 1.75rem 0 0.625rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 700;
    color: var(--foreground);
}

.docs-article p {
    margin: 0 0 1.125rem;
    line-height: 1.75;
    color: var(--gray-700);
}

.docs-article ul,
.docs-article ol {
    margin: 0 0 1.125rem;
    padding-left: 1.375rem;
    line-height: 1.75;
    color: var(--gray-700);
}

.docs-article li {
    margin-bottom: 0.4rem;
}

.docs-article table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
    margin: 0 0 1.5rem;
}

.docs-article th,
.docs-article td {
    text-align: left;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border);
}

.docs-article th {
    background: var(--secondary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.docs-table-scroll {
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

/* UI paths and labels the reader clicks in Shopify, Recharge or MaxLTV */
.docs-path {
    font-family: var(--font-mono);
    font-size: 0.9em;
    font-weight: 700;
    color: var(--foreground);
    /* Long setting and event names (subscriptionNextBillingDateUpdated) wrap
       on a phone instead of widening the step card past the screen. */
    overflow-wrap: anywhere;
}

.docs-callout {
    margin: 0 0 1.5rem;
    padding: 0.875rem 1.125rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--foreground);
    border-radius: 0 6px 6px 0;
    background: var(--secondary);
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--gray-700);
}

.docs-callout strong {
    color: var(--foreground);
}

/* Numbered steps */
.docs-steps {
    list-style: none;
    counter-reset: docs-step;
    margin: 0 0 1.5rem;
    padding: 0;
    display: grid;
    gap: 1rem;
}

.docs-step {
    counter-increment: docs-step;
    position: relative;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.375rem 1.375rem 1.375rem 4rem;
    background: var(--background);
}

.docs-step::before {
    content: counter(docs-step);
    position: absolute;
    left: 1.125rem;
    top: 1.375rem;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--secondary);
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 700;
}

.docs-step--ours {
    background: var(--secondary);
}

.docs-step__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.75rem;
}

.docs-step__head h3 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.docs-step__time {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted-foreground);
    white-space: nowrap;
}

.docs-step p:last-child,
.docs-step ul:last-child,
.docs-step ol:last-child {
    margin-bottom: 0;
}

.docs-tag {
    display: inline-block;
    padding: 0.0625rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--secondary);
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-foreground);
}

.docs-tag--you {
    border-color: var(--foreground);
    color: var(--foreground);
}

.docs-note {
    margin: 1rem 0 0;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--muted-foreground);
    line-height: 1.7;
}

/* Docs home */
.docs-home-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin: 0 0 2rem;
}

@media (min-width: 640px) {
    .docs-home-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.docs-card {
    display: block;
    padding: 1.25rem 1.375rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s;
}

.docs-card:hover {
    border-color: var(--foreground);
}

.docs-card h3 {
    margin: 0 0 0.375rem;
    font-family: var(--font-display);
    font-size: 1.0625rem;
    font-weight: 700;
}

.docs-card p {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--muted-foreground);
}

/* Footer */
.docs-footer {
    border-top: 1px solid var(--border);
    margin-top: 3rem;
    padding: 1.75rem 0 3rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.docs-footer a {
    color: var(--muted-foreground);
}

@media (max-width: 480px) {
    .docs-step {
        padding: 3.5rem 1.125rem 1.25rem;
    }

    .docs-step::before {
        left: 1.125rem;
        top: 1.125rem;
    }
}

/* Draft affordances. A page carrying .docs-draft is not finished: it stays
   noindex, Disallow'd and out of the sidebar until the gaps are filled.
   .docs-gap marks a specific fact only the product team can supply. */
.docs-draft {
    margin: 0 0 2rem;
    padding: 0.875rem 1.125rem;
    border: 1px solid var(--foreground);
    border-radius: 6px;
    background: var(--brand-gold, var(--secondary));
    font-size: 0.9375rem;
    line-height: 1.65;
    color: var(--foreground);
}

.docs-draft strong {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.25rem;
}

.docs-gap {
    display: block;
    margin: 0 0 1.125rem;
    padding: 0.75rem 1rem;
    border-left: 3px solid var(--foreground);
    background: repeating-linear-gradient(
        45deg,
        var(--secondary),
        var(--secondary) 10px,
        transparent 10px,
        transparent 20px
    );
    font-size: 0.9375rem;
    line-height: 1.65;
    color: var(--gray-700);
}

.docs-gap::before {
    content: "Needs your input";
    display: block;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--foreground);
    margin-bottom: 0.25rem;
}

/* Screenshots in a doc. Bordered because most are UI captures on a white
   background, which otherwise bleed into the page. */
.docs-figure {
    margin: 1.5rem 0 1.75rem;
}

.docs-figure img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.docs-figure figcaption {
    margin-top: 0.625rem;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--muted-foreground);
}
