/* ABOUTME: Site styling for the coldroom embodied carbon calculator supplied by Williams.
   ABOUTME: Its script is vendored untouched and selects on these class names, so none may be renamed. */

/* Lives outside the Sass build because node-sass cannot be compiled on current
   machines. Site values are repeated here rather than imported: brand #42c4dd,
   corporate #004990, neutral dark #343434, borders #e4e4e4, radius 5px. */

.carbon-calculator {
    color: #343434;
}

.carbon-calculator .layout {
    display: block;
}

.carbon-calculator h2 {
    margin: 0;
    color: #004990;
    font-size: 20px;
    font-weight: 300;
}

/* Panels ------------------------------------------------------------------ */

.carbon-calculator .comp,
.carbon-calculator .total,
.carbon-calculator .visual {
    margin: 0 0 1.5rem;
    padding: 1.5rem;
    background: #fff;
    border: 1px solid #e4e4e4;
    border-radius: 5px;
}

.carbon-calculator .total {
    border-color: #004990;
    background: #f6f9fc;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.carbon-calculator .comp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid #e4e4e4;
}

.carbon-calculator .actions {
    display: flex;
    gap: .5rem;
}

/* Fields ------------------------------------------------------------------ */

.carbon-calculator .grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.carbon-calculator label {
    display: block;
    color: #737373;
    font-size: 13px;
    line-height: 1.4;
}

.carbon-calculator input[type=number],
.carbon-calculator select {
    display: block;
    width: 100%;
    margin-top: .25rem;
    padding: .5rem .75rem;
    transition: border-color 500ms;
    background: #fff;
    border: 1px solid #d6e1e5;
    border-radius: 5px;
    color: #343434;
    font-size: 16px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.carbon-calculator input[type=number]:focus,
.carbon-calculator select:focus {
    border-color: #42c4dd;
}

/* Same chevron the site puts on its own selects. */
.carbon-calculator select {
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2210px%22%20height%3D%227px%22%3E%3Cpath%20fill%3D%22%23999%22%20stroke%3D%22%23999%22%20stroke-width%3D%22.5%22%20d%3D%22M8.75 0L5 3.943 1.167 0 0 1.2l5 5.143L10 1.2z%22%20%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 1rem) 50%;
}

/* Stepper buttons, so the dimensions can be set without a keyboard on mobile. */
.carbon-calculator .stepper {
    display: flex;
    align-items: stretch;
    gap: .5rem;
}

.carbon-calculator .stepper input[type=number] {
    flex: 1;
    min-width: 0;
}

/* The buttons replace the browser's own spinner. */
.carbon-calculator .stepper input[type=number]::-webkit-inner-spin-button,
.carbon-calculator .stepper input[type=number]::-webkit-outer-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

/* These are the only controls on the site meant to be pressed repeatedly in one
   spot, so they need the double tap taken out of the browser's hands: without
   this a quick second press is read as a zoom gesture rather than a press.
   Pinch to zoom is untouched. */
.carbon-calculator .stepper__button {
    flex: none;
    width: 2.75rem;
    margin-top: .25rem;
    padding: 0;
    background: #fff;
    border-color: #d6e1e5;
    color: #343434;
    font-size: 20px;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.carbon-calculator .stepper__button:hover {
    background: #42c4dd;
    border-color: #42c4dd;
    color: #fff;
}

.carbon-calculator .stepper__button:disabled {
    background: #f6f6f6;
    border-color: #e4e4e4;
    color: #999;
    cursor: not-allowed;
}

/* Set by the calculator on fields it fixes to match an earlier compartment. */
.carbon-calculator input.height-locked {
    background: #f6f6f6;
    border-color: #e4e4e4;
    color: #999;
    cursor: not-allowed;
}

.carbon-calculator .floor-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1rem;
}

.carbon-calculator .floor-row label {
    display: flex;
    align-items: center;
    color: #343434;
    font-size: 14px;
}

.carbon-calculator input[type=checkbox] {
    width: 1rem;
    height: 1rem;
    margin-right: .5rem;
    accent-color: #42c4dd;
}

.carbon-calculator .disabled {
    opacity: .4;
    pointer-events: none;
}

/* Buttons ----------------------------------------------------------------- */

.carbon-calculator button {
    display: inline-block;
    padding: .3rem 1rem;
    transition: background 200ms, border 200ms, color 200ms;
    background: #42c4dd;
    border: 1px solid #42c4dd;
    border-radius: 5px;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    font-weight: 300;
    text-align: center;
    text-transform: uppercase;
}

.carbon-calculator button:hover {
    background: #2fb9d4;
    border-color: #2fb9d4;
}

.carbon-calculator .calculator-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.5rem;
}

.carbon-calculator #btnPrint {
    background: transparent;
    color: #42c4dd;
}

.carbon-calculator #btnPrint:hover {
    background: #42c4dd;
    color: #fff;
}

.carbon-calculator .btn-small {
    padding: .2rem .75rem;
    font-size: 13px;
}

.carbon-calculator .btn-danger {
    background: transparent;
    border-color: #ef7f6b;
    color: #ef7f6b;
}

.carbon-calculator .btn-danger:hover {
    background: #ef7f6b;
    border-color: #ef7f6b;
    color: #fff;
}

/* Totals ------------------------------------------------------------------ */

/* The markup carries a "main" class the site also uses for page width. */
.carbon-calculator .results.main {
    max-width: none;
    margin: .75rem 0 0;
    padding: 0;
    font-size: 18px;
    line-height: 1.6;
}

/* Room drawing ------------------------------------------------------------ */

.carbon-calculator .print-only {
    display: none;
}

.carbon-calculator #roomViz {
    display: block;
    width: 100%;
    height: 560px;
    margin-top: .75rem;
}

.carbon-calculator #roomViz [stroke="#003473"] {
    stroke: #004990;
}

.carbon-calculator .dim {
    fill: #004990;
    font-size: 12px;
    font-weight: 600;
}

.carbon-calculator .label {
    fill: #343434;
    font-size: 12px;
}

/* Terms -------------------------------------------------------------------- */

.carbon-calculator__terms {
    margin-top: 1.5rem;
    color: #737373;
    font-size: 13px;
}

.carbon-calculator__terms ul {
    margin-top: .75rem;
}

.carbon-calculator__terms li {
    margin-left: 1.25rem;
    list-style: disc outside;
}

/* Responsive --------------------------------------------------------------- */

/* Below the two column layout the drawing has the full page width, so let it
   take its own aspect ratio rather than the tall fixed height. */
@media (max-width: 899px) {
    .carbon-calculator #roomViz {
        height: auto;
    }
}

@media (min-width: 900px) {
    .carbon-calculator .layout {
        display: grid;
        grid-template-columns: 2fr 1fr;
        gap: 1.5rem;
        align-items: start;
    }

    .carbon-calculator .visual {
        /* Clear the fixed site header. */
        position: sticky;
        top: 6rem;
    }
}

/* Print -------------------------------------------------------------------- */

@media print {
    .site-header,
    .site-footer,
    .header,
    .cookie-consent,
    .page-contact,
    .carbon-calculator .calculator-actions,
    .carbon-calculator .actions,
    .carbon-calculator .stepper__button {
        display: none;
    }

    main {
        padding-top: 0;
    }

    .carbon-calculator .layout {
        display: block;
    }

    .carbon-calculator .comp,
    .carbon-calculator .total,
    .carbon-calculator .visual {
        position: static;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .carbon-calculator .visual {
        break-before: page;
        page-break-before: always;
        margin-top: 0;
    }

    .carbon-calculator #roomViz {
        height: auto;
    }

    .carbon-calculator .screen-only {
        display: none;
    }

    .carbon-calculator .print-only {
        display: block;
    }
}
