/* layout.css — RCR agent workspace layout corrections.
   Added 2026-09-18 for review findings R4-R8 (APP-REVIEW-20260917.md), approved
   by the owner on September 18.

   Like legibility.css this is a LAYER linked last in index.html, so it wins the
   cascade over styles.css -> premium-product.css -> mobile-fixes.css ->
   native-layout.css -> legibility.css. It does not change colour or the type
   floors (legibility.css tokens are reused: --rcr-label, --rcr-body-sm, --rcr-tap).

   R4  compact hero on return visits      .screen-header.is-return-visit (app.js sets the class)
   R5  CRM heading row                    .crm-heading, .crm-secondary-action (app.js markup)
   R6  Disconnect in an overflow menu     .record-overflow (app.js markup; confirmation in JS)
   R7  empty modules collapse             .empty and .panel:has(> .empty:last-child)
   R8  addresses in title case at 13px    .property-address (app.js title-cases uppercase MLS text)

   To revert: delete this file and its <link> in public/index.html; the app.js
   markup still renders (a plain <details>, a plain heading row). */

:root {
  --rcr-hero-compact: 26px;   /* return-visit screen title size */
  --rcr-empty-title: 18px;    /* heading size inside a module that has nothing to show */
}

/* ------------------------------------------------------ R4: compact hero */

/* First run keeps the full hero. Every later render of the same screen on this
   device paints one line: the title, left aligned, with the eyebrow and the
   description dropped, so the first metric / client / listing sits above the
   fold at 390px. */
.screen-header.is-return-visit {
  max-width: 100%;
  margin: 2px 0 16px;
  padding: 0;
  text-align: left;
}

.screen-header.is-return-visit .eyebrow,
.screen-header.is-return-visit > p:last-child {
  display: none;
}

.screen-header.is-return-visit h1 {
  font-size: var(--rcr-hero-compact);
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0;
  overflow-wrap: anywhere;
}

@media (min-width: 900px) {
  .screen-header.is-return-visit h1 { font-size: 32px; }
}

/* --------------------------------------------------- R5: CRM heading row */

/* The eyebrow gets the whole first line; the title and the single primary
   action share the second. The inner <div> that groups eyebrow + h2 is
   flattened with display:contents so both become grid items. */
.section-heading.crm-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  column-gap: 12px;
  row-gap: 2px;
}

.section-heading.crm-heading > div:first-child { display: contents; }

.section-heading.crm-heading .eyebrow {
  grid-column: 1 / -1;
  white-space: nowrap;
  margin: 0 0 4px;
}

.section-heading.crm-heading h2 {
  grid-column: 1;
  min-width: 0;
}

.section-heading.crm-heading .button-row {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  width: auto;
  margin: 0;
}

.section-heading.crm-heading .button-row > * {
  flex: 0 0 auto;
  width: auto;
}

/* The secondary action lives under the client list, out of the heading. */
.crm-secondary-action {
  display: flex;
  justify-content: flex-start;
  margin: 6px 0 0;
}

.crm-secondary-action .text-button {
  min-height: var(--rcr-tap, 44px);
  padding-inline: 12px;
}

/* -------------------------------------------- R6: Disconnect in overflow */

/* "More" is a <details>, so it works without JavaScript; the menu itself is
   absolutely positioned under the trigger, right aligned to the action row. */
.record-actions { position: relative; }

.record-overflow {
  position: relative;
  margin: 0;
}

.record-overflow > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--rcr-tap, 44px);
  min-width: var(--rcr-tap, 44px);
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: 700 var(--rcr-label-lg, 12px)/1 "Manrope", sans-serif;
  text-transform: uppercase;
  letter-spacing: var(--rcr-track, .04em);
}

.record-overflow > summary::-webkit-details-marker { display: none; }
.record-overflow > summary::marker { content: ""; }

.record-overflow[open] > summary { background: rgba(24, 34, 43, .05); }

.record-overflow-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 6;
  min-width: 180px;
  padding: 6px;
  background: var(--card, #fff);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(24, 34, 43, .16);
}

.record-overflow-menu .text-button {
  width: 100%;
  min-height: var(--rcr-tap, 44px);
  justify-content: flex-start;
  text-align: left;
  border: 0;
}

/* ------------------------------------------------ R7: empty modules */

/* An empty message is one line of secondary text with its action beside it,
   not a 90px centred block. */
.empty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: 0;
  padding: 10px 0;
  text-align: left;
  font-size: var(--rcr-body-sm, 13px);
  line-height: 1.5;
}

.empty > .secondary,
.empty > .primary {
  margin: 0;
}

/* A module whose only content is the empty message collapses around its
   heading: smaller title, no heading margin, tight padding. */
.panel:has(> .empty:last-child) {
  padding: 14px 18px 12px;
}

.panel:has(> .empty:only-child) {
  padding: 4px 18px;
}

.panel:has(> .empty:last-child) > .section-heading {
  margin: 0;
  padding: 0;
  align-items: center;
}

.panel:has(> .empty:last-child) > .section-heading h2 {
  font-size: var(--rcr-empty-title);
  line-height: 1.2;
}

.panel:has(> .empty:last-child) > .section-heading .eyebrow {
  margin-bottom: 2px;
}

.panel:has(> .empty:last-child) > .empty {
  padding: 2px 0 0;
}

/* In the dashboard grid an empty module must not stretch to its tallest
   neighbour, or the collapse buys nothing at desktop width. */
.agent-dashboard-grid > .panel:has(> .empty:last-child) {
  align-self: start;
}

/* ----------------------------------------------- R8: property address */

.property-address {
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--rcr-body-sm, 13px);
  font-weight: 600;
}

/* ------------------------------------------------ R10: full-height sheets */

/* On a phone the centred dialogs (Help & support, Notifications, the hub) are
   full-height sheets. The ID selectors carry the weight mobile-fixes.css uses for
   #supportDialog with !important; being later in the cascade, these win.
   (Originally:
   full-height sheets, as Messages already is: no card margins, no clipped
   content, a sticky heading with the close button, the body scrolls. The
   confirmation dialog stays a small centred card.) Added 2026-09-18 after the
   owner's iPhone screenshot of Help & support. */
@media (max-width: 680px) {
  dialog.center-dialog:not(.message-dialog):not(.action-confirm-dialog) ,
  #supportDialog ,
  #notificationDialog ,
  #hubManagerDialog  {
    inset: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    background: var(--card);
  }

  dialog.center-dialog:not(.message-dialog):not(.action-confirm-dialog) > article ,

  #supportDialog > article ,

  #notificationDialog > article ,

  #hubManagerDialog > article  {
    box-sizing: border-box;
    width: 100% !important;
    max-width: 100% !important;
    height: 100dvh;
    max-height: none !important;
    padding: 0 0 max(28px, env(safe-area-inset-bottom)) !important;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  dialog.center-dialog:not(.message-dialog):not(.action-confirm-dialog) > article > .dialog-heading ,

  #supportDialog > article > .dialog-heading ,

  #notificationDialog > article > .dialog-heading ,

  #hubManagerDialog > article > .dialog-heading  {
    position: sticky;
    top: 0;
    z-index: 2;
    margin: 0;
    /* ADD the system inset to the design padding, never substitute for it. max() gave the heading exactly
       the inset and no breathing room, so on a device reporting an inset the eyebrow sits flush under the
       status bar, and on one reporting none the whole heading rides up into it. .brand-header in this same
       app already uses the additive form; this is the same shape. Owner's iPhone screenshot 2026-09-22,
       Notifications: eyebrow over the clock, close button over the battery. Help & support does not clip
       because transaction-workspace.css:78 sets its padding with !important, so this rule never governed
       it - the asymmetry, not the inset, is why only one of the three clipped. */
    padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 14px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
  }

  /* Android: the shell reserves the status bar natively (see topbar.css r3). */
  html.rcr-native-android dialog.center-dialog:not(.message-dialog):not(.action-confirm-dialog) > article > .dialog-heading,
  html.rcr-native-android #supportDialog > article > .dialog-heading,
  html.rcr-native-android #notificationDialog > article > .dialog-heading,
  html.rcr-native-android #hubManagerDialog > article > .dialog-heading {
    padding-top: 14px;
  }

  dialog.center-dialog:not(.message-dialog):not(.action-confirm-dialog) > article > .dialog-heading h2 ,

  #supportDialog > article > .dialog-heading h2 ,

  #notificationDialog > article > .dialog-heading h2 ,

  #hubManagerDialog > article > .dialog-heading h2  {
    font-size: 30px !important;
    line-height: 1.02;
  }

  dialog.center-dialog:not(.message-dialog):not(.action-confirm-dialog) > article > :not(.dialog-heading) ,

  #supportDialog > article > :not(.dialog-heading) ,

  #notificationDialog > article > :not(.dialog-heading) ,

  #hubManagerDialog > article > :not(.dialog-heading)  {
    padding-inline: 18px;
  }
}
