/* The first frame (index.html, the wave-20 audit's U11). Until the app mounts, and replaces what #root
   holds, a quiet skeleton of its frame stands on the wall: the header, the kit's card and the
   composer's (and, where the page has one, the timeline's card at its foot), in the places the app's
   own take on each layout (styles/layout.css, responsive.css, large-screen.css,
   workspace-viewport.css, command-sheet.css), empty and still. It dresses nothing but the skeleton.
   This file is served as it is, past the build that bakes the adopted looks into the colours
   (build/bakedLooks.ts: acid by day, the Mac's gamma at night), so its colours are written baked: each
   is satin.css's as the app paints it (tests/repo/firstFrame.test.ts holds them to it). */
.first-frame {
  --first-frame-wall: linear-gradient(180deg, #ffdf58 0%, #ffdc4e 55%, #ffd73e 100%);
  --first-frame-header: linear-gradient(180deg, #feeeb4, #fbe49c);
  --first-frame-paper: linear-gradient(165deg, #fff0bb, #fdebaa 55%, #fce5a0);
  --first-frame-glaze: linear-gradient(180deg, rgba(255, 247, 213, 0.6), rgba(255, 245, 206, 0.5));
  --first-frame-line: rgba(151, 78, 0, 0.4);
  --first-frame-edge: inset 0 1px 0 rgba(255, 252, 219, 0.95), inset 0 -10px 16px -14px rgba(214, 98, 0, 0.12);
  --first-frame-shadow: 1px 1px 1px rgba(126, 70, 0, 0.1);
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  background: var(--first-frame-wall);
}
:root[data-theme="dark"] .first-frame {
  --first-frame-wall: linear-gradient(180deg, #181007 0%, #110b05 50%, #0a0703 100%);
  --first-frame-header: linear-gradient(180deg, #22180d, #1a1209);
  --first-frame-paper: linear-gradient(180deg, #241a0e, #1b130a);
  --first-frame-glaze: linear-gradient(180deg, #251a0f, #1f160c);
  --first-frame-line: rgba(255, 211, 143, 0.14);
  --first-frame-edge: inset 0 1px 0 rgba(255, 219, 164, 0.09), inset 0 -10px 16px -14px rgba(0, 0, 0, 0.4);
  --first-frame-shadow: 0 1px 0 rgba(0, 0, 0, 0.5), 2px 6px 16px rgba(0, 0, 0, 0.32);
}

/* Two columns (computers, tablets held sideways): the page 1200px wide at most, the header 58px and its
   edges, the kit's card and the composer's at the golden section, as tall as the window leaves them. */
.first-frame-page {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(100%, 1200px);
  height: 100%;
  margin-inline: auto;
  padding: 16px;
}
.first-frame-header,
.first-frame-card {
  box-sizing: border-box;
  border: 1px solid var(--first-frame-line);
  border-radius: 18px;
  box-shadow: var(--first-frame-edge), var(--first-frame-shadow);
}
.first-frame-header {
  flex: none;
  height: 60px;
  background: var(--first-frame-header);
}
.first-frame-body {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(min(674px, 100% - 332px), 1.618fr) minmax(320px, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 12px;
}
.first-frame-kit,
.first-frame-timeline {
  background: var(--first-frame-glaze);
}
.first-frame-composer {
  background: var(--first-frame-paper);
}
.first-frame-timeline {
  display: none;
  grid-column: 1 / -1;
}

/* Shorter windows tighten the page: 12px from 720px tall, 8px under it, and tablets held sideways. */
@media (min-width: 981px) and (max-height: 895px), (min-width: 721px) and (max-width: 980px) and (min-height: 501px) and (orientation: landscape) {
  .first-frame-page { padding: 8px; gap: 8px; }
}
@media (min-width: 981px) and (min-height: 720px) and (max-height: 895px) {
  .first-frame-page { padding: 12px; gap: 12px; }
}
/* A touch screen's header is 72px tall, as its keys are. */
@media (pointer: coarse) and (min-width: 981px) and (min-height: 501px) {
  .first-frame-header { height: 72px; }
}
/* A tablet held sideways widens the page past 1200px as far as its kit needs (workspace-viewport.css). */
@media (pointer: coarse) and (min-width: 981px) and (max-width: 1599px) and (min-height: 896px) and (orientation: landscape) {
  .first-frame-page { width: min(100%, max(1200px, calc((100dvh - 368.5px) * 560 / 464 * 1.618 + 99px))); }
}
@media (pointer: coarse) and (min-width: 1101px) and (max-width: 1599px) and (min-height: 896px) and (orientation: landscape) {
  .first-frame-page { width: min(100%, max(1200px, calc((100dvh - 369.5px) * 560 / 464 * 1.618 + 99px))); }
}
/* A touch tablet held sideways, tall enough: the timeline's card at the page's foot. */
@media (pointer: coarse) and (min-width: 1101px) and (max-width: 1599px) and (min-height: 864px) {
  .first-frame-body { grid-template-rows: minmax(0, 1fr) 202px; }
  .first-frame-timeline { display: block; }
}

/* Large screens: the page grows with the window, its spacing and keys too; the composer's column ends
   at the timeline's rule beside the kit, or, from 1076px tall, both stop over the timeline's own card,
   the kit's card as tall as its stage allows (workspace-viewport.css). */
@media (min-width: 1600px) and (min-height: 880px) {
  .first-frame-page {
    --first-frame-width: clamp(1400px, 84vw, 1740px);
    width: var(--first-frame-width);
    padding: 24px;
    gap: 20px;
  }
  .first-frame-header { height: 70px; }
  .first-frame-body {
    grid-template-columns: minmax(0, 1.618fr) minmax(440px, 1fr);
    gap: 20px;
  }
  .first-frame-composer {
    align-self: start;
    height: min(100%, max(calc(100% - 9 * clamp(14px, (100dvh - 751px) / 9, 22px) - 26px), 575px));
  }
}
@media (min-width: 1600px) and (min-height: 1076px) {
  .first-frame-body {
    align-content: start;
    grid-template-rows: min(100dvh - 378px, min((var(--first-frame-width) - 68px) * 0.618034 - 32px, 860px) * 0.828571 + 47.9px) 220px;
  }
  .first-frame-composer { height: auto; align-self: stretch; }
  .first-frame-timeline { display: block; }
}

/* Upright tablets: one column, the composer above the kit, the header on one row from 865px wide (two
   rows narrower, below). */
@media (min-width: 744px) and (max-width: 1100px) and (orientation: portrait) {
  .first-frame-body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: clamp(287px, 30dvh + 17px, 371px) minmax(0, 1fr);
  }
  .first-frame-composer { grid-row: 1; }
}
@media (max-width: 980px) {
  .first-frame-page {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }
}

/* Phones, and windows too small for the composer beside the kit: the composer is a sheet lowered to its
   bar, 74px tall, 8px over the window's foot and 680px wide at most, the kit's card over it. */
@media (max-width: 743px), (max-width: 980px) and (max-height: 899px), (max-width: 980px) and (orientation: landscape) {
  .first-frame-body { display: block; }
  .first-frame-kit { height: calc(100% - 92px); }
  .first-frame-composer {
    position: fixed;
    inset: auto max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    max-width: 680px;
    height: 74px;
    margin-inline: auto;
    border-radius: 24px;
  }
  .first-frame-timeline { display: none; }
}
/* In a short window the kit's card keeps 300px, 8px under the header, and scrolls under the sheet: the
   room of its scroll bar is kept as the page keeps it. */
@media (max-width: 980px) and (max-height: 500px) {
  .first-frame-page { gap: 8px; }
  .first-frame-body { flex: none; height: 300px; overflow-y: scroll; }
  .first-frame-kit { height: 100%; }
}
/* Phones' cards are 8px round. */
@media (max-width: 720px) {
  .first-frame-header,
  .first-frame-kit { border-radius: 8px; }
}
/* Two header rows: phones, and the wrapped header of narrow windows (shell.css), its first row 52px
   tall on a touch screen, 44px under a mouse. */
@media (max-width: 720px), (min-width: 721px) and (max-width: 54em), (min-width: 640px) and (max-width: 720px) and (max-height: 500px) and (pointer: fine) {
  .first-frame-header { height: 112px; }
}
@media (max-width: 720px) and (pointer: coarse), (min-width: 721px) and (max-width: 54em) and (pointer: coarse) {
  .first-frame-header { height: 120px; }
}
/* A phone on its side keeps one header row (responsive.css) until the turn-upright notice covers it. */
@media (min-width: 640px) and (max-width: 720px) and (max-height: 500px) and (pointer: coarse) {
  .first-frame-header { height: 60px; }
}

/* Where colours are forced, the system's: an edge on the window's canvas. */
@media (forced-colors: active) {
  .first-frame { background: Canvas; }
  .first-frame-header,
  .first-frame-card { border-color: CanvasText; background: Canvas; box-shadow: none; }
}
