/* Studio base: the Level Lab look as Track Lab and Clatter Lab use it: the
   page base and the button shapes, on the tokens in tokens.css. Load
   tokens.css, then this, before tray.css and the game's own style.css,
   which adds its own tokens and overrides.

   Button hovers are here too (end of the buttons): only where there's a
   real hover, and not once a game has seen a finger (html[data-pointer=
   'touch'], which tools.js sets), so a tap never leaves one stuck.

   Each game keeps:
   - hover styles for its own things;
   - touch-action on html and body (what a stray pinch may do);
   - the Roboto file at assets/fonts/roboto-latin.woff2, beside index.html.
     It's bundled so the apps work offline. The url below is relative to this
     file, so it finds the game's copy. The page's data-theme attribute picks
     the theme (each game's index.html sets it to match the device). */

@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 100 900; /* one variable file covers 300 and 700 */
  font-display: fallback;
  src: url(../assets/fonts/roboto-latin.woff2) format('woff2');
}


/* Page base */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  -webkit-touch-callout: none; /* no long-press menus on pictures */
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  height: 100%;
  /* The bar colour: Safari tints its status bar and bottom toolbar with the
     page background, so this makes them run on from the top bar and tray. */
  background: var(--color-surface);
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size);
  font-weight: var(--font-weight);
  color: var(--color-text);
  line-height: var(--line-height);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

button, input, select { font: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
}

/* Level Lab's scrollbar (the platform's style.css): one step-3 bar, an
   opaque surface track ruled off by a border, the thumb inset a step.
   A browser with overlay scrollbars (phones, most Macs) draws its own and
   takes no width. Firefox has no pseudo-elements for it: a thin bar in the
   same colours. */
@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--color-surface-light) var(--color-surface);
  }
}
::-webkit-scrollbar { width: var(--space-3); height: var(--space-3); }
::-webkit-scrollbar-track:vertical { background: var(--color-surface); border-left: 1px solid var(--color-border); }
::-webkit-scrollbar-track:horizontal { background: var(--color-surface); border-top: 1px solid var(--color-border); }
::-webkit-scrollbar-corner { background: var(--color-surface); }
::-webkit-scrollbar-thumb { background: var(--color-surface-light); background-clip: padding-box; border: var(--space-1) solid transparent; }
::-webkit-scrollbar-thumb:hover { background: var(--color-border-light); background-clip: padding-box; }

/* Buttons: .button, .button-accent, .button-danger, .button-icon. Shapes and
   colours only; hover is the game's. */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1); /* between an icon and its words */
  height: var(--height-input);
  padding: 0 var(--space-2);
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  letter-spacing: 0.01em;
  line-height: 1;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button-accent { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
.button-danger { background: var(--color-error); border-color: var(--color-error); color: var(--color-on-accent); }

.button-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--height-input);
  height: var(--height-input);
  padding: var(--space-1);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-link);
  cursor: pointer;
  font-size: var(--font-size);
  line-height: 1;
  transition: color 0.15s ease;
}
.button-icon:disabled,
.button-icon:disabled:hover {
  background: transparent;
  color: color-mix(in srgb, var(--color-link) 50%, transparent);
  cursor: not-allowed;
}

/* Hover, as low in weight as the shapes (:where), so a button with its own
   look (Play, the corner tools) keeps it. An icon button keeps its own
   background and just lightens. */
@media (hover: hover) {
  :where(html:not([data-pointer='touch'])) .button:hover { background: var(--color-background); color: var(--color-text); border-color: var(--color-accent); }
  :where(html:not([data-pointer='touch'])) .button-accent:hover { background: var(--color-accent-light); border-color: var(--color-accent-light); color: var(--color-on-accent); }
  :where(html:not([data-pointer='touch'])) .button-danger:hover { background: var(--color-error); border-color: var(--color-error); color: var(--color-on-accent); filter: brightness(1.1); }
  :where(html:not([data-pointer='touch'])) .button-icon:hover { color: var(--color-link-light); }
  :where(html:not([data-pointer='touch'])) .button-icon:disabled:hover { color: color-mix(in srgb, var(--color-link) 50%, transparent); }
}

/* Fingers need more than the 35 px look: on a touch screen every button's
   tap area reaches 5 px further on each side (45 px), drawn nowhere. */
@media (pointer: coarse) {
  :where(.button, .button-icon) { position: relative; }
  :where(.button, .button-icon)::after { content: ''; position: absolute; inset: -5px; }
}

/* Reduced motion (a device setting): CSS animations and transitions end at
   once. A loading spinner keeps turning, or it would look stuck. Moves made
   in script check the same setting themselves. */
@media (prefers-reduced-motion: reduce) {
  *:not(.studio-spinner), *::before, *::after {
    animation-duration: 0.01ms !important; /* still ends, so animationend comes */
    animation-iteration-count: 1 !important;
    transition-duration: 0s !important; /* none: a size read right after a change gets the new one */
    scroll-behavior: auto !important;
  }
}
