/* Phones (up to 760 px wide). Loaded last, so it adjusts the desktop layout without changing it.
   The top bar must fit the screen: the product subtitle and the "What you can build"
   tab are left out; parcels, market and the language switch stay. */
@media (max-width: 760px) {
  .app-topbar { gap: 6px !important; padding: 0 8px !important; max-width: 100vw; overflow: hidden; }
  .app-topbar .platform-product small { display: none !important; }
  .app-topbar .platform-product .terrax-mark { width: 36px; height: 36px; }
  .app-topbar .platform-product .terrax-mark svg { width: 24px; height: 24px; }
  .app-topbar .platform-product strong { font-size: 19px; }
  .app-topbar .section-tabs { margin-left: 0 !important; padding: 3px !important; flex: 0 1 auto; min-width: 0; }
  .app-topbar .section-tabs a { padding: 6px 10px !important; font-size: 13px !important; white-space: nowrap; }
  .app-topbar .section-tabs a[href="/app/what-you-can-build"] { display: none !important; }
  .app-topbar .lang-toggle { flex: none; margin-left: auto !important; }
  .app-topbar .lang-toggle button { padding: 5px 8px !important; font-size: 12px !important; }


  /* Site workspace sections: one row that scrolls sideways, with a fade showing there is more. */
  .site-workspace-nav > div { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .site-workspace-nav > div::-webkit-scrollbar { display: none; }
  .site-workspace-nav > div > button { flex: none; white-space: nowrap; padding-left: 14px !important; padding-right: 14px !important; font-size: 14px !important; }
}

/* Phones and tablets: the results rail (print/PDF, share) is hidden below 1100 px, so its two main
   actions sit in a bar at the bottom of the screen. */
.compact-actions { display: none; }
@media (max-width: 1100px) {
  .compact-actions { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; gap: 8px;
    padding: 10px 12px; background: rgba(9, 12, 16, .96);
    border-top: 1px solid rgba(148, 163, 184, .18); backdrop-filter: blur(6px); }
  .compact-actions button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px;
    border-radius: 10px; border: 1px solid rgba(148, 163, 184, .28); background: #121820; color: #e5eaef;
    font: 600 14px var(--tx-font, Inter, sans-serif); cursor: pointer; }
  .compact-actions button.primary { background: #5fe0a0; color: #06110f; border-color: transparent; }
  .compact-actions button:disabled { opacity: .6; }
  .workspace-shell.analysed { padding-bottom: 76px; box-sizing: border-box; }
}

/* Features that are not switched on are hidden everywhere, not shown as "Soon" (user decision 11/11/2026). */
.feature-off { display: none !important; }

/* ---- Phone and tablet as an app (21/11/2026). Only below 1100 px; the desktop layout is unchanged. ---- */

/* Phones: map screen. The map gets the whole screen: a compact search card on top, the layer lenses as
   one row of chips at the bottom, pinch to zoom (no +/- buttons), and the footer as one thin line of links. */
@media (max-width: 760px) {
  .terrax-app:has(.workspace-shell.selecting) .app-topbar { height: 56px; }
  .app-topbar .section-tabs a { padding: 8px 11px !important; }
  .app-topbar .lang-toggle button { padding: 8px 10px !important; }
  .workspace-shell.selecting { height: calc(100dvh - 82px) !important; min-height: 0 !important; }

  .selecting .site-finder { top: 8px !important; left: 8px !important; right: 8px !important; width: auto !important;
    max-height: calc(100% - 140px) !important; padding: 10px 12px 12px !important; border-radius: 14px; box-sizing: border-box; }
  .selecting .site-finder .finder-title, .selecting .site-finder .selection-legal { display: none; }
  .selecting .site-finder .selection-mode-tabs button { min-height: 46px; }
  .selecting .site-finder .selection-method { padding-top: 10px; }

  .selecting .lens-dock-wrap { top: auto !important; bottom: 10px; left: 8px; right: 8px; flex-direction: column-reverse; align-items: stretch; gap: 8px; }
  .has-chat-bubble .selecting .lens-dock-wrap { right: 62px; }
  .selecting .lens-dock { flex-direction: row; width: auto; gap: 6px; padding: 5px; overflow-x: auto; scrollbar-width: none; border-radius: 14px; }
  .selecting .lens-dock::-webkit-scrollbar { display: none; }
  .selecting .lens-dock .lens-title, .selecting .lens-dock .lens-sep { display: none; }
  .selecting .lens-dock .lens { width: auto; flex: none; min-height: 40px; padding: 8px 13px; border-radius: 10px; background: rgba(255, 255, 255, .06); }
  .selecting .lens-dock .lens span { display: inline !important; }
  .selecting .lens-card { width: auto; max-height: 42vh; }
  .selecting .selection-layers-panel { left: 0 !important; right: 0 !important; width: 100% !important; max-width: none !important; box-sizing: border-box; }

  .workspace-shell .leaflet-control-zoom, .selecting .map-compass { display: none !important; }
  .map-edit-toolbar { left: auto !important; right: 8px; bottom: 76px !important; flex-direction: column; padding: 4px; border-radius: 12px; }
  .map-edit-toolbar button:nth-child(1), .map-edit-toolbar button:nth-child(2) { display: none; }
  .map-edit-toolbar button { justify-content: center; min-width: 44px !important; min-height: 44px; padding: 0 !important; border-right: 0; font-size: 0; }
  .map-edit-toolbar button + button { border-top: 1px solid #2f3842; }
  .workspace-shell.selecting .map-navigation-tools { right: 8px !important; bottom: 182px; }
  .workspace-shell.selecting .map-navigation-tools button { width: 44px; height: 44px; }
  .workspace-shell:not(.analysed) .map-info { left: 8px; right: 62px; bottom: 72px; }
  .selecting .parcel-map-status { bottom: 124px !important; max-width: calc(100% - 80px) !important; }
  .selected-site-card { bottom: 72px !important; }

  .terrax-app:has(.workspace-shell.selecting) .platform-footer { flex-wrap: nowrap !important; justify-content: flex-start !important;
    overflow-x: auto; white-space: nowrap; padding: 5px 10px !important; scrollbar-width: none; }
  .terrax-app:has(.workspace-shell.selecting) .platform-footer .footer-copy { display: none; }
}
@media (max-width: 400px) {
  .app-topbar .platform-product strong { display: none; }
}

/* Phones: results. The page scrolls as a whole, like an app: the top bar scrolls away, the section tabs stay
   at the top, the footer comes at the end of the page. Share sits beside the tabs; KML and DXF (desktop tools)
   are left out; one source button per section (not on every row); the DLS units become cards. */
@media (max-width: 760px) {
  html:has(.workspace-shell.analysed) { height: auto !important; overflow-y: auto !important; }
  body:has(.workspace-shell.analysed) { height: auto !important; overflow: visible !important; }
  .terrax-app:has(.workspace-shell.analysed) { height: auto !important; min-height: 100dvh; overflow: visible !important; }
  .workspace-shell.analysed { height: auto !important; overflow: visible !important; }
  .terrax-app:has(.workspace-shell.analysed) .site-workspace-nav { position: sticky !important; top: 0 !important; }
  .workspace-shell.analysed .workspace-map { height: 36svh; min-height: 230px; }

  .terrax-app:has(.workspace-shell.analysed) .site-workspace-nav button.tabs-more { display: none; }
  .terrax-app:has(.workspace-shell.analysed) .site-workspace-nav > div.nav-actions { display: flex !important; flex: none; overflow: visible;
    -webkit-mask-image: none; mask-image: none; padding: 0 6px; border-left: 1px solid rgba(162, 174, 188, .2); }
  .terrax-app:has(.workspace-shell.analysed) .site-workspace-nav .nav-actions button { width: 42px; height: 40px; padding: 0; }
  .site-workspace-nav .nav-actions button[title^="KML"], .site-workspace-nav .nav-actions button[title^="DXF"] { display: none !important; }
  .site-workspace-nav .nav-actions:not(:has(button:not([title^="KML"]):not([title^="DXF"]))) { display: none !important; }

  dt .result-source-button { display: none !important; }
  .insight-block header .result-source-button { width: 40px; height: 40px; }

  .unit-table, .unit-table tbody, .unit-table tfoot { display: block !important; overflow: visible !important; }
  .unit-table thead { display: none; }
  .unit-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; padding: 11px 0; border-bottom: 1px solid var(--ins-line); }
  .unit-table td { display: flex; flex-direction: column; gap: 1px; padding: 0 !important; border: 0 !important; text-align: left !important; white-space: normal; }
  .unit-table td::before { content: attr(data-label); color: var(--ins-muted); font-size: 11.5px; font-weight: 500; }
  .unit-table td:first-child { grid-column: 1 / -1; font-size: 14px; }
  .unit-table td:first-child::before { content: none; }
  .unit-table td:empty { display: none; }

  .general-disclaimer { flex-wrap: wrap; align-items: flex-start !important; }
  .general-disclaimer > span:first-child { flex: 1 1 calc(100% - 40px); }
  .general-disclaimer .all-sources { flex: 1 1 100%; min-height: 44px; margin-top: 10px; }
  .terrax-app:has(.workspace-shell.analysed) .platform-footer .footer-links { flex-wrap: wrap; justify-content: center; }
}

/* Phones and tablets: with no PDF button, the bottom bar would only repeat Share, which is beside the tabs. */
@media (max-width: 1100px) {
  .compact-actions:not(:has(.primary)) { display: none !important; }
  .workspace-shell.analysed:not(:has(.compact-actions .primary)) { padding-bottom: 0; }
  .terrax-app:has(.compact-actions):not(:has(.compact-actions .primary)) .platform-footer { padding-bottom: 5px; }
}
/* Tablets: all section tabs scroll sideways (no hidden "›" button) and Share, KML and DXF sit beside them. */
@media (min-width: 761px) and (max-width: 1100px) {
  .terrax-app:has(.workspace-shell.analysed) .site-workspace-nav button.tabs-more { display: none; }
  .terrax-app:has(.workspace-shell.analysed) .site-workspace-nav > div.nav-actions { display: flex !important; margin-left: 0; }
  .terrax-app:has(.workspace-shell.analysed) .site-workspace-nav > div:not(.nav-actions) { flex: 1 1 auto; }
  .terrax-app:has(.workspace-shell.analysed) .site-workspace-nav > div:not(.nav-actions) { scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
}

/* Phones: after an address is chosen or drawing starts, the search card folds into one round search button
   (top left); tapping it opens the card again. Phones held sideways (laid out at 760 px, see app.js): the card
   sits on the left and the layer chips beside it, so the map stays in view. Desktop never shows the button. */
.finder-reopen { display: none; }
@media (max-width: 760px) {
  .selecting .site-finder.finder-collapsed { right: auto !important; width: auto !important; padding: 0 !important; border: 0 !important;
    background: none !important; box-shadow: none !important; overflow: visible !important; }
  .selecting .site-finder.finder-collapsed > :not(.finder-reopen) { display: none !important; }
  .selecting .site-finder.finder-collapsed .finder-reopen { display: grid; place-items: center; width: 48px; height: 48px; padding: 0;
    border: 1px solid rgba(161, 173, 187, .3); border-radius: 50%; background: rgba(13, 18, 25, .94); color: #e6edf3;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .45); cursor: pointer; }
}
@media (max-width: 760px) and (max-height: 460px) {
  .selecting .site-finder:not(.finder-collapsed) { right: auto !important; width: min(380px, 52%) !important; max-height: calc(100% - 16px) !important; }
  .selecting:has(.site-finder:not(.finder-collapsed)) .lens-dock-wrap { left: calc(min(380px, 52%) + 16px); }
  .selecting .lens-dock .lens { min-height: 36px; padding: 6px 11px; }
  .workspace-shell.analysed .workspace-map { height: 62svh; }
  .selecting .parcel-map-status { top: 8px !important; bottom: auto !important; left: 68px !important; max-width: calc(100% - 140px) !important; }
  .selecting:has(.site-finder:not(.finder-collapsed)) .parcel-map-status { left: calc(min(380px, 52%) + 16px) !important; max-width: calc(48% - 90px) !important; }
}

/* Phones: the start screen as in map apps. Search mode is one rounded search bar with three small buttons under
   it (parcel by title-deed details, draw, upload), floating over the map without a card. Choosing one of them
   opens it as a sheet from the bottom (portrait) with a close button that returns to the search bar. */
.finder-sheet-close { display: none; }
@media (max-width: 760px) {
  .selecting .site-finder.mode-search:not(.finder-collapsed) { display: flex; flex-direction: column; padding: 0 !important; border: 0 !important;
    background: none !important; box-shadow: none !important; overflow: visible !important; max-height: none !important; pointer-events: none;
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  .selecting .site-finder.mode-search > * { pointer-events: auto; }
  .selecting .site-finder.mode-search .selection-mode-content { order: 1; }
  .selecting .site-finder.mode-search .selection-mode-tabs { order: 2; display: flex; gap: 6px; height: auto; margin: 8px 0 0; border: 0; border-radius: 0;
    background: none; overflow: visible; align-self: flex-start; width: max-content; max-width: 100%; flex-wrap: wrap; }
  .selecting .site-finder.mode-search .selection-mode-tabs button { flex: none; flex-direction: row; gap: 6px; min-height: 38px; padding: 0 14px;
    border: 1px solid rgba(161, 173, 187, .3); border-radius: 19px; background: rgba(13, 18, 25, .94); color: #dbe3ea; font-size: 13.5px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .35); }
  .selecting .site-finder.mode-search .selection-mode-tabs button:first-child { display: none; }
  .selecting .site-finder.mode-search .location-search > label { display: none; }
  .selecting .site-finder.mode-search .location-input { height: 50px; padding: 0 16px; gap: 10px; border: 1px solid rgba(161, 173, 187, .32);
    border-radius: 25px; background: rgba(13, 18, 25, .97); box-shadow: 0 8px 22px rgba(0, 0, 0, .45); }
  .selecting .site-finder.mode-search .location-input input { font-size: 16px; }
  .selecting .site-finder.mode-search .location-matches { max-height: calc(100dvh - 250px); border-radius: 14px; box-shadow: 0 10px 26px rgba(0, 0, 0, .45); }
  .selecting .site-finder.mode-search ~ .parcel-map-status,
  .selecting:has(.site-finder.mode-search) .parcel-map-status { top: 112px !important; bottom: auto !important; }
  .selecting:has(.site-finder.mode-search.finder-collapsed) .parcel-map-status { top: 8px !important; left: 68px !important; max-width: calc(100% - 80px) !important; }
}
@media (max-width: 760px) and (min-height: 461px) {
  .selecting .site-finder:not(.mode-search):not(.finder-collapsed) { top: auto !important; bottom: 0 !important; left: 0 !important; right: 0 !important;
    max-height: 80% !important; padding: 22px 14px 18px !important; border-radius: 20px 20px 0 0 !important; overflow-y: auto !important;
    box-shadow: 0 -12px 34px rgba(0, 0, 0, .5) !important; }
  .selecting .site-finder:not(.mode-search):not(.finder-collapsed)::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px;
    margin-left: -20px; border-radius: 2px; background: rgba(161, 173, 187, .4); }
  .selecting .site-finder:not(.mode-search):not(.finder-collapsed) .finder-sheet-close { display: grid; place-items: center; position: absolute; top: 12px; right: 12px;
    z-index: 2; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .08); color: #e6edf3; font-size: 24px; line-height: 1; }
  .selecting .site-finder:not(.mode-search):not(.finder-collapsed) .selection-mode-tabs { margin-right: 46px; }
  .selecting:has(.site-finder:not(.mode-search):not(.finder-collapsed)) :is(.lens-dock-wrap, .map-edit-toolbar, .map-navigation-tools, .parcel-map-status, .map-info) { display: none !important; }
}
@media (max-width: 760px) {
  /* While the address suggestions are open they come first: the three buttons and the map tools step aside. */
  .selecting .site-finder.mode-search:has(.location-matches) { z-index: 950; }
  .selecting .site-finder.mode-search:has(.location-matches) .selection-mode-tabs { display: none; }
  .selecting:has(.site-finder .location-matches) :is(.map-edit-toolbar, .map-navigation-tools, .parcel-map-status) { display: none !important; }
  .selecting .location-input input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
}
@media (max-width: 760px) and (max-height: 460px) {
  .selecting:has(.site-finder.mode-search:not(.finder-collapsed)) .parcel-map-status { top: 8px !important; }
}
