/* Alcohol dilution calculator page */

.page-calc .logo {
    color: #fff;
    text-decoration: none;
}

.calc {
    max-width: 960px;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
}

.calc h2 {
    margin-bottom: 1rem;
}

/* Mode switch */
.calc-modes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem;
    background: #fff;
    padding: 0.25rem;
    border-radius: 8px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.calc-modes button {
    font: inherit;
    font-size: 0.95rem;
    line-height: 1.25;
    padding: 0.5rem 0.25rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #135;
    cursor: pointer;
}

.calc-modes button:hover {
    background: #eef4fb;
}

.calc-modes button[aria-selected="true"] {
    background: #135;
    color: #fff;
    font-weight: 600;
}

/* Layout */
.calc-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 1rem;
    align-items: start;
}

.calc-form,
.calc-output {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.1);
    padding: 1rem;
}

/* Inputs */
.calc-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.calc-field {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-width: 0;
}

.calc-field[hidden] {
    display: none;
}

/* Checkbox over the full width of the form */
.calc-check {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #135;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.calc-check input {
    flex: none;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    accent-color: #135;
    cursor: pointer;
}

.calc-check small {
    font-weight: normal;
    color: #666;
}

.calc-label {
    font-size: 0.85rem;
    color: #135;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.25rem;
}

.calc-label small {
    font-weight: normal;
    color: #666;
}

.calc-input {
    display: flex;
    align-items: center;
    border: 2px solid #bcd;
    border-radius: 6px;
    background: #fff;
    transition: border-color 0.2s;
}

.calc-input:focus-within {
    border-color: #ca2;
}

.calc-field.invalid .calc-input {
    border-color: #c33;
}

.calc-input input {
    flex: 1;
    min-width: 0;
    width: 100%;
    font: inherit;
    font-size: 1.15rem;
    padding: 0.4rem 0.5rem;
    border: none;
    background: transparent;
    outline: none;
    text-align: right;
}

.calc-unit {
    padding: 0 0.4rem 0 0.1rem;
    color: #666;
    font-size: 0.95rem;
}

/* Spinbox buttons */
.calc-step {
    flex: 0 0 auto;
    width: 2.2rem;
    align-self: stretch;
    border: none;
    background: #eef4fb;
    color: #135;
    font: inherit;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.calc-step:first-child {
    border-right: 1px solid #bcd;
    border-radius: 4px 0 0 4px;
}

.calc-step:last-child {
    border-left: 1px solid #bcd;
    border-radius: 0 4px 4px 0;
}

.calc-step:hover {
    background: #dde9f6;
}

.calc-step:active {
    background: #ca2;
    color: #fff;
}

/* Output */
.calc-visual {
    display: block;
    width: 100%;
    max-width: 420px;
    height: auto;
    margin: 0 auto;
}

.calc-visual text {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.calc-main {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.calc-main > div {
    flex: 1;
    background: #fec;
    border-left: 4px solid #ca2;
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    min-width: 0;
}

.calc-main .calc-main-label {
    display: block;
    font-size: 0.8rem;
    color: #555;
    line-height: 1.2;
}

.calc-main .calc-main-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #135;
    line-height: 1.3;
    white-space: nowrap;
}

.calc-details {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.15rem 0.75rem;
    margin-top: 0.6rem;
    font-size: 0.9rem;
}

.calc-details dt {
    color: #555;
}

.calc-details dd {
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
}

.calc-error {
    color: #c33;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.calc-error:empty {
    display: none;
}

.calc-output.has-error .calc-main,
.calc-output.has-error .calc-details {
    opacity: 0.35;
}

/* Explanation */
.calc-info {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 3px 15px rgba(0,0,0,0.1);
    margin-top: 1rem;
}

.calc-info summary {
    padding: 0.8rem 1rem;
    cursor: pointer;
    color: #135;
    font-weight: 600;
}

.calc-info-content {
    padding: 0 1rem 1rem;
    font-size: 0.9rem;
}

.calc-info-content p {
    margin-bottom: 0.6rem;
}

.calc-info-list {
    margin: -0.3rem 0 0.6rem 1.2rem;
}

.calc-info-list li {
    margin-bottom: 0.25rem;
}

/* Nested collapsible section with formulas */
.calc-formulas {
    border-left: 3px solid #ca2;
    background: #f7f9fb;
    border-radius: 4px;
    margin: 0.8rem 0;
    padding: 0 0.8rem;
}

.calc-formulas summary {
    padding: 0.6rem 0;
    cursor: pointer;
    color: #135;
    font-weight: 600;
}

.calc-formulas[open] {
    padding-bottom: 0.4rem;
}

.calc-formula {
    font-family: "Times New Roman", Times, serif;
    font-size: 1.05rem;
    line-height: 1.9;
    background: #fff;
    border-radius: 4px;
    padding: 0.3rem 0.6rem;
    overflow-x: auto;
}

.calc-formula var,
.calc-formulas var {
    font-style: italic;
}

/* Line breaks only between terms of a formula */
.calc-formula .term {
    white-space: nowrap;
}

/* Sum sign with limits above and below: <span>top</span>Σ<span>bottom</span> */
.calc-formula .sum {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    font-size: 1.4em;
    line-height: 1;
    margin: 0 0.1em;
}

.calc-formula .sum > span {
    font-size: 0.45em;
    line-height: 1.1;
}

.calc-sources {
    font-size: 0.8rem;
    color: #666;
}

.calc-sources a {
    color: #258;
}

/* Narrow screens: everything on one screen without scrolling */
@media (max-width: 760px) {
    .calc-body {
        grid-template-columns: 1fr;
        gap: 0.6rem;
    }

    .calc-form,
    .calc-output {
        padding: 0.6rem;
    }

    .calc-form {
        gap: 0.5rem 0.6rem;
    }
}

@media (max-width: 1100px) {
    .page-calc main {
        margin-top: 70px;
    }

    .page-calc .logo img {
        height: 54px;
    }

    .calc {
        padding: 0.75rem 0.6rem 1.5rem;
    }

    .calc h2 {
        display: none;
    }

    .calc-modes {
        margin-bottom: 0.6rem;
    }

    .calc-modes button {
        font-size: 0.85rem;
    }
}
