/*
 * Wave 2 (2 December 2026): phone first screen. Loaded after every other sheet.
 *
 * On a phone the illustrated portrait used to fill about two thirds of the first screen (280px square) and pushed the
 * headline, the introduction and the buttons down to the dock. Now the portrait is a small picture beside the greeting,
 * and the headline, introduction and the primary buttons sit on the first screen at 360x740, 390x844 and 430x932. The
 * picture is the same one (still the placeholder illustration until a real portrait is added), only smaller. The
 * container query is the same one the intro tile already used for its narrow layout (a tile narrower than 560px).
 *
 * It stops below 1240px: between 1240 and about 1305 wide the desktop grid makes the tile 528 to 546px, and the phone
 * arrangement does not belong there (responsive audit R10).
 */
@media (max-width: 1239px) {
  @container (max-width: 560px) {
    #home.heroPersonal8 .heroBody {
      grid-template-columns: 72px minmax(0, 1fr);
      grid-template-areas: "portrait eyebrow" "title title" "intro intro" "actions actions";
      gap: 10px 14px;
      align-items: center;
      align-content: start;
      padding: 12px 18px 16px;
    }
    /* The text blocks stop being boxes of their own so the picture can sit beside the greeting; nothing is reordered for
       keyboard or screen reader users (the greeting, headline, introduction and buttons keep their source order). */
    #home .heroText, #home .heroMain { display: contents; }
    #home .heroMain .eyebrow { grid-area: eyebrow; margin: 0; }
    #home .heroMain h1 { grid-area: title; margin: 2px 0 0; }
    #home .heroMain > p { grid-area: intro; margin: 0; }
    #home .heroBottom { grid-area: actions; margin: 2px 0 0; }
    #home .heroPortrait8 { grid-area: portrait; order: 0; width: 72px; max-width: 72px; justify-self: start; }
    #home .heroPhoto8 { border-radius: 18px; box-shadow: 0 4px 12px #1a2a4626; }
  }
}

/* A phone held sideways: a shorter header and a smaller portrait and headline, so the dock does not cover the headline on
   the first screen (responsive audit R05). The grid rules stay inside the container query, so a narrow tile only. */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 1239px) {
  body.framed #screenScroll header { height: 40px; }
  #home .bar { min-height: 36px; padding-block: 4px; }
  @container (max-width: 560px) {
    #home.heroPersonal8 .heroBody { grid-template-columns: 36px minmax(0, 1fr); padding-top: 6px; row-gap: 4px; }
    #home .heroPortrait8 { width: 36px; max-width: 36px; }
    #home.heroPersonal8 .heroBody .heroMain h1 { font-size: 24px; }
  }
}

/* A phone's menu bar has room for About beside the app and overview buttons, but not on the narrowest screens. */
@media (min-width: 380px) and (max-width: 760px) {
  .systembar > button[data-open="about"] { display: inline-flex; align-items: center; }
}

/* A tile's title bar may never be wider than its tile. With a wider system font (the Linux machines that run the browser
   tests) the "Projects" bar pushed its expand button past the edge; the small source text now shrinks and ends in an ellipsis. */
#grid > .tile > .bar, #grid > .tile > .widgetbar { min-width: 0; }
#grid > .tile > .bar > .source, #grid > .tile > .widgetbar > .source { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#grid > .tile > .bar > button, #grid > .tile > .widgetbar > button, #grid > .tile > .widgetbar > a { flex: 0 0 auto; }

/* Around tablet width the desktop tiles are only about 140px wide. The gaps between a bar's items count even when an item is
   empty, so a bar with a spacer and a "source" note was wider than its tile on wider system fonts. Here the note and the spacer
   go away, the expand button sits at the right, and the bar is a little tighter. */
@media (min-width: 600px) and (max-width: 1000px) {
  #grid > .tile > .bar { gap: 5px; padding-left: 8px; padding-right: 8px; }
  #grid > .tile > .bar > .sp, #grid > .tile > .bar > .source { display: none; }
  #grid > .tile > .bar > button { margin-left: auto; }
}

/* The laptop's base is drawn 3% wider than the laptop on each side. With the fixed 28px page padding it stuck out past the
   page edge between about 1000 and 1476px wide, which Firefox and WebKit show as a sideways scroll (Chrome does not).
   The padding now grows with the width so the base always fits; the frame looks the same. */
@media (min-width: 1000px) {
  body.framed { padding-left: max(28px, 2.9vw); padding-right: max(28px, 2.9vw); }
}
