/* =============================================================================
   Breakside documentation page (/docs.html)

   Layers on top of landing/landing.css for the design tokens (--brand-orange,
   --gray-*, --font-display, spacing, radii) so the docs read as the same site.
   Everything here is doc-page furniture: the section rail, the entry rows, and
   the phone-framed clips.
   ============================================================================= */

/* --- Theme ---------------------------------------------------------------
   The clips ship in light and dark and the page picks a pair at runtime
   (see docs.html), so the page itself has to move with them — dark phone
   screenshots on a white page is the mismatch this whole exercise is about.

   One set of semantic names, defined light and redefined under
   prefers-color-scheme: dark. The phone bezel and the screen behind the video
   are deliberately NOT in here: they're a physical object and stay dark in
   both themes. */

:root {
    --docs-page: var(--gray-50);
    --docs-surface: #fff;
    --docs-line: var(--gray-200);
    --docs-code-bg: var(--gray-100);
    --docs-text-strong: var(--gray-900);
    --docs-text: var(--gray-800);
    --docs-text-soft: var(--gray-600);
    --docs-text-faint: var(--gray-500);
}

@media (prefers-color-scheme: dark) {
    :root {
        --docs-page: #0a0a0a;
        --docs-surface: #161616;
        --docs-line: #2a2a2a;
        --docs-code-bg: #1d1d1d;
        --docs-text-strong: #f2f2f2;
        --docs-text: #dcdcdc;
        --docs-text-soft: #b0b0b0;
        --docs-text-faint: #8a8a8a;
    }
}

body.docs-body {
    background: var(--docs-page);
    color: var(--docs-text);
    font-family: var(--font-display);
}

/* --- Header ------------------------------------------------------------- */

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

.docs-header-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: var(--space-sm) var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.docs-header-logo {
    height: 34px;
    width: auto;
    display: block;
}

.docs-header-spacer { flex: 1; }

.docs-header-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--docs-text-soft);
    text-decoration: none;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-md);
}

.docs-header-link:hover { color: var(--brand-orange); background: var(--docs-page); }

.docs-header-link.primary {
    color: #fff;
    background: var(--brand-orange);
}

.docs-header-link.primary:hover { background: var(--brand-orange-dark); color: #fff; }

/* --- Layout ------------------------------------------------------------- */

.docs-layout {
    max-width: 1120px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg) var(--space-3xl);
    display: grid;
    grid-template-columns: 200px minmax(0, 1fr);
    gap: var(--space-2xl);
    align-items: start;
}

.docs-rail {
    position: sticky;
    top: 72px;
    font-size: 0.875rem;
}

.docs-rail-title {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
    color: var(--docs-text-faint);
    margin-bottom: var(--space-sm);
}

.docs-rail a {
    display: block;
    padding: 4px 0 4px 10px;
    color: var(--docs-text-soft);
    text-decoration: none;
    border-left: 2px solid var(--docs-line);
    line-height: 1.4;
}

.docs-rail a:hover { color: var(--brand-orange); border-left-color: var(--brand-orange-light); }
.docs-rail a.section { font-weight: 700; color: var(--docs-text); margin-top: var(--space-md); }
.docs-rail a.section:first-child { margin-top: 0; }

/* --- Intro -------------------------------------------------------------- */

.docs-intro { margin-bottom: var(--space-2xl); }

.docs-intro h1 {
    font-size: 2rem;
    line-height: 1.15;
    margin-bottom: var(--space-sm);
    color: var(--docs-text-strong);
}

.docs-intro p {
    color: var(--docs-text-soft);
    max-width: 62ch;
    line-height: 1.6;
}

.docs-intro p + p { margin-top: var(--space-sm); }

/* --- Sections ----------------------------------------------------------- */

.docs-section { margin-bottom: var(--space-3xl); scroll-margin-top: 72px; }

.docs-section-head {
    border-bottom: 2px solid var(--brand-orange);
    padding-bottom: var(--space-sm);
    margin-bottom: var(--space-xl);
}

.docs-section-head h2 {
    font-size: 1.5rem;
    color: var(--docs-text-strong);
}

.docs-section-head p {
    color: var(--docs-text-faint);
    font-size: 0.95rem;
    margin-top: 2px;
}

/* --- Entries ------------------------------------------------------------ */

.docs-entry {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 200px;
    gap: var(--space-xl);
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--docs-line);
    /* Centered, not top-aligned: a short paragraph pinned to the top of a
       380px phone reads as a layout bug rather than as a caption. */
    align-items: center;
    scroll-margin-top: 72px;
}

.docs-entry:first-of-type { border-top: none; padding-top: 0; }

/* Text-only entries get the full width. */
.docs-entry.no-clip { grid-template-columns: minmax(0, 1fr); }

.docs-entry h3 {
    font-size: 1.1rem;
    color: var(--docs-text-strong);
    margin-bottom: var(--space-sm);
}

.docs-entry p,
.docs-entry li {
    color: var(--docs-text-soft);
    line-height: 1.65;
    max-width: 60ch;
}

.docs-entry p + p { margin-top: var(--space-sm); }

.docs-entry ul {
    margin: var(--space-sm) 0 0 1.1rem;
    display: grid;
    gap: 4px;
}

.docs-entry strong { color: var(--docs-text); font-weight: 600; }

.docs-entry a, .docs-intro a { color: var(--brand-orange); }

.docs-entry code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--docs-code-bg);
    border: 1px solid var(--docs-line);
    border-radius: var(--radius-sm);
    padding: 1px 5px;
    color: var(--docs-text);
}

.docs-note a { color: var(--brand-orange); }

.docs-note {
    margin-top: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--docs-surface);
    border: 1px solid var(--docs-line);
    border-left: 3px solid var(--accent-purple);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

/* --- Clips -------------------------------------------------------------- */

/* Clips are 480×960, so the screen is exactly 1:2 — sizing the frame to match
   means object-fit: cover crops nothing and the app's header stays visible. */
.docs-clip {
    --clip-w: 180px;
    justify-self: center;
    width: calc(var(--clip-w) + 20px);
}

.docs-clip .device-frame {
    width: calc(var(--clip-w) + 20px);
    height: calc(var(--clip-w) * 2 + 20px);
    border-radius: 30px;
    padding: 10px;
    background: linear-gradient(145deg, var(--gray-700), var(--gray-800));
    box-shadow: 0 18px 34px -14px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.docs-clip .device-screen {
    position: relative;   /* containing block for .device-shade */
    width: 100%;
    height: 100%;
    border-radius: 22px;
    overflow: hidden;
    background: var(--gray-900);
    cursor: pointer;
}

/* Restart transition. A fade through black, not a wipe: a wipe is directional
   and competes with the app's own motion inside the frame, and a dip to white
   is harsh against the dark theme. What goes dark here reads as the phone's
   screen, which is why the same treatment works in both palettes. */
.docs-clip .device-shade {
    position: absolute;
    inset: 0;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 640ms ease;   /* must match FADE_MS in docs.html */
}

.docs-clip .device-shade.on { opacity: 1; }

.docs-clip video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}

/* --- Footer ------------------------------------------------------------- */

.docs-footer {
    border-top: 1px solid var(--docs-line);
    background: var(--docs-surface);
}

.docs-footer-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-lg);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    align-items: center;
    font-size: 0.875rem;
    color: var(--docs-text-faint);
}

.docs-footer a { color: var(--docs-text-soft); text-decoration: none; }
.docs-footer a:hover { color: var(--brand-orange); }

/* --- Responsive --------------------------------------------------------- */

@media (max-width: 900px) {
    .docs-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-lg);
        padding: var(--space-lg) var(--space-md) var(--space-2xl);
    }

    /* On a phone, only one thing stays pinned. The rail is the useful one, so
       the header scrolls away and the rail takes the top. */
    .docs-header { position: static; }

    .docs-section, .docs-entry { scroll-margin-top: 60px; }

    .docs-rail {
        position: sticky;
        top: 0;
        background: var(--docs-page);
        border-bottom: 1px solid var(--docs-line);
        margin: 0 calc(-1 * var(--space-md));
        padding: var(--space-sm) var(--space-md);
        display: flex;
        gap: var(--space-sm);
        overflow-x: auto;
        z-index: 40;
    }

    .docs-rail-title, .docs-rail a:not(.section) { display: none; }

    .docs-rail a.section {
        margin-top: 0;
        border-left: none;
        white-space: nowrap;
        padding: 4px 10px;
        border-radius: var(--radius-full);
        background: var(--docs-surface);
        border: 1px solid var(--docs-line);
    }

    .docs-entry {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-lg);
    }

    /* Stacked layout has the width to spare, and a phone screenshot on a phone
       wants to be nearer life size. */
    .docs-clip {
        --clip-w: 240px;
        justify-self: center;
    }
}
