/* ==========================================================
   DIY Audio Lab — application layer
   Load AFTER diyaudiolab-styles.css. Adds the wide, dense
   tool layouts an app needs — page frame, masthead, cards,
   compact controls, code surfaces, charts — on top of the
   design system, using only its tokens. No new colour is
   introduced here.

   Tier 2 of 3:
     diyaudiolab-styles.css   design system
     diyaudiolab-app.css      this file — shared by every app
     <page>.css               one page's own chrome
   ========================================================== */

/* ==========================================================
   Page frame — the design system's reading column is too
   narrow for a two-pane tool, so the width moves to .container.
   ========================================================== */

body {
    max-width: none;
    margin: 0;
    padding: 32px 24px 56px;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}
.container-wide { max-width: 1600px; }
.container-reading { max-width: 900px; }

/* ==========================================================
   Masthead
   ========================================================== */

.header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 6px;
}

/* h1 keeps the design system's 40px heading scale */
.header h1 { margin: 0; }

.subtitle {
    text-align: center;
    margin: 0 auto 24px;
    max-width: 60ch;
}

/* Nav pills read as secondary actions — signal blue, never green */
.nav-links {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 28px;
}

.nav-links a {
    font-size: 14px;
    font-weight: 600;
    padding: 7px 14px;
    border: 1.5px solid var(--link-hover);
    border-radius: var(--radius-control);
    color: var(--link-hover);
    transition: background-color 0.12s ease;
}
.nav-links a:hover {
    background: var(--dal-blue-50);
    text-decoration: none;
}

/* ==========================================================
   Layout columns
   ========================================================== */

.row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
}
.col { flex: 1; min-width: 300px; }
.col-plot { flex: 1; min-width: 500px; }
.col-side { width: 300px; flex-shrink: 0; }
.col-main { flex: 1; min-width: 600px; }

/* ==========================================================
   Cards — .card comes from the design system (1px border,
   10px radius, no shadow). Only the header rule is added.
   ========================================================== */

.card {
    padding: 20px;
    margin-bottom: 20px;
}

.card > h2 {
    font-size: 17px;
    font-weight: 600;
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.card > h3 {
    margin-top: 20px;
}

/* ==========================================================
   Dense controls
   A parameter grid can't carry the design system's 17px label
   and 16px input, so the tool runs one scale down. Colour,
   radius and focus ring are unchanged.
   ========================================================== */

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

input[type="number"],
input[type="text"],
select {
    font-size: 14px;
    padding: 7px 10px;
    margin-bottom: 12px;
}

input[type="file"] {
    font-size: 13px;
    padding: 7px 10px;
    margin-bottom: 12px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    width: 100%;
}
input[type="file"]::file-selector-button {
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 5px 12px;
    margin-right: 12px;
    background: transparent;
    color: var(--link-hover);
    border: 1.5px solid var(--link-hover);
    border-radius: 6px;
    cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--dal-blue-50); }

.param-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.param-item {
    background: var(--panel);
    border-radius: var(--radius-control);
    padding: 10px;
}
.param-item label { font-size: 12px; margin-bottom: 4px; }
.param-item input { margin-bottom: 0; padding: 6px 8px; }

.help-text {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ==========================================================
   Buttons — a step down from the design system's default size
   for a control-dense tool. Roles are unchanged: signal-blue
   primary for the one main action, blue outline secondary,
   plain tertiary. Destructive actions borrow the error token
   for their text only.
   ========================================================== */

.btn {
    font-size: 14px;
    padding: 8px 16px;
    margin-right: 6px;
    margin-bottom: 6px;
}

.btn-sm {
    font-size: 12px;
    padding: 5px 10px;
}

.btn-danger {
    background: transparent;
    border-color: transparent;
    color: var(--error);
}
.btn-danger:hover { background: var(--error-bg); }

.btn-row { margin-top: 16px; }
.btn-row .btn:last-child { margin-right: 0; }

/* ==========================================================
   Status notes — same anatomy as the design system's .note,
   kept under the .status name because the scripts write it.
   ========================================================== */

.status {
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius-control);
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 12px;
}
.status.info    { border-left-color: var(--link); background: var(--info-bg); }
.status.success { border-left-color: var(--success); background: var(--success-bg); }
.status.warning { border-left-color: var(--warning); background: var(--warning-bg); }
.status.error   { border-left-color: var(--error); background: var(--error-bg); }

/* ==========================================================
   Tabs — the design system owns the underline treatment and
   the aria-selected state; only the scale steps down here.
   .tab-content is the app's own panel switching.
   ========================================================== */

.tabs {
    gap: 18px;
    margin-bottom: 16px;
}
.tab { font-size: 14px; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ==========================================================
   Equations — technical notation, so it wears the mono stack
   on the panel tint rather than a serif face.
   ========================================================== */

.equation {
    background: var(--panel);
    border-radius: var(--radius-control);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 15px;
    line-height: 1.7;
    text-align: center;
    color: var(--text);
    margin-bottom: 16px;
}

/* ==========================================================
   Metrics — .metric-grid/.metric come from the design system,
   which already gives the value the accent and the label the
   mono stack. A tool packs them tighter and seats each cell on
   the panel tint. Note this adds no `display`, so the utility
   .hidden still wins over the grid.
   ========================================================== */

.metric-panels {
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 12px;
}
.metric-panels .metric {
    background: var(--panel);
    border-radius: var(--radius-control);
    padding: 10px 12px;
    text-align: center;
}
.metric-panels .metric-value { font-size: 22px; line-height: 1.2; }
.metric-panels .metric-label { font-size: 11px; letter-spacing: 0.3px; }

/* ==========================================================
   Progress — .progress/.progress-bar come from the design
   system; only the surrounding rhythm is set here.
   ========================================================== */

.progress { margin: 16px 0 8px; }

/* ==========================================================
   Code areas — the sanctioned dark ground: fit log, SPICE
   listing, CSV listing. Inline code stays on the light tint.
   ========================================================== */

.code-surface {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.55;
    background: var(--code-surface);
    color: var(--code-text);
    border-radius: var(--radius-control);
    padding: 14px;
    white-space: pre-wrap;
    overflow-y: auto;
}
.code-surface::selection,
.code-surface *::selection { background: var(--code-selection); }

.code-surface.tall { max-height: 250px; }
.code-surface.short { max-height: 200px; }

/* ==========================================================
   Tables
   ========================================================== */

table { font-size: 13px; }
th, td { padding: 8px 10px 8px 0; }

.points-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.points-table th,
.points-table td {
    padding: 5px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.points-table th {
    background: var(--panel);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
}
.points-table tr:hover { background: var(--panel); }

.points-table-container,
.series-list {
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    overflow-y: auto;
    margin-bottom: 12px;
}
.points-table-container { max-height: 160px; }
.series-list { max-height: 200px; }

.empty-state,
.points-table td.empty-state {
    padding: 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
}

/* ==========================================================
   Series list
   ========================================================== */

.series-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    cursor: pointer;
}
.series-item:last-child { border-bottom: none; }
.series-item:hover { background: var(--panel); }
.series-item.active {
    background: var(--highlight);
    box-shadow: inset 3px 0 0 var(--accent);
}

.series-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    margin-right: 8px;
    flex-shrink: 0;
}
.series-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 8px;
}

.row-remove {
    color: var(--text-muted);
    cursor: pointer;
    margin-left: 8px;
    font-size: 15px;
    line-height: 1;
    padding: 0 4px;
}
.row-remove:hover { color: var(--error); }
/* ==========================================================
   Plot
   ========================================================== */

/* The plotting library draws its own SVG in here, so this element only
   supplies the frame. overflow:hidden is required: Plotly (and most
   others) size the SVG to the element's BORDER box, so with
   box-sizing:border-box it would otherwise paint over the right and
   bottom border and square off the corners. */
.plot-frame {
    width: 100%;
    height: 550px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    overflow: hidden;
}

/* ==========================================================
   Tutorial steps
   ========================================================== */

.step {
    display: flex;
    gap: 14px;
    margin-bottom: 20px;
    align-items: flex-start;
}
.step-number {
    background: var(--accent);
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}
.step-content { flex: 1; }
.step-content h4 { margin: 2px 0 6px; font-size: 15px; }
.step-content p { margin: 0; color: var(--text-secondary); font-size: 14px; }

/* ==========================================================
   Responsive
   ========================================================== */

@media (max-width: 900px) {
    body { padding: 24px 16px 40px; }
    .header h1 { font-size: 30px; }
    .header .brand-mark { width: 34px; height: 34px; }
    .col-side, .col-main, .col, .col-plot { width: 100%; min-width: 0; }
    .plot-frame { height: 420px; }
}
