/* Layout for phones, small tablets and other narrow screens (October 2026).
   Everything is inside the media query below, so screens of 816 pixels or more keep the usual layout.
   The usual layout needs 816 pixels (an 800-pixel calculator plus the page margins), so on any
   narrower screen it could not be shown without scrolling sideways anyway. */

@media screen and (max-width: 815px) {

    body {
        overflow-x: hidden;
    }

    body {
        margin: 0;
        -webkit-text-size-adjust: 100%;
    }

    #root {
        padding: 0 6px;
    }

    /* ---- Wizard: one step at a time, full width, height follows the content ---- */

    .wizard-main {
        box-sizing: border-box;
        width: 100% !important;
        max-width: 100%;
        height: auto !important;
    }

    .taxben-form .output-info {
        box-sizing: border-box;
        width: 100%;
    }

    /* Help texts (the "?" bullets) open across the width of the screen */
    .info-main {
        left: 8px !important;
        right: 8px;
        max-width: none;
    }

    .wizard-steps-container {
        height: auto;
        white-space: normal;
    }

    .wizard-steps-tray {
        margin-left: 0 !important;
        height: auto;
    }

    .wizard-step {
        display: none;
        width: 100% !important;
        height: auto;
    }

    .wizard-step.wizard-step-current {
        display: block;
    }

    .wizard-step-content {
        box-sizing: border-box;
        padding: 8px 10px;
        text-align: left;
        overflow: visible;
    }

    /* Step bar: the current step shows its name, the other steps only their number
       (and "Run" for the last one), so that all the steps fit on one line without scrolling. */
    .wizard-path-container {
        height: auto;
        overflow: hidden;
    }

    .wizard-path-table {
        width: 100%;
        table-layout: fixed;
        counter-reset: taxben-step;
    }

    .wizard-path-step,
    .wizard-path-step.active {
        counter-increment: taxben-step;
        height: 36px;
        width: 30px;
        padding: 0;
        font-size: 0 !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        border-right: 1px solid rgba(255, 255, 255, 0.4);
    }

    .wizard-path-step::before {
        content: counter(taxben-step);
        font-size: 14px;
        font-weight: bold;
    }

    .wizard-path-step.active {
        width: auto;
        padding: 0 6px;
        font-size: 14px !important;
        border-right: none;
    }

    .wizard-path-step.active::before {
        content: counter(taxben-step) ". ";
    }

    .wizard-path-step.last,
    .wizard-path-step.last.active {
        width: 42px;
    }

    .wizard-path-step.last::before {
        content: "Run";
        font-variant: small-caps;
    }

    .wizard-path-step.last.active {
        font-size: 0 !important;
    }

    .wizard-buttons-container {
        height: auto;
        padding: 6px 0;
    }

    .wizard-buttons-container input[type=button],
    .taxben-form input[type=button] {
        min-height: 36px;
    }

    /* ---- Tables used to lay out the steps: one column ---- */

    .taxben-form table.struct,
    .taxben-form table.struct > tbody,
    .taxben-form table.struct > tbody > tr,
    .taxben-form table.struct > tbody > tr > td,
    .taxben-form table.struct > tr,
    .taxben-form table.struct > tr > td {
        display: block;
        width: auto !important;
        box-sizing: border-box;
    }

    .taxben-form table.struct > tbody > tr > td,
    .taxben-form table.struct > tr > td {
        border: none !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Fixed widths that do not fit on a phone */
    .taxben-form [style*="width: 480px"],
    .taxben-form [style*="width:480px"],
    .taxben-form [style*="width: 350px"],
    .taxben-form [style*="width:350px"] {
        width: auto !important;
        max-width: 100%;
    }

    /* Cells of the layout tables have fixed heights on wide screens */
    .taxben-form table.struct td {
        height: auto !important;
    }

    /* Inner scroll areas: on a phone the whole page scrolls instead */
    .taxben-form [style*="max-height"] {
        max-height: none !important;
        overflow: visible !important;
        padding-right: 0 !important;
    }

    .taxben-form #form-summary-container {
        margin-left: 0;
        width: 100%;
        height: auto;
        overflow: visible;
    }

    .taxben-form #form-summary table td:nth-child(2n) {
        width: 45%;
        padding-left: 8px;
    }

    /* Sliders and range tables use the width of the screen */
    .taxben-form .ui-slider-horizontal {
        box-sizing: border-box;
        width: auto !important;
        max-width: none;
        margin-left: 20px !important;
        margin-right: 26px !important;
    }

    .taxben-form table.range {
        width: calc(100% - 46px) !important;
        margin-left: 20px !important;
        margin-right: 26px !important;
    }

    .taxben-form .ui-slider-horizontal {
        margin-bottom: 12px;
    }

    .taxben-form .step-3 .child-age {
        flex: 1 1 auto;
        margin-top: 8px;
        margin-bottom: 18px;
    }

    .taxben-form table.range .ui-slider-horizontal {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* ---- Touch targets of at least 24 pixels (WCAG 2.2) ---- */

    .taxben-form input[type=radio],
    .taxben-form input[type=checkbox] {
        width: 24px;
        height: 24px;
        margin: 2px 6px 2px 0;
        vertical-align: middle;
    }

    .taxben-form .list-commands a {
        display: inline-block;
        padding: 6px 4px;
        margin: 0 6px 0 0 !important;
    }

    .taxben-form #form-summary a {
        display: inline-block;
        min-width: 24px;
        min-height: 24px;
        line-height: 24px;
    }

    .taxben-form .taxb-output-type-item {
        min-height: 34px;
        display: flex;
        align-items: center;
    }

    /* ---- Countries: the name under each flag ---- */

    .taxben-form .step-2 .country-list > div {
        width: 78px;
        margin: 0 2px 10px 2px;
    }

    .taxben-form .step-2 .country-list label {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
    }

    .taxben-country-name {
        display: block;
        flex-basis: 100%;
        font-size: 11px;
        line-height: 1.15;
        text-align: center;
        white-space: normal;
        margin-top: 2px;
    }

    .taxben-form .step-2 .year-list > div {
        width: 66px;
    }

    /* ---- Previous / Reset / Next / Run: one row, always visible at the bottom of the screen ---- */

    .wizard-buttons-container {
        position: -webkit-sticky;
        position: sticky;
        bottom: 0;
        z-index: 20;
        background-color: #fff;
        border-top: 1px solid #c9d6de;
        box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.12);
        padding: 6px 4px;
    }

    .wizard-buttons-container table td div,
    .wizard-buttons-container table td:first-child div,
    .wizard-buttons-container table td:last-child div {
        float: none;
        width: auto;
        display: flex;
        gap: 6px;
    }

    .wizard-buttons-container table {
        table-layout: auto;
    }

    .wizard-buttons-container table td {
        width: auto;
    }

    .wizard-buttons-container table input[type=button] {
        width: auto;
        min-width: 60px;
        height: 38px;
        padding: 0 10px;
        position: static;
    }

    /* ---- Buttons "-" and "+" under the sliders (js/mobile.js) ---- */

    .taxben-stepper {
        display: flex;
        justify-content: flex-end;
        gap: 14px;
        margin: -4px 26px 10px 20px;
    }

    .taxben-stepper-group {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .taxben-stepper-label {
        font-size: 12px;
        color: #575757;
    }

    .taxben-stepper-button {
        width: 36px;
        height: 32px;
        padding: 0;
        border: 1px solid #006FB3;
        border-radius: 5px;
        background-color: #fff;
        color: #006FB3;
        font-size: 20px;
        font-weight: bold;
        line-height: 1;
        cursor: pointer;
    }

    .ui-slider[style*="display: none"] + .taxben-stepper,
    .ui-slider[style*="display:none"] + .taxben-stepper {
        display: none;
    }

    /* ---- Intro step: the indicator tiles one below the other ---- */

    .taxb-intro-container {
        margin-top: 15px !important;
        flex-direction: column;
        align-items: stretch;
    }

    .taxb-intro-item {
        width: auto !important;
        min-height: 0 !important;
        height: auto !important;
        margin: 5px 0 !important;
        padding: 12px !important;
    }

    #wizard-step-intro h2 {
        margin-top: 15px !important;
    }

    /* ---- Flexible rows: stack the columns ---- */

    .taxben-form .taxb-flex-row {
        flex-direction: column;
        flex-wrap: wrap !important;
    }

    .taxben-form .taxb-flex-column {
        width: auto !important;
        max-width: 100% !important;
        flex: 1 1 auto !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* The two labour market tabs stay side by side (their row has an inline "flex-wrap: nowrap") */
    .taxben-form .taxb-flex-row[style*="nowrap"] {
        flex-direction: row;
        flex-wrap: nowrap !important;
    }

    .taxb-flex-container {
        box-sizing: border-box;
        min-width: 0 !important;
    }

    .taxben-form .taxb-flex-row .labourMarket-tab {
        flex: 1 1 50% !important;
        min-width: 0 !important;
        width: auto !important;
        white-space: normal;
        box-sizing: border-box;
    }

    /* Output type step: nothing wider than the screen, also on the smallest phones */
    .taxben-form .step-1 .taxb-flex-container,
    .taxben-form .step-1 .taxb-flex-row,
    .taxben-form .step-1 .taxb-flex-column,
    .taxben-form .step-1 .ui-controlgroup,
    .taxben-form .step-1 label,
    .taxben-form .step-1 h3 {
        box-sizing: border-box;
        max-width: 100%;
        min-width: 0;
        white-space: normal;
    }

    #adult1ActivityTabsWrapper,
    #adult1ActivityTabsWrapper .taxb-flex-row {
        box-sizing: border-box;
        max-width: 100%;
    }

    /* ---- Sliders: larger handles, and the finger can drag them (see js/mobile.js) ---- */

    .ui-slider {
        touch-action: pan-y;
    }

    .ui-slider-horizontal .ui-slider-handle {
        min-width: 30px;
        height: 1.6em;
        top: -0.55em;
    }

    /* ---- Results ---- */

    .taxben-result-button-container,
    .taxben-result-button-container-top,
    #taxben-result-footnote,
    #result-info-buttons,
    #share-link-row,
    #share-link-version-note {
        width: 100% !important;
        box-sizing: border-box;
    }

    .taxben-result-button-container .taxben-result-button,
    .taxben-result-button-container input[type=button] {
        float: none;
        display: block;
        width: 100%;
        max-width: none;
        margin: 0 0 6px 0;
        box-sizing: border-box;
    }

    /* "Right-click to choose the file's name" does not apply to phones */
    .taxben-result-button-container #download-button span {
        display: none;
    }

    .taxben-result-button-container .log-link {
        display: block;
        text-align: right;
        margin-bottom: 6px;
    }

    /* Charts use the width of the screen, so that the whole chart is visible */
    .taxben-chart {
        box-sizing: border-box;
        width: 100%;
        height: 500px;
    }

    /* Title and subtitle of the main chart, moved above it by js/mobile.js */
    #taxben-chart-heading {
        padding: 6px 2px 4px 2px;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-weight: bold;
    }

    #taxben-chart-heading-title {
        position: relative;
        display: inline-block;
        margin-right: 40px;
        color: #0297C9;
        font-size: 16px;
    }

    #taxben-chart-heading-subtitle {
        margin-top: 4px;
        color: #7A7A7A;
        font-size: 12px;
    }

    /* Net replacement rates: the three charts one below the other (js/mobile.js adds the class) */
    #taxben-chart.nrr-layout {
        height: auto;
        min-height: 300px;
    }

    #taxben-chart.nrr-layout .taxben-chart {
        height: auto;
        border: none;
    }

    #taxben-chart.nrr-layout .taxb-flex-row {
        flex-direction: column;
        height: auto !important;
    }

    /* The button that saves the three charts as an image goes on its own line, above the charts,
       so that it does not cover the title of the first chart */
    #taxben-chart.nrr-layout #nrr-charts-download-btn {
        float: none !important;
        position: static !important;
        display: block;
        margin: 6px 6px 0 auto;
    }

    #taxben-chart.nrr-layout .taxb-flex-column {
        box-sizing: border-box;
        min-width: 0 !important;
        max-width: 100%;
    }

    #taxben-chart.nrr-layout [data-nrr-chart-1],
    #taxben-chart.nrr-layout [data-nrr-chart-2],
    #taxben-chart.nrr-layout [data-nrr-chart-3] {
        width: auto !important;
        height: 300px;
    }

    #taxben-chart.nrr-layout [data-nrr-chart-1] {
        height: 400px;
    }

    #taxben-data-table {
        width: 100%;
    }

    .taxben-table-scroll {
        max-height: 60vh;
    }

    #share-link-name {
        width: 100% !important;
        box-sizing: border-box;
        margin: 4px 0;
    }

    #share-link-row label {
        display: block;
    }

    #share-link-input {
        width: 100% !important;
    }

    /* Dialogs (warnings) fit the screen */
    .ui-dialog {
        max-width: 95vw;
    }
}

@media (max-width: 815px) {
    /* Link "Open the calculator in full screen", inside the frame of the oecd.org page (js/mobile.js) */
    #taxben-fullscreen-bar {
        display: block;
        margin: 0 0 8px 0;
        padding: 8px 10px;
        background-color: #DDE9EF;
        border: 1px solid #0B1E2D;
        text-align: center;
        font-size: 14px;
    }

    #taxben-fullscreen-bar a {
        display: inline-block;
        min-height: 24px;
        line-height: 24px;
        font-weight: bold;
        color: #005F8F;
    }
}
