/* Studio shell: the page frame every Studio game with a board has. A bar on
   top with the game's name in the middle and the Menu button on the right,
   the stage (the view and its corner tools) filling the middle, and the
   tray along the bottom. On tokens.css and base.css.

     <div class="studio-app">
       <header class="studio-topbar">
         ...the game's own controls...
         <div class="studio-brand" aria-hidden="true">Track Lab</div>
         <button class="button studio-menu-button" aria-label="Menu" ...><i data-icon="menu" data-size="16"></i><span class="studio-menu-word">Menu</span></button>
       </header>
       <main class="studio-stage">...</main>
       <div class="studio-bottom">...the tray...</div>
     </div>

   The notch and the home bar (the apps, and Safari with viewport-fit=cover):
   the top inset goes inside the bar and the bottom one inside the tray, so
   their colour runs behind them; the sides keep clear. In the apps
   (html.in-app, which the game sets) the tray sits on the home bar, as
   app tab bars do. StudioTools.fitBrand(topbar) hides the name when it has
   no room. On a phone the Menu button is its icon alone. */

.studio-app {
  height: 100%;
  height: 100dvh; /* the visible height on phones, with the browser bars */
  display: flex;
  flex-direction: column;
  padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
}

.studio-topbar {
  position: relative;
  flex: none;
  /* plus its bottom line, so the bar's height inside is all space and buttons */
  height: calc(var(--height-header) + var(--border-width) + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  gap: var(--content-gap);
  padding: env(safe-area-inset-top) var(--content-gap) 0;
  background: var(--color-surface);
  border-bottom: var(--border-width) var(--border-style) var(--color-border);
}

.studio-brand {
  position: absolute;
  left: 50%;
  top: calc(50% + env(safe-area-inset-top) / 2);
  transform: translate(-50%, -50%);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-dark);
  white-space: nowrap;
  pointer-events: none;
}
.studio-brand.no-room { visibility: hidden; }

.studio-menu-button { gap: var(--space-1); flex: none; margin-left: auto; }
@media (max-width: 560px) {
  .studio-menu-button { width: var(--height-input); padding: 0; justify-content: center; }
  .studio-menu-button .studio-menu-word { display: none; }
}

.studio-stage { position: relative; flex: 1 1 auto; min-height: 0; }

/* Starting up: the page comes as <body class="loading">, and the game takes
   the class off once its view has drawn. Until then the controls that are
   about to be set up are hidden, keeping their space so nothing jumps, and
   a spinner turns on the stage:

     <div class="studio-loader" role="status"><div class="studio-spinner"></div>Loading…</div>

   Give the stage the view's own background colour, so the words show in
   either theme and nothing flashes when the view draws. */
body.loading .studio-topbar > :not(.studio-brand),
body.loading .studio-tools,
body.loading .studio-bottom > * { visibility: hidden; }
.studio-loader {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  color: var(--color-core-darker); /* on the view's sky, in either theme */
  font-weight: var(--font-weight-bold);
  pointer-events: none;
}
body.loading .studio-loader { display: flex; }
.studio-spinner {
  width: 40px;
  height: 40px;
  border: 5px solid color-mix(in srgb, var(--color-accent) 25%, transparent);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  /* A soft shadow on both edges of the ring, so it stands out on any view. It
     isn't pushed down: it turns too. */
  box-shadow: 0 0 8px var(--overlay-black-50), inset 0 0 8px var(--overlay-black-50);
  animation: studio-spin 0.8s linear infinite;
}
@keyframes studio-spin { to { transform: rotate(360deg); } }
/* It keeps turning with reduced motion on (base.css leaves it out), only slower */
@media (prefers-reduced-motion: reduce) { .studio-spinner { animation-duration: 2.4s; } }

.studio-bottom {
  flex: none;
  min-width: 0;
  background: var(--color-surface);
  border-top: var(--border-width) var(--border-style) var(--color-border);
  padding: var(--content-gap) var(--content-gap) calc(var(--content-gap) + env(safe-area-inset-bottom));
}
.in-app .studio-bottom { padding-bottom: var(--content-gap); }
