/* Studio side panel (the Menu): see panel.js. A panel that slides in from
   the right over everything, with the game dimmed behind it. Closed, it
   stays in the page (so it can slide) but can't be seen or tapped. Uses
   the tokens from base.css. */
.studio-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s 0.2s; /* hide once the slide out ends */
}
.studio-panel.open { visibility: visible; pointer-events: auto; transition: none; }
.studio-panel-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay-black-50);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.studio-panel.open .studio-panel-backdrop { opacity: 1; }
.studio-panel-sheet {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 85vw);
  display: flex;
  flex-direction: column;
  /* Two spaces between sections, easier to read (the header keeps one under
     it). Gap skips hidden sections. */
  gap: calc(var(--content-gap) * 2);
  /* Clear of the notch and home bar */
  padding: calc(var(--content-gap) + env(safe-area-inset-top)) calc(var(--content-gap) + env(safe-area-inset-right))
    calc(var(--content-gap) + env(safe-area-inset-bottom)) var(--content-gap);
  overflow-y: auto;
  background: var(--color-surface);
  border-left: var(--border-width) var(--border-style) var(--color-border);
  box-shadow: var(--shadow-drop);
  transform: translateX(calc(100% + var(--content-gap)));
  transition: transform 0.2s ease;
  touch-action: pan-y;
}
.studio-panel.open .studio-panel-sheet { transform: none; }
.studio-panel-sheet:focus { outline: none; }
@media (prefers-reduced-motion: reduce) {
  .studio-panel, .studio-panel-backdrop, .studio-panel-sheet { transition: none; }
}

/* A header bar, as in Level Lab's dialogs (.modal-part-header), as tall as
   the top bar so their bottom lines meet. */
.studio-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(var(--height-header) + var(--border-width)); /* plus its line, like the top bar */
  /* Out to the panel's edges (its right padding includes the safe area) */
  margin: calc(-1 * var(--content-gap)) calc(-1 * (var(--content-gap) + env(safe-area-inset-right)))
    calc(-1 * var(--content-gap)) calc(-1 * var(--content-gap));
  padding: 0 calc(var(--content-gap) + env(safe-area-inset-right)) 0 var(--content-gap);
  border-bottom: var(--border-width) var(--border-style) var(--color-border);
}
.studio-panel-title { font-weight: var(--font-weight-bold); }
.studio-panel-section { display: flex; flex-direction: column; }
.studio-panel-section > * + * { margin-top: var(--content-gap); }
.studio-panel-label {
  font-weight: var(--font-weight-bold);
  color: var(--color-text-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.studio-panel-name { font-weight: var(--font-weight-bold); overflow-wrap: anywhere; }
.studio-panel-text { color: var(--color-text-dark); }
.studio-panel-section > .button { align-self: flex-start; }
/* An "Are you sure?" card (studio/tools.js) under its button in the panel,
   in the flow instead of floating under the corner tools */
.studio-panel-section > .studio-confirm { position: static; width: auto; }

/* A choice of two or three (Levels or Sandbox): buttons side by side in a
   well, the chosen one raised with a blue outline (inside its edge, so
   nothing shifts). The game marks it aria-pressed="true". */
.studio-panel-choice {
  display: flex;
  padding: var(--space-1);
  background: var(--color-background);
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-sm);
}
.studio-panel-choice > button {
  flex: 1 1 0;
  min-height: 40px;
  padding: var(--space-1) var(--space-2);
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--color-text-dark);
  font: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.studio-panel-choice > button[aria-pressed='true'] {
  background: var(--color-surface-light);
  color: var(--color-text);
  font-weight: var(--font-weight-bold);
  box-shadow: inset 0 0 0 var(--border-width) var(--color-accent);
}
@media (hover: hover) {
  :where(html:not([data-pointer='touch'])) .studio-panel-choice > button:not([aria-pressed='true']):hover { color: var(--color-text); } /* see base.css */
}

/* A setting that turns on and off: the whole row is the button. */
.studio-panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 45px;
  padding: 0 var(--space-2);
  background: var(--color-background);
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-lg);
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
@media (hover: hover) {
  :where(html:not([data-pointer='touch'])) .studio-panel-row:hover { border-color: var(--color-accent); } /* see base.css */
}
.studio-switch {
  position: relative;
  flex: none;
  width: 50px;
  height: 30px;
  border-radius: 15px;
  background: var(--color-border-light);
  transition: background-color 0.15s ease;
}
.studio-switch::after {
  content: '';
  position: absolute;
  top: var(--space-1);
  left: var(--space-1);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--color-text);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.studio-panel-row[aria-checked='true'] .studio-switch { background: var(--color-accent); }
.studio-panel-row[aria-checked='true'] .studio-switch::after {
  transform: translateX(20px);
  background: var(--color-on-accent);
}
