/* ================================================================
   3D-Funktionsplotter, Tool-specific styles
   ================================================================
   Loaded only by pages/werkzeuge/funktionsplotter-3d.html. Extends
   the shared plotter chrome (plotter.css) with the controls unique
   to a surface plotter: the per-surface list rows, the four
   Definitionsbereich fields and the height-colour legend gradient.
   Defines only new `.fp3-*` classes. Colours, fonts, radii and
   transitions go through the design tokens; the pixel sizes (gaps,
   paddings, control dimensions) are literals tuned to this sidebar's
   control density, matching the single-variable Funktionsplotter.
   ================================================================ */

/* ── Surface list ──────────────────────────────────────────────── */
.fp3-surf-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 8px;
}

.fp3-surf-row {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg);
    padding: 7px 8px 6px;
}

.fp3-surf-head {
    display: flex;
    align-items: center;
    gap: 6px;
}

.fp3-surf-vis {
    width: var(--checkbox-size);
    height: var(--checkbox-size);
    flex: 0 0 auto;
    accent-color: var(--checkbox-accent);
    cursor: pointer;
}

.fp3-surf-swatch {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex: 0 0 auto;
    border: 1px solid rgba(255, 255, 255, 0.28);
}

.fp3-surf-name {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text);
    white-space: nowrap;
    flex: 1 1 auto;          /* grows so the delete button sits flush right */
}

.fp3-surf-del {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    padding: 0;
    line-height: 1;
    font-size: 15px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.fp3-surf-del:hover:not(:disabled) {
    color: var(--color-error);
    border-color: var(--plotter-error-border);
}
.fp3-surf-del:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.fp3-surf-expr {
    display: block;
    width: 100%;             /* own full-width line: room for a long input */
    margin-top: 6px;
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    outline: none;
    transition: border-color var(--transition-fast), background-color var(--transition-fast);
}
.fp3-surf-expr:focus {
    border-color: var(--accent);
    background: var(--bg);
}
.fp3-surf-expr.error {
    border-color: var(--color-error);
    background: var(--plotter-error-bg);
}

.fp3-surf-err {
    font-family: var(--font-ui);
    font-size: 10.5px;
    color: var(--color-error);
    line-height: 1.35;
    margin-top: 4px;
    display: none;
}
.fp3-surf-err.visible {
    display: block;
}

/* ── Add-surface button ────────────────────────────────────────── */
.fp3-add-btn {
    width: 100%;
    background: transparent;
    border: 1px dashed var(--border-active);
    color: var(--text-muted);
    padding: 6px 10px;
    font-family: var(--font-ui);
    font-size: 11.5px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.fp3-add-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--text-bright);
}
.fp3-add-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Definitionsbereich grid (x von / x bis / y von / y bis) ────── */
.fp3-dom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    margin-bottom: 8px;
}
.fp3-dom-cell {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.fp3-cap {
    font-family: var(--font-ui);
    font-size: 9px;
    font-weight: var(--font-semibold);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--text-dim);
}

.fp3-mini-input {
    width: 100%;
    min-width: 0;
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 3px 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    outline: none;
    transition: border-color var(--transition-fast);
}
.fp3-mini-input:focus {
    border-color: var(--accent);
}

.fp3-dom-error {
    font-family: var(--font-ui);
    font-size: 10.5px;
    color: var(--color-error);
    line-height: 1.4;
    margin: 2px 0 6px;
    display: none;
}
.fp3-dom-error.visible {
    display: block;
}

/* ── Height-colour legend gradient ─────────────────────────────────
   The five stops mirror the heightColor() ramp in render.ts (deep
   blue, cyan, green, amber, warm red). Literal hex, like every other
   colour in the plotter renderer: the plotter canvas is always dark
   by project convention, so the theme tokens do not apply to the
   surface palette. Keep this gradient in sync with HEIGHT_STOPS. */
.fp3-legend-gradient {
    background: linear-gradient(
        to right,
        #3b6fd6 0%,
        #33c4d4 25%,
        #6dbe82 50%,
        #e8b34a 75%,
        #d6604a 100%
    );
}

/* syncLegend() toggles the [hidden] attribute on #fp3-legend, but
   .plotter-legend (plotter.css) sets display:flex, which outranks the
   browser's default [hidden] rule. This explicit, higher-specificity
   rule lets the legend actually disappear when the height colormap is
   off. Same pattern as .fp-int-mode[hidden] in the single-variable
   plotter. */
#fp3-legend[hidden] { display: none; }

/* ── Status strip readout widths ───────────────────────────────────
   Reserve room so populating the trace readout on pointer-enter does
   not widen the bar and wrap the window readout onto a second row.
   Rendered in font-mono, so `ch` units pin the reservation to actual
   glyph width. Sized for the longest live string each readout can
   produce (the (x, y, z) hit triple, and the three x/y/z ranges). */
#fp3-status-trace  { min-width: 44ch; }
#fp3-status-window { min-width: 40ch; }

/* ── Mobile touch floor for the delete button ──────────────────────
   Mirror of fp-fn-del: desktop keeps 20 px so the 220 px sidebar can
   spare the room; at <=860 px the rail reflows wide and the hitbox
   grows to the 44 px tap floor while the visual `×` stays at the
   desktop font-size. */
@media (max-width: 860px) {
    .fp3-surf-del {
        min-width: var(--touch-target-min);
        min-height: var(--touch-target-min);
        padding: 10px;
        box-sizing: border-box;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: auto;
        height: auto;
    }
}
