/*
 * Fitting the 2009–2016 design, a fixed 970px desktop page, to any screen.
 * Named so it loads after the theme and application.css and wins over both.
 *
 * One strategy throughout:
 * 1. Fluid at every width. Pages are 970px at most and otherwise fill the
 *    screen less a gutter, and grids wrap by how much room their content
 *    needs, so tablets and narrow windows work without a breakpoint.
 * 2. One phone breakpoint, 720px, for what can't adapt by itself: the header
 *    stacks, forms go full width, the logbook pins its date column.
 * 3. Touch screens, by (hover: none) rather than width, get what hover
 *    would otherwise reveal.
 */

/* Touch screens have no hover, so the row pencil is always shown. */
@media (hover: none) {
  table.cp-grid .cp-row-edit { opacity: 1; }
}

@media (max-width: 720px) {
  /* ---------- Flash messages sit closer under the header ---------- */
  .cp-flash { margin-top: 10px; }

  /* ---------- Header: logo shrinks, greeting drops below it ---------- */
  .cp-header { flex-wrap: wrap; gap: 0; padding: 8px 12px 6px; }
  .cp-header .cp-logo { max-width: 100%; }
  .cp-header .cp-logo img { width: min(180px, 100%); }
  .cp-header .cp-usernav { width: 100%; font-size: 12px; }

  /* ---------- Tabs scroll sideways if they don't fit ---------- */
  .cp-tabs { padding-left: 0; overflow-x: auto; }
  .cp-tabs li { padding: 0 1.2em; white-space: nowrap; }

  /* ---------- Landing: the pitch and its links come first, with the sample
     logbook, too wide to show whole, after them ---------- */
  .cp-hero { padding: 16px 12px 20px; }
  .cp-hero h1 { font-size: 24px; }
  .cp-hero-pitch { order: 1; }
  .cp-hero-pitch .cp-hero-copy:first-child { margin-top: 0; }
  .cp-hero-sample { order: 2; }
  .cp-features { padding: 14px 12px 18px; }
  .cp-prose { padding: 6px 14px 14px; }

  /* ---------- Forms: full width, and 16px text so iOS doesn't zoom on focus ---------- */
  .cp-page { padding-top: 14px; }
  .cp-panel { padding: 14px 12px 18px; }
  .cp-field input, .cp-field select, .cp-entry .cp-field textarea { max-width: 100%; font-size: 16px; }
  .cp-field input:not([type=checkbox]):not([type=radio]) { width: 100%; }
  .cp-entry .cp-field textarea { width: 100%; }
  .cp-entry fieldset { min-width: 0; }
  .cp-entry .cp-field input.cp-short { width: 110px; }
  .cp-entry .cp-field input.cp-num { width: 70px; }
  .cp-entry .cp-field input[type=date] { width: auto; }
  .cp-entry-groups fieldset { flex: 1 1 100%; }
  .cp-btn-pill { padding: 5px 14px; font-size: 13px; }
  .cp-profile { grid-template-columns: 1fr; gap: 2px; }
  .cp-profile dd { margin-bottom: 8px; overflow-wrap: anywhere; }
  .cp-import-commit { flex-wrap: wrap; }

  /* ---------- Logbook: the bar wraps, the grid scrolls sideways ---------- */
  .cp-logbook-bar { flex-wrap: wrap; padding: 8px 12px; }
  .cp-logbook-bar .pager { width: 100%; }
  .cp-logbook-bar .pager a, .cp-logbook-bar .pager .current { display: inline-block; padding: 4px 6px; }
  .cp-logbook { padding: 0 0 10px; -webkit-overflow-scrolling: touch; }
  /* The date column stays put while the rest scrolls; the shadow fills the
     1px border-spacing gap so scrolled cells don't show through it. */
  .cp-logbook table.cp-grid thead tr:last-child th:first-child,
  .cp-logbook table.cp-grid tbody td:first-child:not([colspan]) {
    position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--cp-grid-line);
  }

  /* ---------- Public lookups: cells wrap so the tables fit ---------- */
  table.cp-lookup-results td { white-space: normal; overflow-wrap: break-word; }
  table.cp-lookup-results td:first-child { white-space: nowrap; }

  /* ---------- Map ---------- */
  .cp-map { height: 65vh; margin: 0 0 10px; border-left: 0; border-right: 0; }
  .cp-map-notes { margin: 0 12px 10px; }

  /* ---------- Footer ---------- */
  .cp-footer { padding-bottom: 24px; }
}
