/*
 * Phones (≤767px): nothing scrolls sideways and text is readable.
 * Loaded last by the public bundle, the account shell and the admin layout.
 *  - wide tables are stacked as cards by js/ir-stack.js (.ir-stacked)
 *  - chip rows / tab bars wrap instead of scrolling
 *  - type scale: body 15px, small/meta ≥13px, h1 22, h2 18, h3 16
 */
@media (max-width: 767px) {
    html, body { overflow-x: clip; }
    html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

    /* ---------- tables: no inner scrollbars ---------- */
    #main table, .ir-acc-content table, .ir-table-wrap, .ir-main .table-responsive { overflow-x: visible !important; }
    #main table:not(.ir-stacked), .ir-acc-content table:not(.ir-stacked) { display: table; width: 100% !important; table-layout: auto; }
    #main td, #main th, .ir-acc-content td, .ir-acc-content th, .ir-main td, .ir-main th { overflow-wrap: break-word; word-break: normal; }
    .ir-acc-content table th { white-space: normal; }
    table.ir-stacked, table.ir-stacked > tbody, table.ir-stacked > thead, table.ir-stacked > tfoot,
    table.ir-stacked > tbody > tr, table.ir-stacked > tr, table.ir-stacked > tfoot > tr { display: block !important; width: 100% !important; }
    table.ir-stacked { border: 0 !important; background: none !important; min-width: 0 !important; }
    table.ir-stacked > thead, table.ir-stacked tr.ir-stack-head { display: none !important; }
    table.ir-stacked > tbody > tr > td, table.ir-stacked > tbody > tr > th, table.ir-stacked > tr > td, table.ir-stacked > tr > th,
    table.ir-stacked > tfoot > tr > td { display: block !important; width: auto !important; max-width: 100%; height: auto !important; box-sizing: border-box; text-align: left !important; white-space: normal !important; }
    table.ir-stacked--data > tbody > tr, table.ir-stacked--data > tr { margin: 0 0 10px; padding: 8px 10px; border: 1px solid #dfe5ea; border-radius: 10px; background: #fff; box-sizing: border-box; }
    table.ir-stacked--data td, table.ir-stacked--data th { border: 0 !important; padding: 3px 0 !important; }
    table.ir-stacked--data td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; color: #4b5d6b; font-size: 13px; }
    table.ir-stacked--data td[data-label=""]::before { content: none; }
    table.ir-stacked--layout td { padding: 4px 0 !important; border: 0 !important; }
    table.ir-stacked img { max-width: 100%; height: auto; }
    table.ir-stacked input[type=text], table.ir-stacked input[type=email], table.ir-stacked textarea, table.ir-stacked select { width: 100% !important; max-width: 100%; box-sizing: border-box; }

    /* calendars keep 7 columns but shrink to fit */
    table#calendar, .ir-acc-content table#calendar { display: table !important; table-layout: fixed; width: 100% !important; font-size: 12px; }
    table#calendar td, table#calendar th { padding: 2px !important; width: auto !important; height: auto !important; min-width: 0 !important; overflow: hidden; overflow-wrap: anywhere; vertical-align: top; }
    table#calendar td * { max-width: 100%; font-size: 11px !important; line-height: 1.25; }
    table#calendar img { display: none; }

    /* ---------- chip rows / tab bars wrap ---------- */
    #thin-menu-col ul { flex-wrap: wrap !important; overflow: visible !important; padding-bottom: 0 !important; }
    #thin-menu-col li a { white-space: normal !important; font-size: 14px !important; }
    #details-place #actions li { flex-wrap: wrap !important; overflow: visible !important; }
    #tabs-min .ui-tabs-nav, .ui-tabs .ui-tabs-nav { display: flex !important; flex-wrap: wrap !important; overflow: visible !important; gap: 4px; padding: 0 !important; height: auto !important; }
    #tabs-min .ui-tabs-nav li, .ui-tabs .ui-tabs-nav li { float: none !important; flex: 1 1 auto; width: auto !important; margin: 0 !important; white-space: normal !important; text-align: center; }
    #tabs-min .ui-tabs-nav li a, .ui-tabs .ui-tabs-nav li a { float: none !important; display: block; padding: 9px 10px !important; font-size: 14px !important; }

    /* ---------- generic overflow guards ---------- */
    #main *, .ir-acc-content *, #container * { max-width: 100%; }
    /* …but never inside a map: Leaflet panes are 0px wide and popups/tiles must keep their own size */
    #main .leaflet-container *, #container .leaflet-container *, .ir-acc-content .leaflet-container * { max-width: none !important; }
    #main pre, .ir-acc-content pre { white-space: pre-wrap; }
    #main a, .ir-acc-content a, #main p, #main li { overflow-wrap: break-word; }
    #signup, #signup.translate, #wrapper { width: auto !important; max-width: 100% !important; box-sizing: border-box; }
    #signup *, #wrapper > * { max-width: 100%; box-sizing: border-box; }
    .registration2, table.registration2 { width: 100% !important; }
    .login-holder, .column-483-left, .column-483-right, fieldset.form1, #login, .login-blue-white, #cform { width: auto !important; max-width: 100% !important; min-width: 0 !important; float: none !important; box-sizing: border-box; }
    #signup .shown, #signup .nonInputText { max-width: 100%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
    #signup .nonInputText { display: block; }
    #signup select, #signup .dateSelect { max-width: 100%; margin-right: 0 !important; }
    #signup input[type=text], #signup input[type=password], #signup .input-default { width: 100% !important; box-sizing: border-box; }
    #footer, #footer_links, #footer_links ul { width: auto !important; max-width: 100% !important; box-sizing: border-box; }
    #footer_links, #footer_links ul { padding-left: 8px !important; padding-right: 8px !important; float: none !important; position: static !important; left: auto !important; right: auto !important; }
    #footer_links ul { display: flex !important; flex-wrap: wrap; justify-content: center; gap: 4px 12px; padding: 0 8px !important; margin: 0 !important; width: auto !important; }
    #footer_links li { float: none !important; margin: 0 !important; white-space: normal; }

    /* ---------- type scale ---------- */
    body { font-size: 15px; line-height: 1.5; }
    #main, #container, .ir-acc-content { font-size: 15px; }
    #main h1, #container h1, .ir-acc-content h1 { font-size: 22px !important; line-height: 1.25 !important; }
    #main h2, #container h2, .ir-acc-content h2 { font-size: 18px !important; line-height: 1.3 !important; }
    #main h3, #container h3, .ir-acc-content h3 { font-size: 16px !important; line-height: 1.35 !important; }
    #main p, #main li, #main td, #main dd, #main label, .ir-acc-content p, .ir-acc-content li, .ir-acc-content td, .ir-acc-content label { font-size: max(14px, 1em); }
    #main small, #main .small, #main .date, #main .meta, #main .votes, #main .input-desc,
    #footer, #footer *, #footer-container, #footer-container *, #signupPrompt, #signupPrompt *,
    .ir-acc-content small, .ir-acc-content .small { font-size: max(13px, 0.85em) !important; }
    input, select, textarea, button { font-size: 16px !important; } /* also stops iOS zooming into fields */
    #header1 input, #header1 button { font-size: 15px !important; }
}

/* admin (bootstrap) on phones */
@media (max-width: 767px) {
    .ir-main { padding-left: 10px !important; padding-right: 10px !important; overflow-x: clip; }
    .ir-main .container, .ir-main .container-fluid, .ir-main .row, .ir-main form, .ir-main .span12, .ir-main [class*="span"], .ir-main .well, .ir-main fieldset { width: auto !important; max-width: 100% !important; min-width: 0 !important; float: none !important; margin-left: 0 !important; margin-right: 0 !important; box-sizing: border-box; }
    .ir-main .row { --bs-gutter-x: 0; }
    .ir-main * { max-width: 100%; }
    .ir-main img, .ir-main iframe, .ir-main video { height: auto; }
    .ir-main input[type=text], .ir-main input[type=email], .ir-main input[type=password], .ir-main input[type=url], .ir-main input[type=number], .ir-main select, .ir-main textarea, .ir-main .input-xlarge, .ir-main .input-xxlarge, .ir-main .input-large { width: 100% !important; max-width: 100% !important; box-sizing: border-box; }
    .ir-main table:not(.ir-stacked) { width: 100% !important; }
    .ir-main .btn-group, .ir-main .nav, .ir-main .pagination { flex-wrap: wrap; }
    .ir-divgrid .tableheaderrow { display: none !important; }
    .ir-divgrid .tableevenrow, .ir-divgrid .tableoddrow { float: none !important; display: block; width: auto !important; line-height: 1.5 !important; padding: 2px 10px !important; background: #fff !important; text-align: left !important; overflow-wrap: anywhere; }
    .ir-divgrid .tableevenrow[data-label]::before, .ir-divgrid .tableoddrow[data-label]::before { content: attr(data-label) ": "; font-weight: 600; color: #4b5d6b; font-size: 13px; text-transform: uppercase; }
    .ir-divgrid .ir-cell-first { margin-top: 10px; padding-top: 8px !important; border-top: 2px solid #c9d3db; }
    .ir-main .as-selections { width: auto !important; height: auto !important; overflow: visible !important; display: flex; flex-wrap: wrap; white-space: normal; }
    .ir-main .as-selections li { float: none !important; }
    .ir-main table, .ir-main td, .ir-main th, .ir-main p, .ir-main label { font-size: 14px; }
    .ir-main h1 { font-size: 22px; } .ir-main h2 { font-size: 18px; } .ir-main h3 { font-size: 16px; }
    .ir-side a { font-size: 14px !important; padding: 7px 16px !important; }
    .ir-side summary { font-size: 13px !important; }
}

/* phones: lift the remaining tiny legacy text (10–12px) to a readable size */
@media (max-width: 767px) {
    #acc, #acc p, #acc h1, #acc h2, #acc .acc-h1 { font-size: 13px !important; line-height: 1.4 !important; }
    #header1 #logo, #header1 #menu a, #header1 #user a { font-size: 14px !important; }
    .rinfocolumn .typeRow, .mediaColumn .timeStamp, .review-title-top, ul > li.first > a,
    #restaurantVote .scoreCard .votes, .ir-share a, .blueitem-small .text-holder-2, .video_info, #masthead p { font-size: 13px !important; line-height: 1.45 !important; }
    .mediaColumn .review, .ir-details-wrap .main_description { font-size: 14px !important; line-height: 1.5 !important; }
    .irc-field label, .irc-lead, .irc-lead strong, .irc-req { font-size: 14px !important; }
    .irc-note, .irc-help, .irc-note .irc-req { font-size: 13px !important; }
    #cform label { font-size: 14px !important; } #cform .forget_pw { font-size: 13px !important; }
    /* account shell */
    .ir-acc-logo small, .ir-profile-head .ir-plan, .ir-profile-head .ir-small, .ir-small, .ir-stats-mini span { font-size: 13px !important; }
    /* admin */
    .ir-main small, .ir-main .text-muted, .ir-main .comment, .ir-main .redlink, .ir-main .manualEmails td { font-size: 13px !important; }
    .leaflet-control-attribution { font-size: 11px !important; } /* map credits stay small on purpose */
}
@media (max-width: 767px) {
    #signup-onwer label, #signup-onwer label strong, #signup-onwer .large-col label, #signup-onwer .legal label { font-size: 14px !important; }
    #signup-onwer .input-desc, #signup-onwer .smalltext, #signup-onwer .nomeristorantetext, #signup-onwer .nomeristorantetext a, #signup-onwer .termsofuse { font-size: 13px !important; line-height: 1.45 !important; }
}
/* session 13: suggest_restaurant + user_register leftovers (11px text, 8px overflow at 320px) */
@media (max-width: 767px) {
    .buttonsSuggest p, #ownerButton p, .buttonsSuggest + p a, .buttonsSuggest ~ p a, #why, #why a { font-size: 13px !important; line-height: 1.45 !important; }
    .nonInputTextPicture { max-width: 100%; box-sizing: border-box; }
    .nonInputTextPicture table, .nonInputTextPicture tbody, .nonInputTextPicture tr, .nonInputTextPicture td { display: block; width: auto !important; max-width: 100%; padding-left: 0 !important; padding-right: 0 !important; box-sizing: border-box; }
    .nonInputTextPicture td:empty { display: none; }
    .nonInputTextPicture td > div, .nonInputTextPicture img { max-width: 100% !important; height: auto; box-sizing: border-box; }
}
