/*
 * RESTRICTED ACCESS: This software is proprietary and closed-source.
 * NO AI TRAINING OR ANALYSIS: Use of this code for machine learning training,
 * automated analysis, ingestion by AI agents, or dataset creation is prohibited
 * without prior written permission from the copyright holder.
 * See TERMS.txt and https://www.yoozecase.com/terms
 *
 * Purpose: Styling for the Manual element.
 *
 * Every neutral colour is derived from the inherited text colour, never from a
 * fixed light or dark value and never from prefers-color-scheme. The manual
 * sits inside someone else's theme: what matters is whether THIS SECTION is on
 * a light or dark background, which only the inherited colour knows. A reader
 * whose operating system is in dark mode may well be looking at a light page.
 *
 * Typography is left to the theme: a manual should read like the site it is on.
 */

.yc-manual {
    --yc-manual-accent: #0ca678;
    --yc-manual-space: 1.5rem;
    --yc-manual-radius: 4px;

    /* Neutral grey reads acceptably on light and dark alike; browsers that
       support color-mix get a properly derived value below. */
    --yc-manual-border: rgba(128, 128, 128, 0.35);
    --yc-manual-surface: rgba(128, 128, 128, 0.12);
}

@supports (color: color-mix(in srgb, currentColor 50%, transparent)) {
    .yc-manual {
        --yc-manual-border: color-mix(in srgb, currentColor 22%, transparent);
        --yc-manual-surface: color-mix(in srgb, currentColor 7%, transparent);
    }
}

/* Secondary text: the theme's own colour, softened. Never a hardcoded grey,
   which is what made this text unreadable on a light background before. */
.yc-manual-toc-title,
.yc-manual-badge,
.yc-manual-crumb,
.yc-manual-desc-missing,
.yc-manual-muted,
.yc-manual-meta dt {
    color: inherit;
    opacity: 0.8;
}

/* Navigation views: one thing on screen at a time. Only applied once JS adds
   .yc-manual-nav, so with no JS the whole manual is a single readable page. */

.yc-manual-nav .yc-manual-landing { display: none; }
.yc-manual-nav.yc-manual-home .yc-manual-landing { display: block; }
.yc-manual-nav .yc-manual-chapter { display: none; }
.yc-manual-nav .yc-manual-chapter.is-active { display: block; }
.yc-manual-nav .yc-manual-chapter.section-view .yc-manual-section { display: none; }
.yc-manual-nav .yc-manual-chapter.section-view .yc-manual-section.is-active { display: block; }

/* While searching, everything is a candidate again; the filter's hidden
   attribute decides what shows. */
.yc-manual-nav.yc-manual-searching .yc-manual-landing { display: none; }
.yc-manual-nav.yc-manual-searching .yc-manual-chapter { display: block; }
.yc-manual-nav.yc-manual-searching .yc-manual-chapter.section-view .yc-manual-section { display: block; }
.yc-manual-nav.yc-manual-searching .yc-manual-chapter[hidden],
.yc-manual-nav.yc-manual-searching .yc-manual-section[hidden] { display: none; }

/* Current entry in the sidebar: where you are now. */
.yc-manual-nav-list a {
    display: block;
    border-left: 2px solid transparent;
    padding-left: .55rem;
    margin-left: -.55rem;
    transition: color 120ms ease, border-color 120ms ease;
}
.yc-manual-nav-list a.is-current {
    font-weight: 700;
    color: var(--yc-manual-accent);
    border-left-color: var(--yc-manual-accent);
}
@media (prefers-reduced-motion: reduce) {
    .yc-manual-nav-list a { transition: none; }
}

/* Overview cards on the landing view */
.yc-manual-overview { margin-top: var(--yc-manual-space); }
.yc-manual-overview-title {
    margin: 0 0 .75rem;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .72;
}
.yc-manual-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: .75rem;
}
.yc-manual-overview-card {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    padding: .9rem 1rem;
    border: 1px solid var(--yc-manual-border);
    border-radius: var(--yc-manual-radius);
    text-decoration: none;
    color: inherit;
    transition: border-color 120ms ease, transform 120ms ease;
}
.yc-manual-overview-card:hover {
    border-color: var(--yc-manual-accent);
    transform: translateY(-1px);
}
.yc-manual-overview-card:focus-visible {
    outline: 2px solid var(--yc-manual-accent);
    outline-offset: 2px;
}
.yc-manual-overview-name { font-weight: 600; }
.yc-manual-overview-meta { font-size: .82rem; opacity: .68; }

/* Media in authored content */
.yc-manual-media { margin: 0 0 var(--yc-manual-space); }
.yc-manual-img {
    max-width: 100%;
    height: auto;
    border-radius: var(--yc-manual-radius);
}
.yc-manual-img-zoom { cursor: zoom-in; }
.yc-manual-img-zoom:focus-visible {
    outline: 2px solid var(--yc-manual-accent);
    outline-offset: 2px;
}

/* Lightbox */
.yc-manual-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1040;
    align-items: center;
    justify-content: center;
    padding: 4vmin;
    background: rgba(0, 0, 0, 0.85);
}
.yc-manual-lightbox.is-open { display: flex; }
.yc-manual-lightbox-img {
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--yc-manual-radius);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}
.yc-manual-lightbox-close {
    position: absolute;
    top: 2vmin;
    right: 2vmin;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}
.yc-manual-lightbox-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Collapsible "advanced" section */
.yc-manual-section-advanced {
    margin-bottom: var(--yc-manual-space);
    border: 1px solid var(--yc-manual-border);
    border-radius: var(--yc-manual-radius);
    padding: 0 1rem;
}
.yc-manual-section-summary {
    cursor: pointer;
    list-style: none;
    padding: 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
}
.yc-manual-section-summary::-webkit-details-marker { display: none; }
.yc-manual-section-summary::before {
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 5px 0 5px 8px;
    border-color: transparent transparent transparent currentColor;
    transition: transform 120ms ease;
    opacity: 0.7;
}
.yc-manual-section-advanced[open] .yc-manual-section-summary::before {
    transform: rotate(90deg);
}
.yc-manual-section-summary .yc-manual-section-title {
    margin: 0;
}
.yc-manual-section-summary:focus-visible {
    outline: 2px solid var(--yc-manual-accent);
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    .yc-manual-section-summary::before { transition: none; }
}
.yc-manual-video {
    width: 100%;
    max-height: 32rem;
    border-radius: var(--yc-manual-radius);
    background: #000;
}
.yc-manual-yt,
.yc-manual-yt-frame {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: var(--yc-manual-radius);
}
.yc-manual-yt {
    position: relative;
    cursor: pointer;
    color: #fff;
    background: #111 center / cover no-repeat;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .6rem;
}
.yc-manual-yt-play {
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 14px 0 14px 24px;
    border-color: transparent transparent transparent currentColor;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,.5));
}
.yc-manual-yt-label { font-size: .9rem; opacity: .9; }
.yc-manual-yt:focus-visible { outline: 3px solid var(--yc-manual-accent); outline-offset: 2px; }

/* Search */

.yc-manual-search-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: var(--yc-manual-space);
}

.yc-manual-search {
    flex: 1 1 16rem;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--yc-manual-border);
    border-radius: var(--yc-manual-radius);
    background: transparent;
    color: inherit;
    font-size: 1rem;
}

.yc-manual-search:focus-visible {
    outline: 2px solid var(--yc-manual-accent);
    outline-offset: 1px;
}

.yc-manual-search-count {
    font-size: 0.85rem;
    opacity: 0.8;
}

/* The "no matches" line shows only when a search returns nothing; the root
   carries the class, set by JS, rather than relying on :has(). */
.yc-manual-search-empty {
    display: none;
    padding: 1rem 0;
    font-style: italic;
    opacity: 0.8;
}

.yc-manual-no-results .yc-manual-search-empty {
    display: block;
}

.yc-manual-hit {
    padding: 0 0.05em;
    border-radius: 2px;
    background: color-mix(in srgb, var(--yc-manual-accent) 30%, transparent);
    color: inherit;
}

@supports not (color: color-mix(in srgb, red 30%, transparent)) {
    .yc-manual-hit {
        background: rgba(12, 166, 120, 0.3);
    }
}

/* Table of contents */

.yc-manual-toc-title {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.yc-manual-toc .uk-nav-sub {
    padding-left: 1rem;
}

.yc-manual-toc a:focus-visible {
    outline: 2px solid var(--yc-manual-accent);
    outline-offset: 2px;
}

/* Contents toggle: hidden on desktop, a floating button on phones. */

.yc-manual-toc-toggle {
    display: none;
}

.yc-manual-toc-toggle-icon,
.yc-manual-toc-toggle-icon::before,
.yc-manual-toc-toggle-icon::after {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
}

.yc-manual-toc-toggle-icon {
    position: relative;
}

.yc-manual-toc-toggle-icon::before,
.yc-manual-toc-toggle-icon::after {
    content: '';
    position: absolute;
    left: 0;
}

.yc-manual-toc-toggle-icon::before {
    top: -6px;
}

.yc-manual-toc-toggle-icon::after {
    top: 6px;
}

.yc-manual-toc-backdrop {
    display: none;
}

/* Header */

.yc-manual-title {
    margin-bottom: 0.25rem;
}

.yc-manual-badge {
    display: inline-block;
    margin: 0 0 var(--yc-manual-space);
    padding: 0.2em 0.6em;
    border: 1px solid var(--yc-manual-border);
    border-radius: var(--yc-manual-radius);
    font-size: 0.8rem;
}

/* Chapters and sections */

.yc-manual-chapter + .yc-manual-chapter {
    margin-top: calc(var(--yc-manual-space) * 1.5);
}

.yc-manual-chapter-title {
    padding-bottom: 0.3rem;
    border-bottom: 2px solid var(--yc-manual-border);
}

/* Anchor jumps and scroll-spy both want headings to land below the sticky
   offset, not flush against the top. */
.yc-manual-chapter-title,
.yc-manual-section-title,
.yc-manual-field-title {
    scroll-margin-top: 96px;
}

/* Settings */

.yc-manual-field {
    padding-bottom: var(--yc-manual-space);
    margin-bottom: var(--yc-manual-space);
    border-bottom: 1px solid var(--yc-manual-border);
}

.yc-manual-field-title {
    margin-bottom: 0.35rem;
}

/* The anchor stays reachable by keyboard, and appears on hover or focus for
   everyone else. Never hidden from assistive technology. */
.yc-manual-anchor {
    margin-left: 0.4em;
    font-weight: 400;
    text-decoration: none;
    opacity: 0;
    transition: opacity 120ms ease-in-out;
}

.yc-manual-field-title:hover .yc-manual-anchor,
.yc-manual-anchor:focus-visible {
    opacity: 1;
}

.yc-manual-anchor:focus-visible {
    outline: 2px solid var(--yc-manual-accent);
    outline-offset: 2px;
}

.yc-manual-crumb {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
}

.yc-manual-crumb-label {
    font-weight: 600;
}

.yc-manual-crumb-label::after {
    content: ':';
}

.yc-manual-crumb-sep {
    padding: 0 0.15em;
}

.yc-manual-desc {
    margin: 0 0 0.75rem;
}

.yc-manual-desc-missing {
    font-style: italic;
}

/* Type / default / options */

.yc-manual-meta {
    display: grid;
    grid-template-columns: minmax(6rem, max-content) 1fr;
    gap: 0.35rem 1rem;
    margin: 0;
    font-size: 0.9rem;
}

.yc-manual-meta dt {
    font-weight: 600;
}

.yc-manual-meta dd {
    margin: 0;
}

.yc-manual-options {
    margin: 0;
    padding-left: 1.1rem;
}

.yc-manual-note {
    padding: 0.75rem 1rem;
    margin-bottom: var(--yc-manual-space);
    border-left: 3px solid var(--yc-manual-accent);
    border-radius: var(--yc-manual-radius);
    background: var(--yc-manual-surface);
}

.yc-manual-note strong {
    display: block;
}

/* Authored prose */

.yc-manual-prose > *:first-child {
    margin-top: 0;
}

.yc-manual-prose > *:last-child {
    margin-bottom: 0;
}

.yc-manual-prose {
    margin-bottom: 0.75rem;
}

.yc-manual-code {
    position: relative;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    border-radius: var(--yc-manual-radius);
    background: var(--yc-manual-surface);
}

.yc-manual-copy {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    min-height: 32px;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--yc-manual-border);
    border-radius: var(--yc-manual-radius);
    background: transparent;
    color: inherit;
    font-size: 0.78rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 120ms ease-in-out;
}

.yc-manual-code:hover .yc-manual-copy,
.yc-manual-copy:focus-visible {
    opacity: 1;
}

.yc-manual-copy:focus-visible {
    outline: 2px solid var(--yc-manual-accent);
    outline-offset: 1px;
}

/* Callouts: the type is carried by its title text and its border, never by
   colour alone. */

.yc-manual-callout {
    padding: 0.75rem 1rem;
    margin: 0 0 var(--yc-manual-space);
    border: 1px solid var(--yc-manual-border);
    border-left: 3px solid var(--yc-manual-callout-accent, var(--yc-manual-accent));
    border-radius: var(--yc-manual-radius);
    background: var(--yc-manual-surface);
}

.yc-manual-callout-tip {
    --yc-manual-callout-accent: #0ca678;
}

.yc-manual-callout-note {
    --yc-manual-callout-accent: #1c7ed6;
}

.yc-manual-callout-warning {
    --yc-manual-callout-accent: #e8590c;
}

.yc-manual-callout-title {
    margin: 0 0 0.35rem;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--yc-manual-callout-accent, var(--yc-manual-accent));
}

.yc-manual-callout > *:last-child {
    margin-bottom: 0;
}

/* Smartphone: the two-column meta list becomes stacked rows, and the table of
   contents becomes a panel that slides in from the side. */

@media (max-width: 959px) {
    .yc-manual-toc-toggle {
        display: inline-flex;
        gap: 0.6rem;
        align-items: center;
        min-height: 44px;
        margin-bottom: var(--yc-manual-space);
        padding: 0.5rem 1rem;
        border: 1px solid var(--yc-manual-border);
        border-radius: var(--yc-manual-radius);
        background: transparent;
        color: inherit;
        font: inherit;
        cursor: pointer;
    }

    .yc-manual-toc-toggle:focus-visible {
        outline: 2px solid var(--yc-manual-accent);
        outline-offset: 2px;
    }

    /* The aside leaves the flow and waits off-screen. An overlay panel needs
       its own opaque background: Canvas / CanvasText are a matched system
       colour pair the browser keeps readable in light and dark, so the panel
       stays legible without asking the OS via prefers-color-scheme (which
       reports the OS, not the page it floats over). */
    .yc-manual-aside {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1030;
        width: min(20rem, 84vw);
        height: 100%;
        padding: 1.25rem;
        overflow-y: auto;
        background: Canvas;
        color: CanvasText;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.25);
        transform: translateX(-100%);
        transition: transform 200ms ease-in-out;
    }

    .yc-manual-toc-open .yc-manual-aside {
        transform: translateX(0);
    }

    /* Its inner sticky wrapper must not fight the panel on mobile. */
    .yc-manual-aside > div {
        position: static !important;
    }

    .yc-manual-toc-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1029;
        background: rgba(0, 0, 0, 0.5);
        opacity: 0;
        pointer-events: none;
        transition: opacity 200ms ease-in-out;
    }

    .yc-manual-toc-open .yc-manual-toc-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    /* The copy button has no hover on touch, so it stays visible. */
    .yc-manual-copy {
        opacity: 1;
    }

    /* Primary controls in the panel are the main touch targets: give them the
       44px the rest of the UI honours. */
    .yc-manual-toc-list a,
    .yc-manual-nav-list a {
        display: flex;
        align-items: center;
        min-height: 44px;
    }

    .yc-manual-meta {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }

    .yc-manual-meta dd {
        margin-bottom: 0.5rem;
    }

    .yc-manual-crumb {
        word-break: break-word;
    }
}

/* Smartphone (640px): tighten spacing, stack the search bar so the count sits
   under the field, and single-column the overview cards early. */
@media (max-width: 640px) {
    .yc-manual {
        --yc-manual-space: 1.1rem;
    }

    .yc-manual-search-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.4rem;
    }

    .yc-manual-overview-grid {
        grid-template-columns: 1fr;
    }
}

/* Small phone (420px): remove the negative-margin accent rail so nothing sits
   under the viewport edge, and keep the panel within a narrow screen. */
@media (max-width: 420px) {
    .yc-manual-nav-list a {
        margin-left: 0;
        padding-left: 0.4rem;
    }

    .yc-manual-aside {
        width: 92vw;
    }

    .yc-manual-chapter-title {
        overflow-wrap: anywhere;
    }
}

@media (prefers-reduced-motion: reduce) {
    .yc-manual-anchor,
    .yc-manual-copy,
    .yc-manual-aside,
    .yc-manual-toc-backdrop {
        transition: none;
    }
}

/* Print: the sidebar is noise on paper, and anchors have no meaning. */

@media print {
    .yc-manual-toc,
    .yc-manual-anchor {
        display: none;
    }

    .yc-manual-field {
        break-inside: avoid;
    }
}
