/*
 * Residential Load Calculation
 * Updated stylesheet
 *
 * The existing page colors, typography, button colors, grid layout,
 * popup appearance, and general spacing have been retained.
 */

/* ---------- Base layout ---------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 10px;
    background-color: LightGray;
    color: #000;
    font-family: Verdana, Arial, "Trebuchet MS", Geneva, sans-serif;
    font-size: 100%;
    line-height: 1.2;
    text-align: center;
}

.page-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.centerPage {
    margin-right: auto;
    margin-left: auto;
    font-size: 100%;
    text-align: center;
}

/* ---------- Headings and text ---------- */

h1 {
    padding: 20px 0 10px;

    color: #000;
    font-family: Times, "Times New Roman", Georgia, serif;
    text-align: center;
}

h2 {
    margin-bottom: 10px;
    color: #000;
    font-family: Times, Verdana, Arial, "Trebuchet MS", Geneva, sans-serif;
    font-size: 125%;
    text-align: center;
}

p {
    padding: 5px 0;
    border: none;
    color: #000;
    font-family: Verdana, Arial, "Trebuchet MS", Geneva, sans-serif;
    font-size: 100%;
    line-height: 1.6;
}

strong {
    font-weight: 700;
}

sup,
sub {
    font-size: smaller;
}

sup {
    vertical-align: super;
}

sub {
    vertical-align: sub;
}

/* ---------- Links ---------- */

a:link {
    color: Blue;
}

a:hover {
    color: Red;
}

.lornmac {
    font-size: 170%;
}

.lornmac a {
    color: #000;
    font-family: Times, "Times New Roman", Georgia, serif;
    text-decoration: none;
}

/* ---------- Navigation ---------- */

.myNav {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    margin-right: auto;
    margin-left: auto;
    padding: 8px 0;
    border-bottom: 1px solid #E8E8E8;
    background-color: LightGray;
    text-align: center;
}

/* ---------- Navigation buttons ---------- */

.styled1,
.styled2,
.styled3 {
    display: inline-block;
    width: 25%;
    height: 30px;
    margin: 4px 0;
    padding: 5px;
    border: medium solid;
    border-radius: 30px 5px;
    font-size: 75%;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.styled1 {
    border-color: orchid;
    background-color: yellow;
    color: #000;
}

.styled1:hover {
    border-color: yellow;
    background-color: orchid;
    color: #000;
}

.styled2 {
    border-color: blue;
    background-color: Orange;
    color: #000;
}

.styled2:hover {
    border-color: orange;
    background-color: blue;
    color: #fff;
}

.styled3 {
    border-color: green;
    background-color: #ff3333;
    color: #000;
}

.styled3:hover {
    border-color: #ff3333;
    background-color: green;
    color: #fff;
}

/* ---------- Forms and calculation grids ---------- */

input,
select,
button {
    font: inherit;
}

input,
select {
    border: 1px solid #777;
    border-radius: 5px;
}

input {
    display: block;
    width: 60%;
    margin-right: auto;
    margin-left: auto;
    padding: 3px 1px;
    background-color: yellow;
    font-size: 115%;
    text-align: center;
}

select {
    display: block;
    width: 60%;
    margin-right: auto;
    margin-left: auto;
    padding: 3px 1px;
    background-color: yellow;
    font-size: 115%;
    text-align: center;
    text-align-last: center;
}

option {
    text-align: center;
}

.matrix-container,
.matrix-container-motor,
.matrix-container-5col {
    display: grid;
    gap: 15px;
    max-width: 1100px;
    margin: 20px auto;
    align-items: center;
}

.matrix-container {
    grid-template-columns: 1fr 2fr 1fr 1fr;
}

.matrix-container-motor {
    grid-template-columns: 2fr 1fr 1fr 1fr;
}

.matrix-container-5col {
    grid-template-columns: 1fr 2fr 1.5fr 1fr 1fr;
}

.matrix-container input,
.matrix-container .matrix-constant,
.matrix-container .matrix-header,
.matrix-container-motor input,
.matrix-container-motor .matrix-constant,
.matrix-container-motor .matrix-header,
.matrix-container-5col input,
.matrix-container-5col select,
.matrix-container-5col .matrix-constant,
.matrix-container-5col .matrix-header {
    width: 100%;
    height: 100%;
    min-width: 0;
    margin: 0;
    padding: 6px;
}

.matrix-constant {
    background-color: #f0f0f0;
    color: #333;
    font-weight: 700;
    text-align: center;
}

.matrix-header {
    border-radius: 8px;
    background-color: darkblue;
    color: #fff;
    font-weight: 700;
    text-align: center;
}

.matrix-header-connectedLoad {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 6px;
    border-radius: 8px;
    background-color: darkgoldenrod;
    color: #000;
    font-weight: 700;
    text-align: center;
}

.total-grand {
    font-weight: 700;
}

.matrix-summary {
    max-width: 700px;
    margin: 10px auto;
    text-align: left;
}

.summary-container {
    max-width: 500px;
    margin: 15px auto;
    padding: 12px;
    border: 1px dashed #ccc;
    background: transparent;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.4;
    text-align: left;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ---------- Informational popups ---------- */

.popup-container {
    position: relative;
    display: inline-block;
    cursor: help;
}

.popup-box {
    position: absolute;
    bottom: 125%;
    left: 50%;
    z-index: 30;
    display: none;
    width: 350px;
    max-width: min(350px, 85vw);
    padding: 10px;
    transform: translateX(-50%);
    border: 4px solid #ff0000;
    border-radius: 6px;
    background-color: #fff;
    box-shadow: 8px 8px 15px rgba(0, 0, 0, 0.7);
    color: #000;
    text-align: center;
}

.popup-container:hover .popup-box,
.popup-container:focus-within .popup-box {
    display: block;
}

/* ---------- Footer ---------- */

footer {
    width: auto;
    height: auto;
    margin-top: 1%;
    margin-bottom: 1%;
    padding: 5px;
    font-family: Verdana, Arial, "Trebuchet MS", Geneva, sans-serif;
    font-size: 75%;
    text-align: center;
}

/* ---------- Accessibility and interaction ---------- */

/* A visible keyboard focus indicator without changing the normal appearance. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* Prevent hover-only effects from being forced on touch devices. */
@media (hover: none) {
    .styled1:hover,
    .styled2:hover,
    .styled3:hover {
        /* Keep the normal button appearance on touch screens. */
        filter: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

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

@media screen and (max-width: 700px) {
    body {
        padding: 8px;
    }

    .page-wrapper {
        padding: 0 8px;
    }

    .matrix-container,
    .matrix-container-motor,
    .matrix-container-5col {
        gap: 8px;
    }

    .matrix-container {
        grid-template-columns: 0.8fr 1.7fr 0.9fr 0.9fr;
    }

    .matrix-container-motor {
        grid-template-columns: 1.7fr 1fr 1fr 1fr;
    }

    .matrix-container-5col {
        grid-template-columns: 0.8fr 1.5fr 1.2fr 0.9fr 0.9fr;
    }

    .styled1,
    .styled2,
    .styled3 {
        width: 31%;
    }
}

@media screen and (max-width: 430px) {
    .matrix-container,
    .matrix-container-motor,
    .matrix-container-5col {
        gap: 5px;
    }

    .matrix-container input,
    .matrix-container-motor input,
    .matrix-container-5col input,
    .matrix-container-5col select {
        padding: 5px 2px;
        font-size: 90%;
    }

    .matrix-header,
    .matrix-header-connectedLoad,
    .matrix-constant {
        font-size: 85%;
    }

    .popup-box {
        width: 280px;
    }
}

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

@media print {
    @page {
        margin: 0.5in;
    }

    /*
     * .noPrint hides only the element carrying that class and its contents.
     * Keep this rule inside @media print so the screen page is unaffected.
     */
    .noPrint {
        display: none !important;
    }

    .hiddenUntilPrinted {
        display: block !important;
    }

    .myPageBreaker,
    p.pageBreak {
        break-before: page;
        page-break-before: always;
    }

    body {
        padding: 0;
        background: #fff;
        color: #000;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    .page-wrapper {
        width: 100%;
        max-width: none;
        padding: 0;
    }

    .myNav {
        position: static;
    }

    footer {
        margin: 0;
        padding: 0;
        text-align: center;
    }

    a:link,
    a:visited,
    a:hover {
        color: #000;
        text-decoration: none;
    }
}
