/*
 * stem.css - shared layout for the STEM knowledge hubs (GIS, Computer
 * Science, Math, Science). Loaded after /css/style.css.
 *
 * Each page sets its accent once on <body>:
 *   <body class="stem-page" style="--accent:#22c55e; --accent-rgb:34,197,94;">
 * and every component below derives its colours from those two tokens.
 */

.stem-page {
    --accent: var(--accent-cyan);
    --accent-rgb: 0, 240, 255;
    --stem-card-bg: rgba(10, 15, 20, 0.85);
    --stem-text: #a0b0c0;
    --stem-text-strong: #d0e0f0;
    --stem-muted: #4a4a5e;
    --stem-max: 1100px;
}

/* --- Hero --- */
.stem-hero { text-align: center; padding: 4rem 1.5rem 2rem; }
.stem-title {
    font-size: 2.2rem; font-weight: 700; color: var(--accent);
    margin-bottom: 0.5rem; letter-spacing: 1px;
    overflow-wrap: anywhere; /* long snake_case titles must not widen the page on phones */
}
.stem-subtitle {
    font-family: var(--font-sans); color: var(--text-dim); font-size: 0.95rem;
    max-width: 700px; margin: 0 auto; line-height: 1.6;
}

/* --- Sections --- */
.stem-section { max-width: var(--stem-max); margin: 0 auto; padding: 2rem 1.5rem; }
.stem-section:last-of-type { padding-bottom: 4rem; }
.stem-header {
    color: var(--accent);
    border-bottom: 1px solid rgba(var(--accent-rgb), 0.2);
    padding-bottom: 0.5rem; margin-bottom: 1.5rem;
    overflow-wrap: anywhere; /* safety net; long snake_case headings also carry <wbr> after underscores */
}
.stem-note {
    font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 1px;
    color: var(--stem-muted); margin: -0.75rem 0 1rem;
}

/* --- Cards --- */
.stem-grid {
    display: grid; gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
}
.stem-card {
    background: var(--stem-card-bg);
    border: 1px solid rgba(var(--accent-rgb), 0.15);
    border-radius: 6px; padding: 1.5rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.stem-card:hover {
    border-color: rgba(var(--accent-rgb), 0.4);
    box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.06);
}
.stem-card h3 { color: #fff; margin-bottom: 0.8rem; font-size: 1.15rem; }
.stem-card p, .stem-card li { color: var(--stem-text); font-size: 0.88rem; line-height: 1.7; }
.stem-card ul { margin: 0.5rem 0 0 1.2rem; }
.stem-card strong { color: var(--stem-text-strong); }
.stem-card a { color: var(--accent-cyan); text-decoration: none; }
.stem-card a:hover { text-decoration: underline; }
.stem-tag { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 1px; margin-bottom: 0.5rem; }
.stem-page code {
    color: var(--accent); background: rgba(var(--accent-rgb), 0.08);
    padding: 0.1rem 0.4rem; border-radius: 3px; font-size: 0.82rem;
}

/* --- Toolbox: compact link/download tiles --- */
.stem-toolbox {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
}
.stem-tool {
    --tool: var(--accent);
    display: flex; flex-direction: column; gap: 0.35rem;
    background: var(--stem-card-bg);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--tool);
    border-radius: 6px; padding: 1rem 1.1rem;
    text-decoration: none; color: inherit;
    transition: border-color 0.2s, transform 0.2s, background 0.2s;
}
.stem-tool:hover, .stem-tool:focus-visible {
    border-color: var(--tool); transform: translateY(-2px);
    background: rgba(12, 18, 26, 0.95);
}
.stem-tool-kind {
    font-family: var(--font-mono); font-size: 0.65rem; letter-spacing: 2px;
    color: var(--tool); text-transform: uppercase;
}
.stem-tool-name { font-family: var(--font-mono); color: #e8e8ff; font-size: 0.92rem; font-weight: 700; }
.stem-tool-desc { color: #8a8a9e; font-size: 0.8rem; line-height: 1.5; font-family: var(--font-sans); }

/* --- Panel: bordered container for interactive widgets --- */
.stem-panel {
    background: radial-gradient(circle at 50% 40%, rgba(var(--accent-rgb), 0.05), transparent 60%),
                rgba(5, 8, 12, 0.9);
    border: 1px solid rgba(var(--accent-rgb), 0.2);
    border-radius: 8px; padding: 1.5rem;
}

/* --- Segmented control --- */
.stem-seg { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.stem-seg button {
    background: rgba(var(--accent-rgb), 0.1);
    border: 1px solid rgba(var(--accent-rgb), 0.3);
    color: var(--accent); padding: 0.45rem 1.1rem; border-radius: 4px;
    cursor: pointer; font-family: var(--font-mono); font-size: 0.8rem;
    text-transform: uppercase; letter-spacing: 1px; transition: all 0.2s;
}
.stem-seg button:hover, .stem-seg button[aria-pressed="true"] {
    background: rgba(var(--accent-rgb), 0.3); border-color: var(--accent); color: #fff;
}
.stem-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Topic tabs (js/stem-tabs.js). Without JS every panel shows, with its own heading. --- */
.stem-tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: -0.5rem 0 1.25rem; }
.stem-tab {
    background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-color);
    color: var(--text-secondary); border-radius: 4px; padding: 0.4rem 0.85rem;
    font: 600 0.72rem/1.2 var(--font-mono); letter-spacing: 1px; text-transform: uppercase;
    cursor: pointer; transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.stem-tab:hover { color: var(--text-primary); border-color: #2a2a44; }
.stem-tab[aria-selected="true"] {
    color: var(--accent); border-color: rgba(var(--accent-rgb), 0.55);
    background: rgba(var(--accent-rgb), 0.1);
}
.stem-tab:focus-visible, .stem-tabpanel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stem-tabpanel-h {
    font: 700 0.95rem/1.3 var(--font-mono); color: var(--accent); letter-spacing: 1px;
    margin: 0 0 1rem; overflow-wrap: anywhere;
}
.stem-tabpanel + .stem-tabpanel { margin-top: 2.5rem; }
.stem-tabset.is-tabbed .stem-tabpanel-h { display: none; }
.stem-tabset.is-tabbed .stem-tabpanel + .stem-tabpanel { margin-top: 0; }
.stem-tabset { scroll-margin-top: 5rem; }
.stem-tabnav { display: none; }
.stem-tabset.is-tabbed .stem-tabnav {
    display: flex; justify-content: space-between; gap: 1rem;
    margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--border-color);
}
.stem-tabnav-btn {
    background: none; border: 1px solid var(--border-color); color: var(--text-secondary);
    border-radius: 4px; padding: 0.4rem 0.8rem; cursor: pointer;
    font: 0.72rem/1.2 var(--font-mono); letter-spacing: 1px; text-transform: uppercase;
}
.stem-tabnav-btn:hover { color: var(--accent); border-color: rgba(var(--accent-rgb), 0.5); }
.stem-tabnav-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Live status terminal lines --- */
.stem-status-line { color: var(--text-secondary); padding-left: 1.2rem; }
.stem-status-line .ok   { color: var(--accent-green); }
.stem-status-line .warn { color: var(--accent-yellow); }
.stem-status-line .fail { color: var(--accent-red); }
.stem-status-line .dim  { color: var(--text-dim); }

@media (max-width: 640px) {
    .stem-title { font-size: 1.7rem; }
    .stem-hero { padding: 3rem 1.25rem 1.5rem; }
}
