/*
 * ck-glass.css · Apple Liquid Glass v2 for the whole site, phone only (2026-11-17).
 * Recipe copied from Jarvis's ck-command-glass.css (Apple Liquid Glass v3).
 * Micah: "for any bottom menus ... it should always be Liquid Glass", and every
 * phone page should be "easy as heck to use", like a native iOS 26 app.
 *
 * Two materials, like iOS 26:
 *   CLEAR   = bars, pills and toasts that sit at the bottom: barely tinted, light
 *             blur, the content behind stays readable through it.
 *   FROSTED = anything with text to read that pops up (sheets, dialogs, menus,
 *             popovers, drawers): same glass, more frost so the text holds up.
 * Both get the specular rim (hairline gradient border, bright top-left and bottom)
 * and a soft inner light. Done with border-box backgrounds, no pseudo elements.
 *
 * Desktop is untouched: every rule that changes a surface lives inside a phone
 * media query. Load it LAST in <head> so it wins. Pages: portal.html,
 * realtor.html, apply.html, apply-property.html, index.html, partners.html.
 * Opt-in classes for new UI: .ck-glass-clear, .ck-glass-frost.
 */
:root {
  /* v3 (Jarvis 11/17, from Apple's Liquid Glass guidance): CLEAR glass lenses the
     content behind it instead of scattering it: light blur, slight dim, more color.
     The look comes from the edge: a thin darkened edge plus bright specular corners. */
  --lgc-fill: rgba(16,16,20,.10);
  --lgc-blur: blur(3px) saturate(175%) brightness(.8) contrast(1.05);
  --lgc-inner: inset 1.5px 1.5px 1px -1px rgba(255,255,255,.55), inset -1.5px -1.5px 1px -1px rgba(255,255,255,.28),
    inset 0 0 0 .5px rgba(255,255,255,.14), inset 0 0 4px 1px rgba(0,0,0,.22), inset 0 0 18px rgba(255,255,255,.05);
  --lgc-rim: linear-gradient(150deg, rgba(255,255,255,.42) 0%, rgba(255,255,255,.06) 25%, rgba(0,0,0,.18) 50%, rgba(255,255,255,.05) 75%, rgba(255,255,255,.26) 100%);
  --lgc-drop: 0 8px 24px rgba(0,0,0,.28);
  --lgf-fill: rgba(24,24,28,.56);
  --lgf-fill-solid: rgba(20,20,24,.80); /* long reads over a busy page with no dim behind it */
  --lgf-blur: blur(28px) saturate(185%) brightness(.9);
  --lg-rim: linear-gradient(150deg, rgba(255,255,255,.50) 0%, rgba(255,255,255,.12) 22%, rgba(255,255,255,.05) 50%, rgba(255,255,255,.10) 78%, rgba(255,255,255,.34) 100%);
  --lg-sheen2: linear-gradient(180deg, rgba(255,255,255,.10) 0%, rgba(255,255,255,0) 42%, rgba(255,255,255,.03) 100%);
  --lg-inner: inset 0 1px 1px rgba(255,255,255,.22), inset 0 -1px 1px rgba(255,255,255,.10), inset 0 0 12px rgba(255,255,255,.04);
  --lg-drop: 0 10px 30px rgba(0,0,0,.38), 0 1px 3px rgba(0,0,0,.25);
  --lg-pop-drop: 0 24px 60px rgba(0,0,0,.5), 0 2px 8px rgba(0,0,0,.25);
  /* Gap between a floating bottom surface and the screen edge (home bar aware). */
  --lg-gap: max(calc(env(safe-area-inset-bottom, 0px) * .5 + 8px), 10px);
}

/* Opt-in utility classes (any width) */
.ck-glass-clear {
  border: 1px solid transparent !important;
  background: linear-gradient(var(--lgc-fill), var(--lgc-fill)) padding-box, var(--lgc-rim) border-box !important;
  -webkit-backdrop-filter: var(--lgc-blur) !important; backdrop-filter: var(--lgc-blur) !important;
  box-shadow: var(--lgc-inner), var(--lgc-drop) !important;
}
.ck-glass-frost {
  border: 1px solid transparent !important;
  background: var(--lg-sheen2) padding-box, linear-gradient(var(--lgf-fill), var(--lgf-fill)) padding-box, var(--lg-rim) border-box !important;
  -webkit-backdrop-filter: var(--lgf-blur) !important; backdrop-filter: var(--lgf-blur) !important;
  box-shadow: var(--lg-inner), var(--lg-pop-drop) !important;
}

@media (max-width: 768px) {
  /* ── Pages only scroll up and down. The sources of sideways drift are fixed in
     each page; this just stops the horizontal rubber band. ── */
  html, body { overscroll-behavior-x: none; }
  /* iOS zooms into any field under 16px on focus and the zoomed page then drags
     sideways. The dropdown search box (ck-select.js) was 0.78rem. */
  .ck-sel-search { font-size: 16px !important; }

  /* ══ CLEAR glass: everything that sits at the bottom ══ */
  #navBorrowerTabs,                       /* portal: borrower Applications / eSign pill */
  #crmScreen .ckm-tabbar,                 /* portal: admin CRM tab bar */
  #crmScreen #ckDock,                     /* portal: admin dock (481-640px) */
  .ck-mtabbar,                            /* realtor: partner tab bar */
  .crm-toast, .rt-toast, .ck-toast, .env-toast-portal, .ts-ready-toast, #stageMoveToast {
    border: 1px solid transparent !important;
    background: linear-gradient(var(--lgc-fill), var(--lgc-fill)) padding-box, var(--lgc-rim) border-box !important;
    -webkit-backdrop-filter: var(--lgc-blur) !important; backdrop-filter: var(--lgc-blur) !important;
    box-shadow: var(--lgc-inner), var(--lgc-drop) !important;
  }
  /* Toasts carry text: a touch more tint so the words hold over any page. */
  .crm-toast, .rt-toast, .ck-toast, .env-toast-portal, .ts-ready-toast, #stageMoveToast {
    background: var(--lg-sheen2) padding-box, linear-gradient(rgba(22,22,26,.58), rgba(22,22,26,.58)) padding-box, var(--lg-rim) border-box !important;
    -webkit-backdrop-filter: var(--lgf-blur) !important; backdrop-filter: var(--lgf-blur) !important;
    border-radius: 18px !important;
  }
  /* Clear glass needs brighter labels to read over busy content, like Apple's. */
  #crmScreen .ckm-tab:not(.active), .ck-mtabbar a:not(.active):not(.is-active), .ck-mtabbar button:not(.active):not(.is-active),
  #navBorrowerTabs .nav-portal-tab:not(.is-active) {
    color: #e4e4e7; text-shadow: 0 1px 2px rgba(0,0,0,.45);
  }

  /* ══ FROSTED glass: every pop-up with text ══ */
  .crm-modal, .ck-modal, .ck-confirm-dlg, .modal-box, .modal-overlay .modal,
  .sm-dialog, .bv-modal, .esign-disclosure-modal, .setpin-modal, .audit-modal, .llc-modal, .doc-tag-modal,
  .ckm-sheet, .crm-bell-panel, .crm-qc-panel, .crm-profile-pop, .nav-admin-menu,
  .ck-pop, .opps-sort-menu, .ck-sel-pop, .cst-menu, .ckqc-panel,
  .profile-panel, .ck-acct-panel, .rail.open {
    border: 1px solid transparent !important;
    background: var(--lg-sheen2) padding-box, linear-gradient(var(--lgf-fill), var(--lgf-fill)) padding-box, var(--lg-rim) border-box !important;
    -webkit-backdrop-filter: var(--lgf-blur) !important; backdrop-filter: var(--lgf-blur) !important;
    box-shadow: var(--lg-inner), var(--lg-pop-drop) !important;
  }
  /* Pop-ups that open over the live page with no dimmed backdrop behind them
     (menus, popovers, the bell): more frost so busy content never fights the text. */
  .crm-bell-panel, .crm-qc-panel, .crm-profile-pop, .nav-admin-menu, .ck-pop, .opps-sort-menu, .ck-sel-pop, .cst-menu {
    background: var(--lg-sheen2) padding-box, linear-gradient(var(--lgf-fill-solid), var(--lgf-fill-solid)) padding-box, var(--lg-rim) border-box !important;
  }
  /* Sticky drawer headers painted solid cut the glass into a band. They stay
     sticky, so they get their own frost (content scrolling under them blurs,
     like an iOS nav bar) instead of going see-through. */
  .profile-panel-hdr, .ck-acct-hdr, .crm-bell-head, .crm-notif-foot {
    background: rgba(24,24,28,.35) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  }

  /* Drawers: rounded inner edge, like the Jarvis side drawer. */
  .ck-acct-panel, .profile-panel { border-right: 0 !important; border-radius: 28px 0 0 28px; }
  .rail.open { border-left: 0 !important; border-radius: 0 28px 28px 0; }
}

/* ── Bottom sheets float as a glass card above the home bar, rounded on every
   corner (iOS 26), instead of a slab glued to the bottom edge. Same breakpoint
   the pages use to turn dialogs into sheets. ── */
@media (max-width: 640px) {
  .crm-modal, .ck-modal, .ck-confirm-dlg, .modal-box, .modal-overlay .modal {
    width: calc(100% - 16px) !important; max-width: calc(100% - 16px) !important;
    margin: 0 auto var(--lg-gap) !important;
    border-radius: 32px !important;
    max-height: min(90vh, calc(100dvh - 24px - env(safe-area-inset-top, 0px))) !important;
    padding-bottom: 1.1rem !important;
    overscroll-behavior: contain;
  }
  .ckm-sheet {
    left: 8px !important; right: 8px !important; bottom: var(--lg-gap) !important;
    border-radius: 32px !important;
    padding-bottom: 14px !important;
  }
  /* A grab handle on every sheet says "drag me down" (ck-swipe.js does the drag).
     Drawn with ::before so no page markup changes. */
  .crm-modal::before, .ck-modal::before, .modal-back.open .modal-box::before {
    content: ''; display: block; flex: none; width: 38px; height: 5px; border-radius: 3px;
    background: rgba(255,255,255,.28); margin: -12px auto 14px;
  }
  .modal-back.open .modal-box::before { margin: 8px auto 0; }
  .modal-back.sd-page .modal-box::before { content: none; }
  .ck-sheet-dragging { transition: none !important; animation: none !important; }
}

/* ── Floating tab bars (iOS 26): one glass bar that floats above the home bar ── */
@media (max-width: 480px) {
  #crmScreen .ckm-tabbar {
    left: 10px !important; right: 10px !important; bottom: var(--lg-gap) !important;
    padding: 0 4px !important; border-radius: 28px !important;
    border-top: 1px solid transparent !important;
  }
  #crmScreen .ckm-tab { height: 56px; }
}

@media (prefers-reduced-transparency: reduce) {
  .ck-glass-clear, .ck-glass-frost,
  #navBorrowerTabs, #crmScreen .ckm-tabbar, #crmScreen #ckDock, .ck-mtabbar,
  .crm-toast, .rt-toast, .ck-toast, .env-toast-portal, .ts-ready-toast, #stageMoveToast,
  .crm-modal, .ck-modal, .ck-confirm-dlg, .modal-box, .modal-overlay .modal,
  .sm-dialog, .bv-modal, .esign-disclosure-modal, .setpin-modal, .audit-modal, .llc-modal, .doc-tag-modal,
  .ckm-sheet, .crm-bell-panel, .crm-qc-panel, .crm-profile-pop, .nav-admin-menu,
  .ck-pop, .opps-sort-menu, .ck-sel-pop, .cst-menu, .ckqc-panel, .profile-panel, .ck-acct-panel, .rail.open {
    -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
    background: #18181b !important;
  }
}

/* realtor.html pins these two sheets solid with an id selector + !important;
   match its weight so they get the same glass on the phone. */
@media (max-width: 768px) {
  #taskModal .modal-box, #rtTplOverlay .modal-box {
    background: var(--lg-sheen2) padding-box, linear-gradient(var(--lgf-fill), var(--lgf-fill)) padding-box, var(--lg-rim) border-box !important;
    box-shadow: var(--lg-inner), var(--lg-pop-drop) !important;
  }
}
/* Sheet header and footer were painted solid (gold-black / near-black), cutting the
   glass into three bands. They scroll with the sheet, so let the material run through. */
@media (max-width: 640px) {
  .modal-box .modal-hd, .modal-box .modal-ft,
  #taskModal .modal-hd, #rtTplOverlay .modal-hd, #taskModal .modal-ft, #rtTplOverlay .modal-ft { background: transparent !important; }
}
/* The floating sheet is 16px narrower than the old edge-to-edge slab, which pushed
   paired fields (Due date + Repeat, Deal + Contact) onto stacked rows. Keep pairs
   side by side and trim the side padding a touch, so the form stays compact. */
@media (max-width: 640px) {
  .modal-box .modal-body { padding-left: 1.25rem !important; padding-right: 1.25rem !important; }
  .modal-box .modal-hd { padding-left: 1.25rem !important; padding-right: 1.25rem !important; }
  .modal-box .fld-row { flex-wrap: nowrap; }
  .modal-box .fld-row > .fld { flex: 1 1 0; min-width: 0; }
  .modal-box .fld-row > .fld:empty { display: none; }
}
