/*
 * Calculator Fullscreen Core — v4.52.0
 * Shared by the homepage calculator and all calculator landing pages.
 * Native Fullscreen API is enhanced with a CSS fixed-position fallback for
 * browsers where arbitrary-element fullscreen is unavailable.
 */

html.mto-fullscreen-lock,
body.mto-fullscreen-lock {
    overflow: hidden;
    overscroll-behavior: none;
}

.mto-fullscreen-toolbar {
    display: none;
}

.is-mto-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147483000 !important;
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    height: 100dvh !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    margin: 0 !important;
    overflow: auto !important;
    overscroll-behavior: contain;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--surface) !important;
    box-shadow: none !important;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

.is-mto-fullscreen::backdrop {
    background: var(--surface);
}

.is-mto-fullscreen .mto-fullscreen-toolbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 58px;
    margin: 0 0 16px;
    padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.mto-fullscreen-toolbar-copy {
    min-width: 0;
    display: grid;
    gap: 1px;
}

.mto-fullscreen-toolbar-copy > span {
    color: var(--text-tertiary);
    font-size: 10px;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.mto-fullscreen-toolbar-copy strong {
    overflow: hidden;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.35;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mto-fullscreen-toolbar-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.mto-fullscreen-hint {
    color: var(--text-tertiary);
    font-size: 11px;
}

.mto-fullscreen-toolbar button,
.tool-fullscreen-button {
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
}

.mto-fullscreen-toolbar button:hover,
.tool-fullscreen-button:hover,
.tool-fullscreen-button.is-active {
    border-color: var(--primary-border-strong);
    background: var(--primary-soft-subtle);
    color: var(--primary-dark);
}

.mto-fullscreen-toolbar button:focus-visible,
.tool-fullscreen-button:focus-visible,
.calc-tool--fullscreen:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.mto-fullscreen-toolbar svg,
.tool-fullscreen-button svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.calculator-heading-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* Generic tool surfaces keep a comfortable task width while the surface itself
   fills the viewport. */
[data-calculator-page] .is-mto-fullscreen {
    padding-inline: max(14px, calc((100vw - 960px) / 2));
    padding-bottom: max(18px, env(safe-area-inset-bottom));
}

[data-calculator-page] .is-mto-fullscreen .mto-fullscreen-toolbar {
    margin-inline: min(-14px, calc((960px - 100vw) / 2));
}

/* Homepage calculator: scale the keypad rather than stretching it across a
   desktop monitor. */
[data-calculator].is-mto-fullscreen {
    padding: 0 max(12px, calc((100vw - 600px) / 2)) max(16px, env(safe-area-inset-bottom)) !important;
}

[data-calculator].is-mto-fullscreen .mto-fullscreen-toolbar {
    margin-inline: min(-12px, calc((600px - 100vw) / 2));
}

[data-calculator].is-mto-fullscreen .calculator-screen {
    margin-top: 0;
    min-height: clamp(180px, 26vh, 250px);
    padding: 18px 18px 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

[data-calculator].is-mto-fullscreen .calc-key {
    min-height: clamp(58px, 9.5vh, 82px);
}

[data-calculator].is-mto-fullscreen .calculator-tools {
    margin-bottom: 0;
}

/* Scientific and Casio benefit from a slightly denser landscape layout. */
.is-mto-fullscreen:is(.scientific-tool, .casio-unified) {
    padding-inline: max(10px, calc((100vw - 900px) / 2));
}

.is-mto-fullscreen.casio-unified .casio-model-keypad button,
.is-mto-fullscreen.scientific-tool .scientific-keypad button {
    min-height: clamp(46px, 7.2vh, 64px);
}

@media (max-width: 760px) {
    .calculator-heading-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .tool-fullscreen-button {
        min-height: 42px;
    }

    [data-calculator-page] .is-mto-fullscreen,
    .is-mto-fullscreen:is(.scientific-tool, .casio-unified) {
        padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right));
    }

    [data-calculator-page] .is-mto-fullscreen .mto-fullscreen-toolbar,
    [data-calculator].is-mto-fullscreen .mto-fullscreen-toolbar {
        margin-inline: calc(-1 * max(8px, env(safe-area-inset-left))) calc(-1 * max(8px, env(safe-area-inset-right)));
    }

    [data-calculator].is-mto-fullscreen {
        padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)) !important;
    }

    .is-mto-fullscreen .mto-fullscreen-toolbar {
        min-height: 54px;
        margin-bottom: 10px;
    }

    .mto-fullscreen-hint { display: none; }

    .mto-fullscreen-toolbar-copy strong { font-size: 13px; }

    [data-calculator].is-mto-fullscreen .calculator-screen {
        min-height: clamp(190px, 27vh, 250px);
    }

    [data-calculator].is-mto-fullscreen .calc-key {
        min-height: clamp(54px, 8.4vh, 68px);
    }
}

@media (max-width: 420px) {
    .tool-fullscreen-button span[data-fullscreen-label] {
        max-width: 110px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mto-fullscreen-toolbar {
        gap: 8px;
    }

    .mto-fullscreen-toolbar-copy > span { display: none; }
    .mto-fullscreen-toolbar-actions { gap: 6px; }
    .mto-fullscreen-toolbar button { min-height: 38px; padding-inline: 9px; }

    [data-calculator].is-mto-fullscreen .calculator-grid { gap: 6px; }
    [data-calculator].is-mto-fullscreen .calc-key { min-height: 54px; }
}

@media (orientation: landscape) and (max-height: 520px) {
    .is-mto-fullscreen .mto-fullscreen-toolbar {
        min-height: 46px;
        margin-bottom: 7px;
        padding-top: max(6px, env(safe-area-inset-top));
        padding-bottom: 6px;
    }

    [data-calculator].is-mto-fullscreen .calculator-screen {
        min-height: 108px;
        margin-bottom: 5px;
        padding-block: 10px 12px;
    }

    [data-calculator].is-mto-fullscreen .calculator-result { font-size: 42px; }
    [data-calculator].is-mto-fullscreen .calc-key { min-height: 44px; }

    .is-mto-fullscreen.casio-unified .casio-model-keypad button,
    .is-mto-fullscreen.scientific-tool .scientific-keypad button {
        min-height: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .is-mto-fullscreen { scroll-behavior: auto; }
}

/* Once inside the focused workspace, the sticky toolbar is the single exit
   control. Hide the original entry trigger to avoid duplicate exit actions. */
[data-calculator].is-mto-fullscreen .calc-tool--fullscreen,
[data-calculator].is-mto-fullscreen .tool-divider--fullscreen {
    display: none;
}

[data-calculator].is-mto-fullscreen .calculator-tools {
    grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
}

@media (max-width: 760px) {
    [data-calculator].is-mto-fullscreen .calculator-tools {
        grid-template-columns: 1fr auto 1fr;
    }
}


/* v4.56.9 — Scientific fullscreen follows the same light, structured UI as the page calculator. */
.is-mto-fullscreen.scientific-tool {
    display: flex;
    width: 100%;
    max-width: none;
    min-height: 100dvh;
    margin: 0;
    padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    border: 0;
    border-radius: 0;
    background: #fff;
    color: #17212b;
    flex-direction: column;
    overflow-y: auto;
}
.is-mto-fullscreen.scientific-tool > .mto-fullscreen-toolbar {
    position: static;
    z-index: 8;
    display: flex;
    width: 100%;
    min-height: 48px;
    margin: 0 0 10px;
    padding: 0 0 10px;
    border: 0;
    border-bottom: 1px solid #e1e7ec;
    border-radius: 0;
    background: #fff;
    color: #263744;
    box-shadow: none;
}
.is-mto-fullscreen.scientific-tool > .mto-fullscreen-toolbar .mto-fullscreen-toolbar-copy > span { color: #71818d; }
.is-mto-fullscreen.scientific-tool > .mto-fullscreen-toolbar .mto-fullscreen-hint { color: #71818d; }
.is-mto-fullscreen.scientific-tool > .mto-fullscreen-toolbar button {
    min-width: 44px;
    min-height: 44px;
    padding: 0 11px;
    border: 1px solid #d6e0e8;
    border-radius: 7px;
    background: #fff;
    color: #40515f;
    box-shadow: none;
}
.is-mto-fullscreen.scientific-tool > .mto-fullscreen-toolbar button svg { width: 20px; height: 20px; }
.is-mto-fullscreen.scientific-tool .scientific-screen {
    flex: 0 0 auto;
    min-height: 116px;
    margin: 0;
    padding: 12px 14px;
}
.is-mto-fullscreen.scientific-tool .scientific-result { min-height: 48px; font-size: clamp(34px, 6vw, 52px); }
.is-mto-fullscreen.scientific-tool .scientific-keypad {
    flex: 0 0 auto;
    grid-template-columns: minmax(0,1fr);
    gap: 12px;
    margin-top: 12px;
}
.is-mto-fullscreen.scientific-tool .scientific-message { flex: 0 0 auto; }
.is-mto-fullscreen.scientific-tool .mto-sci-session { flex: 0 0 auto; }

@media (max-width: 420px) and (orientation: portrait) {
    .is-mto-fullscreen.scientific-tool {
        padding-inline: max(9px, env(safe-area-inset-left)) max(9px, env(safe-area-inset-right));
    }
    .is-mto-fullscreen.scientific-tool > .mto-fullscreen-toolbar { margin-bottom: 8px; }
    .is-mto-fullscreen.scientific-tool > .mto-fullscreen-toolbar .mto-fullscreen-hint,
    .is-mto-fullscreen.scientific-tool > .mto-fullscreen-toolbar .mto-fullscreen-toolbar-copy > span { display: none; }
    .is-mto-fullscreen.scientific-tool .scientific-screen { min-height: 104px; padding: 10px 11px; }
    .is-mto-fullscreen.scientific-tool .scientific-keypad { gap: 9px; margin-top: 9px; }
    .is-mto-fullscreen.scientific-tool .scientific-function-grid { gap: 4px; }
    .is-mto-fullscreen.scientific-tool .scientific-function-grid button { min-height: 42px; font-size: 11.5px; }
    .is-mto-fullscreen.scientific-tool .scientific-basic-grid { gap: 5px; padding-top: 9px; }
    .is-mto-fullscreen.scientific-tool .scientific-basic-grid button { min-height: 50px; font-size: 17px; }
}

@media (orientation: landscape) and (max-height: 520px) {
    .is-mto-fullscreen.scientific-tool {
        display: grid;
        grid-template-columns: minmax(210px,.72fr) minmax(0,1.72fr);
        grid-template-rows: auto minmax(0,1fr) auto;
        gap: 8px 12px;
        padding-top: max(7px, env(safe-area-inset-top));
        overflow: hidden auto;
    }
    .is-mto-fullscreen.scientific-tool > .mto-fullscreen-toolbar {
        grid-column: 1 / -1;
        grid-row: 1;
        min-height: 42px;
        margin: 0;
        padding-bottom: 7px;
    }
    .is-mto-fullscreen.scientific-tool > .mto-fullscreen-toolbar .mto-fullscreen-toolbar-copy > span,
    .is-mto-fullscreen.scientific-tool > .mto-fullscreen-toolbar .mto-fullscreen-hint { display: none; }
    .is-mto-fullscreen.scientific-tool > .mto-fullscreen-toolbar button { min-width: 40px; min-height: 40px; }
    .is-mto-fullscreen.scientific-tool .scientific-screen {
        grid-column: 1;
        grid-row: 2;
        align-self: start;
        min-height: 0;
        padding: 8px 10px;
    }
    .is-mto-fullscreen.scientific-tool .scientific-result { min-height: 36px; font-size: 30px; }
    .is-mto-fullscreen.scientific-tool .scientific-keypad {
        grid-column: 2;
        grid-row: 2 / span 2;
        grid-template-columns: minmax(0,1.42fr) minmax(0,1fr);
        align-self: start;
        gap: 10px;
        margin: 0;
    }
    .is-mto-fullscreen.scientific-tool .scientific-function-grid { gap: 4px; }
    .is-mto-fullscreen.scientific-tool .scientific-function-grid button { min-height: 34px; font-size: 11px; }
    .is-mto-fullscreen.scientific-tool .scientific-basic-grid {
        gap: 4px;
        padding: 0 0 0 10px;
        border-top: 0;
        border-left: 1px solid #e1e7ec;
    }
    .is-mto-fullscreen.scientific-tool .scientific-basic-grid button { min-height: 38px; font-size: 15px; }
    .is-mto-fullscreen.scientific-tool .scientific-message {
        grid-column: 1;
        grid-row: 3;
        margin-top: 0;
        font-size: 11px;
    }
    .is-mto-fullscreen.scientific-tool .mto-sci-session { display: none; }
}


.is-mto-fullscreen.casio-unified {
    background: #15181c;
}
.is-mto-fullscreen.casio-unified > .mto-fullscreen-toolbar {
    border-color: rgba(255,255,255,.08);
    background: #0e1013;
    color: #fff;
}
.is-mto-fullscreen.casio-unified > .mto-fullscreen-toolbar .mto-fullscreen-toolbar-copy span,
.is-mto-fullscreen.casio-unified > .mto-fullscreen-toolbar .mto-fullscreen-hint {
    color: rgba(255,255,255,.55);
}
.is-mto-fullscreen.casio-unified > .mto-fullscreen-toolbar button {
    border-color: rgba(255,255,255,.1);
    background: #25292f;
    color: #fff;
}


/* v4.56.2 — focused Casio fullscreen. Keep navigation/history out of the calculation viewport. */
.is-mto-fullscreen.casio-unified :is(.casio-related,.mto-sci-session) {
    display: none !important;
}
.is-mto-fullscreen.casio-unified {
    width: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
}
@media (max-width:420px) and (orientation:portrait) {
    .is-mto-fullscreen.casio-unified {
        padding: max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(10px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));
    }
    .is-mto-fullscreen.casio-unified .casio-model-head { margin-bottom: 7px; }
    .is-mto-fullscreen.casio-unified .casio-model-keypad { gap: 4px; }
    .is-mto-fullscreen.casio-unified .casio-model-keypad button { min-height: clamp(44px,7.2vh,54px); }
}
@media (orientation:landscape) and (max-height:520px) {
    .is-mto-fullscreen:is(.casio-model-570,.casio-model-580) {
        display: grid;
        grid-template-columns: minmax(220px,.75fr) minmax(420px,1.4fr);
        grid-template-rows: auto auto auto auto 1fr;
        gap: 5px 10px;
        align-content: center;
        padding: max(7px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(7px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));
    }
    .is-mto-fullscreen:is(.casio-model-570,.casio-model-580) > .mto-fullscreen-toolbar { grid-column:1 / -1; grid-row:1; margin-bottom:2px; }
    .is-mto-fullscreen:is(.casio-model-570,.casio-model-580) > .casio-model-head { grid-column:1; grid-row:2; margin:0; }
    .is-mto-fullscreen:is(.casio-model-570,.casio-model-580) > .casio-model-screen { grid-column:1; grid-row:3; }
    .is-mto-fullscreen:is(.casio-model-570,.casio-model-580) > .casio-model-toolbar { grid-column:1; grid-row:4; margin:0; }
    .is-mto-fullscreen:is(.casio-model-570,.casio-model-580) > .casio-status { grid-column:1; grid-row:5; margin:0; align-self:start; }
    .is-mto-fullscreen:is(.casio-model-570,.casio-model-580) > .casio-model-keypad { grid-column:2; grid-row:2 / span 4; align-self:center; gap:4px; }
    .is-mto-fullscreen:is(.casio-model-570,.casio-model-580) > .casio-model-keypad button { min-height: clamp(38px,7.3vh,46px); }
    .is-mto-fullscreen:is(.casio-model-570,.casio-model-580) .casio-model-head > div:first-child > p:not(.casio-eyebrow) { display:none; }
}
