/* Print.
   ------------------------------------------------------------------------------------
   Reprinting is the distribution model (CLAUDE.md: "free to read and free to reprint"),
   and the two real paths are an adult child printing a door's steps to take to a parent,
   and somebody printing the who-to-call list before making the calls. Until this file
   existed both of those printed whatever the screen CSS happened to do, which on the
   front page was six empty boxes over two and a half sheets.

   One sheet rather than several. Base.astro links it on all 41 pages with media="print",
   so it never blocks a screen render, and everything it touches is cross-cutting: the
   fixed furniture, the two-column reading grids, page breaks, and the one accent that has
   to survive. The front page's deck is handled here too rather than in explorer.css,
   because explorer.css is the front page's own sheet and this is the only place a rule
   that spans the site can sit.

   Two facts drive most of what follows.

   1. Chrome prints with "Background graphics" OFF by default. Anything whose only bound
      is background:var(--raised) disappears, and anything whose meaning is a fill loses
      its meaning. So boxes get a border, and the one thing that must not vanish, the
      band that says a window is closing, is forced with print-color-adjust.
   2. Letter is 816px and A4 is 794px, both under the 900px and 820px breakpoints, so a
      printed page is already in the site's narrow layout. The single-column forcing below
      is for the wide paper case, not the ordinary one.

   Not changed, on purpose: the type scale. 23px is roughly 17pt, which is what large
   print means, and it is the reason a door runs to a dozen sheets. Shrinking it would be
   optimising paper over a reader who is 75, which is the trade this site never makes.
   Not changed either: the palette. --ink clears 9.56:1 on white and prints as a dark grey
   on a mono printer, so there is nothing for a print sheet to fix. */

@media print{


  /* Headless print-to-PDF honours this, which is worth saying because it accounts for
     nearly every sheet this file adds. Rendered with margin:0, as the pages were before it
     existed, a stage page is 15 sheets; with 14mm it is 18. The 14mm sheets are the honest
     number: text running to the edge of the paper is not a page anybody prints. */
  @page{margin:14mm}

  /* The reading measure is a screen number: 600px inside a 1180px page. On paper the
     column is about 710px and a 600px measure leaves a quarter of every sheet blank with
     the text jammed left, which reads as a fault rather than as a margin. At full column
     width, 23px type gives about 52 characters, still inside a good measure. */
  :root{--measure:100%; --measure-lead:100%}

  html{background:#fff}
  html.hatchfloat body{padding-bottom:0}  /* hatch.css reserves 96px for a button that is gone */

  /* ---------- furniture ----------
     Everything here is a way of moving around the site. None of it moves anything on
     paper, and three of them are position:fixed, which in print means they reprint on
     every single sheet. */
  .upnav,                          /* the way back up, and the search field it carries */
  .sitesearch, .ssresults,         /* the field again, in the front page's rail */
  .hatch, .hatchsheet,             /* the whole map: fixed, so it lands on every sheet */
  .sitefoot,                       /* six internal links, none of them typeable */
  .closer, .xclose, .panel,        /* the explorer's controls and its empty panel slot */
  .railarc, .actlabel,             /* the seven-stage nav in a stage hero */
  .cascade, .cascade-note,         /* the door chooser: seven tiles, one and a half sheets */
  .stagenav .k::after,             /* a reading-progress slab */
  .more, a.close, .find, .count,   /* the button, in its three spellings; see below */
  .wrap > main > section:not(.hero) > .rail::before,
  .wrap > main > section:not(.hero) > .rail::after{
    display:none !important;
  }

  /* The three buttons above are one object written three times, and explorer.css says so:
     .more on the front page, .close at the foot of a topic, and the search page's own field
     and its submit. All of them are background:var(--ink) with color:var(--ground), which is
     the one construction that fails silently when a printer drops backgrounds: white words
     on white paper, with the padding still there. Each of them is also a control, and a
     control does nothing in the hand. The search page keeps its heading and the paragraph
     explaining that nothing you type is sent anywhere, which is the only part of it worth
     carrying.

     a.close, not .close. modules.css also uses .close as a spacing modifier on a module,
     and two of the elements carrying it are m-band, the band that says what is on a clock.
     A bare .close here would have hidden the one thing this file exists to keep. */

  /* Hiding .sitefoot leaves the <footer> that holds it: a rule across the column, 56px of
     margin above it and 16px of padding below, with nothing between them. On a topic page
     that stray rule was the last thing on the sheet. Its own rule, because :has() is not
     universal and an engine without it must drop this line rather than the block above.
     Scoped by :has rather than by position, because <footer> is also how a section states
     where its numbers came from, and those have to print (editorial rules 2 and 4). */
  footer:has(.sitefoot){display:none !important}

  /* ---------- the front page's deck ----------
     Six cards, position:absolute inside a .field of computed height, offset by transforms
     and scaled by a custom property the entrance animation writes. Printed as-is they came
     out as six empty framed boxes spread over two and a half sheets, because the paint
     that fills them never runs in a print render. Flattened to what they actually say on
     paper: a numbered list of the six doors, which is this site's table of contents.

     The stage bodies stay hidden. Each one is the first four steps of a door and then "and
     N more, in order"; four steps of a set of instructions is worse on paper than none,
     because there is no link to follow to the rest. */
  html.js .explorer[data-open="false"] .field,
  .explorer .field{
    position:static !important; display:block !important; height:auto !important;
  }
  html.js .explorer[data-open="false"] .field .stage,
  .explorer .field .stage{
    position:static !important; width:auto !important; height:auto !important;
    transform:none !important; translate:none !important; opacity:1 !important;
    margin:0 0 -1px !important; box-shadow:none !important; break-inside:avoid;
  }
  html.js .explorer[data-open="false"] .field .hit,
  .explorer .field .hit{height:auto !important; transform:none !important}
  .explorer .field .stage-body{display:none !important}
  .explorer .field :is(.lat, .bar, .mk){display:none !important}
  .explorer .field .stage::before{bottom:0 !important; height:auto !important}
  .explorer{display:block !important}
  .rail{opacity:1 !important; transform:none !important}

  /* ---------- the one accent ----------
     --closing means a window is closing, and on the front page it is the only route to
     door 02. It is the one thing on the site that must not be lost to a printer setting,
     so it is forced. The band also gets a real frame: .m-band and .now already have an
     ink border, .urgent had only a background and would have printed as bare text. */
  .urgent, .m-band, .now, .closing{
    -webkit-print-color-adjust:exact; print-color-adjust:exact;
  }
  .urgent{
    border:2px solid var(--ink-line); border-left-width:8px;
    margin:0 0 26px; padding:0;
  }
  .urgent div{padding:16px 20px}

  /* ---------- the stage hero band ----------
     On screen the hero is a full-bleed field of the stage's ramp stop, and the mark's
     solid halves are filled with the page white so they read as cut out of it. On paper
     the field is either absent (backgrounds off, the default) or a full-bleed flood of
     ink on the first sheet of every stage, and neither is wanted; the mark would then be
     white on white and lose its solid halves either way. So the band goes and the fill
     comes back to the stop, where print-color-adjust is deliberately NOT set: a drawing
     that prints as an outline is still the drawing, and only the closing-window band is
     worth forcing colour for. The stage's position is stated three times in text on the
     same sheet, so nothing here is the only carrier of anything. */
  section.hero::before{display:none !important}
  .hero .mk .a{fill:var(--stop)}

  /* ---------- boxes that were only a fill ----------
     With backgrounds off these lose every edge they had. .brief is the summary block the
     gate requires on any page over 600 words, so it is the worst one to lose. */
  .brief, .next, .spine a, .three > div{
    border:1px solid var(--rule); border-radius:var(--radius);
  }
  .next, .spine a, .three > div{break-inside:avoid}
  .brief{padding:22px 24px}
  .three > div{padding:18px 20px}

  /* ---------- the reading grid stops being a grid ----------
     .body is display:grid on both the door pages and the stage pages, one column of prose
     and one for the evidence box beside it. Below 900px, which every sheet of paper already
     is, it collapses to a single column with no row gap, so on paper the grid is doing
     nothing that a block would not do.

     It does one thing a block would not: it fragments badly. Chromium's grid fragmentation
     puts a list that crosses a sheet boundary and the paragraph after it into the same
     lines, printed one on top of the other. It happened on door 02 and door 01 and it is
     the worst defect a print sheet can introduce, because the page still looks plausible in
     a page count and is unreadable in the hand. display:block is the same layout on paper
     and fragments correctly.

     Not the hero's .body. stage.css makes that one a flex column with a min-height, and the
     drawing inside it is sized by flex rather than by its own box; turned into a block it
     grew to half a sheet and printed across the contents list underneath. The overlap
     scanner did not catch that one, because a drawing on top of words is not two words on
     top of each other. Looking at the sheet caught it. */
  section:not(.hero) > .body, .step .body{display:block !important}

  /* ---------- the drawings ----------
     There is no "force one column" block here, and there was one in the first pass. Letter
     is 816px and A4 is 794px, both already under the 900px and 820px breakpoints, so the
     printed page is in the site's narrow layout before this file does anything. Forcing
     grid-template-columns:1fr and grid-column:1 on the reading grids on top of that put two
     blocks of a step into the same grid cell on door 02, and they printed one on top of the
     other, unreadable. The screen layout was already right; the override was the bug.

     Three cells of an "In short" row at 230px each is a 20-character line, so that one grid
     does get capped at two. The figure rules repeat what fig.css does at 900px, so that a
     landscape or A3 sheet does not get back the square well with a 60%-scaled drawing
     floating inside it. */
  .three{grid-template-columns:repeat(auto-fit,minmax(300px,1fr)) !important}
  .fig{padding-top:0; display:flex; flex-direction:column; align-items:center}
  .fig > svg{position:static; width:min(100%,260px); height:auto}
  .imgnote{position:static; margin-top:12px}

  /* ---------- where a sheet may break ----------
     A heading at the foot of a sheet with its first line overleaf is the failure that
     matters here, because the door pages are numbered steps and the directory is numbered
     calls: a reader who turns the page mid-step has lost the step.

     What gets break-inside:avoid is only what is small enough to be worth a gap. Every
     forced break costs whatever is left of the sheet above it, and the first pass of this
     file put avoid on the tall blocks too: the "In short" summary, the band that says what
     is on a clock, the four acts of the arc. Printed, that made half-empty sheet after
     half-empty sheet and added five sheets to door 02. Those blocks are prose, they read
     perfectly well across a fold, and orphans/widows below is the right protection for
     them. A phone number separated from the name above it is not prose, and that is the
     one break worth paying a gap to prevent. */
  :is(h1,h2,h3,h4,h5,.chronhead,.actname,.stagenum,.eyebrow,.subhead,.hd){
    break-after:avoid; break-inside:avoid;
  }
  p, li, dd, dt, blockquote{orphans:3; widows:3}
  .evidence, .rule-card, .geo, .aside, .pull, .worry,
  .qcalls li, .entry, .act, .meta, .stg, figure, .fig, .provs li, .m-defs > div,
  .stagenav{
    break-inside:avoid;
  }
  /* .act is a recommendation card on a stage page and a whole act of the arc on the front
     page. The second one is three stages long and must be allowed to break. */
  .acts > .act{break-inside:auto}

  /* ---------- addresses ----------
     A source a reader cannot reach is not a source (editorial rule 2), so an external
     address is printed after its link text. Internal links are left alone: they resolve to
     /doors/03-bringing-it-up.html, which is not something anybody can type, and there are
     enough of them on a door page to bury the prose. Where the link text already is the
     address, which is how the directory and the stage pages write theirs, nothing is
     added. Telephone links are never touched: the number is the link text. */
  a[href^="http"]::after{
    content:" (" attr(href) ")";
    font:400 13px/1.4 var(--font-mono); color:var(--muted);
    word-break:break-all; text-decoration:none;
  }
  :is(.link, .num, .cnum, .howto, .provs) a::after{content:none}
  a{text-decoration-thickness:1px}

  /* ---------- where the sheet came from ----------
     The site foot is hidden above, so without this a printed sheet about fraud arrives
     with no way to check who wrote it. That is the shape a second-wave operator's leaflet
     takes (editorial rule 10), and it is the one line of provenance a reprint cannot do
     without. Once, at the end. \00B7 is escaped because a stylesheet has no charset of
     its own. */
  body::after{
    content:"The Fraud Clinic \00B7  thefraudclinic.ca";
    display:block; margin:30px 0 0; padding-top:12px;
    border-top:1px solid var(--rule);
    font:500 13px/1.5 var(--font-mono); letter-spacing:var(--track-label);
    text-transform:uppercase; color:var(--muted);
  }

  /* Nothing moves on paper. */
  *{transition:none !important; animation:none !important}

  /* Under data-shape="lighter" paper opens every fold (DESIGN_SYSTEM, "Folds and the page
     switch"). The summary stays, as the heading of what it held, and loses its Show label,
     which names a press that paper cannot take. Behind @supports for the same reason as
     .why in onpage.css: hiding the control in an engine that cannot open the content
     would print neither. */
  @supports selector(::details-content){
    main[data-shape="lighter"] details:not(.m-term, .stagemenu)::details-content{content-visibility:visible; display:block}
    main[data-shape="lighter"] details:not(.m-term, .stagemenu) > summary{display:block; border:0; padding:0; min-height:0}
    main[data-shape="lighter"] details:not(.m-term, .stagemenu) > summary::after{content:none}
  }
}
