/* The site as an app on phones (≤760px), loaded on every page with app.js. On a phone the rewize.com
   header and the footer give way to an app bar on top (logo or back + title, and a menu) and a tab bar
   at the bottom (Home, Search, Saved, Account); dialogs open as bottom sheets; pages slide into
   each other; taps answer at once. Wider screens are not touched, except for the page transitions. */

.app-bar, .app-tabs, .app-sheet { display: none; }

@media (max-width: 760px) {
  :root {
    --app-bar: calc(56px + env(safe-area-inset-top, 0px));
    --app-tab: calc(64px + env(safe-area-inset-bottom, 0px));
  }
  /* A page that is a flow or has its own action bar at the bottom (a property, a form): no tab bar. */
  body.app-flow { --app-tab: 0px; }

  html { -webkit-text-size-adjust: 100%; }
  body { padding-bottom: var(--app-tab); -webkit-tap-highlight-color: transparent; overscroll-behavior-x: none; }
  a, button, label, summary, [role="button"], input[type="checkbox"], input[type="radio"] { touch-action: manipulation; }
  /* Text inputs at 16px or more: iOS zooms the page into anything smaller. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea { font-size: max(16px, 1em) !important; }

  /* rewize.com's header and the footer: their links live in the menu sheet. */
  .rwold:has(#main-header-nav), .frame:has(> .footer), body > .footer { display: none !important; }
  .toTop, .switch { display: none !important; }
  /* Breadcrumbs: the app bar's Back and title do their job. */
  .ar-crumbs, .at-crumbs, .bl-crumbs, .co-crumbs, .lp-crumbs, .pr-crumbs, .pp-crumbs { display: none !important; }

  /* ---------- App bar ---------- */
  .app-bar {
    position: sticky; top: 0; z-index: 9000; display: flex; align-items: center; gap: 4px;
    height: var(--app-bar); padding: env(safe-area-inset-top, 0px) 8px 0;
    background: color-mix(in srgb, var(--page, #FCFCFC) 88%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
    border-bottom: 1px solid transparent; transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.2s;
    view-transition-name: app-bar;
  }
  .app-bar.is-scrolled { border-bottom-color: var(--line, #E7E9EE); }
  .app-bar.is-hidden { transform: translateY(-100%); }
  .app-bar__logo { display: flex; align-items: center; height: 44px; padding: 0 8px; }
  .app-bar__logo img { height: 22px; width: auto; }
  .app-bar__title { flex: 1; min-width: 0; margin: 0; padding: 0 4px; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; color: var(--ink, #14292A); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .app-bar__spacer { flex: 1; }
  .app-icon {
    flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 999px;
    background: transparent; color: var(--ink, #14292A); cursor: pointer;
  }
  .app-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .app-icon:active { background: var(--tile, #F5F6F8); }
  .app-icon:focus-visible, .app-tabs a:focus-visible, .app-sheet a:focus-visible, .app-sheet button:focus-visible { outline: 2px solid var(--accent, #25767C); outline-offset: 2px; }

  /* ---------- Tab bar ---------- */
  .app-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 9000; display: grid; grid-template-columns: repeat(4, 1fr);
    height: var(--app-tab); padding: 6px 4px env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--surface, #FFFFFF) 92%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
    border-top: 1px solid var(--line, #E7E9EE);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    view-transition-name: app-tabs;
  }
  html.app-reading .app-tabs { transform: translateY(100%); }
  body.app-flow .app-tabs { display: none; }
  .app-tabs a {
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; padding-top: 4px;
    border-radius: 14px; color: var(--muted, #5F6673); font-size: 11px; font-weight: 500; letter-spacing: 0.01em; text-decoration: none;
    -webkit-user-select: none; user-select: none;
  }
  .app-tabs a svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; transition: scale 0.15s; }
  .app-tabs a[aria-current="page"] { color: var(--accent-ink, #25767C); font-weight: 600; }
  .app-tabs a[aria-current="page"] svg { stroke-width: 2.1; }
  .app-tabs a[aria-current="page"] svg .fill { fill: currentColor; fill-opacity: 0.16; }
  .app-tabs a:active svg { scale: 0.88; }
  .app-tabs__ico { position: relative; }
  .app-tabs__badge {
    position: absolute; top: -3px; left: 15px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--accent-ink, #25767C); color: #FFFFFF; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
  }

  /* What sticks to the top of a page sits under the app bar, and moves up when the bar hides. */
  /* The list's filters scroll away with the page (a slim bar, .lt-mini, stays); its full-screen map fills
     what the app bar, the filters and the tab bar leave. */
  /* No blur there: a blurred parent would hold the pop-overs (position: fixed) inside it instead of the screen. */
  .lt-toolbar { position: relative !important; top: auto !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: var(--page, #FCFCFC) !important; }
  .view-split.is-mapmode .lt-map { height: calc(100dvh - var(--tb, 120px) - var(--app-bar) - var(--app-tab)) !important; }
  .lt-mini { top: calc(var(--app-top, var(--app-bar)) + 8px) !important; }
  /* The filters' pop-overs open as sheets above the tab bar. */
  .pop, .pop--wide { bottom: calc(var(--app-tab-now, var(--app-tab)) + 12px) !important; z-index: 9001 !important; }

  /* What is pinned to the bottom of a page sits above the tab bar. */
  .lt-nudge { bottom: calc(var(--app-tab-now, var(--app-tab)) + 68px) !important; transition: bottom 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }  /* above the map/list button */
  .lt-mapswitch, .fv-tray { bottom: calc(var(--app-tab-now, var(--app-tab)) + 12px) !important; transition: bottom 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); }
  .au-toast, .fv-toast, .pp-toast, .lt-toast { bottom: calc(var(--app-tab-now, var(--app-tab)) + 16px) !important; }
  body:has(.pop:not([hidden])) .lt-mapswitch, html.app-locked .lt-mapswitch { display: none !important; }  /* out of the way of a sheet */
  .lt-mapswitch { height: 44px !important; padding: 0 18px !important; font-size: 14px !important; }
  body.app-flow .pp-toast { bottom: 92px !important; }

  /* ---------- Small links and text buttons: 44px to tap, the same size to see ---------- */
  :is(.ov-appt__actions > a, .ov-appt__actions > button, .ov-inq__ask, .ov-link, .fv-visit, .fv-link, .fv-note-add, .fv-pick,
    .pp-link, .pp-where > a, .pp-cmp__links > a, .hero__browse, .au-links > button, .sl-link, .pr-cta__link, .co-door__more,
    .co-talk__tel, .sr-widen > a, .at-tag, .seg button, .views button) { position: relative; }
  :is(.ov-appt__actions > a, .ov-appt__actions > button, .ov-inq__ask, .ov-link, .fv-visit, .fv-link, .fv-note-add, .fv-pick,
    .pp-link, .pp-where > a, .pp-cmp__links > a, .hero__browse, .au-links > button, .sl-link, .pr-cta__link, .co-door__more,
    .co-talk__tel, .sr-widen > a, .at-tag)::after { content: ""; position: absolute; inset: -13px -4px; }
  :is(.seg button, .views button)::after { content: ""; position: absolute; inset: -6px 0; }
  .pn-switch { min-height: 44px; }
  .leaflet-touch .leaflet-control-zoom a { width: 40px; height: 40px; line-height: 40px; }

  /* ---------- Taps answer at once ---------- */
  /* `scale`, not `transform`: it adds to whatever a control is already positioned with (translateX(-50%)). */
  .btn, .chip, .card, .pill, .round, button, [role="button"], .app-sheet__link { transition: scale 0.12s ease, filter 0.12s ease, background-color 0.12s; }
  .btn:active, .card:active, .round:active, .pill:active, .chip:active, button:not(:disabled):active, .app-sheet__link:active { scale: 0.97; }
  .card:active { filter: brightness(0.97); }

  /* ---------- Dialogs open as bottom sheets ---------- */
  dialog[open]:not(.pp-lightbox):not(.app-keep) {
    width: 100vw !important; max-width: none !important; max-height: 92dvh !important; margin: auto 0 0 !important;
    border-radius: 26px 26px 0 0 !important; padding-bottom: env(safe-area-inset-bottom, 0px);
    animation: app-sheet-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  dialog[open]:not(.pp-lightbox):not(.app-keep)::before {
    content: ""; position: sticky; top: 0; z-index: 3; display: block; width: 40px; height: 5px; margin: 8px auto -13px; border-radius: 999px;
    background: var(--line, #D9DDE3);
  }
  dialog::backdrop { animation: app-fade-in 0.32s ease; }
  dialog.app-dragging { animation: none; transition: none; }
  dialog.app-closing { transform: translateY(100%) !important; transition: transform 0.22s ease-in !important; }

  /* ---------- Sheets of the app layer (the menu) ---------- */
  .app-sheet { position: fixed; inset: 0; z-index: 200001; display: block; }
  .app-sheet[hidden] { display: none; }
  .app-sheet__backdrop { position: absolute; inset: 0; border: 0; padding: 0; background: rgba(14, 41, 43, 0.42); animation: app-fade-in 0.28s ease; }
  .app-sheet__panel {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow: auto; overscroll-behavior: contain;
    padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px)); border-radius: 26px 26px 0 0;
    background: var(--surface, #FFFFFF); color: var(--ink, #14292A); box-shadow: 0 -20px 50px -20px rgba(14, 41, 43, 0.35);
    animation: app-sheet-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .app-sheet__grab { display: block; width: 40px; height: 5px; margin: 0 auto 14px; border-radius: 999px; background: var(--line, #D9DDE3); }
  .app-sheet__who { display: flex; align-items: center; gap: 12px; padding: 4px 4px 16px; border-bottom: 1px solid var(--line, #E7E9EE); }
  .app-sheet__avatar { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; background: var(--chip, #E9F1F2); color: var(--chip-ink, #1D5D62); font-weight: 600; }
  .app-sheet__who b { display: block; font-size: 16px; font-weight: 600; }
  .app-sheet__who small { display: block; font-size: 13px; color: var(--muted, #5F6673); overflow: hidden; text-overflow: ellipsis; }
  .app-sheet__who .btn { margin-left: auto; }
  .app-sheet h2 { margin: 18px 4px 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted, #5F6673); }
  .app-sheet__list { margin: 0; padding: 0; list-style: none; }
  .app-sheet__link {
    display: flex; align-items: center; gap: 14px; width: 100%; min-height: 52px; padding: 0 6px; border: 0; border-radius: 14px;
    background: none; color: var(--ink, #14292A); font: inherit; font-size: 16px; text-align: left; text-decoration: none; cursor: pointer;
  }
  .app-sheet__link:active { background: var(--tile, #F5F6F8); }
  .app-sheet__link svg { flex: none; width: 22px; height: 22px; fill: none; stroke: var(--accent-ink, #25767C); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .app-sheet__link .app-sheet__go { margin-left: auto; width: 18px; height: 18px; stroke: var(--faint, #687080); }
  .app-sheet__lang { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 999px; background: var(--tile, #F5F6F8); }
  .app-sheet__lang a { display: grid; place-items: center; height: 44px; border-radius: 999px; color: var(--ink-soft, #2C484A); font-size: 15px; font-weight: 500; text-decoration: none; }
  .app-sheet__lang a[aria-current="true"] { background: var(--surface, #FFFFFF); color: var(--ink, #14292A); font-weight: 600; box-shadow: 0 2px 8px -4px rgba(14, 41, 43, 0.35); }
  .app-sheet__fine { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 18px 6px 0; font-size: 13px; color: var(--muted, #5F6673); }
  .app-sheet__fine a { color: inherit; }
  html.app-locked, html.app-locked body { overflow: hidden; }

  /* ---------- Demo button and its sheet ---------- */
  .app-demo {
    flex: none; position: relative; height: 30px; margin: 0 2px; padding: 0 12px; border: 1px solid var(--accent-ink, #25767C); border-radius: 999px;
    background: var(--chip, #E9F1F2); color: var(--accent-ink, #25767C); font: inherit; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; cursor: pointer;
  }
  .app-demo::after { content: ""; position: absolute; inset: -7px -4px; }  /* 44px to tap, 30px to see */
  .app-demo:focus-visible { outline: 2px solid var(--accent, #25767C); outline-offset: 2px; }
  .app-sheet--demo .pn-demo, .app-sheet--demo .pp-demo {
    display: block; margin: 0; padding: 0 4px 4px; border: 0; border-radius: 0; background: none; box-shadow: none; max-width: none;
    font-size: 15px; line-height: 1.5; color: var(--ink-soft, #2C484A);
  }
  .app-sheet--demo .pn-demo p, .app-sheet--demo .pp-demo p { margin: 0 0 16px; }
  .app-sheet--demo nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
  .app-sheet--demo nav > span { flex: 0 0 100%; margin: 4px 0 2px; font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted, #5F6673); }
  .app-sheet--demo nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; font-size: 15px; }

  /* Installed on the home screen: no browser bar above, so the app bar keeps clear of the notch. */
  @media (display-mode: standalone) {
    .app-bar { padding-top: max(env(safe-area-inset-top, 0px), 8px); }
  }
}

@keyframes app-sheet-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes app-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- From page to page: the new page slides in, back slides it out ---------- */
@media (max-width: 760px) and (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-group(root) { animation-duration: 0.3s; animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); }
  ::view-transition-old(root) { animation: app-out 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  ::view-transition-new(root) { animation: app-in 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
  html:active-view-transition-type(back)::view-transition-old(root) { animation-name: app-out-back; }
  html:active-view-transition-type(back)::view-transition-new(root) { animation-name: app-in-back; }
  html:active-view-transition-type(tab)::view-transition-old(root) { animation: app-fade-out 0.18s ease both; }
  html:active-view-transition-type(tab)::view-transition-new(root) { animation: app-fade-in 0.18s ease both; }
  ::view-transition-group(app-bar), ::view-transition-group(app-tabs) { animation: none; }
}
@keyframes app-in { from { transform: translateX(100%); } }
@keyframes app-out { to { transform: translateX(-30%); opacity: 0.6; } }
@keyframes app-in-back { from { transform: translateX(-30%); opacity: 0.6; } }
@keyframes app-out-back { to { transform: translateX(100%); } }
@keyframes app-fade-out { to { opacity: 0; } }

/* ---------- Inside the iOS app (html.rw-app, set by RWApp in i18n.js) ----------
   The app has its own navigation bar, tab bar, menu, sign-in and chat: the site's give way, at any width.
   The bars take no room, so what is pinned to them sits at the web view's edges. */
/* --rw-bottom: how much of the page's bottom the app's own tab bar covers (the app sets it); what is pinned to the
   bottom (the Map button, toasts, the save-search card) sits above it. The app's scroll view already leaves that room
   at the end of the page, so the body adds none. */
html.rw-app { --app-bar: 0px; --app-tab: var(--rw-bottom, 0px); --app-top: 0px; --app-tab-now: var(--rw-bottom, 0px); }
html.rw-app body { padding-bottom: 0 !important; }
html.rw-app .app-bar, html.rw-app .app-tabs, html.rw-app .app-sheet, html.rw-app .app-demo { display: none !important; }
html.rw-app .rwold:has(#main-header-nav), html.rw-app .frame:has(> .footer), html.rw-app body > .footer,
html.rw-app .toTop, html.rw-app .switch { display: none !important; }
/* The chat is the app's (Συνομιλία tab); the prototype's demo notes and role switch stay on the website. */
html.rw-app #chat, html.rw-app .pn-demo, html.rw-app #pp-demo { display: none !important; }
/* Each page's own controls are native in the app (RWApp.bar in i18n.js; iOS 27: the tabs stay, the page's actions sit
   above them, a property's tools on its photo). They still do the work: the app presses the page's hidden controls.
   Property: Contact, call, WhatsApp below; Back, share, price alert, heart on the photo. Search: Filters, Map, Save
   search, and on the map List, Filters, the pen. Favourites: the compare tray. My searches, My properties: the header's button. */
html.rw-app .pp-bar, html.rw-app .pp-tools, html.rw-app .pp-round--back, html.rw-app .pp-back,
html.rw-app .lt-mapswitch, html.rw-app #save-search, html.rw-app #filters-btn, html.rw-app .lt-draw,
html.rw-app .lt-maptop__back, html.rw-app .lt-maptop__flt,
html.rw-app .fv-tray, html.rw-app .sr-head > .btn { display: none !important; }
/* Pinned to the bottom with their own offsets (property.css, list.css, panel.css, auth.css): above the app's tab bar
   and the page's actions instead, at any width (on an iPad the actions sit at the bottom too). */
html.rw-app .pp-toast, html.rw-app .lt-toast, html.rw-app .fv-toast, html.rw-app .au-toast,
html.rw-app .lt-nudge { bottom: calc(var(--rw-bottom, 0px) + 16px) !important; }
html.rw-app .lt-drawer__foot { padding-bottom: calc(var(--rw-bottom, 0px) + 12px); }
/* The photos take 45% of the screen's height on a phone. */
@media (max-width: 760px) {
  html.rw-app .pp-photos { aspect-ratio: auto !important; height: 45svh; }
  html.rw-app .pp-ph img { height: 100%; object-fit: cover; }
  html.rw-app .pop, html.rw-app .pop--wide { bottom: calc(var(--rw-bottom, 0px) + 12px); max-height: calc(70vh - var(--rw-bottom, 0px)); }
  html.rw-app.lt-mapfull .lt-homecard { bottom: calc(var(--rw-bottom, 0px) + 16px) !important; }
  html.rw-app.lt-mapfull .lt-attr { bottom: calc(var(--rw-bottom, 0px) + 2px) !important; }
}


/* ---------- Desktop and tablets (over 760px): the header comes back on the way up ----------
   The site's header (rewize.com's) sticks to the top; reading down it slides away, any move up brings it back
   (app.js, header()). --hdr is how much of the top it covers now (its height, or 0): what else sticks to the top
   (the list's filters and map, the account pages' side column, the property's price box, contents lists) sits under it. */
@media (min-width: 761px) {
  .rwold:has(#main-header-nav) { position: sticky; top: 0; z-index: 10000; transition: transform .3s ease, box-shadow .3s ease; }
  html.hdr-hidden .rwold:has(#main-header-nav) { transform: translateY(-100%); }
  html.hdr-stuck .rwold:has(#main-header-nav) { box-shadow: 0 12px 30px -20px rgba(14, 41, 43, 0.35); }
}
@media (min-width: 761px) and (prefers-reduced-motion: reduce) { .rwold:has(#main-header-nav) { transition: none; } }

/* A dialog that takes the focus itself on touch screens (app.js), so no text box opens the keyboard: no ring. */
dialog[tabindex="-1"]:focus { outline: none; }
