/* Base: what every page of the editor shares - the page, buttons and fields, the top bar with the way back
   (Sets / set / level), the status line and the status badges of levels and sets. */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-default);
  font-family: var(--font-family);
  font-size: var(--font-size-md);
}

a {
  color: inherit;
}

/* Hidden stays hidden, whatever display a class gives the element. */
[hidden] {
  display: none !important;
}

.editor__input {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-control);
  color: var(--text-default);
  font: inherit;
}

.editor__input:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.editor__input--number {
  width: 4.5rem;
}

.editor__checkbox {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--surface-selected);
}

.editor__checkbox:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.editor__visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.editor__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-control);
  color: var(--text-default);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.editor__button:hover {
  background: var(--surface-control-hover);
}

.editor__button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.editor__button:disabled {
  opacity: 0.5;
  cursor: default;
}

.editor__button--primary {
  color: var(--text-on-primary);
  background: var(--surface-primary);
}

.editor__button--primary:hover {
  background: var(--surface-primary-hover);
}

.editor__button--small {
  padding: 0 var(--space-2);
  font-size: var(--font-size-sm);
}

.editor__button--icon {
  min-width: 2rem;
  padding: var(--space-1);
}

/* The top bar: the way back on the left, the page's own buttons, then the signed-in user. */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-panel);
}

.topbar__title {
  margin: 0;
  font-size: var(--font-size-lg);
}

.topbar__crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: normal;
}

.topbar__crumb {
  color: var(--text-muted);
  text-decoration: none;
}

.topbar__crumb:hover {
  color: var(--text-default);
  text-decoration: underline;
}

.topbar__crumb--current {
  color: var(--text-default);
  font-weight: 600;
}

.topbar__crumb-separator {
  color: var(--text-muted);
}

.topbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

/* The round ? next to the account button on every page. */
.help-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  background: var(--surface-control);
  color: var(--text-default);
  font-weight: 600;
  text-decoration: none;
}

.help-link:hover {
  background: var(--surface-control-hover);
}

.help-link:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* The signed-in user: a round button with their initials (like Microsoft's) that opens the account menu -
   the name, Change password and Sign out. */
.account__button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--surface-primary);
  color: var(--text-default);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.account__button:hover,
.account[open] > .account__button {
  background: var(--surface-primary-hover);
}

.account__button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.account__who {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0 0 var(--space-1);
  padding: 0 var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.account__name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.account__role {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.page {
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space-4);
}

.status {
  min-height: 1.4em;
  margin: 0;
  color: var(--text-muted);
}

.status.has-error {
  color: var(--text-error);
}

/* A level's (or set's) state as a small label: in the game, changed since, waiting for approval, ... */
.badge {
  display: inline-block;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface-control);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  white-space: nowrap;
}

.badge--approved {
  background: var(--badge-approved);
  color: var(--text-approved);
}

.badge--changed,
.badge--waiting,
.badge--scrolls {
  background: var(--badge-warning);
  color: var(--text-warning);
}

.badge--error {
  background: var(--badge-error);
  color: var(--text-error);
}

/* One of the admins' badges on a level (#375) - a name, not a state: blue, with a border so it reads apart. */
.badge--label {
  border: 1px solid var(--text-info);
  background: var(--badge-info);
  color: var(--text-info);
}

/* An admin's x on a badge, to take it off the level. */
.badge__remove {
  margin-left: var(--space-1);
  padding: 0 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.badge__remove:hover {
  background: var(--surface-control-hover);
}

.badge__remove:focus-visible {
  outline: 2px solid var(--focus-ring);
}

/* A level's comment (#373) where levels are listed: one muted line, the whole text as its title. */
.level-comment {
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A level drawn small (level-draw.js): the sky shows around a level of another shape. */
.thumbnail {
  display: block;
  width: 100%;
  height: auto;
  background: var(--map-sky);
  image-rendering: pixelated;
}

/* The editor's version in the bottom right corner (version.js); clicks go through it. */
.version {
  position: fixed;
  right: var(--space-2);
  bottom: var(--space-1);
  z-index: 5;
  margin: 0;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface-page);
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  opacity: 0.85;
  pointer-events: none;
}

.version.has-error {
  color: var(--text-error);
}

/* A small menu that opens under its button (a details element). */
.menu {
  position: relative;
}

.menu > summary {
  list-style: none;
}

.menu > summary::-webkit-details-marker {
  display: none;
}

.menu__items {
  position: absolute;
  right: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 12rem;
  margin-top: var(--space-1);
  padding: var(--space-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-panel);
  box-shadow: 0 0.5rem 1.5rem var(--shadow);
}

/* Opened where its right-aligned place would reach past the window's left edge: from the button's left instead. */
.menu__items--from-left {
  right: auto;
  left: 0;
}

.menu__items .editor__button {
  justify-content: flex-start;
}

/* A key or a mouse action, drawn as a key cap (the editor's shortcuts and the help page). */
.key {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 var(--space-1);
  border: 1px solid var(--border-subtle);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-control);
  color: var(--text-default);
  font: inherit;
  font-size: 0.85em;
  line-height: 1.5;
  text-align: center;
  white-space: nowrap;
}

/* Light, dark or as the computer is set (js/theme.js): three small buttons, the chosen one marked. */
.theme-switch {
  display: inline-flex;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: var(--font-size-sm);
}

.theme-switch button {
  flex: 1;
  padding: 0.125rem var(--space-2);
  border: 0;
  border-left: 1px solid var(--border-subtle);
  background: var(--surface-control);
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.theme-switch button:first-child {
  border-left: 0;
}

.theme-switch button:hover {
  background: var(--surface-control-hover);
  color: var(--text-default);
}

.theme-switch button[aria-pressed="true"] {
  background: var(--surface-selected);
  color: var(--text-on-selected);
}

.theme-switch button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: -2px;
}

/* The editor's pages on a phone (page.js blockPhone, #469): all that is left is that it needs a bigger screen. */
.phone-block__page {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--surface-page);
  color: var(--text-default);
  font-family: var(--font-family);
}

.phone-block {
  max-width: 22rem;
  padding: var(--space-4);
  display: grid;
  gap: var(--space-4);
  text-align: center;
}

.phone-block__title {
  margin: 0;
  font-size: 1.5rem;
}

.phone-block__text {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--font-size-lg);
}

.phone-block__link {
  color: var(--text-default);
  font-size: var(--font-size-lg);
}

.phone-block__button {
  padding: var(--space-4);
  font-size: var(--font-size-lg);
  text-decoration: none;
  text-align: center;
}
