/* /features/estimating/ only: the body of the hero's live instrument (a floor plan being taken
   off beside the estimate sheet it feeds; js/pages/estimating.js). The instrument's shell
   (stage, board header, activity footer) is .site-instrument in css/public-site.css. */

.est-board {
    /* One colour per takeoff item, on the plan and as the line's dot in the sheet. */
    --est-green: #15803D;
    --est-blue: #2563EB;
    --est-violet: #7C3AED;
    --est-amber: #C2410C;
    --est-teal: #0E7490;
}

.est-board__body { display: grid; grid-template-columns: 44% minmax(0, 1fr); gap: 14px; height: 400px; }

.est-pane { position: relative; display: flex; flex-direction: column; min-height: 0; overflow: hidden; border: 1px solid var(--site-line); border-radius: 10px; background: #fff; }
.est-pane__head {
    flex: none;
    height: 36px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--site-line);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--site-text);
    white-space: nowrap;
}
.est-pane__tag { font-family: var(--site-font-mono); font-size: 10.5px; font-weight: 400; letter-spacing: .06em; text-transform: uppercase; color: var(--site-subtle); }

/* ---------- The plan ---------- */
.est-plan__floor {
    position: relative;
    flex: 1;
    background-color: var(--site-paper);
    background-image:
        linear-gradient(rgba(23, 20, 31, .06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(23, 20, 31, .06) 1px, transparent 1px);
    background-size: 24px 24px;
}
.est-room {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--site-text-2);
    background: #fff;
    font-family: var(--site-font-mono);
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--site-subtle);
}
.est-room--bed-1  { left: 6%;  top: 8%;  width: 30%; height: 34%; }
.est-room--bed-2  { left: 40%; top: 8%;  width: 26%; height: 34%; }
.est-room--deck   { left: 70%; top: 8%;  width: 24%; height: 34%; }
.est-room--study  { left: 6%;  top: 46%; width: 24%; height: 42%; }
.est-room--living { left: 34%; top: 46%; width: 60%; height: 42%; }

/* Measurements (built by the script; position and colour set inline from its item list) */
.est-measure {
    position: absolute;
    z-index: 2;
    border-radius: 3px;
    cursor: pointer;
    opacity: 0;
    transform: scale(.7);
    pointer-events: none;
    transition: opacity .4s ease, transform .4s cubic-bezier(.34, 1.3, .64, 1), box-shadow .2s ease;
}
.est-measure.is-drawn { opacity: 1; transform: none; pointer-events: auto; }
.est-measure--area { border: 2px dashed currentColor; background: color-mix(in srgb, currentColor 12%, transparent); }
.est-measure--length { border: 3px solid currentColor; }
.est-measure--volume {
    border: 2px dashed currentColor;
    background: repeating-linear-gradient(-45deg, color-mix(in srgb, currentColor 16%, transparent) 0 6px, transparent 6px 12px);
}
.est-measure:hover, .est-measure.is-hot { z-index: 4; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 30%, transparent); }
.est-measure__label {
    position: absolute;
    top: -22px;
    left: 50%;
    transform: translateX(-50%);
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--site-ink-2);
    color: #fff;
    font-family: var(--site-font-mono);
    font-size: 10.5px;
    white-space: nowrap;
    pointer-events: none;
}
.est-measure__label:empty { display: none; }
/* A count: numbered markers dropped one at a time, no outline of its own. It shares the
   Living room with the tiles, so only the markers take clicks, and its label sits below. */
.est-measure--count { border: 0; background: none; }
.est-measure--count.is-drawn { pointer-events: none; }
.est-measure--count .est-measure__label { top: auto; bottom: -24px; }
.est-measure--count:hover, .est-measure--count.is-hot { box-shadow: none; }
.est-measure--count.is-hot .est-marker { box-shadow: 0 0 0 2px #fff, 0 0 0 5px color-mix(in srgb, currentColor 35%, transparent); }
.est-marker {
    position: absolute;
    width: 18px;
    height: 18px;
    margin: -9px 0 0 -9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 0 2px #fff;
    opacity: 0;
    transform: scale(.4);
    transition: opacity .25s ease, transform .3s cubic-bezier(.34, 1.6, .64, 1);
}
.est-marker span { font-family: var(--site-font-mono); font-size: 9px; color: #fff; }
.est-marker.is-dropped { opacity: 1; transform: none; pointer-events: auto; cursor: pointer; }

/* ---------- The sheet ---------- */
.est-fx {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--site-line);
    background: #FAFAFC;
}
.est-fx__icon { font-family: Georgia, 'Times New Roman', serif; font-size: 13px; font-style: italic; color: var(--site-accent); }
.est-fx__cell { padding: 2px 7px; border-radius: 4px; background: var(--site-panel); font-family: var(--site-font-mono); font-size: 10.5px; color: var(--site-text-2); white-space: nowrap; }
.est-fx__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--site-font-mono); font-size: 12px; color: var(--site-accent); transition: opacity .18s ease; }
.est-fx__text.is-swapping { opacity: 0; }

.est-sheet__lines { flex: 1; min-height: 0; overflow: hidden; }
.est-table { width: 100%; border-collapse: collapse; }
.est-table th {
    padding: 7px 10px;
    background: var(--site-paper);
    font-family: var(--site-font-mono);
    font-size: 10px;
    font-weight: 400;
    letter-spacing: .08em;
    text-transform: uppercase;
    text-align: left;
    color: var(--site-subtle);
    white-space: nowrap;
}
.est-table td { padding: 8px 10px; border-top: 1px solid #ECEAF1; font-size: 12.5px; color: var(--site-text-2); white-space: nowrap; }
.est-table td:nth-child(2) { max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; }
.est-table .num { text-align: right; }
.est-table td.est-amount { font-weight: 600; color: var(--site-text); }
.est-table tbody tr { cursor: pointer; transition: background-color .2s ease; }
.est-table tbody tr:hover td { background: #F7F5FC; }
.est-table tbody tr.is-hot td { background: var(--site-panel); }
/* backwards, never both: a transform left on a <tr> after the animation stops Chrome hit-testing
   the row, and clicking a line does nothing. */
.est-table tbody tr.is-new { animation: est-line-in .45s cubic-bezier(.34, 1.3, .64, 1) backwards; }
@keyframes est-line-in { from { opacity: 0; transform: translateY(-8px); } }
.est-table td.is-flash { animation: est-cell-flash .9s ease; }
@keyframes est-cell-flash { from { background: #FFF1C2; } }
.est-table__empty td { font-style: italic; color: var(--site-subtle); cursor: default; }
.est-dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: currentColor; vertical-align: 0; }

.est-totals { flex: none; padding: 8px 12px; border-top: 1px solid var(--site-line); background: #FAFAFC; }
.est-totals__row { display: flex; justify-content: space-between; padding: 2px 0; font-size: 12.5px; color: var(--site-muted); }
.est-totals__value { display: inline-block; font-weight: 600; color: var(--site-text); }
.est-totals__row--grand { margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--site-line); font-weight: 600; color: var(--site-text); }
.est-totals__row--grand .est-totals__value { font-size: 15px; color: var(--site-accent); }

/* ---------- Narrow: the plan above the sheet ---------- */
@media (max-width: 760px) {
    .est-board__body { grid-template-columns: minmax(0, 1fr); height: auto; }
    .est-plan { height: 230px; }
    .est-sheet__lines { flex: none; height: 206px; }   /* room for every line, so nothing below moves as they land */
    .est-col-item, .est-col-unit, .est-col-rate { display: none; }
    /* Just the contract price, once: the rest of the build-up, and the figures in the header
       that repeat it, are the desktop view's. */
    .est-board .site-instrument__figures { display: none; }
    .est-totals__row:not(.est-totals__row--grand) { display: none; }
    .est-totals__row--grand { margin-top: 0; padding-top: 2px; border-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .est-measure, .est-marker, .est-fx__text, .est-table tbody tr { transition: none; }
}
