/*
 * Warm floor planner (calculator/planirovshchik-teplogo-pola.html.twig, warm-floor/editor.js). Tokens only: the light and the
 * dark theme come from engine.css and site.css. Pipe colours are data colours (the same in both themes).
 * Targets are at least 44 px; the plan is an inline SVG, its text is 12 px or more at the real scale.
 */

.wfp {
    margin: var(--s-5) 0;
}

.wfp-fallback {
    margin: 0;
    padding: var(--s-4);
    border: 1px dashed var(--c-border-strong);
    border-radius: var(--radius-lg);
    color: var(--c-muted);
}

.wfp-main {
    display: grid;
    gap: var(--s-5);
}

@media (min-width: 960px) {
    .wfp-main {
        grid-template-columns: minmax(0, 1fr) 300px;
        align-items: start;
    }
}

.wfp-canvas {
    min-width: 0;
}

.wfp-side {
    min-width: 0;
    display: grid;
    gap: var(--s-3);
}

.wfp-h2 {
    margin: var(--s-5) 0 var(--s-2);
    font-size: var(--fs-h3);
}

.wfp-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    margin-bottom: var(--s-3);
}

.wfp-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    align-items: center;
}

.wfp-btn {
    min-height: 44px;
    min-width: 44px;
    padding: 0 var(--s-3);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-text);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
}

.wfp-btn:hover {
    background: var(--c-row-hover);
}

.wfp-btn[aria-pressed="true"] {
    background: var(--c-accent);
    border-color: var(--c-accent);
    color: var(--c-on-accent);
}

.wfp-btn--danger {
    color: var(--c-error);
}

.wfp-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.wfp-btn:focus-visible,
.wfp-svg:focus-visible,
.wfp-select:focus-visible,
.wfp-list__item:focus-visible,
.wfp input:focus-visible,
.wfp select:focus-visible {
    outline: 2px solid var(--c-focus);
    outline-offset: 2px;
}

.wfp-select,
.wfp input:not([type="checkbox"]),
.wfp select {
    min-height: 46px;
    padding: 0 var(--s-3);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-text);
    font: inherit;
    font-size: 16px;
    max-width: 100%;
}

.wfp-check {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    min-height: 44px;
    font-size: var(--fs-sm);
}

.wfp-svg {
    display: block;
    width: 100%;
    height: clamp(300px, 56vh, 560px);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius-lg);
    background: var(--c-surface-alt);
    touch-action: none;
    user-select: none;
}

.wfp-svg[data-tool="room"],
.wfp-svg[data-tool="zone"],
.wfp-svg[data-tool="collector"] {
    cursor: crosshair;
}

.wfp-svg[data-tool="pan"] {
    cursor: grab;
}

.wfp-grid {
    fill: none;
    stroke: var(--c-border);
    stroke-width: 1;
    stroke-opacity: 0.6;
}

.wfp-room {
    fill: color-mix(in srgb, var(--c-accent) 10%, transparent);
    stroke: var(--c-accent);
    stroke-width: 2;
    stroke-linejoin: round;
}

.wfp-room.is-selected {
    stroke-width: 3;
    fill: color-mix(in srgb, var(--c-accent) 18%, transparent);
}

.wfp-dim {
    fill: var(--c-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums lining-nums;
}

/* A halo under the room labels: the pipe runs under them and must not make them unreadable. */
.wfp-name,
.wfp-area,
.wfp-dim {
    paint-order: stroke;
    stroke: var(--c-surface-alt);
    stroke-width: 4px;
    stroke-linejoin: round;
}

.wfp-name {
    fill: var(--c-text);
    font-size: 14px;
    font-weight: 700;
}

.wfp-area {
    fill: var(--c-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums lining-nums;
}

.wfp-hatch-bg {
    fill: transparent;
}

.wfp-hatch-line {
    stroke: var(--c-muted);
    stroke-width: 2;
}

.wfp-zone {
    stroke: var(--c-muted);
    stroke-width: 1.5;
}

.wfp-zone.is-selected {
    stroke: var(--c-accent);
    stroke-width: 3;
}

.wfp-zone-draft {
    fill: color-mix(in srgb, var(--c-accent) 15%, transparent);
    stroke: var(--c-accent);
    stroke-dasharray: 6 4;
}

.wfp-pipe {
    fill: none;
    stroke-width: 2.5;
    stroke-linejoin: round;
    stroke-linecap: round;
    stroke-opacity: 0.9;
}

.wfp-loop-dot {
    stroke: var(--c-surface);
    stroke-width: 2;
}

.wfp-loop-num {
    fill: #fff;
    font-size: 11px;
    font-weight: 700;
}

.wfp-collector rect {
    fill: var(--c-accent-soft);
    stroke: var(--c-accent);
    stroke-width: 2;
}

.wfp-collector.is-selected rect {
    stroke-width: 3;
}

.wfp-collector text {
    fill: var(--c-text);
    font-size: 12px;
    font-weight: 700;
}

.wfp-handle {
    fill: var(--c-surface);
    stroke: var(--c-accent);
    stroke-width: 2;
}

.wfp-draft {
    fill: none;
    stroke: var(--c-accent);
    stroke-width: 2;
    stroke-dasharray: 6 4;
}

.wfp-draft-dot {
    fill: var(--c-accent);
}

.wfp-draft-dot.is-first {
    fill: var(--c-surface);
    stroke: var(--c-accent);
    stroke-width: 2;
}

.wfp-hint {
    margin: var(--s-2) 0 0;
    color: var(--c-muted);
    font-size: var(--fs-sm);
}

.wfp-status {
    min-height: 1.5em;
    margin: var(--s-2) 0 0;
    font-size: var(--fs-sm);
    font-weight: 600;
}

.wfp-rooms .wfp-muted,
.wfp-muted {
    margin: 0;
    color: var(--c-muted);
    font-size: var(--fs-sm);
}

.wfp-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--s-1);
}

.wfp-list__item {
    width: 100%;
    min-height: 44px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-2);
    padding: 0 var(--s-3);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-text);
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.wfp-list__item[aria-pressed="true"] {
    border-color: var(--c-accent);
    background: var(--c-accent-soft);
}

.wfp-list__meta {
    color: var(--c-muted);
    font-size: var(--fs-sm);
    font-weight: 400;
    font-variant-numeric: tabular-nums lining-nums;
    white-space: nowrap;
}

.wfp-form {
    display: grid;
    gap: var(--s-3);
}

.wfp-form__title {
    margin: 0;
    font-weight: 700;
}

.wfp-field {
    display: grid;
    gap: var(--s-1);
}

.wfp-field label {
    font-size: var(--fs-sm);
    font-weight: 600;
}

.wfp-field__hint {
    margin: 0;
    color: var(--c-muted);
    font-size: var(--fs-xs);
}

.wfp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}

.wfp-supply p {
    margin: 0;
    font-size: var(--fs-sm);
}

.wfp-result {
    display: grid;
    gap: var(--s-3);
}

.wfp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
}

.wfp-table caption {
    text-align: left;
    padding-bottom: var(--s-2);
    font-weight: 600;
}

.wfp-table th,
.wfp-table td {
    padding: var(--s-2);
    border-bottom: 1px solid var(--c-border);
    text-align: left;
    vertical-align: top;
}

.wfp-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums lining-nums;
    white-space: nowrap;
}

.wfp-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: var(--s-1);
    border-radius: 2px;
    vertical-align: middle;
}

.wfp-totals {
    margin: 0;
    display: grid;
    gap: var(--s-1);
}

.wfp-totals__row {
    display: flex;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-1) 0;
    border-bottom: 1px solid var(--c-border);
    font-size: var(--fs-sm);
}

.wfp-totals dt {
    color: var(--c-muted);
}

.wfp-totals dd {
    margin: 0;
    font-weight: 700;
    font-variant-numeric: tabular-nums lining-nums;
    text-align: right;
}

.wfp-files {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
}

.wfp-link-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    margin-top: var(--s-3);
}

.wfp-link {
    flex: 1 1 260px;
    min-width: 0;
    min-height: 46px;
    padding: 0 var(--s-3);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-text);
    font: inherit;
    font-size: var(--fs-sm);
}

.wfp-results,
.wfp-files-wrap {
    margin-top: var(--s-6);
}

/* Full screen: the root covers the viewport above the site header, footer, cookie banner and ads (z-index). The plan takes
   all the room under the toolbar; the panels (rooms, result, project) float over the plan at the right (wide screens)
   or as a bottom sheet (below 768 px), one at a time. Without the Fullscreen API this class is the whole mode. */
.wfp-fs-only {
    display: none;
}

.wf--fullscreen .wfp-fs-only {
    display: inline-flex;
}

.wf--fullscreen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    margin: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    padding: var(--s-2) var(--s-3);
    background: var(--c-bg);
    color: var(--c-text);
    overflow: hidden;
}

.wf--fullscreen .wfp-main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.wf--fullscreen .wfp-canvas {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.wf--fullscreen .wfp-toolbar {
    margin-bottom: var(--s-2);
}

.wf--fullscreen .wfp-stage {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.wf--fullscreen .wfp-svg {
    flex: 1 1 auto;
    height: auto;
    min-height: 180px;
}

.wf--fullscreen .wfp-side,
.wf--fullscreen .wfp-results,
.wf--fullscreen .wfp-files-wrap {
    display: none;
}

.wf--fullscreen[data-panel="rooms"] .wfp-side,
.wf--fullscreen[data-panel="result"] .wfp-results,
.wf--fullscreen[data-panel="files"] .wfp-files-wrap {
    display: grid;
    align-content: start;
}

.wf--fullscreen .wfp-panel {
    position: absolute;
    top: var(--wfp-panel-top, 96px);
    right: var(--s-3);
    bottom: var(--s-3);
    z-index: 2;
    width: min(340px, calc(100% - 2 * var(--s-3)));
    margin: 0;
    padding: var(--s-3);
    overflow: auto;
    box-sizing: border-box;
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius-lg);
    background: var(--c-surface);
    box-shadow: var(--shadow-pop);
    align-content: start;
}

.wf--fullscreen .wfp-results,
.wf--fullscreen .wfp-files-wrap {
    gap: var(--s-3);
}

.wf--fullscreen .wfp-h2 {
    margin-top: var(--s-3);
}

.wf--fullscreen .wfp-panel .wfp-h2:first-of-type {
    margin-top: var(--s-2);
}

.wf--fullscreen .wfp-panel-close {
    justify-self: end;
}

@media (max-width: 767px) {
    /* Phones: the toolbar is one row that scrolls sideways, so the plan keeps the height of the screen. */
    .wf--fullscreen .wfp-toolbar,
    .wf--fullscreen .wfp-group {
        flex-wrap: nowrap;
    }
    .wf--fullscreen .wfp-toolbar {
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
        padding-bottom: var(--s-1);
    }
    .wf--fullscreen .wfp-toolbar > .wfp-group,
    .wf--fullscreen .wfp-toolbar .wfp-btn,
    .wf--fullscreen .wfp-toolbar select,
    .wf--fullscreen .wfp-toolbar .wfp-check {
        flex: none;
        white-space: nowrap;
    }
    .wf--fullscreen .wfp-panel {
        top: auto;
        right: var(--s-2);
        left: var(--s-2);
        bottom: var(--s-2);
        width: auto;
        max-height: 65%;
    }
}

html.wf-fs-lock,
html.wf-fs-lock body {
    overflow: hidden;
}

@media print {
    .wf--fullscreen {
        position: static;
        inset: auto;
        z-index: auto;
        display: block;
        padding: 0;
        background: #fff;
        color: #000;
        overflow: visible;
    }

    .wfp-fs-only,
    .wfp-panel-close {
        display: none !important;
    }

    html.wf-fs-lock,
    html.wf-fs-lock body {
        overflow: visible;
    }

    .wfp-toolbar,
    .wfp-side,
    .wfp-files-wrap,
    .wfp-status,
    .wfp-hint,
    .wfp-howto,
    .wfp-fallback,
    .wfp-link-row,
    .wfp-h2 + p {
        display: none !important;
    }

    .wfp-main {
        display: block;
    }

    .wfp-svg {
        height: auto;
        aspect-ratio: 4 / 3;
        border: 0;
        background: #fff;
    }

    .wfp-results,
    .wfp-files-wrap {
        display: block;
        margin-top: var(--s-4);
    }

    .wfp-table th,
    .wfp-table td,
    .wfp-totals__row {
        font-size: 11pt;
    }

    .wfp-room {
        fill: none;
        stroke: #000;
    }

    .wfp-grid {
        display: none;
    }
}
