/* The app guide (/app-guide): index of cards, chapter pages with a sticky
   sidebar (search + contents), prev/next. Colours come from style.css's :root. */

/* ===== Search ===== */
.ag-search {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
}
.ag-search:focus-within { border-color: rgba(240, 168, 48, 0.5); }
.ag-search-icon { display: flex; color: var(--text-secondary); }
.ag-search-icon svg { width: 16px; height: 16px; }
.ag-search input {
    flex: 1;
    min-width: 0;
    padding: 0.6rem 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
}
.ag-search.is-large { max-width: 560px; margin: 2rem auto 0; padding: 0 1.1rem; }
.ag-search.is-large input { padding: 0.9rem 0; font-size: 1.05rem; }
.ag-search.is-large .ag-search-icon svg { width: 20px; height: 20px; }

.ag-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 60vh;
    overflow-y: auto;
    margin: 0;
    padding: 0.35rem;
    list-style: none;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.ag-results a, .ag-results .ag-none {
    display: block;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    color: var(--text);
}
.ag-results a:hover, .ag-results a.is-active { background: var(--bg-card-hover); }
.ag-results .ag-r-title { display: block; font-weight: 600; font-size: 0.92rem; }
.ag-results .ag-r-meta { display: block; font-size: 0.78rem; color: var(--accent-light); margin-top: 0.1rem; }
.ag-results .ag-r-snip { display: block; font-size: 0.82rem; color: var(--text-secondary); margin-top: 0.2rem; line-height: 1.45; }
.ag-results mark { background: rgba(240, 168, 48, 0.25); color: inherit; border-radius: 2px; }
.ag-results .ag-none { color: var(--text-secondary); font-size: 0.9rem; }

/* ===== Index ===== */
.ag-index {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 2rem 5rem;
}
.ag-index-hero { text-align: center; padding: 4.5rem 0 2.5rem; }
.ag-index-hero h1 {
    font-size: 3.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--text) 10%, var(--accent-light) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.ag-index-hero .section-subtitle { margin-bottom: 0; }

.ag-safety {
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
    max-width: 760px;
    margin: 0 auto 3rem;
    padding: 1.1rem 1.3rem;
    border: 1px solid rgba(240, 168, 48, 0.25);
    border-radius: var(--radius);
    background: rgba(240, 168, 48, 0.06);
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.6;
}
.ag-safety strong { color: var(--text); }
.ag-safety-icon { display: flex; color: var(--accent-light); padding-top: 0.1rem; }

.ag-section { margin-top: 2.5rem; }
.ag-section h2 {
    justify-content: flex-start;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.35rem;
    margin-bottom: 1rem;
}
.ag-section-icon { display: flex; color: var(--accent-light); }
.ag-section-icon svg { width: 20px; height: 20px; }

.ag-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}
.ag-card {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 1.1rem 1.2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(18, 21, 30, 0.6);
    color: var(--text);
    transition: border-color 0.2s, transform 0.2s, background 0.2s;
}
a.ag-card:hover { border-color: rgba(240, 168, 48, 0.4); background: var(--bg-card); transform: translateY(-2px); }
.ag-card-title { font-weight: 700; font-size: 1rem; }
.ag-card-text { color: var(--text-secondary); font-size: 0.88rem; line-height: 1.5; }
.ag-card.is-pending { opacity: 0.55; }
.ag-card-soon {
    align-self: flex-start;
    margin-top: 0.2rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.ag-missing {
    margin-top: 3rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
}

/* ===== Chapter page ===== */
.ag-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 3rem;
    max-width: 1140px;
    margin: 0 auto;
    padding: 2.5rem 2rem 5rem;
}

.ag-sidebar {
    position: sticky;
    top: 5.5rem;
    align-self: start;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
    padding-right: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}
.ag-toc-wrap > summary { display: none; }
.ag-toc { margin-top: 1.1rem; font-size: 0.88rem; }
.ag-toc a, .ag-toc .is-pending {
    display: block;
    padding: 0.28rem 0.6rem;
    border-radius: 6px;
    color: var(--text-secondary);
}
.ag-toc a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.ag-toc a.is-current { color: var(--text); background: rgba(240, 168, 48, 0.12); font-weight: 600; }
.ag-toc .is-pending { opacity: 0.45; }
.ag-toc-home { font-weight: 600; margin-bottom: 0.4rem; }
.ag-toc-section { margin-top: 0.9rem; }
.ag-toc-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0 0.6rem 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text);
}
.ag-toc-title svg { width: 14px; height: 14px; color: var(--accent-light); }
.ag-toc ul { list-style: none; margin: 0; padding: 0; }

.ag-main { min-width: 0; max-width: 760px; }
.ag-crumbs { display: flex; gap: 0.45rem; font-size: 0.82rem; color: var(--text-secondary); }
.ag-crumbs a { color: var(--accent-light); }
.ag-head { margin: 0.8rem 0 2rem; }
.ag-head h1 { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.015em; line-height: 1.15; }
.ag-lead { margin-top: 0.7rem; color: var(--text-secondary); font-size: 1.08rem; line-height: 1.6; }

.ag-body { font-size: 1rem; line-height: 1.75; color: #c9cdd8; }
.ag-body > * + * { margin-top: 1.1rem; }
.ag-body h2 {
    text-align: left;
    margin-top: 2.6rem;
    font-size: 1.35rem;
    color: var(--text);
    scroll-margin-top: 5.5rem;
}
.ag-body h2 .ag-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.7rem;
    height: 1.7rem;
    margin-right: 0.55rem;
    border-radius: 50%;
    background: rgba(240, 168, 48, 0.15);
    color: var(--accent-light);
    font-size: 0.9rem;
    vertical-align: 0.15em;
}
.ag-body strong { color: var(--text); }
.ag-body a { color: var(--accent-light); text-decoration: underline; text-decoration-color: rgba(240, 168, 48, 0.35); text-underline-offset: 3px; }
.ag-body kbd {
    display: inline-block;
    padding: 0 0.35rem;
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.05);
    font: 0.85em -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
}
.ag-body code { font-size: 0.88em; padding: 0.05rem 0.3rem; border-radius: 4px; background: rgba(255, 255, 255, 0.06); }
.ag-body ul, .ag-body ol { padding-left: 1.3rem; }
.ag-keys { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.ag-keys td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.ag-keys td:first-child { width: 1%; white-space: nowrap; }
.ag-body li + li { margin-top: 0.35rem; }

.ag-note {
    padding: 0.9rem 1.1rem;
    border-left: 3px solid var(--accent-light);
    border-radius: 0 8px 8px 0;
    background: rgba(240, 168, 48, 0.06);
    font-size: 0.93rem;
}

.ag-figure { margin: 1.6rem 0; }
.ag-figure img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 10px;
    border: 1px solid var(--border);
}
.ag-shot-todo {
    padding: 1.2rem 1.2rem;
    border: 1px dashed rgba(240, 168, 48, 0.45);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}
.ag-shot-todo::before {
    content: "Screenshot to take: " attr(data-shot);
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 600;
    color: var(--accent-light);
}
.ag-figure figcaption { margin-top: 0.55rem; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }

.ag-checked { margin-top: 2.5rem; font-size: 0.82rem; color: var(--text-secondary); }

.ag-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}
.ag-pager a {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-weight: 600;
}
.ag-pager a:hover { border-color: rgba(240, 168, 48, 0.4); }
.ag-pager span { font-size: 0.78rem; font-weight: 500; color: var(--text-secondary); }
.ag-pager-next { grid-column: 2; text-align: right; }
.ag-main .ag-missing { text-align: left; margin-top: 2rem; }

/* ===== Narrow screens ===== */
@media (max-width: 1024px) {
    .ag-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
    .ag-layout { grid-template-columns: 1fr; gap: 1.5rem; padding: 1.5rem 1rem 4rem; }
    .ag-sidebar { position: static; max-height: none; overflow: visible; }
    .ag-toc-wrap > summary {
        display: block;
        margin-top: 0.8rem;
        padding: 0.55rem 0.8rem;
        border: 1px solid var(--border);
        border-radius: 10px;
        cursor: pointer;
        font-weight: 600;
        font-size: 0.9rem;
    }
    .ag-head h1 { font-size: 1.9rem; }
}
@media (max-width: 640px) {
    .ag-index { padding: 0 1rem 4rem; }
    .ag-index-hero { padding-top: 3rem; }
    .ag-index-hero h1 { font-size: 2.3rem; }
    .ag-cards { grid-template-columns: 1fr; }
    .ag-pager { grid-template-columns: 1fr; }
    .ag-pager-next { grid-column: 1; }
    .ag-keys td:first-child { white-space: normal; }
}
