/* shell.css — page shells.

   SH-FULL — the home page. No rails: identity and routes unroll into a masthead
   and the index takes the full measure. Not a centred fixed-width container —
   that is the SaaS look the anti-pattern list refuses. */
.page {
  padding: var(--u2);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.page > main { flex: 1 0 auto; }

/* Flex items default to min-width:auto, so they refuse to shrink below their
   min-content and one wide descendant silently widens the whole page. This is
   the same class of blowout as a bare 1fr grid track. */
.page > * { min-width: 0; }

@media (max-width: 520px) { .page { padding: var(--u1); } }

/* SH-3RAIL. 15% global rail / 70% field / 15% local rail (C1).
   Rails are sticky, never fixed (C14). Collapses to one column at 800px
   preserving DOM order and access to both rails. */

.shell {
  display: grid;
  grid-template-columns: var(--rail) var(--field) var(--rail);
  min-height: 100vh;
}

/* SH-2RAIL-L — global rail + field, no local rail. The home page: the index
   carries its own plates, so a second rail of thumbnails would only repeat it. */
.shell--2 { grid-template-columns: var(--rail) minmax(0, 1fr); }

.rail  { min-width: 0; padding: var(--u2) var(--u1); }
.field { min-width: 0; padding: var(--u2); }

.rail--global { border-right: var(--hair) solid var(--rule); }
.rail--local  { border-left:  var(--hair) solid var(--rule); }

/* Sticky inner column. The global rail splits into a top group and a bottom
   group pushed to the foot — direction_2 §1: "a large, quiet white interval
   between them… the left side behaves like a permanent institutional
   letterhead rather than ordinary navigation." */
.rail__inner {
  position: sticky;
  top: var(--u2);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--u4));
}
.rail__bottom { margin-top: auto; padding-top: var(--u4); }

/* Skip link — part of the keyboard path, not decoration. */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: var(--u-half) var(--u1);
  background: var(--paper);
  border: var(--hair) solid var(--ink);
  font-size: var(--t-caption);
  z-index: 10;
}
.skip:focus { left: var(--u1); top: var(--u1); }

/* ── Collapse ─────────────────────────────────────────────────────────────
   Order is preserved: global rail → field → local rail. Both rails stay
   reachable; nothing is hidden behind an interaction. */
@media (max-width: 800px) {
  /* minmax(0,1fr), never 1fr: a bare 1fr is minmax(AUTO,1fr) and floors the
     track at min-content, so one intrinsically-wide descendant widens the whole
     column — and here all three regions share it. */
  .shell { grid-template-columns: minmax(0, 1fr); }
  /* Rows sit at the top: on a short page the shell's min-height must not
     stretch the menu bar's row, or the bar changes height (and the page
     moves) when the menu opens. */
  .shell { align-content: start; }

  .rail__inner { position: static; min-height: 0; display: block; }
  .rail__bottom { padding-top: var(--u2); }

  /* No rule under the phone masthead (client). */
  .rail--global,
  .rail--local {
    border-right: 0;
    border-left: 0;
    border-bottom: 0;
  }
  .rail--local {
    border-bottom: 0;
    border-top: var(--hair) solid var(--rule);
  }
}

@media (max-width: 520px) {
  .rail, .field { padding: var(--u1); }
}
