/* ==========================================================================
   SYNC — Beyond the Physical Stage
   Screen: browser review of the master publication.

   ≥ 900 px  Sheets on the GT poster wall, at true A4 proportion.
             Spreads (default): whole spread fits the window height.
             Pages: one sheet per row at actual size (210 mm ≈ 794 px).
             Grid overlay: columns, baselines and margins (key G).
   < 900 px  Reading view: the same content reflows into one column with
             the GT site's mobile sizes (same 900 px breakpoint as GT).
   ========================================================================== */

@media screen {
  html { background: var(--wall); scroll-padding-top: 4rem; }
  body { padding: 4.75rem 1.5rem 5rem; }

  .publication {
    --sheet: min(calc((100vw - 4rem) / 2), calc((100vh - 8rem) * 210 / 297));
    display: grid;
    grid-template-columns: repeat(2, var(--sheet));
    justify-content: center;
    row-gap: 3.5rem;
  }
  .sheet { box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 8px 24px -12px rgba(0,0,0,.35); }
  .sheet--first { grid-column: 2; }

  /* spine shading on facing pages */
  .sheet[data-side="verso"] .page { box-shadow: inset -14px 0 18px -16px rgba(0,0,0,.28); }
  .sheet[data-side="recto"] .page { box-shadow: inset 14px 0 18px -16px rgba(0,0,0,.22); }

  /* page label under each sheet */
  .sheet::after {
    content: attr(data-folio) "\2003" attr(data-template);
    position: absolute; left: 0; top: 100%;
    margin-top: .7rem;
    font: 700 .66rem/1 var(--din);
    letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
    white-space: nowrap;
  }
  .sheet[data-side="recto"]::after { left: auto; right: 0; }
  html[data-edition="web"] .sheet::after { content: attr(data-folio); }   /* readers see page numbers only */

  /* contents: hover lights the note in the signal colour (as a playing note in the Sync UI);
     entries whose pages are planned but not laid out yet are dimmed (review only) */
  .score a:not(.is-planned):hover .score__track i { background: var(--signal); }
  .score a:not(.is-planned):hover .score__t { text-decoration: underline; text-underline-offset: .2em; }
  .score a:is(.is-planned, :not([href])) { cursor: default; }   /* :not([href]) = web edition */
  .score a:is(.is-planned, :not([href])) :is(.score__t, .score__p, .score__n, i) { opacity: .35; }

  html.view-pages .publication {
    --sheet: min(calc(100vw - 3rem), 210mm);
    grid-template-columns: var(--sheet);
  }
  html.view-pages .sheet--first { grid-column: auto; }
  html.view-pages .sheet .page { box-shadow: none; }
  html.view-pages .sheet::after { left: 0; right: auto; }

  /* ---- Grid overlay (key G) ------------------------------------------- */
  html.show-grid .page::after {
    content: "";
    position: absolute; inset: 0;
    pointer-events: none; z-index: 10;
    background:
      /* margins */
      linear-gradient(to right, rgba(230,0,90,.55) 0 1px, transparent 1px) var(--margin-x) 0 / 1px 100% no-repeat,
      linear-gradient(to right, rgba(230,0,90,.55) 0 1px, transparent 1px) calc(100% - var(--margin-x)) 0 / 1px 100% no-repeat,
      linear-gradient(rgba(230,0,90,.55) 0 1px, transparent 1px) 0 var(--margin-top) / 100% 1px no-repeat,
      linear-gradient(rgba(230,0,90,.55) 0 1px, transparent 1px) 0 calc(100% - var(--margin-bottom)) / 100% 1px no-repeat,
      /* baselines (every 5 mm, live area only) */
      repeating-linear-gradient(to bottom, transparent 0 calc(var(--bl) - 1px), rgba(230,0,90,.22) calc(var(--bl) - 1px) var(--bl))
        var(--margin-x) var(--margin-top) / calc(100% - 2 * var(--margin-x)) calc(100% - var(--margin-top) - var(--margin-bottom)) no-repeat,
      /* 10 columns */
      repeating-linear-gradient(to right, rgba(83,174,229,.16) 0 var(--col), transparent var(--col) calc(var(--col) + var(--gutter)))
        var(--margin-x) 0 / calc(100% - 2 * var(--margin-x)) 100% no-repeat;
  }

  /* ---- Review bar ------------------------------------------------------ */
  .review-bar {
    position: fixed; inset: 0 0 auto; z-index: 100;
    display: flex; align-items: center; gap: 1.5rem;
    height: 3rem; padding: 0 1.5rem;
    background: var(--paper); border-bottom: 1px solid var(--line);
    font: 400 .72rem/1 var(--din); letter-spacing: .08em; text-transform: uppercase;
  }
  .review-bar__title { font-weight: 700; letter-spacing: .12em; white-space: nowrap; text-decoration: none; color: inherit;
    display: inline-flex; align-items: center; gap: .55rem; }
  .review-bar__title::before {                    /* Sync dot mark */
    content: ""; width: 1rem; height: 1rem;
    background: url("../illustrations/sync-mark.svg") center / contain no-repeat;
  }
  .review-bar__doc { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html[data-edition="web"] .review-only { display: none !important; }
  .review-bar__pdf {
    display: inline-flex; align-items: center; padding: .5rem .8rem;
    background: var(--ink); color: var(--paper); text-decoration: none; border: 1px solid var(--ink);
  }
  .review-bar__pdf[hidden] { display: none; }
  .review-bar__meta { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .review-bar__controls { margin-left: auto; display: flex; gap: .4rem; }
  .review-bar button {
    font: inherit; letter-spacing: inherit; text-transform: inherit;
    padding: .5rem .8rem; border: 1px solid var(--ink); background: var(--paper); color: var(--ink); cursor: pointer;
  }
  .review-bar button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
  .review-bar button:focus-visible { outline: 3px solid currentColor; outline-offset: 2px; }
  .review-bar kbd { font: inherit; opacity: .55; margin-left: .35rem; }
  .review-bar__sep { width: .6rem; }
}

/* ==========================================================================
   Reading view (phones / narrow windows) — same breakpoint as GT (900 px).
   Screen only: the print viewport is also < 900 px wide, so this must never
   apply to print.
   ========================================================================== */
@media screen and (max-width: 899px) {
  :root {
    --mm: 3.6px;                /* decorative sizes (rules, marks) */
    --pt: 1.7px;                /* 10 pt body → 17 px, as on GT mobile */
    --margin-x: 1.25rem;        /* GT --g at 390 px */
    --gutter: 1rem;
    --bl: 1.6rem;               /* GT body line ≈ 1.55 × 17 px */
    --fs-micro: .72rem;
    --fs-mast: .8rem;
    --fs-caption: .8rem;
    --fs-standfirst: 1.25rem;
    --fs-statement: 1.45rem;
    --fs-lede: 1.5rem;
    --fs-pull: 1.8rem;
    --fs-h2: clamp(2.3rem, 9.5vw, 3rem);
    --fs-num: 4.8rem;
    --fs-display: clamp(3.1rem, 14.5vw, 4.6rem);
    --lh-small: 1.3;
  }
  body { padding: 3rem 0 0; }
  .publication { display: block; }

  .sheet { width: auto; aspect-ratio: auto; box-shadow: none; border-bottom: 1px solid var(--line); overflow-x: clip; }   /* diagram glows stay on screen */
  .sheet::after { content: none; }
  .page {
    position: static;
    display: flex; flex-direction: column; gap: var(--bl);
    padding: 3rem var(--margin-x) 3.5rem;
    overflow: visible;
    box-shadow: none !important;
  }
  .page > * { grid-column: auto; grid-row: auto; }
  .runhead, .folio { display: none; }
  html.show-grid .page::after { content: none; }

  /* fill the column, capped only on tablet-wide windows (as on the website: 80ch) */
  .text, .caption, .imprint, .legend { max-width: 80ch; }
  .standfirst { line-height: 1.35; max-width: 30em; }
  .statement, .pull { max-width: 22ch; }

  .masthead, .cover-foot, .imprint, .legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; }
  .masthead { padding-top: 0; order: -1; align-self: stretch; }
  .masthead > :nth-child(2) { display: none; }
  .cover-foot { padding-top: 0; align-self: stretch; }
  .cover-foot > :last-child { text-align: left; }
  .brandmark { align-self: start; }
  .lede br { display: none; }   /* print line breaks; let the phone measure decide */
  .imprint, .legend { flex-direction: column; }
  .imprint > div, .legend li { grid-column: auto; }

  .fig--bleed { margin-inline: calc(-1 * var(--margin-x)); }
  .fig > img { height: auto; flex: none; }
  .spacer { display: none; }

  .score { --score-cols: 1.6rem minmax(0, 1fr) 24% 1.6rem; max-width: 40rem; }
  .score a, .score__axis { column-gap: .75rem; }
  .score a { height: auto; min-height: 2.9rem; }
  .score__t { font-size: 1rem; white-space: normal; line-height: 1.2; padding-block: .4rem; }
  .score__axis { height: 1.6rem; }
  .score__ticks span:nth-child(even) { display: none; }

  .review-bar { gap: .75rem; padding: 0 1rem; }
  .review-bar__meta, .review-bar__controls > :not(.review-bar__pdf) { display: none; }   /* phones: reading view only; PDF stays */
  .review-bar__doc { min-width: 0; }
}
