/* Phase-Field Lab: layout on top of the shared studio design (tools.css). */

/* ---------- Transport controls ---------- */

.transport {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 18px;
}

.btn.run {
    height: 32px;
    padding: 0 16px 0 12px;
    border: 0;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--chip-a), var(--chip-b));
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--chip-a) 30%, transparent);
}

.btn.run:hover {
    filter: brightness(1.07);
}

.btn.run[aria-pressed="true"] {
    background: linear-gradient(135deg, #e0662f, #b8461d);
    box-shadow: 0 2px 8px rgb(224 102 47 / 35%);
}

.btn.run .i-pause,
.btn.run[aria-pressed="true"] .i-play {
    display: none;
}

.btn.run[aria-pressed="true"] .i-pause {
    display: inline;
}

.btn.run svg {
    fill: currentColor;
    stroke: currentColor;
}

.speed select {
    height: 30px;
    padding: 0 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--ink);
}

.layout-seg {
    width: 190px;
}

.tabs.three {
    grid-template-columns: repeat(3, 1fr);
}

/* ---------- Model card ---------- */

.card.static {
    border-color: color-mix(in srgb, var(--accent-2) 45%, var(--line));
    box-shadow: var(--card-shadow-open);
}

.card-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px 6px;
}

.model-tiles button span {
    font-size: 11px;
}

.model-desc {
    line-height: 1.5;
}

.equation {
    display: grid;
    gap: 2px;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--ink);
}

.eq-line {
    min-height: 1.6em;
    overflow-x: auto;
    overflow-y: hidden;
    font-size: 11.5px;
}

.eq-line .katex-display {
    margin: 4px 0;
}

.eq-line .katex {
    font-size: 1.12em;
}

.eq-line.raw {
    padding: 4px 0;
    font-family: var(--mono);
    font-size: 11px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--ink-2);
}

.eq-note {
    margin: 2px 0 4px;
    font-size: 11px;
    color: var(--ink-3);
    line-height: 1.4;
}

.seg.wrap {
    grid-auto-flow: row;
    grid-template-columns: repeat(3, 1fr);
}

.seg.wrap button {
    height: auto;
    min-height: 26px;
    padding: 4px 6px;
    line-height: 1.25;
}

.init-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.param-group {
    display: grid;
    gap: 9px;
    margin-top: 6px;
}

.param {
    display: grid;
    grid-template-columns: 1fr 76px;
    align-items: center;
    gap: 3px 10px;
}

.param>label {
    grid-column: 1 / -1;
    font-size: 11.5px;
    color: var(--ink-2);
}

.param input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

.param input[type="number"] {
    width: 100%;
    height: 26px;
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--panel-2);
    font-family: var(--mono);
    font-size: 11.5px;
    text-align: right;
}

/* ---------- Colour bar ---------- */

.cbar {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--ink-2);
}

.cbar i {
    display: block;
    height: 12px;
    border-radius: 6px;
    border: 1px solid var(--line);
}

.plane-tiles button {
    padding: 8px 4px;
}

.plane-tiles b {
    font-size: 13px;
    color: var(--ink);
}

.plane-tiles span {
    font-size: 10.5px;
    color: var(--ink-3);
}

.view-dirs .btn {
    height: 28px;
    font-size: 12px;
}

/* ---------- Viewport: 3D and slice panes ---------- */

.pf-viewport {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 8px;
    background: var(--app-bg);
}

.pf-viewport[data-layout="3d"] {
    grid-template-columns: 1fr;
}

.pf-viewport[data-layout="3d"] #pane2d,
.pf-viewport[data-layout="slice"] #pane3d {
    display: none;
}

.pf-viewport[data-layout="slice"] {
    grid-template-columns: 1fr;
}

.pane {
    position: relative;
    min-width: 0;
    min-height: 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--panel);
    box-shadow: var(--card-shadow);
}

.pane canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

#c3d {
    cursor: grab;
}

#c3d:active {
    cursor: grabbing;
}

#c2d {
    cursor: ns-resize;
}

.pane-label {
    position: absolute;
    top: 10px;
    left: 12px;
    display: grid;
    padding: 6px 10px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--panel) 80%, transparent);
    backdrop-filter: blur(6px);
    border: 1px solid var(--line);
    pointer-events: none;
    line-height: 1.3;
    max-width: calc(100% - 24px);
}

.pane-label b {
    font-family: var(--serif);
    font-size: 14px;
    font-weight: 600;
}

.pane-label span {
    font-size: 11.5px;
    color: var(--ink-2);
}

.hud-stats {
    position: absolute;
    right: 12px;
    top: 10px;
    padding: 6px 10px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--panel) 80%, transparent);
    backdrop-filter: blur(6px);
    border: 1px solid var(--line);
    font-family: var(--mono);
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--ink-2);
    pointer-events: none;
    text-align: right;
}

.hud-stats b {
    color: var(--ink);
}

.triad {
    position: absolute;
    left: 10px;
    bottom: 10px;
    width: 86px;
    height: 86px;
    pointer-events: none;
}

.triad text {
    font: 600 14px var(--sans);
    fill: #fff;
    text-anchor: middle;
    dominant-baseline: central;
}

.scalebar {
    position: absolute;
    right: 14px;
    bottom: 12px;
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: 5px 9px;
    border-radius: 7px;
    background: color-mix(in srgb, var(--panel) 80%, transparent);
    backdrop-filter: blur(6px);
    border: 1px solid var(--line);
    pointer-events: none;
    font-size: 11px;
    color: var(--ink-2);
}

.scalebar i {
    display: block;
    height: 4px;
    border: 1.5px solid var(--ink);
    border-top: 0;
}

.nogpu {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--app-bg);
    z-index: 20;
    text-align: center;
}

.nogpu h2 {
    font-family: var(--serif);
    margin: 0 0 8px;
}

.nogpu p {
    max-width: 52ch;
    color: var(--ink-2);
    margin: 0 auto;
}

@media (max-width: 860px) {
    .pf-viewport {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .pf-viewport[data-layout="3d"],
    .pf-viewport[data-layout="slice"] {
        grid-template-rows: 1fr;
    }

    .transport {
        margin-left: auto;
    }

    .transport .speed,
    .toolbar .tb-sep,
    #btn-theme {
        display: none;
    }
}

/* "Reset with these settings" pulses when a change needs a reset. */
.btn.primary.block.pulse {
    animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
    50% {
        box-shadow: 0 0 0 5px color-mix(in srgb, var(--chip-a) 30%, transparent);
    }
}

#mem-note.warn .warn {
    color: var(--danger);
    font-weight: 600;
}
