/* Michigan Plate Readers: the screen layout from 40em up. Linked after site.css with media="screen", on web pages only: review packets
   and the PDF copies of agency pages print with site.css alone, and phones (below 40em) render with site.css alone. Colours, type
   sizes, dark mode and focus styles are all site.css's (the home page's counts excepted, below); this file sets widths and spacing. A selector equal to one in site.css wins by
   order. In short: running text at about 100 characters a line (the measure, 88ch, from 68ch); beside the sidebar the column grows to
   100rem (from 76rem); long tables, the fact box and the keys use the column's width; a table cell of running text wraps at the
   measure too; vertical spacing is tighter. Nothing moves into a side rail.
   An em in a media query is the browser's default type size (16px), not the page's 15.5px: 40em is 640px, 48em 768px, 64em 1024px,
   85em 1360px and 100em 1600px. */

@media screen and (min-width: 40em) {
  /* Tokens: the measure (prose) from 68ch to 88ch; "content" (tables, the fact box, heading rules, statements, the figures section) from
     60rem to the column's whole width. Running text at line height 1.5 (1.55 in site.css); tables keep their 1.45. */
  :root { --measure: 88ch; --content: 100%; }
  body { line-height: 1.5; }

  /* Vertical rhythm: headings and the h2 rule, paragraphs, the page head, each labeled statement. */
  h1 { margin-bottom: .45rem; }
  h2 { margin: 1.9rem 0 .55rem; padding-top: .65rem; }
  h3 { margin: 1.35rem 0 .35rem; }
  p { margin: .6rem 0; }
  hr { margin: 1.4rem 0; }
  .crumbs { margin-bottom: .25rem; }
  .place { margin: -.2rem 0 .55rem; }
  .agency-status { margin: 0 0 .75rem; }
  .lede { max-width: 78ch; margin-bottom: .85rem; }      /* 78ch in the lede's larger type is the measure in body type: one right edge */
  .finding { margin: .95rem 0; }
  .finding p { margin: .35rem 0; }
  .notice, blockquote.reply { margin: .8rem 0; }
  pre { max-width: 60rem; }                               /* the request text on File your own keeps its width */

  /* Tables: a table of long text (documents, the timeline, "What we sent") may use the column's whole width; a short one keeps its 60rem;
     a table in a .table-wrap keeps its own rules (the codebook's change from 85em is below). Each row loses about 2.5px of padding. */
  :not(.table-wrap) > table:not(.kv) { width: auto; min-width: min(100%, 60rem); }
  table { margin: .5rem 0 1.1rem; }
  th, td { padding-top: .3rem; padding-bottom: .3rem; }
  /* The documents table's title column was held to 34rem while the redaction column beside it could grow, which squeezed the titles to
     a few words a line; it is free here, and a long address in a title may break anywhere. Cells of running text are held to the
     measure from 48em and 85em (below). */
  table.docs td:first-child { max-width: none; overflow-wrap: anywhere; }

  /* The fact box: the column's whole width, in as many 13rem columns as fit. The Records requests entry, the one value with line breaks,
     runs across all of them, one request a line. */
  .factbox { padding: .7rem 1rem .2rem; margin: .75rem 0 1.1rem; }
  .factbox dl > div { margin-bottom: .5rem; }
  .factbox dl > div:has(br) { column-span: all; padding-top: .5rem; }      /* the row that spans the columns keeps a gap from the tallest column above it, whose last margin a spanner drops */
  .pdf-button { margin: -.45rem 0 1rem; }
  .on-this-page { margin: -.35rem 0 1.15rem; }

  /* "How to read this page": the label definitions side by side, as many to a row as fit at 17rem or more. The heading and the closing
     note take a row each; the note's right padding holds its text to the measure, since a max-width would let it join the labels' row. */
  .label-key { max-width: none; display: flex; flex-wrap: wrap; column-gap: 1.6rem; margin: .75rem 0 .95rem; }
  .label-key > .label-key-line { flex: 1 1 17rem; }
  .label-key > .label-key-head, .label-key > .label-key-note { flex: 1 0 100%; max-width: none; }
  .label-key > .label-key-note { padding-right: max(0px, calc(100% - var(--measure))); }
  .label-key p { margin: .2rem 0; }

  /* Other keys and blocks: a little less space around each. */
  .state-key { margin: .8rem 0 .7rem; }
  .stats { margin: .9rem 0 1.1rem; }
  figure.chart { margin: 1rem 0 1.2rem; }

  /* The home page (the one page with the status line): more room between its four blocks and larger counts, so they read as four parts
     and fill more of a laptop's first screen (Chance, 11/23, on the home page in Safari on a MacBook: "content is a bit cramped with a
     lot of empty space on the page"). */
  article.page:has(> .state-line) > .lede { margin-bottom: 2rem; }
  article.page:has(> .state-line) > .stats { margin: 0 0 2.25rem; gap: 1.5rem 2rem; }
  article.page:has(> .state-line) .stat { padding-left: 1rem; }
  article.page:has(> .state-line) .stat .label, article.page:has(> .state-line) .stat .note { font-size: .875rem; }
  article.page:has(> .state-line) .stat .value { font-size: 2.125rem; margin: .35rem 0 .3rem; }
  article.page:has(> .state-line) > .state-line { margin: 0 0 1.75rem; gap: .6rem .7rem; }
  .feed-day { margin-top: .9rem; }
  .feed-list li { margin-bottom: .45rem; }

  /* The figures section of an agency page. Its own stylesheet loads after this one, so these selectors carry one more element to win.
     Figure 1 (and the event-log figure) keeps its 60rem, since a wider drawing is a taller one; the counts spread across the column and
     their source note keeps to the measure; the two bar charts sit side by side once two fit at 24rem, each still at most 34rem, so
     their labels stay near the text size. */
  section.page-figs { margin-bottom: 1.2rem; }
  section.page-figs > figure.pf-figure { max-width: 60rem; margin: .7rem 0 1rem; }
  section.page-figs .pf-counts { margin: .7rem 0 1rem; }
  section.page-figs .pf-counts p.muted, section.page-figs figcaption { max-width: var(--measure); }      /* the captions too, which otherwise run the drawing's full 60rem */
  section.page-figs .pf-bars { display: flex; flex-wrap: wrap; align-items: flex-start; column-gap: 2rem; }
  section.page-figs .pf-bars > figure.pf-figure { flex: 1 1 24rem; margin: .7rem 0 1rem; }
}

/* From 48em, where site.css's phone rules end and a table's narrow columns stop wrapping: two tables whose text would otherwise run past
   110 characters a line on a screen 900px wide (and past 130 at 1280px) are held to the measure, counted in the cell's own smaller
   type (about 100 characters, as in the prose). The timeline's entries wrap at it; the title column of the four-column tables of what
   we sent ("What we sent" on an agency page; the Documents page, which had the same lists, gave way to Records, Letters and All files on 11/23) is set to it, so that the room a short table keeps
   (60rem) goes to the narrow columns beside it, not to longer title lines. */
@media screen and (min-width: 48em) {
  #timeline + table td { max-width: var(--measure); }
  table.docs td:first-child:nth-last-child(4) { width: var(--measure); }
}

/* Beside the sidebar (from 64em): the column grows to 100rem (76rem in site.css), so a 1920px window has about 120px to its right, not
   about 500; less padding above, below and at its sides. The footer follows the column. Below 64em the column and the footer keep
   site.css's narrow layout, with the menu across the top. */
@media screen and (min-width: 64em) {
  /* The sidebar is 17.5rem here (site.css's --side, 15rem, is the width without this file): the name and the icon beside it need about
     224px on one line in Safari's type on a Mac and 216px on Windows, and 15rem left 197px, so the name ran past the sidebar's edge
     (Chance, 11/23: "Title's cut off"); 17.5rem leaves about 236px. */
  :root { --side: 17.5rem; }
  main.wrap { max-width: 100rem; padding: 1.5rem 2.5rem 2.5rem; }
  .foot { max-width: 100rem; padding: 1rem 2.5rem 2rem; }
}

/* From 85em: every cell of running text wraps at the measure, request records sit two across, and the codebook's tables size to their
   text. */
@media screen and (min-width: 85em) {
  /* A table cell of running text wraps at the measure: about 100 characters a line in the cell's type. Without it, at 1920px a
     document title, a redaction note or the source of a camera's location ran to between 120 and 165 characters a line. Below 85em
     the columns share a narrower table as they did, and only the two tables held above reach the measure. */
  :not(.table-wrap) > table:not(.kv) td { max-width: var(--measure); }

  /* Two or more request records under "Requests and responses" sit two across, like cards. The tables have no wrapper, so they float:
     the first, third and fifth start a row, the heading after the run clears them, and their bottom margin equals the usual gap above
     an h2. A page with one record is unchanged. */
  table.kv:has(+ table.kv), table.kv + table.kv { float: left; width: calc(50% - .85rem); margin: 0 0 1.9rem; }
  table.kv:has(+ table.kv):nth-child(odd of table.kv),
  table.kv + table.kv:nth-child(odd of table.kv) { clear: left; margin-right: 1.6rem; }
  table.kv + table.kv + :not(table.kv) { clear: both; }
  article.page:has(table.kv + table.kv) { display: flow-root; }      /* holds the floats if a run ever ends the page */

  /* The codebook's tables on the Data page fill their scrolling frame, so on a wide screen their Meaning column ran past 150 characters
     a line. Here they size to their text, at least 56rem (the sortable tables' minimum), and each cell wraps at the measure. */
  .table-wrap > table.codebook { width: auto; min-width: min(100%, 56rem); }
  .table-wrap > table.codebook td { max-width: var(--measure); }
}

/* Wide screens (from 100em): the status key on the Requests page four across, so its eleven statuses take three rows. */
@media screen and (min-width: 100em) {
  .state-key { grid-template-columns: repeat(4, max-content minmax(0, 1fr)); }
}
