/* ============================================================
   Codli Design Gallery — styles of the gallery itself (g-*).
   Components on the pages are the library's own (.r-*, codli-design.css); this file only lays out
   the shell additions, live demos, previews of the html samples, the phone frame and the TOC.
   ============================================================ */

:root {
    --g-phone-panel-w: 452px;
    --g-toc-w: 220px;
    /* Syntax colours of code blocks (GalleryMarkdownTheme → hljs-*). */
    --g-hl-keyword: #7c3aed;
    --g-hl-string: #047857;
    --g-hl-number: #b45309;
    --g-hl-title: #1d4ed8;
    --g-hl-type: #0f766e;
    --g-hl-comment: #667085;
}

[data-theme="dark"] {
    --g-hl-keyword: #c4b5fd;
    --g-hl-string: #6ee7b7;
    --g-hl-number: #fcd34d;
    --g-hl-title: #93c5fd;
    --g-hl-type: #5eead4;
    --g-hl-comment: #98a2b3;
}

/* ---------- Shell additions ---------- */

.g-topbar { justify-content: flex-end; }
.g-toolbar { display: flex; align-items: center; gap: var(--s-1); margin-left: auto; }
.g-toolbar-btn { gap: var(--s-2); }
.g-toolbar-icon { display: inline-flex; width: 16px; height: 16px; }
.g-toolbar-icon svg { width: 16px; height: 16px; }
.g-swatch {
    width: 14px; height: 14px;
    border-radius: var(--r-pill);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 0 0 1px var(--border-default);
    flex-shrink: 0;
}

.g-nav { overflow-y: auto; }
.g-nav-foot { flex-direction: column; align-items: flex-start; gap: 2px; }
.g-nav .r-nav-item { justify-content: space-between; }
.g-nav-live {
    font-size: 10px;
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, 0.1);
    color: var(--brand-200);
}

/* ---------- Page: header, live demos, document, TOC ---------- */

.g-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-8);
    max-width: 1280px;
}
@media (min-width: 1280px) {
    .g-page:not(.is-embedded) { grid-template-columns: minmax(0, 1fr) var(--g-toc-w); }
}
.g-page-main { min-width: 0; max-width: 980px; }
.g-page-header { margin-bottom: var(--s-6); }
.g-crumb { color: var(--text-tertiary); font-size: var(--t-small); margin-bottom: var(--s-1); }
.g-page-header .r-page-title code {
    font-family: var(--font-mono);
    font-size: 0.8em;
    padding: 0 0.25em;
    border-radius: var(--r-xs);
    background: var(--bg-muted);
}
.g-page-header .r-page-title:focus { outline: none; }

.g-live { margin-bottom: var(--s-10); }
.g-demo-grid { display: grid; gap: var(--s-6); }

.g-demo {
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-lg);
    background: var(--bg-surface);
    overflow: hidden;
}
.g-demo-head { padding: var(--s-4) var(--s-5) 0; }
.g-demo-title { font-size: var(--t-h4); font-weight: 600; margin: 0 0 var(--s-1); color: var(--text-primary); }
.g-demo-desc { margin: 0; color: var(--text-secondary); font-size: var(--t-small); line-height: 1.6; max-width: 72ch; }
.g-demo-desc code, .g-demo-desc kbd { font-family: var(--font-mono); font-size: 0.92em; }
.g-demo-stage {
    margin: var(--s-4) var(--s-5);
    padding: var(--s-8) var(--s-5);
    border-radius: var(--r-md);
    background-color: var(--bg-app);
    background-image: radial-gradient(var(--border-subtle) 1px, transparent 1px);
    background-size: 16px 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--s-4);
    min-height: 120px;
}
.g-demo-stage.is-start { display: block; padding: var(--s-5); }
.g-demo-foot { padding: 0 var(--s-5) var(--s-4); display: flex; gap: var(--s-2); }
.g-demo-foot:empty { display: none; }
.g-demo-code { border-top: 1px solid var(--border-subtle); }
.g-demo-code > summary {
    cursor: pointer;
    padding: var(--s-2) var(--s-5);
    font-size: var(--t-small);
    color: var(--text-secondary);
    user-select: none;
}
.g-demo-code > summary:hover { color: var(--text-primary); }
.g-demo-code .md-pre { margin: 0; border-radius: 0; max-height: 420px; overflow: auto; }

.g-demo-log {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2);
    margin-top: var(--s-4);
    font-size: var(--t-small);
    color: var(--text-secondary);
}
.g-demo-log-label { font-weight: 600; color: var(--text-primary); }

/* The library document below the demos. */
.g-doc { min-width: 0; }

/* Live preview of an ```html sample from docs/*.md (MarkdownPreprocessor). transform makes the stage the
   containing block of position:fixed descendants (drawers, layers), so a sample cannot cover the gallery. */
.g-preview {
    margin: 0 0 var(--s-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    background: var(--bg-app);
    overflow: hidden;
}
.g-preview-label {
    padding: var(--s-1) var(--s-3);
    font-size: var(--t-micro);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--text-tertiary);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}
.g-preview-stage {
    padding: var(--s-5);
    transform: translateZ(0);
    max-height: 560px;
    overflow: auto;
}
.g-preview-stage svg:empty { display: none; }
.g-preview + .md-pre { margin-top: 0; }

.g-toc {
    position: sticky;
    top: calc(var(--topbar-h) + var(--safe-top) + var(--s-6));
    align-self: start;
    max-height: calc(100vh - var(--topbar-h) - var(--s-12));
    overflow-y: auto;
    display: none;
    flex-direction: column;
    gap: 2px;
    font-size: var(--t-small);
    border-left: 1px solid var(--border-subtle);
    padding-left: var(--s-4);
}
@media (min-width: 1280px) { .g-toc { display: flex; } }
.g-toc-title {
    font-size: var(--t-micro);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: var(--s-2);
}
.g-toc-item { color: var(--text-secondary); text-decoration: none; padding: 2px 0; line-height: 1.4; }
.g-toc-item:hover { color: var(--text-accent); }
.g-toc-l3 { padding-left: var(--s-3); font-size: 12px; }

/* ---------- Phone preview ---------- */

.r-shell.g-with-phone { padding-right: var(--g-phone-panel-w); }
/* With the phone open the page has less room: the TOC goes, the document keeps its width. */
.g-with-phone .g-page:not(.is-embedded) { grid-template-columns: minmax(0, 1fr); }
.g-with-phone .g-toc { display: none; }
.g-phone {
    position: fixed;
    top: calc(var(--topbar-h) + var(--safe-top));
    right: 0;
    bottom: 0;
    width: var(--g-phone-panel-w);
    z-index: 40;
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-md);
}
.g-phone-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--s-2) var(--s-3) var(--s-2) var(--s-4);
    font-size: var(--t-small);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
}
.g-phone-device { flex: 1; overflow: auto; padding: var(--s-4) 0; display: flex; justify-content: center; }
.g-phone-device iframe {
    box-sizing: content-box; /* reset.css makes everything border-box: the bezel must not eat the 390 px */
    width: 390px;
    height: 844px;
    flex-shrink: 0;
    border: 10px solid var(--ink-900, #12131e);
    border-radius: 44px;
    background: var(--bg-app);
    box-shadow: var(--shadow-lg);
}
@media (max-width: 960px) {
    .g-phone-toggle, .g-phone { display: none; }
    .r-shell.g-with-phone { padding-right: 0; }
    .g-toolbar-text { display: none; }
}

/* Embedded page (inside the phone frame). */
.g-embedded { padding: var(--s-4); padding-top: calc(var(--s-4) + var(--safe-top)); min-height: 100vh; background: var(--bg-app); }

/* ---------- Menu demo ---------- */

.g-menu-card {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
    width: min(100%, 460px);
    padding: var(--s-4) var(--s-5);
}
.g-menu-card:focus-visible { box-shadow: var(--shadow-focus-ring); outline: none; }
.g-menu-card-title { font-weight: 600; color: var(--text-primary); }
.g-menu-card-meta { font-size: var(--t-small); color: var(--text-secondary); margin-top: 2px; }
.g-trigger-row { display: flex; flex-wrap: wrap; gap: var(--s-8); justify-content: center; }
.g-trigger-row figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: var(--s-2); }
.g-trigger-row figcaption { font-size: var(--t-caption); color: var(--text-tertiary); }
.g-menu-table { background: var(--bg-surface); }
.g-menu-table tr[data-codli-menu-scope]:focus-within,
.g-menu-table tr[data-codli-menu-scope]:focus { background: var(--bg-accent-subtle); outline: none; }
.g-col-actions { width: 48px; text-align: right; }
.g-settings-preview { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
