/*
 * The desktop's proportions, after the reference: cards are a quarter or half of the width, in two heights, so rows line
 * up and only a few things are large. Applies to the laptop-sized desktop; narrower screens stack as before.
 */
@media (min-width: 1240px) {
  /* 12.25rem is 196px at the normal text size; with larger browser text the rows grow with it (responsive audit R07). */
  #grid { --cell: max(196px, 12.25rem); grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: var(--cell); grid-auto-flow: row; align-items: stretch; }
  #grid > .tile { display: flex; flex-direction: column; grid-column: span 3; grid-row: span 1; min-height: 0; height: 100%; overflow: hidden; }
  #grid > .tile[hidden] { display: none; }
  /* Half width */
  #grid > #home, #grid > #career, #grid > #featured, #grid > #writing, #grid > #spotify, #grid > #resources, #grid > #books, #grid > #notes, #grid > #freeform { grid-column: span 6; }
  /* Two cells tall */
  #grid > #home, #grid > #career, #grid > #featured, #grid > #projects, #grid > #contact, #grid > #writing, #grid > #calendar,
  #grid > #spotify, #grid > #podcasts, #grid > #map, #grid > #resources, #grid > #books, #grid > #notes, #grid > #freeform { grid-row: span 2; }
  #grid > .tile > .widgetbar, #grid > .tile > .bar { flex: 0 0 auto; }
  #grid > .tile > .provider { flex: 0 0 auto; margin-top: auto; }

  /* With much larger text the dense cards scroll rather than hide their last lines and buttons (responsive audit R07).
     At the normal size they fit, so no scrollbar shows. */
  #grid > #home, #grid > #career, #grid > #featured, #grid > #books { overflow-y: auto; scrollbar-width: thin; }
  #grid #home .heroBody { min-height: 0; overflow-y: auto; scrollbar-width: thin; }
  #grid > #career > .careerbody { padding-bottom: 5px; }

  /* The Books card holds a chosen book's details inside its two rows (responsive audit R08): one sliding row of
     categories and tighter spacing. Everything it showed before is still there, the count sentence included. */
  #grid #books > .bookIntro, #grid #books > .bookChips, #grid #books > .bookRail, #grid #books > .bookDetail { flex: 0 0 auto; }
  #grid #books .bookIntro { padding-top: 7px; }
  #grid #books .bookIntro h2 { margin: 0; line-height: 1.25; }
  #grid #books .bookIntro p { line-height: 1.35; }
  #grid #books .bookChips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-block: 2px; scroll-padding-inline: 16px; }
  #grid #books .bookChips > * { flex: 0 0 auto; }
  #grid #books .bookChip:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
  /* The shelf strip has spare room under the titles; the details box moves up into some of it. */
  #grid #books .bookRail { margin: 0 0 -6px; }
  #grid #books .bookRail .bookTable { margin-top: 3px; }
  /* The arrows at the ends of the shelf move it, so its own scrollbar does not need a line of the card. */
  #grid #books .bookScroll { padding-bottom: 0; scrollbar-width: none; }
  #grid #books .bookStep { top: 53px; }
  #grid #books .bookDetail { margin-top: 3px; min-height: 34px; padding-block: 3px; row-gap: 0; line-height: 1.3; }
  #grid #books > .provider { min-height: 0; padding-block: 3px; }

  /* Each card's contents take the room left between its header and footer; anything longer scrolls inside the card. */
  #grid > #contact > .pad, #grid > #spotify > .embedhost, #grid > #podcasts > .embedhost, #grid > #miro > .embedhost,
  #grid > #map > .embedhost, #grid > #clock > .clock, #grid > #office > .officebody, #grid > #assistant > .assistantFace, #grid > #visitors > .visitorBody { flex: 1 1 0; min-height: 0; overflow: auto; scrollbar-width: thin; }
  #grid > .featuredTile > .featuredPicture { flex: 1 1 0; height: auto; min-height: 110px; }
  #grid > .featuredTile > .featuredInfo { flex: 0 0 auto; }

  #grid > #contact > .pad { padding-top: 12px; padding-bottom: 8px; }
  /* The picture sits beside the name, which leaves room for every button and logo below. */
  #grid > #contact .contactPhoto8 { float: left; width: 48px; height: 48px; margin: 0 10px 0 0; }
  #grid > #contact .contactname { min-height: 48px; font-size: 1.25rem; line-height: 1.2; }
  #grid > #contact .pad > p { clear: both; }
  #grid > #contact .contactQuickStatus:empty { display: none; }

  #grid > #spotify .providerpreview, #grid > #podcasts .providerpreview, #grid > #miro .providerpreview { height: auto; min-height: 100%; }
  #grid > #spotify .providerpreview { gap: 8px; padding-top: 12px; padding-bottom: 10px; }
  #grid > #spotify .artistArt { width: 58px; height: 58px; }

  /* A quarter-width podcast card: three covers across, so all the shows are in view. */
  #grid > #podcasts .providerpreview { display: flex; flex-direction: column; justify-content: flex-start; gap: 8px; padding: 10px 12px; }
  #grid > #podcasts .podShelf { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; margin: 0; }
  #grid > #podcasts { container-type: inline-size; }
  #grid > #podcasts .podArt { width: 100%; max-width: min(76px, 21cqi); height: auto; aspect-ratio: 1; margin-inline: auto; }
  #grid > #podcasts .previewinfo { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 10px; width: 100%; }
  #grid > #podcasts .previewinfo .tiny { flex: 1 1 100%; }
  #grid > #podcasts .previewinfo h2 { flex: 1 1 0; min-width: 0; margin: 0; font-size: .9375rem; }
  #grid > #podcasts .previewinfo .loadbutton { margin-top: 0; }

  #grid > #office .officebody { gap: 10px; padding: 8px 12px; }
  #grid > #office .officebody > :first-child { transform: scale(.82); transform-origin: top left; margin-right: -9px; }
  #grid > #office .officebody b { display: block; font-size: .875rem; line-height: 1.3; }
  #grid > #office .officebody p { margin: 2px 0; font-size: .75rem; line-height: 1.35; }
  #grid > #office .officebody button { min-height: 24px; margin: 0; padding-block: 0; }

  #grid > #assistant .assistantFace { gap: 10px; padding: 12px 14px; }
  #grid > #assistant .assistantFace strong { font-size: 1.0625rem; line-height: 1.25; }
  #grid > #assistant .assistantFace small { font-size: .75rem; }

  /* The intro keeps its words and photo side by side at every width of this grid. */
  /* Padding trimmed by the same amount above and below the middle line, so centred words and photo stay where they were,
     and the tallest widths no longer overflow the card by a few pixels (which would now show as a scrollbar). */
  #grid #home .heroBody { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 18px; padding: 5px 20px 9px; }
  #grid #home .heroPortrait8 { order: 0; max-width: 340px; }
  #grid #home.heroPersonal8 .heroBody .heroMain h1 { font-size: clamp(26px, 6.1cqi, 43px); }

  /* One-cell cards */
  #grid > #clock .clock { padding: 2px 8px 4px; }
  #grid > #clock .clockFaces { gap: 4px; }
  #grid > #clock .clockCity { gap: 1px; }
  #grid > #clock .clockCity svg { width: 51px; height: 51px; }

  #grid > #miro .providerpreview { display: flex; align-items: center; justify-content: center; padding: 6px 14px; }
  #grid > #miro .providericon { display: none; }
  #grid > #miro .previewinfo { text-align: center; }
  #grid > #miro .previewinfo h2 { margin: 2px 0 6px; font-size: 1.0625rem; }
  #grid > #miro .previewinfo .loadbutton { margin-top: 0; }

  #grid > #visitors .visitorBody { justify-content: flex-start; gap: 2px; padding: 2px 14px 6px; }
  #grid > #visitors .statRow { grid-template-columns: minmax(0, 1fr) 54px auto; gap: 8px; padding: 3px 0; }
  #grid > #visitors .statName b { font-size: .8125rem; line-height: 1.2; }
  #grid > #visitors .statName small { line-height: 1.2; }
  #grid > #visitors .statValue { flex-direction: row; align-items: center; gap: 6px; min-width: 0; }
  #grid > #visitors .statValue b { font-size: 1rem; }
  #grid > #visitors .statSpark { height: 22px; }
  #grid > #visitors .statNote { font-size: .75rem; line-height: 1.3; }

  #grid > #photos > #photoLibrary { flex: 1 1 0; min-height: 0; overflow: auto; }
  #grid > #photos .photoempty { gap: 4px; min-height: 0; height: 100%; padding: 6px 12px; align-content: center; }
  /* The longer explanation shows in the Photos window; the small card keeps its title and button. */
  #grid > #photos .photoempty .photosymbol, #grid > #photos .photoempty p { display: none; }
  #grid > #photos > .provider { flex-wrap: nowrap; gap: 8px; min-height: 0; padding-top: 4px; padding-bottom: 4px; font-size: .75rem; line-height: 1.3; }
  #grid > #photos > .provider > .sp { display: none; }
  #grid > #photos > .provider > button { flex: 0 0 auto; margin-left: auto; }
  #grid > #photos.hasGallery > .ownerGallery { display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; margin: 6px 10px 0; }
  #grid > #photos.hasGallery .galleryFrame { flex: 1 1 0; min-height: 0; }
  #grid > #photos.hasGallery .galleryFrame img { height: 100%; }
  #grid > #photos.hasGallery .galleryControls { padding: 2px 0; }
  #grid > #photos.hasGallery > #photoLibrary:not(:has(.photoitem)) { display: none; }

  #grid > #freeform > .canvaswrap { display: flex; flex-direction: column; flex: 1 1 0; min-height: 0; }
  #grid > #freeform .ffBoard { flex: 1 1 0; height: auto; min-height: 0; aspect-ratio: auto; }
  #grid > #freeform .ffBoard canvas { width: 100%; height: 100%; }
}

/* Below the grid: live stats stays a small card, no taller than it needs; on a phone it takes the row so it can be read. */
@media (max-width: 1239px) {
  #grid > #visitors { align-self: start; }
}
@media (max-width: 760px) {
  #grid > #visitors { grid-column: 1 / -1; }
}
