/* ═══════════════════════════════════════════════
   magnolia — api reference styles

   Chrome (reset, header, glitch title, tool nav, footer) comes from
   ware/shell/app-shell.css, linked ahead of this file. Only tokens are
   overridden here, plus the two @keyframes below: this page uses a smoother
   glitch curve than the shell's, and redefining them here wins because this
   stylesheet loads second.
   ═══════════════════════════════════════════════ */

/* -- PALETTE -- */
:root {
    --bg: #080808;
    --surface: #0d1117;
    --panel: #111820;
    --border: #1a2a3a;
    --text: #e0f0f0;
    --dim: #5a7a8a;
    --accent: #00f5ff;
    --accent2: #00c4cc;
    --bright: #7df9ff;
    --orange: #ff7c1f;

    /* -- SHELL OVERRIDES -- */
    --scanline:      rgba(0,200,200,0.03);
    --title-size:    14px;
    --title-color:   var(--accent);
    --title-glow:    0 0 12px rgba(0,245,255,0.3);
    --glitch-speed:  3s;
    --glitch-tint-1: rgba(0,245,255,0.25);
    --glitch-tint-2: rgba(0,245,255,0.25);
    --footer-pad:    10px 24px;
    --backlink-color: var(--accent);
    --backlink-hover: #ffffff;
    --backlink-glow:  var(--accent);
}

body {
    user-select: none;
    -webkit-user-select: none;
}

a { color: var(--accent); }

@keyframes glitch-1 {
    0%   { transform: translate(0); }
    20%  { transform: translate(-2px, 1px); }
    40%  { transform: translate(2px, -1px); }
    60%  { transform: translate(-1px, -2px); }
    80%  { transform: translate(1px, 2px); }
    100% { transform: translate(0); }
}
@keyframes glitch-2 {
    0%   { transform: translate(0); }
    20%  { transform: translate(2px, -1px); }
    40%  { transform: translate(-2px, 1px); }
    60%  { transform: translate(1px, 2px); }
    80%  { transform: translate(-1px, -2px); }
    100% { transform: translate(0); }
}
.header-stat {
    font-family: 'Courier Prime', monospace;
    font-size: 10px;
    color: var(--dim);
}
.header-stat span { color: var(--accent); }

/* -- MAIN -- */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px 24px;
}

/* -- SEARCH -- */
.search-row {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    flex-shrink: 0;
}
.search-input {
    flex: 1;
    font-family: 'Courier Prime', monospace;
    font-size: 12px;
    background: var(--surface);
    color: var(--accent);
    border: 1px solid var(--border);
    border-right: none;
    padding: 10px 14px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input::placeholder { color: #1a3a4a; }
.search-input:focus {
    border-color: var(--accent2);
    box-shadow: 0 0 12px rgba(0,245,255,0.1);
}
.search-clear {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    background: var(--surface);
    color: var(--dim);
    border: 1px solid var(--border);
    padding: 0 14px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    letter-spacing: 0.05em;
}
.search-clear:hover {
    color: var(--accent);
    border-color: var(--accent);
}

/* -- MODULE TABS -- */
.module-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 16px;
    flex-shrink: 0;
}
.module-tab {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    background: none;
    color: var(--dim);
    border: 1px solid transparent;
    padding: 5px 8px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.module-tab:hover {
    color: var(--accent2);
    border-color: var(--border);
}
.module-tab.active {
    color: var(--accent);
    border-color: var(--accent);
    text-shadow: 0 0 6px rgba(0,245,255,0.3);
}

/* -- STATS -- */
.stats-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    font-family: 'Courier Prime', monospace;
    font-size: 10px;
    color: var(--dim);
    flex-shrink: 0;
}
.stats-bar .stat-count { color: var(--accent2); }
.stats-bar .stat-sep { color: var(--border); }

/* -- API CONTAINER (scrollable) -- */
#api-modules {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}
#api-modules::-webkit-scrollbar { width: 6px; }
#api-modules::-webkit-scrollbar-track { background: var(--surface); }
#api-modules::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
#api-modules::-webkit-scrollbar-thumb:hover { background: var(--dim); }

/* -- MODULE SECTIONS -- */
.module-section { margin-bottom: 24px; }

.module-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    margin-bottom: 10px;
    transition: background 0.15s, border-color 0.15s;
}
.module-header:hover {
    background: var(--panel);
    border-color: var(--dim);
    border-left-color: var(--accent2);
}
.module-header h2 {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: var(--accent);
    text-shadow: 0 0 6px rgba(0,245,255,0.2);
    margin: 0;
}
.module-desc {
    font-family: 'Courier Prime', monospace;
    font-size: 10px;
    color: var(--dim);
}
.module-count {
    font-family: 'Courier Prime', monospace;
    font-size: 9px;
    color: var(--dim);
    margin-left: auto;
    padding: 2px 8px;
    border: 1px solid var(--border);
}
.module-toggle {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    color: var(--dim);
    transition: transform 0.2s;
}
.module-section.collapsed .module-toggle { transform: rotate(-90deg); }
.module-section.collapsed .module-body { display: none; }
.module-body { padding-left: 4px; }

/* -- TYPE BLOCKS -- */
.type-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent2);
    padding: 12px 16px;
    margin-bottom: 14px;
}
.type-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}
.type-block pre {
    margin: 0;
    font-family: 'Courier Prime', monospace;
    font-size: 12px;
    color: var(--bright);
    line-height: 1.6;
    white-space: pre-wrap;
}
.type-block .type-desc {
    font-family: 'Courier Prime', monospace;
    font-size: 11px;
    color: var(--dim);
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

/* -- CONSTANTS BLOCK -- */
.constants-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--orange);
    padding: 12px 16px;
    margin-bottom: 14px;
}
.constants-block pre {
    margin: 0;
    font-family: 'Courier Prime', monospace;
    font-size: 12px;
    color: var(--orange);
    line-height: 1.6;
}
.constants-block .constants-desc {
    font-family: 'Courier Prime', monospace;
    font-size: 11px;
    color: var(--dim);
    margin-top: 8px;
}

/* -- FUNCTION CARDS -- */
.func-card {
    border: 1px solid var(--border);
    margin-bottom: 6px;
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.func-card:hover {
    border-color: var(--dim);
}
.func-card.expanded {
    border-color: var(--accent2);
    box-shadow: 0 0 8px rgba(0,245,255,0.05);
}

.func-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.func-header:hover { background: var(--panel); }

.func-name {
    font-family: 'Courier Prime', monospace;
    font-size: 12px;
    font-weight: bold;
    color: var(--bright);
    white-space: nowrap;
}
.func-signature-preview {
    font-family: 'Courier Prime', monospace;
    font-size: 10px;
    color: #1a3a4a;
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 50%;
}
.func-toggle {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    color: var(--dim);
    flex-shrink: 0;
    transition: transform 0.2s, color 0.15s;
}
.func-card.expanded .func-toggle {
    color: var(--accent2);
    transform: rotate(90deg);
}

.func-body {
    display: none;
    padding: 0 14px 14px;
    border-top: 1px solid var(--border);
}
.func-card.expanded .func-body { display: block; }

.func-sig {
    background: var(--panel);
    padding: 10px 14px;
    margin: 10px 0;
    border-left: 2px solid var(--accent2);
    overflow-x: auto;
}
.func-sig code {
    font-family: 'Courier Prime', monospace;
    font-size: 12px;
    color: var(--bright);
    white-space: pre;
}

.func-desc {
    font-family: 'Courier Prime', monospace;
    font-size: 12px;
    color: #aaaaaa;
    line-height: 1.7;
    margin-bottom: 12px;
}

.func-example-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    color: var(--dim);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}
.func-example pre {
    margin: 0;
    border: 1px solid var(--border);
    padding: 10px 14px;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.5;
    background: var(--panel);
}
.func-example pre.hljs {
    background: var(--panel);
    padding: 10px 14px;
}

/* -- NO RESULTS -- */
.no-results {
    text-align: center;
    padding: 60px 20px;
    color: var(--dim);
    font-family: 'Courier Prime', monospace;
    font-size: 12px;
}

/* -- FOOTER -- */
/* padding, border and flex-shrink come from the shell. */
footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg);
}
footer .footer-left {
    font-family: 'Courier Prime', monospace;
    font-size: 10px;
    color: var(--dim);
}
footer .footer-right {
    font-family: 'Press Start 2P', monospace;
    font-size: 6px;
    color: var(--dim);
    letter-spacing: 0.1em;
}
footer .footer-right span { color: var(--accent); }

/* -- MOBILE -- */
@media (max-width: 640px) {
    header { padding: 12px 16px; }
    h1.glitch { font-size: 11px; }
    .header-right { gap: 8px; }
    .module-tabs { gap: 2px; }
    .module-tab { font-size: 6px; padding: 4px 6px; }
    .func-signature-preview { display: none; }
    .func-header { padding: 7px 10px; }
    .func-body { padding: 0 10px 10px; }
    .func-name { font-size: 11px; }
    .search-row { flex-direction: column; gap: 0; }
    .search-clear { border-top: none; }
    main { padding: 16px; }
}
