/* Phone layout, loaded last on the home page and in the studio.
   Three things a narrow touch screen needs that a narrowed desktop page does
   not give it: targets the size of a finger, windows that use the whole
   screen, and a studio whose buttons stay in sight under the picture. */

/* ---------------------------------------------------------------- the bar */
@media (max-width: 1023px) {
    #mobile-menu-btn {
        min-width: 44px; min-height: 44px; margin-right: -10px;
        display: inline-flex; align-items: center; justify-content: center;
    }
    #lang-en-hero, #lang-pt-hero, #lang-en-mobile, #lang-pt-mobile {
        min-width: 42px !important; min-height: 38px !important;
        display: inline-flex; align-items: center; justify-content: center;
    }
    .nav-icon-btn { min-width: 44px !important; min-height: 44px !important; }

    /* the menu: one row to a finger, no gaps to miss between them */
    #mobile-menu { margin-top: 0.5rem !important; padding-top: 0.25rem !important; }
    #mobile-menu .space-y-3 > * { margin-top: 0 !important; }
    #mobile-menu a {
        display: flex !important; align-items: center; min-height: 46px; width: 100%;
        font-size: 0.875rem; letter-spacing: 0.1em;
    }
    /* buttons keep their own display: the page shows and hides them by sign-in state */
    #mobile-menu button { min-height: 46px; align-items: center; font-size: 0.875rem; letter-spacing: 0.1em; }
    #mobile-menu a { border-bottom: 1px solid rgba(242, 240, 237, 0.07); }
    #mobile-menu #mobile-login-btn, #mobile-menu #mobile-user-profile { padding-top: 0 !important; border-top: 0 !important; }
    #mobile-menu #mobile-user-profile { min-height: 46px; align-items: center; }
}

/* Signed in, the studio's bar showed the e-mail address and pushed the
   language switch and the menu off the screen. On a phone the round mark is
   enough; the address is in the menu. */
@media (max-width: 639px) {
    #mobile-user-email { display: none !important; }
    #mobile-user-profile {
        padding: 0 !important; background: transparent !important;
        min-width: 40px; min-height: 44px; align-items: center; justify-content: center;
    }
    nav .flex.items-center.gap-3 { gap: 0.35rem !important; min-width: 0; }
    nav > div > .flex.items-center.justify-between { gap: 0.5rem; }
    div:has(> div > #lang-en-mobile) { margin-right: 0 !important; padding-left: 2px !important; padding-right: 2px !important; }
}
@media (max-width: 359px) {
    #lang-en-hero, #lang-pt-hero, #lang-en-mobile, #lang-pt-mobile { min-width: 34px !important; }
    .nav-brand { font-size: 0.82rem !important; letter-spacing: 0.1em !important; }
    .nav-icon-btn { min-width: 40px !important; }
}

/* ------------------------------------------------------------ the windows */
@media (max-width: 599px) {
    #auth-modal, #kit-modal, #kit-id-modal, #kit-shipping-modal, #widget-type-modal,
    #stripe-payment-modal, #inquiry-modal, #order-modal {
        padding: 0.5rem !important;
    }
    #auth-modal > div, #kit-modal > div, #kit-id-modal > div, #kit-shipping-modal > div,
    #widget-type-modal > div, #stripe-payment-modal > div, #inquiry-modal > div, #order-modal > div {
        width: 100% !important; max-width: none !important; margin: 0 !important;
        max-height: calc(100vh - 1rem) !important;
        max-height: calc(100dvh - 1rem) !important;
        overflow-y: auto !important; overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }
    #order-modal > div { padding: 1.1rem !important; }
    #auth-modal .p-6, #kit-modal .p-6, #kit-id-modal .p-6, #kit-shipping-modal .p-6,
    #stripe-payment-modal .p-6, #inquiry-modal .p-6, #widget-type-modal .p-6 { padding: 1.1rem !important; }

    /* fields a thumb can hit; 16px text, so iOS does not zoom the page on focus */
    #auth-modal input:not([type=checkbox]), #kit-id-modal input:not([type=checkbox]),
    #kit-shipping-modal input:not([type=checkbox]), #kit-shipping-modal select, #kit-shipping-modal textarea,
    #inquiry-modal input:not([type=checkbox]), #inquiry-modal select, #inquiry-modal textarea,
    #order-modal input:not([type=checkbox]), #order-modal select, #order-modal textarea {
        min-height: 48px; font-size: 16px !important;
    }
    #order-modal input[type=checkbox], #kit-shipping-modal input[type=checkbox],
    #inquiry-modal input[type=checkbox], #auth-modal input[type=checkbox] {
        width: 22px !important; height: 22px !important; flex: 0 0 22px; margin-top: 0 !important;
        accent-color: #C8A96A;
    }
    #order-modal label:has(+ input[type=checkbox]), #order-modal input[type=checkbox] + label,
    #kit-shipping-modal input[type=checkbox] + label { font-size: 0.8125rem !important; line-height: 1.45; }
    #order-modal .flex.items-start.gap-2, #kit-shipping-modal .flex.items-start.gap-2 { gap: 0.7rem !important; align-items: center !important; }

    #order-modal-close, #close-auth-modal, #close-kit-modal, #close-kit-id-modal,
    #close-kit-shipping-modal, #close-stripe-payment-modal, #close-widget-type-modal,
    #inquiry-modal [data-close], #inquiry-modal button[aria-label] {
        min-width: 44px; min-height: 44px; margin: -10px -10px -10px 0;
        display: inline-flex; align-items: center; justify-content: center;
    }
    #order-modal button[type=submit], #order-modal-cancel, #validate-promo-app,
    #ks-next-btn, #ks-cancel, #ks-validate-promo, #stripe-submit-button,
    #auth-modal button[type=submit], #inquiry-modal button[type=submit] { min-height: 48px; }
    #switch-to-signup, #switch-to-reset, #switch-to-signin { min-height: 40px; padding: 0 0.25rem; }
}

/* --------------------------------------------------------- the home page */
@media (max-width: 767px) {
    /* a paragraph in a left-aligned card starts where its heading starts */
    .step-card .step-desc { margin: 0 !important; max-width: none !important; text-wrap: pretty; }

    /* three promises under the last buttons: a short list, not three squeezed columns */
    .cta-trust { flex-direction: column; gap: 0.3rem !important; }
    .cta-trust .cta-dot { display: none; }

    .final-cta .hero-buttons { margin-bottom: 1.5rem; }

    /* the two link lists share a row, so the footer is not three screens long */
    footer .footer-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) !important; gap: 1.5rem 1.25rem !important; }
    footer .footer-grid > .footer-about, footer .footer-grid > .footer-rights { grid-column: 1 / -1; }
    footer .footer-col-title { margin-bottom: 0.4rem !important; }
    footer .footer-col li { margin-bottom: 0 !important; }
    footer .footer-col li > a { display: flex; align-items: center; min-height: 40px; }
    footer .footer-company a { display: inline-block; padding: 0.5rem 0; }
    .footer-short { line-height: 1.9 !important; }
}

/* ------------------------------------------------------------- the studio */
@media (max-width: 767px) {
    /* Once there is a photograph the heading has done its work. Without it
       the picture sits at the top and Start stays on the screen below it:
       while a photograph is being framed a finger on the picture moves the
       picture, so nothing a visitor needs may be a scroll away. */
    body.abs-has-photo #studio-top,
    body.abs-running #studio-top,
    body.abs-restored #studio-top { display: none !important; }
    body.abs-has-photo #error-messages:empty,
    body.abs-running #error-messages:empty { display: none; }

    body.abs-has-photo #canvas-container,
    body.abs-running #canvas-container,
    body.abs-restored #canvas-container {
        width: min(100%, max(220px, calc(100vh - 17rem))) !important;
        min-height: 0 !important; height: auto !important;
        align-self: center; flex: 0 0 auto;
    }
    @supports (height: 100svh) {
        body.abs-has-photo #canvas-container,
        body.abs-running #canvas-container,
        body.abs-restored #canvas-container {
            width: min(100%, max(220px, calc(100svh - 17rem))) !important;
        }
    }
    body.abs-has-photo .demo, body.abs-running .demo, body.abs-restored .demo { gap: 0.75rem !important; }

    .controls-block { padding: 1rem !important; max-width: none !important; }
    .controls-block .control-btn { min-height: 48px; }
    .controls-block .arrow-btn { min-width: 44px !important; min-height: 44px !important; }

    /* with a photograph: what to press comes first, another photograph last */
    body.abs-has-photo .controls-block > .panel-actions,
    body.abs-running .controls-block > .panel-actions,
    body.abs-restored .controls-block > .panel-actions { order: 2 !important; margin-bottom: 1rem !important; }
    body.abs-has-photo .controls-block > section.controls-section:nth-of-type(2),
    body.abs-running .controls-block > section.controls-section:nth-of-type(2),
    body.abs-restored .controls-block > section.controls-section:nth-of-type(2) { order: 3 !important; }
    body.abs-has-photo .controls-block > section.controls-section:nth-of-type(1),
    body.abs-running .controls-block > section.controls-section:nth-of-type(1),
    body.abs-restored .controls-block > section.controls-section:nth-of-type(1) { order: 4 !important; margin-bottom: 1rem !important; }
    body.abs-has-photo .controls-block > .mb-6:first-child,
    body.abs-running .controls-block > .mb-6:first-child,
    body.abs-restored .controls-block > .mb-6:first-child { order: 5 !important; margin-bottom: 0 !important; }
}

/* A photograph that cannot move up or down in its frame lets a vertical
   swipe over it scroll the page. */
body.abs-has-photo.abs-y-fixed:not(.abs-running) #canvas-container > canvas { touch-action: pan-y !important; }

/* The circle the thread will fill, shown while the photograph is framed. */
.studio-ring {
    display: none; position: absolute; inset: 0; z-index: 15; pointer-events: none; border-radius: inherit;
    background: radial-gradient(circle closest-side,
        transparent calc(100% - 2px),
        rgba(242, 240, 237, 0.75) calc(100% - 2px), rgba(242, 240, 237, 0.75) calc(100% - 1px),
        rgba(0, 0, 0, 0.58) 100%);
}
body.abs-has-photo:not(.abs-running) .studio-ring { display: block; }

/* ------------------------------------------------ saved versions (studio) */
/* Nothing saved: no heading and no empty band between the panel and Help. */
.slots-head { display: none; text-align: center; margin-bottom: 0.75rem; }
.slots-head h2 { font-family: 'Montserrat', 'Inter', sans-serif; font-weight: 300; font-size: 1.5rem; margin: 0 0 0.35rem; color: #F2F0ED; }
.slots-head p { margin: 0; font-size: 0.875rem; color: rgba(242, 240, 237, 0.6); }
#project-slots-section:has(.gallery-face) .slots-head { display: block; }
#gallery-3d-wrapper:not(:has(.gallery-face)) { display: none !important; }
#project-slots-section:not(:has(.gallery-face)) { margin-top: 0 !important; margin-bottom: 1.5rem !important; }

/* A finger cannot hover: the button that removes a saved version is always there. */
@media (hover: none) {
    .gallery-face .delete-slot-btn { opacity: 1 !important; background-color: rgba(11, 11, 12, 0.72) !important; border: 1px solid rgba(242, 240, 237, 0.35) !important; }
}

/* The hint about fingers is for screens that are touched. */
@media (hover: hover) and (pointer: fine) {
    [data-translate="studio.framingHint"] { display: none !important; }
}

/* A narrow laptop: the picture gives up some width so that neither it nor the
   panel is cut by the edge of the window. */
@media (min-width: 1024px) and (max-width: 1279px) {
    #canvas-container {
        width: 460px !important; height: 460px !important;
        min-width: 460px !important; min-height: 460px !important;
        max-width: 460px !important; max-height: 460px !important;
        flex: 0 0 460px !important;
    }
    .demo { gap: 1.25rem !important; padding: 0 0.75rem; }
}
