/* The phone (390 x 844), measured against today's app.

   Linked once, from the page frame (src/app.rs), right after the Tailwind
   stylesheet, so it reaches the customer's pages and the support pages
   alike. A page's own stylesheet (admin.css and the like) is linked later in
   the body and would win a tie, so the rules here that override one carry
   `:root` in front for the weight, never `!important`.

   Every rule sits under a phone-width query: nothing here may change a
   desktop picture. Values are read off today's pictures at 390 px, never
   off its CSS (decision 7). */

/* -- the support pages ---------------------------------------------------
   Today's support pages give every <button> a 44 px touch target up to
   768 px wide; where today's has a button and the port a link styled as
   one, the link takes the same. */
@media (max-width: 768px) {
  :root a.at-btn, :root a.acx-btn, :root a.ga-action, :root a.ga-back,
  :root a.ga-refresh, :root .ga-page-button, :root a.mf-obtn { min-width: 44px; min-height: 44px; }
  /* The timing run's way back is a link in today's (36 px), the nesting
     run's a button. */
  :root a.at-back { min-height: 0; }
  :root .at-nrun-bar a.at-back { min-height: 44px; }
}

/* Today's shadcn text fields have 16 px type below 768 px (14 px above);
   its other fields keep 14 px. The 44 px floor reaches only the fields that
   say type="text" in today's markup, which its search fields do not: those
   stay 36 px tall. Where today's has a select button (44 px like every
   button) the port has a native select. */
@media (max-width: 767px) {
  :root .acx-search > input,
  :root .at-timing-search,
  :root .mf-input,
  :root .rt-block input,
  :root .xw-input,
  :root .mf-fin[name=search], :root .mf-fin.it-locale { font-size: 16px; }
  :root .acx-search > input,
  :root .at-timing-search,
  :root [data-ga-search],
  :root .mf-fin[name=search], :root .mf-fin.it-locale { min-height: 0; }
  :root .ad-frame select { min-height: 44px; }
}

/* /admin: the Users head sits 4 px from the tab panel, not 10. */
@media (max-width: 767px) {
  :root .ad-section-head { padding: 4px 0; }
}

/* /admin/customer-visits: the filters at full width, 12 px apart; the
   selects 44 px tall like every button; the Show Errors box a 44 px
   square (today's checkbox is a button), running past its 40 px row. */
@media (max-width: 767px) {
  :root .acx-select { height: auto; }
  :root .acx-check > input { width: 44px; height: 44px; }
}

/* /admin/timing: the search field and Søk stay on one line (Søk runs 1 px
   past the page's edge, as today's), the status filter and the refresh
   below them. */
@media (max-width: 767px) {
  :root .at-tools#timing-search {
    display: grid; grid-template-columns: 160px 120px 55px; align-items: start;
    column-gap: 8px; row-gap: 8px;
  }
  :root #timing-search > .at-timing-search { grid-column: 1 / 3; width: 288px; }
  :root #timing-search > button[type=submit] { grid-column: 3; }
  :root #timing-search > .at-btn-icon { grid-column: 2; justify-self: start; }
}

/* /runtime-configuration: below 768 px a field's help goes under its
   field, 12 px below, and the field takes the card's width (the port's
   widths are inline styles, hence the one !important); the bolt's three
   tiles one under the other. */
@media (max-width: 767px) {
  :root .rt-side { flex-direction: column; align-items: stretch; gap: 12px; }
  :root .rt-block { width: auto !important; }
  :root .rt-tiles { grid-template-columns: minmax(0, 1fr); }
  :root .ad-frame input[type=number] { min-height: 44px; }
}

/* The correction page below 768 px: one column whose width follows its
   widest line (the download button with the customer's long file name),
   so the card runs past the screen as today's does; the two treatments
   one under the other. */
@media (max-width: 767px) {
  :root .rk-grid { grid-template-columns: auto; }
  :root .rk-col, :root .rk-step-main { min-width: auto; }
  :root .rk-choices { grid-template-columns: 1fr; }
}

/* The lists' pager below 768 px (analyses, parametric designs, STL
   comparisons): one line, the words wrapping inside it; the material field
   of the parametric designs at full width (its 220 px is inline). */
@media (max-width: 767px) {
  :root .ga-pager { flex-wrap: nowrap; }
  :root .ga-clear { display: inline-flex; align-items: center; min-height: 44px; }
  :root .ga-input[name=material] { width: 100% !important; }
}

/* /admin/pricing below 768 px: the title and the poll's tools wrap onto two
   lines, as today's head does. */
@media (max-width: 767px) {
  :root .pr-head { flex-wrap: wrap; }
  /* The runs' list grows with its longest e-mail, never cut (459 px at
     390 on today's), and its search field is a 36 px, 16 px one. */
  :root .pr-grid { grid-template-columns: auto; }
  :root .pr-who { min-width: auto; }
  :root .pr-name { overflow: visible; text-overflow: clip; }
  :root .pr-search input { font-size: 16px; min-height: 0; }
}

/* /contact-requests: the search and Refresh wrap 12 px apart; the search
   field says no type in today's, so it stays 36 px (14 px type). */
@media (max-width: 767px) {
  :root .acx-toolbar { row-gap: 12px; }
  :root .acx-list-search > input { min-height: 0; }
}

/* -- the admin pages at the phone -------------------------------------------
   /material-lookdev: today's selects are buttons, 44 px tall up to 768 px. */
@media (max-width: 768px) {
  :root .ld-page .xw-sel-t { height: 44px; }
}
/* /manufacturing's plate filter says no type in today's: no 44 px floor. */
@media (max-width: 767px) {
  :root .mf-filter > .mf-input { min-height: 0; }
}
/* /admin/timing/<id>: the related pages are links in today's (32 px). */
@media (max-width: 768px) {
  :root .at-related > a.at-btn { min-height: 0; }
}
/* /admin/stl-comparisons/<id>: "Til delen" ends at its words; the button
   under it sits 16 px below (today's head on a phone). */
@media (max-width: 767px) {
  :root .stl-link { padding-bottom: 0; }
}
/* The menus' items are not buttons in today's: no 44 px floor (the row
   menu on /admin is 4 + 32 + 32 + 4 px tall at 390). */
@media (max-width: 768px) {
  :root .ad-pop .ad-pop-item { min-height: 0; min-width: 0; }
}
/* The visits lists' "Vis 100" with no more rows is a disabled button in
   today's, 44 px tall like every button on a phone; the port's is a span. */
@media (max-width: 768px) {
  :root span.acx-btn[aria-disabled=true] { min-width: 44px; min-height: 44px; }
}

/* -- the board's alert dialogs -------------------------------------------
   Below 640 px today's alerts centre their title and sentence and stack
   their buttons full width, 44 px tall, 6 px apart, the way on above the
   way back. "Sett tykkelse for DXF/DWG" and the login gate take the whole
   width of the frame (390 px, 4 px corners, the 1 px line at both edges);
   "Slett fil?" stops 5 px short of each edge (380 px). Measured on the
   oracle's pictures at 390 x 844 (board-dialogs/*--phone). */
@media (max-width: 639px) {
  :root .cad-dialog-frame .cad-alert__header,
  :root .cad-delete-dialog__panel .cad-alert__header { text-align: center; }
  :root .cad-dialog-frame .cad-alert__footer,
  :root .cad-delete-dialog__panel .cad-alert__footer { flex-direction: column-reverse; gap: 6px; }
  :root .cad-dialog-frame .cad-alert__footer .cad-dialog-button,
  :root .cad-delete-dialog__panel .cad-alert__footer .cad-dialog-button { width: 100%; min-height: 44px; }
  :root dialog:has(> .cad-dialog-frame) { padding-left: 0; padding-right: 0; }
  :root .cad-dialog-frame { max-width: 100vw; }
  :root dialog:has(> .cad-delete-dialog__panel) { padding-left: 5px; padding-right: 5px; }
  :root .cad-delete-dialog__panel { max-width: 100%; }
}

/* The editor's "Gå til handlekurv?" at 390 px: as the board's alerts, full
   width (today's, editor-dialogs/go-to-basket--phone). An alert is the
   panel whose first block holds the title; "Kan ikke produseres" (an
   icon beside its title) keeps its own look. */
@media (max-width: 639px) {
  :root [data-editor-dialog-overlay]:has(> [aria-modal] > div:first-child > [data-slot=title]) { padding-left: 0; padding-right: 0; }
  :root [data-editor-dialog-overlay] > [aria-modal]:has(> div:first-child > [data-slot=title]) { max-width: 100%; }
  :root [data-editor-dialog-overlay] > [aria-modal] > div:first-child:has(> [data-slot=title]) { text-align: center; }
  :root [data-editor-dialog-overlay] > [aria-modal]:has(> div:first-child > [data-slot=title]) > div:nth-child(2) { flex-direction: column-reverse; }
  :root [data-editor-dialog-overlay] > [aria-modal]:has(> div:first-child > [data-slot=title]) > div:nth-child(2) > button { width: 100%; min-height: 44px; }
}

/* /admin/timing/<id>: today's values do not break inside a word, so a long
   reason runs past the card and widens the page (592 px at 390). */
@media (max-width: 767px) {
  :root .at-inputs dd { overflow-wrap: normal; }
}

/* /admin/nesting/<id> below 768 px: Tilbake and Nesting-oversikt, then the
   title, then Oppdater under it (today's order on a phone); the overview
   link stays a 36 px link; the figures grow with their widest value. */
@media (max-width: 767px) {
  :root .at:has(> .at-nrun-bar) { display: flex; flex-direction: column; }
  :root .at-nrun-bar { display: contents; }
  :root .at-nrun-bar > div { order: 0; align-self: flex-start; }
  :root .at:has(> .at-nrun-bar) > .at-nrun-title { order: 1; }
  :root .at-nrun-bar > a { order: 2; margin-top: 12px; }
  :root .at:has(> .at-nrun-bar) > :not(.at-nrun-bar):not(.at-nrun-title) { order: 3; }
  :root .at-nrun-bar > div > a.at-btn-line { min-height: 0; }
  :root .at-figure { min-width: auto; }
}

/* /admin/stl-comparisons: the search's 16 px type; "Bare siste svar per
   del" a 44 px box like today's button checkbox. The thread's reply box
   (/admin/contact-messages/<id>) has the same 16 px type. */
@media (max-width: 767px) {
  :root .stl-search input { font-size: 16px; }
  :root .stl-check input, :root .stl-layers input { width: 44px; height: 44px; flex-shrink: 0; }
  :root .stl-layers { row-gap: 8px; }
  :root textarea[data-acx-reply] { font-size: 16px; }
}

/* The support pages' dialogs (Add User, Edit User, Delete User) below
   640 px: the head centred, the fields' 16 px type, the read-only box a
   44 px square, the buttons stacked full width with Save on top. */
@media (max-width: 639px) {
  :root .ad-dialog-head { text-align: center; }
  :root .ad-dialog input:not([type=checkbox]) { font-size: 16px; }
  :root .ad-check > input[type=checkbox] { width: 44px; height: 44px; }
  :root .ad-dialog-foot { flex-direction: column-reverse; }
  :root .ad-dialog-foot > * { width: 100%; }
}

/* /manufacturing's card heads: the action keeps its width (Add tool), the
   words beside it wrap. */
@media (max-width: 767px) {
  :root .mf-card-hr > button, :root .mf-card-hr > a { flex-shrink: 0; }
}

/* The correction page's small actions are buttons in today's (44 px on a
   phone): "Velg fil" in the drop zone, "Bytt fil", and the new round's
   "Avbryt, behold løsningen kunden har". */
@media (max-width: 768px) {
  :root .rk-drop .rk-btn, :root a.rk-btn-sm { min-height: 44px; }
  :root .rk-calm-more { display: inline-flex; align-items: center; min-height: 44px; }
}

/* /geometry-issue-templates: the list's card grows to its longest code
   (today's runs 8 px past the page's padding at 390). */
@media (max-width: 767px) {
  :root .it-grid { grid-template-columns: 1fr; }
}

/* Today's "404 Oops!" page below 768 px: the number at 60 px, Go Back a
   44 px button (the page has no admin sheet, so the floor is set here). */
@media (max-width: 767px) {
  :root .min-h-screen.justify-center > span.text-\[96px\] { font-size: 60px; }
  :root .min-h-screen.justify-center button { min-height: 44px; }
}

/* /admin/nesting/<id>, further down: the parts table widens its card and
   the solver card beside it in the grid (today's page is 579 px wide at
   390), and "Åpne pristilbud" is a 32 px link in today's. The head's links
   sit at the top of their row. */
@media (max-width: 767px) {
  :root .at-pair { grid-template-columns: auto; }
  /* The cards in that pair take their content's least width (the parts
     table's 481 px), so both cards are 531 px wide and the page 579 px, as
     today's (the cards' min-width 0 kept them at 294 px). */
  :root .at-pair > .at-card, :root .at-pair > .at-card > .at-card-body { min-width: auto; }
  :root .at-parts-wrap { overflow: visible; }
  :root .at-quote-end > a.at-btn { min-height: 0; }
  :root .at-nrun-bar > div { align-items: flex-start; }
  :root .at-nrun-bar > a { margin-top: 16px; }
}

/* The bolt's matrices: the cells' numbers at 16 px, from the right, 12 px
   in from the left edge and 27 px from the right (today's number fields
   keep 15 px for their spinner), so a value wider than its cell shows its
   start and is cut on the right ("10" of 100, "Ing" of Ingen grense), as
   today's (the cut read "from the left"). The
   save rows wrap rather than squeeze their icons away. */
@media (max-width: 767px) {
  :root .rt-cellin, :root form[data-tiers] .rt-cellin { font-size: 16px; text-align: right; padding: 0 27px 0 12px; }
  :root .rt-buttons { flex-wrap: wrap; }
  :root .rt-buttons > button { flex-shrink: 0; }
  :root .rt-to .rt-native { min-height: 0; }
}

/* The thread at 390: a message's meta stays one row whose words wrap
   inside it ("i dag / 12:11", "Ikke lest / ennå"); the customer's address
   in the head breaks anywhere ("…-phone / @vi3.co"). */
@media (max-width: 767px) {
  :root .acx-msg-meta { flex-wrap: nowrap; }
  :root .acx-thread-meta > span:not(.acx-thread-wants) { word-break: break-all; }
}

/* The correction page below 640 px: what blocks "Send til kunden" wraps
   under the button when the two do not fit (beside it on the 612 px page
   of a long file name), and the sent correction's "Rett på nytt" has its
   note under it. */
@media (max-width: 639px) {
  /* 16 px between the button and its note (today's 714 - 698 at
     390; the port had 12, the page 4 px short: correction/active 3.21 %). */
  :root .rk-again { flex-direction: column; align-items: flex-start; gap: 16px; }
  :root .rk-send { flex-wrap: wrap; row-gap: 16px; }
}

/* -- the board at the phone ----------------------------------------------
   (The drawing card's height, B-320, is in styles/board.css: it holds at
   1024 as well.) */

/* B-321. The status dialog up to 768 px: today's buttons are 44 px touch
   targets there. "Samtalen (1)" is 44 px tall (42.25 above 768 px), which
   makes the dialog 1.75 px taller and puts every line 0.9 px higher; the
   X is a 44 px square hanging from the same corner (16 px from the top and
   the right of the panel's inner edge), its cross at the square's left
   edge, centred top to bottom (the cross at 317,156 on a dialog from
   12,122 at 390; at 345,142 from 769 px up). */
@media (max-width: 768px) {
  :root .cad-support .cad-support__toggle { min-height: 44px; }
  :root .cad-support > .cad-alert__close { width: 44px; height: 44px; align-items: center; justify-content: flex-start; }
}

/* B-322. The thread (/admin/contact-messages/<id>) below 768 px. Today's
   message takes up to 92 % of the thread (the port's 85 % held the
   customer's meta row to 207 px, so the address and the time wrapped, and
   made support's bubble 207 px where today's is 224.5); the words of a
   meta row that does wrap sit centred beside each other ("i dag / 03:27"
   beside the address); the reply box has 16 px type on 24 px lines and is
   three lines tall (90 px; 14 on 20 and 80 px from 768 px up); Send's icon
   sits 6 px from its word (74 px wide). Today's has the 92 %, the centring
   and the 6 px at every width; above the phone they are filed (B-410). */
@media (max-width: 767px) {
  :root .acx-msg { max-width: 92%; }
  :root .acx-msg-meta { align-items: center; }
  :root .acx-reply > textarea { height: 90px; line-height: 24px; }
  :root .acx-reply .acx-send { gap: 6px; }
}

/* The correction page's two text boxes below 768 px ("Melding til kunden",
   "Svar til kunden"): today's text areas have 16 px type on 24 px lines
   there and are three lines tall, 90 px (14 on 20 and 80 px from 768 px
   up), read off correction-flow/uploaded--phone; the port's kept 14 on 20
   and 80 px, so everything under the box sat 10 px higher. */
@media (max-width: 767px) {
  :root .rk-text { height: 90px; font-size: 16px; line-height: 24px; }
}
