/* Wide screens (owner round 14: iPad and desktop). The phone layout (up to 900 px, the tab bar) is untouched; from 901 px the rail is there and these rules
   shape the content so it is not a stretched phone: the Overview's hero beside the cashflow and the "By currency" list, Collection as a list with the
   chosen unit's page beside it (shell.js viewHtml wraps the two in .split), Properties as a tighter grid, forms and settings at a readable width, and
   hover states for a pointer. Inside the iPhone and iPad app the shell draws the navigation itself (the native tab bar, a sidebar on iPad), so the web
   rail never shows there and only the content rules apply, gated on the window width like everywhere else. Values from css/tokens.css. */

/* ---------- a native sheet on the iPad is wide: the form inside keeps a readable width, centred ---------- */
@media(min-width:700px){
  html.native-ios.native-sheet .scrim .modal > .body, html.native-ios.native-sheet .scrim .modal > .foot{ width:100%; max-width:720px; margin-inline:auto }
}

/* ---------- the app: no web rail, the content column centred, whatever the window (iPad, Split View, Stage Manager) ---------- */
html.native-ios .rail{ display:none !important }
html.native-ios .content{ margin-inline:auto }

/* inside the app, More and the settings-like screens read at a column's width on a tablet (the rows were stretching across the whole iPad) */
@media(min-width:700px){
  html.native-ios body[data-view="more"] .content, html.native-ios body[data-view="settings"] .content, html.native-ios body[data-view="team"] .content,
  html.native-ios body[data-view="unit"] .content, html.native-ios body[data-view="import"] .content, html.native-ios body[data-view="tutorial"] .content{ max-width:880px }
}
/* inside the app the property grid is two columns on a phone (native-ios.css); from a tablet's width the cards keep a card's size instead of growing with the window */
@media(min-width:700px){ html.native-ios .plist{ grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); gap:18px 14px } }

/* a tablet held upright (an iPad in portrait, 744 to 900 px) keeps the phone's one column and the tab bar, but as a centred column of a readable width, not a stretched phone */
@media(min-width:700px) and (max-width:900px){
  .content{ max-width:760px; margin-inline:auto }
  .appbar .big, .appbar .row{ max-width:732px; margin-inline:auto }
  /* inside the iPad app the large title is the system's own and starts at the system's 20 pt margin, so the column takes the window's width and starts there too
     (centred at 760 px, the cards began 30 pt further in than their own title and the line of choices under it). A phone on its side is not "regular" and keeps the centred column. */
  html.native-ios.native-regular .content{ max-width:none; padding-left:max(20px, var(--safe-l)); padding-right:max(20px, var(--safe-r)) }
  html.native-ios.native-regular .appbar .row{ padding-inline:22px }   /* the row starts 2 px outside the bar (native-ios.css), so 22 puts its first word on the same 20 */
}

@media(min-width:1600px){ .content{ max-width:1440px } }   /* a very wide window: the column grows a little, the cards keep their proportions */
@media(min-width:901px){
  .content{ max-width:1280px }
  .company-overview{ display:none }   /* the company's name is in the rail already: the masthead card only repeated it */
  /* Properties: a tighter grid, pictures a little shorter, so a company with many properties sees them at a glance */
  .plist{ grid-template-columns:repeat(auto-fill, minmax(250px, 1fr)); gap:16px }
  .pcard-img{ aspect-ratio:4 / 3.4 }
  .ucards{ align-items:start }   /* a short card keeps its own height beside a taller one (seen on the iPad: a card's rows spread over the row's height) */
  /* forms and settings read best at about 70 characters: they do not stretch across a desktop */
  body[data-view="settings"] .content, body[data-view="team"] .content, body[data-view="unit"] .content, body[data-view="property"] .content,
  body[data-view="import"] .content, body[data-view="tutorial"] .content{ max-width:880px }
  /* the hero stays one card: its figures do not need a desktop's whole width */
  .ledger{ max-width:none }
}

/* ---------- the Overview from 1000 px (an iPad 13-inch upright, an 11-inch on its side): twelve columns; the hero takes seven, the cashflow and the currency list the other five ---------- */
@media(min-width:1000px){
  body[data-view="overview"] .content{ display:grid; grid-template-columns:repeat(12, minmax(0, 1fr)); column-gap:16px; row-gap:16px; align-content:start }
  body[data-view="overview"] .content > *{ grid-column:1 / -1; min-width:0; margin-bottom:0 }
  /* the hero is as tall as the side column and uses the height (owner bug 2, round 17: a short hero left a dead band under it): the figures at the top, the bar and
     its legend in the middle, the exchange rates at the foot, the room shared between them */
  body[data-view="overview"] .content > .ledger{ grid-column:1 / 8; align-self:stretch; display:flex; flex-direction:column; padding-block:26px 22px }
  body[data-view="overview"] .content > .ledger > .hbar{ margin-top:auto; height:18px; border-radius:9px }
  body[data-view="overview"] .content > .ledger > .hlegend{ gap:12px; margin-top:16px; font-size:calc(14px * var(--dt,1)) }
  body[data-view="overview"] .content > .ledger > .fxfold{ margin-top:auto; padding-top:16px }
  body[data-view="overview"] .content > .ledger .hero-num .big{ font-size:calc(46px * var(--dt-cap,1)) }
  body[data-view="overview"] .content:has(> .dbycur) > .ledger{ grid-row:span 2 }
  body[data-view="overview"] .content > .cfcard, body[data-view="overview"] .content > .dbycur{ grid-column:8 / 13 }
  body[data-view="overview"] .content > p.muted{ display:none }   /* "Different currencies, totalled separately": the By currency card says it */
  body[data-view="overview"] .content > .qstrip, body[data-view="overview"] .content > .cstrip{ margin-bottom:0; padding-bottom:2px }
  body[data-view="overview"] .content > h2.dcur{ margin:8px 0 -4px }
  body[data-view="overview"] .content > .devstrip{ grid-column:1 / -1 }
  /* the cashflow card in its five columns: the small chart on its own line, the three figures under it */
  body[data-view="overview"] .content > .cfcard .cfline-body{ flex-wrap:wrap } body[data-view="overview"] .content > .cfcard .cfmini{ flex:1 1 100% }
}

/* ---------- Collection from 1100 px: the list on the start side, the unit's own page beside it (a tap on a name opens it there, not as a new screen) ---------- */
@media(min-width:1100px){
  .split{ display:block }
  .split.has-unit, .split.msgsplit{ display:grid; grid-template-columns:minmax(360px, 440px) minmax(0, 1fr); column-gap:20px; align-items:start }
  .split-list{ min-width:0 }
  .split.has-unit .split-list .ucards, .split.msgsplit .split-list .ucards{ grid-template-columns:1fr }
  .split:not(.has-unit) .split-list .ucards{ grid-template-columns:repeat(auto-fill, minmax(340px, 1fr)); gap:14px }   /* nothing open: the cards use the width */
  .split-list .ctools{ flex-wrap:wrap }
  .split-list .cchips{ flex-wrap:wrap; overflow-x:visible }   /* the list column is 440 px: the last filter chip ("Paid in advance") was cut at its edge; the chips wrap to a second line instead of scrolling */
  .split-detail{ min-width:0; position:sticky; top:16px; max-height:calc(100vh - 32px); overflow:auto; overscroll-behavior:contain; padding:2px 2px 16px }
  .split-detail > .tools:first-child{ margin-top:0 }
  .ucard.cc.is-open{ box-shadow:0 0 0 2px var(--c-primary), var(--sh) }
}

/* ---------- a pointer: hover states, the same as the press states, never colour alone ---------- */
@media(hover:hover) and (pointer:fine){
  .ucard.cc:hover, .pcard:hover .pcard-img, .lcard:hover{ box-shadow:var(--sh-float) }
  .morerow:hover, .setrow[data-prop]:hover, .setrow[data-unit]:hover, .dquiet:hover{ background:var(--surface-3) }
  .chip:hover:not(.on), .cchip:hover:not([aria-pressed="true"]){ background:var(--surface-3) }
  .rh-row:hover{ background:var(--surface-3) }
}
@media(prefers-reduced-motion:reduce){ .ucard.cc, .pcard-img{ transition:none } }
