/* ============================================================
   What the public site adds around a view of the application.
   A view is an element .app holding markup with the application's
   class names; kit.css holds the application's rules for it.

   .app          a view that follows the width it is given
   .shot > .app  a view laid out at a fixed size and scaled to fit:
                 the full window (.shot--desk) or a phone (.shot--phone)
   ============================================================ */

/* The view stands for the application's document: nothing of the public site reaches into it. */
.app {
  container: app / inline-size;
  position: relative;
  display: block;
  isolation: isolate;
  text-align: start;
  /* The application writes its colour scheme on the document itself; light-dark() reads it. */
  color-scheme: light;
  --app-h: 0px;
}
:root[data-theme="dark"] .app { color-scheme: dark; }
/* :where keeps the reset as weak as the application's own universal rules, which follow it. */
.app :where(*:not(svg, svg *)),
.app :where(*)::before,
.app :where(*)::after { all: revert; }
.app svg { display: revert; flex: none; }
/* A view is a picture and never scrolls: no scrollbar of the application shows in it. The rule
   stands after the reset, which is as strong and would set the width back. */
.app,
.app * { scrollbar-width: none; }

/* A heading of the application stands in a view as x-h1 … x-h4: the outline of the page stays the
   site's. These are the browser's own values for a heading, which the application's rules build on. */
.app :where(x-h1, x-h2, x-h3, x-h4) { display: block; font-weight: bold; }
.app :where(x-h1) { margin-block: 0.67em; font-size: 2em; }
.app :where(x-h2) { margin-block: 0.83em; font-size: 1.5em; }
.app :where(x-h3) { margin-block: 1em; font-size: 1.17em; }
.app :where(x-h4) { margin-block: 1.33em; }

/* A fixed picture of the application: laid out at its real size, scaled to the room it gets,
   cut off at the bottom. The format never follows the content. */
.shot {
  position: relative;
  container-type: inline-size;
  aspect-ratio: var(--shot-w) / var(--shot-h);
  overflow: hidden;
}
.shot > .app {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--shot-w) * 1px);
  height: calc(var(--shot-h) * 1px);
  overflow: hidden;
  transform-origin: 0 0;
  scale: tan(atan2(100cqw, calc(var(--shot-w) * 1px)));
  --app-h: calc(var(--shot-h) * 1px);
}
.shot--desk { --shot-w: 1280; --shot-h: 800; }
/* A phone screen: 9 to 19.5. */
.shot--phone { --shot-w: 390; --shot-h: 845; }

/* The window the application stands in. */
.window {
  padding: 8px;
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}
.window > .shot { border-radius: 18px; }

/* The phone the application stands in. */
.device {
  padding: 9px;
  border-radius: 38px;
  background: #0f172a;
  box-shadow: var(--shadow-raised);
}
:root[data-theme="dark"] .device { background: #2b3441; }
.device > .shot { border-radius: 30px; }

/* A long page of the application shown from its top: cut after a fixed height, fading out.
   The fade sits at a fixed distance from the top, so a view that is shorter than the cut has none. */
.window--cut { position: relative; max-height: 640px; overflow: hidden; }
.window--cut::after {
  content: "";
  position: absolute;
  inset: 552px 0 auto;
  height: 88px;
  background: linear-gradient(transparent, var(--surface));
  pointer-events: none;
}

/* The main view of a module page shows more of the page before it is cut. */
.window--tall { max-height: 860px; }
.window--tall::after { inset: 772px 0 auto; }

/* A part the application lays over a page (a dialog, a drawer, a menu) stands in the flow here.
   Inside it a rule may limit a height by the window; the part is read from a window 900 px high,
   and with no height at all such a limit would close the part's content. */
.app--part { --app-h: 900px; }
.app--part > * {
  position: static !important;
  inset: auto !important;
  width: auto !important;
  max-width: none !important;
  height: auto !important;
  max-height: none !important;
  margin: 0 !important;
  transform: none !important;
  opacity: 1 !important;
  visibility: visible !important;
  box-shadow: none !important;
}

/* A part whose height the application takes from the window (a chat and its thread): read from a
   window 900 px high, it stands as high here. */
.app--tall { --app-h: 900px; }

/* A phone beside the copy of a module page. */
.feat .device { width: min(300px, 80vw); justify-self: center; }

/* Two phones side by side: a page of the client and what opens from it. The second stands a little
   lower, so the two read as one step after the other. On a phone they stay side by side, smaller. */
.devices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 2.4vw, 28px);
  align-items: start;
  justify-self: center;
  width: min(580px, 100%);
  margin: 0;
}
.devices > .device { width: auto; justify-self: stretch; }
.devices > .device:nth-child(2) { margin-top: clamp(28px, 6vw, 64px); }
.devices > figcaption { grid-column: 1 / -1; color: var(--c-500); font-size: 0.8rem; line-height: 1.4; text-align: center; }
.devices > figcaption a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
@media (max-width: 720px) {
  .devices > .device { padding: 6px; border-radius: 26px; }
  .devices > .device > .shot { border-radius: 21px; }
}
