/* ─── Shared interface chrome for the experiment pages ───
   Loaded after style.css and built on its design tokens, so life/,
   shrink/, and clt/ present one interface language: mono labels,
   hairline borders, and translucent panels floating over the canvas. */

/* ─── Back link ───
   Plain inline link on article pages; add .back--pill on full-canvas
   pages to pin it over the simulation. */
.back {
    font-family: var(--mono);
    font-size: 14px;
    color: var(--body);
    text-decoration: none;
    transition: color 0.15s;
}
.back:hover,
.back:focus-visible { color: var(--ink); }
.back--pill {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));
    z-index: 60;
    background: rgba(248, 248, 247, 0.82);
    padding: 5px 9px;
    border-radius: 4px;
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

/* ─── Buttons ───
   One button style everywhere: toolbar icons, panel actions, resets,
   full-screen toggles, help-card close. */
.btn {
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.2;
    color: var(--body);
    background: rgba(248, 248, 247, 0.82);
    border: 1px solid var(--rule);
    padding: 7px 10px;
    border-radius: 4px;
    cursor: pointer;
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    transition: border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--faint); color: var(--ink); }
.btn.active { color: var(--ink); border-color: var(--ink); }

/* ─── Toolbar — floating buttons pinned top-right ─── */
.toolbar {
    position: fixed;
    top: calc(10px + env(safe-area-inset-top));
    right: calc(12px + env(safe-area-inset-right));
    z-index: 60;
    display: flex;
    gap: 6px;
}

/* ─── Controls panel — translucent card docked bottom-left ─── */
.panel {
    position: fixed;
    z-index: 55;
    left: calc(12px + env(safe-area-inset-left));
    bottom: calc(12px + env(safe-area-inset-bottom));
    width: 300px;
    max-width: calc(100vw - 24px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(248, 248, 247, 0.9);
    border: 1px solid var(--rule);
    border-radius: 8px;
    padding: 14px 16px;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}
@media (max-width: 640px) {
    .panel {
        width: auto;
        right: calc(12px + env(safe-area-inset-right));
    }
}

/* ─── Labelled controls (sliders, selects) ─── */
.control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.lab {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--body);
}
.lab b { color: var(--ink); font-weight: 500; }

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 2px;
    background: var(--rule);
    outline: none;
    margin: 8px 0 2px;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--ink);
    cursor: pointer;
}
input[type=range]::-moz-range-thumb {
    width: 16px; height: 16px;
    border: none;
    border-radius: 50%;
    background: var(--ink);
    cursor: pointer;
}

select {
    width: 100%;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 6px 8px;
    cursor: pointer;
}

/* ─── Segmented control ─── */
.seg {
    display: flex;
    border: 1px solid var(--rule);
    border-radius: 5px;
    overflow: hidden;
}
.seg button {
    flex: 1;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--body);
    background: transparent;
    border: none;
    padding: 8px 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.seg button + button { border-left: 1px solid var(--rule); }
.seg button.active { background: var(--ink); color: var(--bg); }

/* ─── Button rows inside panels / control stacks ─── */
.btnrow { display: flex; gap: 8px; }
.btnrow .btn { flex: 1; background: transparent; }

/* ─── Legend ─── */
.legend {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--body);
    margin-top: 12px;
}
.legend span { display: inline-flex; align-items: center; }
.legend i {
    width: 9px; height: 9px;
    border-radius: 50%;
    margin-right: 6px;
    display: inline-block;
}

/* ─── Help modal ─── */
.help-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: flex-start;
    justify-content: center;
    background: rgba(20, 20, 20, 0.5);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.help-modal.show { display: flex; }
.help-card {
    background: var(--bg);
    color: var(--body);
    font-family: var(--sans);
    max-width: 880px;
    width: calc(100% - 32px);
    margin: clamp(16px, 4vh, 44px) 16px 24px;
    padding: 24px 28px 26px;
    border-radius: 10px;
    line-height: 1.5;
    font-size: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.help-card h1 {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 25px;
    color: var(--title);
    margin: 0 0 2px;
}
.help-card .sub {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--faint);
    margin-bottom: 14px;
}
.help-card .cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 32px;
}
@media (max-width: 640px) { .help-card .cols { grid-template-columns: 1fr; } }
.help-card h2 {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 17px;
    color: var(--title);
    margin: 12px 0 4px;
}
.help-card p { margin: 0 0 8px; }
.help-card ul,
.help-card ol { margin: 0 0 8px; padding-left: 18px; }
.help-card li { margin-bottom: 3px; }
.help-card code {
    font-family: var(--mono);
    font-size: 0.86em;
    background: rgba(0, 0, 0, 0.05);
    padding: 1px 4px;
    border-radius: 3px;
}
.help-card .keys { color: var(--ink); font-weight: 500; }
.help-close { float: right; }
.help-card .foot {
    margin-top: 22px;
    font-size: 13px;
    color: var(--faint);
    text-align: center;
}
@media (max-width: 640px) {
    .help-card { padding: 22px 20px 26px; }
}

/* ─── Utilities & focus ─── */
.hide { display: none !important; }

.btn:focus-visible,
.seg button:focus-visible,
input[type=range]:focus-visible,
select:focus-visible {
    outline: 2px solid var(--faint);
    outline-offset: 2px;
}
