/* A 90s desktop: one bevelled window on a teal background, with CGA colours for the tiers. */
:root {
  color-scheme: light dark;
  --desktop: #008080;
  --surface: #c0c0c0;
  --field: #ffffff;
  --text: #000000;
  --muted: #3f3f3f;
  --link: #0000aa;
  --danger: #a00000;
  --title-from: #000080;
  --title-to: #1084d0;
  --title-text: #ffffff;
  --progress: #000080;
  --bevel-light: #ffffff;
  --bevel-mid: #dfdfdf;
  --bevel-dark: #808080;
  --bevel-darkest: #000000;
  --tier-s: #ff5555;
  --tier-a: #ffaa33;
  --tier-b: #ffff55;
  --tier-c: #55ff55;
  --tier-d: #55ffff;
  --tier-f: #ff55ff;
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --font-body: Tahoma, Geneva, "MS Sans Serif", Verdana, sans-serif;
  --raised:
    inset -1px -1px 0 var(--bevel-darkest), inset 1px 1px 0 var(--bevel-light),
    inset -2px -2px 0 var(--bevel-dark), inset 2px 2px 0 var(--bevel-mid);
  --sunken:
    inset -1px -1px 0 var(--bevel-light), inset 1px 1px 0 var(--bevel-dark),
    inset -2px -2px 0 var(--bevel-mid), inset 2px 2px 0 var(--bevel-darkest);
}

@media (prefers-color-scheme: dark) {
  :root {
    --desktop: #003c3c;
    --surface: #2d2d3a;
    --field: #16161e;
    --text: #e6e6e6;
    --muted: #b4b4c0;
    --link: #8fb4ff;
    --danger: #ff8080;
    --title-from: #1c1c66;
    --title-to: #0f6aa8;
    --progress: #4f9be0;
    --bevel-light: #5a5a6e;
    --bevel-mid: #3e3e4c;
    --bevel-dark: #15151c;
    --bevel-darkest: #000000;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--desktop);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

::selection {
  background: var(--title-from);
  color: var(--title-text);
}

a {
  color: var(--link);
}

h1,
h2 {
  font-family: var(--font-pixel);
  font-weight: 400;
  overflow-wrap: anywhere;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1rem, 4vw, 1.5rem);
  line-height: 1.5;
}

h2 {
  margin: 2rem 0 0.75rem;
  font-size: 0.8rem;
}

/* The window */
#app > div {
  width: calc(100% - 2rem);
  max-width: 60rem;
  margin: 1.5rem auto;
  padding: 3px;
  background: var(--surface);
  box-shadow: var(--raised);
}

.site-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  min-height: 3rem;
  padding: 0.4rem 0.6rem;
  background: linear-gradient(90deg, var(--title-from), var(--title-to));
  color: var(--title-text);
}

.logo {
  font-family: var(--font-pixel);
  font-size: 1rem;
  color: var(--title-text);
  text-decoration: none;
}

.tagline,
.muted {
  font-size: 0.9rem;
}

.tagline {
  color: var(--title-text);
}

.muted {
  color: var(--muted);
}

/* Logging in and out, on the right of the title bar. */
.account {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  color: var(--title-text);
  font-size: 0.9rem;
}

.account a {
  color: var(--title-text);
  white-space: nowrap;
}

.account button {
  padding: 0.2rem 0.6rem;
  white-space: nowrap;
}

main {
  padding: 1.5rem 1rem 3rem;
}

/* Loading screen. Python keeps the main thread busy while it starts, so these animations stick to
   opacity and transform, which browsers can keep running on the compositor. */
.boot {
  display: grid;
  justify-items: center;
  gap: 1.25rem;
  padding: 3rem 1rem;
  text-align: center;
}

.boot p {
  margin: 0;
}

.boot-tiers {
  display: flex;
  gap: 0.5rem;
}

.boot-tiers span {
  display: grid;
  place-items: center;
  width: clamp(2.25rem, 11vw, 3.5rem);
  aspect-ratio: 1;
  color: #000000;
  font-family: var(--font-pixel);
  font-size: clamp(0.8rem, 3.5vw, 1.25rem);
  box-shadow:
    inset -2px -2px 0 rgb(0 0 0 / 45%),
    inset 2px 2px 0 rgb(255 255 255 / 70%);
  opacity: 0.3;
  animation: boot-tier 1.8s linear infinite;
  will-change: opacity, transform;
}

.boot-tiers span:nth-child(1) {
  background: var(--tier-s);
}

.boot-tiers span:nth-child(2) {
  background: var(--tier-a);
  animation-delay: 0.2s;
}

.boot-tiers span:nth-child(3) {
  background: var(--tier-b);
  animation-delay: 0.4s;
}

.boot-tiers span:nth-child(4) {
  background: var(--tier-c);
  animation-delay: 0.6s;
}

.boot-tiers span:nth-child(5) {
  background: var(--tier-d);
  animation-delay: 0.8s;
}

.boot-tiers span:nth-child(6) {
  background: var(--tier-f);
  animation-delay: 1s;
}

@keyframes boot-tier {
  0%,
  45%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }

  10% {
    opacity: 1;
    transform: translateY(-0.4rem);
  }

  25% {
    opacity: 1;
    transform: translateY(0);
  }
}

.boot-title {
  font-family: var(--font-pixel);
  font-size: clamp(0.8rem, 3.5vw, 1.1rem);
}

.boot-bar {
  width: min(100%, 24rem);
  height: 1.5rem;
  padding: 4px;
  overflow: hidden;
  background: var(--field);
  box-shadow: var(--sunken);
}

.boot-bar span {
  display: block;
  width: 35%;
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--progress) 0 0.6rem, transparent 0 0.75rem);
  animation: boot-bar 1.8s steps(24) infinite;
  will-change: transform;
}

@keyframes boot-bar {
  from {
    transform: translateX(-100%);
  }

  to {
    transform: translateX(286%);
  }
}

/* Wybthon's "couldn't start" message, which replaces everything above. */
#app > #wyb-loading:not(:has(*)) {
  padding: 3rem 1rem;
  color: var(--danger);
  font-weight: 700;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .boot-tiers span,
  .boot-bar span {
    animation: none;
    opacity: 1;
  }

  .boot-bar span {
    width: 100%;
  }
}

/* Forms and buttons */
.text-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.text-form input {
  flex: 1 1 14rem;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  font: inherit;
  color: inherit;
  background: var(--field);
  border: 0;
  border-radius: 0;
  box-shadow: var(--sunken);
}

/* The main button of each form, outlined like a dialog's default button. */
button {
  padding: 0.45rem 0.9rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--text);
  border-radius: 0;
  box-shadow: var(--raised);
  cursor: pointer;
}

button:active:not(:disabled),
button[aria-pressed="true"] {
  box-shadow: var(--sunken);
}

button:active:not(:disabled) {
  padding: calc(0.45rem + 1px) calc(0.9rem - 1px) calc(0.45rem - 1px) calc(0.9rem + 1px);
}

button:disabled {
  color: var(--bevel-dark);
  text-shadow: 1px 1px 0 var(--bevel-light);
  cursor: default;
}

button.secondary,
button.danger {
  border-color: transparent;
}

button.secondary[aria-pressed="true"] {
  background: repeating-conic-gradient(var(--bevel-light) 0 25%, var(--surface) 0 50%) 0 0 / 2px 2px;
}

button.danger {
  color: var(--danger);
}

.error {
  flex-basis: 100%;
  margin: 0.25rem 0;
  color: var(--danger);
  font-size: 0.9rem;
  font-weight: 700;
}

/* Logging in */
.login {
  max-width: 26rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 700;
}

.login-form input {
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-weight: 400;
  color: inherit;
  background: var(--field);
  border: 0;
  border-radius: 0;
  box-shadow: var(--sunken);
}

.login-form button {
  align-self: flex-start;
}

.login-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.notice {
  margin: 0.25rem 0;
  font-weight: 700;
}

/* Lists of categories and rankings */
.card-list {
  display: grid;
  margin: 0;
  padding: 2px;
  list-style: none;
  background: var(--field);
  box-shadow: var(--sunken);
}

.card-list > .muted {
  margin: 0;
  padding: 0.6rem 0.75rem;
}

.card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.75rem;
}

.card + .card {
  border-top: 1px dotted var(--bevel-dark);
}

.card a {
  font-weight: 700;
}

.score {
  font-family: var(--font-pixel);
  font-size: 0.75rem;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.6rem;
  background: var(--surface);
  box-shadow: var(--raised);
  font-size: 0.9rem;
}

.pill .pill-delete,
.pill .pill-delete:active:not(:disabled) {
  display: grid;
  place-items: center;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  line-height: 1;
}

@media (pointer: coarse) {
  .pill .pill-delete,
  .pill .pill-delete:active:not(:disabled) {
    width: 2rem;
    height: 2rem;
  }
}

/* Page header */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.votes {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Tier board */
.board {
  display: grid;
  gap: 2px;
  padding: 2px;
  background: var(--bevel-dark);
  box-shadow: var(--sunken);
}

.tier {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  min-height: 4.5rem;
  background: var(--surface);
}

.tier-label {
  display: grid;
  place-items: center;
  margin: 0;
  font-size: 1.5rem;
  color: #000000;
  box-shadow:
    inset -2px -2px 0 rgb(0 0 0 / 45%),
    inset 2px 2px 0 rgb(255 255 255 / 70%);
}

.tier-S .tier-label {
  background: var(--tier-s);
}

.tier-A .tier-label {
  background: var(--tier-a);
}

.tier-B .tier-label {
  background: var(--tier-b);
}

.tier-C .tier-label {
  background: var(--tier-c);
}

.tier-D .tier-label {
  background: var(--tier-d);
}

.tier-F .tier-label {
  background: var(--tier-f);
}

.tier-unranked {
  grid-template-columns: minmax(0, 1fr);
  margin-top: 1rem;
  box-shadow: var(--sunken);
}

.tier-unranked .tier-label {
  place-items: start;
  padding: 0.75rem 0.75rem 0;
  font-size: 0.65rem;
  color: var(--muted);
  box-shadow: none;
}

.tier-items {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.5rem;
  margin: 0;
  padding: 0.75rem;
  list-style: none;
}

.tier.is-over .tier-items {
  background: var(--field);
  outline: 2px dashed var(--text);
  outline-offset: -4px;
}

.chip {
  padding: 0.4rem 0.75rem;
  overflow-wrap: anywhere;
  background: var(--surface);
  box-shadow: var(--raised);
  user-select: none;
}

.chip.is-editable {
  cursor: grab;
}

.chip.is-held {
  background: var(--title-from);
  color: var(--title-text);
  box-shadow: var(--sunken);
}

.chip:focus-visible,
button:focus-visible {
  outline: 2px dotted currentColor;
  outline-offset: -5px;
}

input:focus-visible,
a:focus-visible {
  outline: 2px dotted currentColor;
  outline-offset: 2px;
}

input:focus-visible {
  outline-offset: -5px;
}

@media (max-width: 30rem) {
  #app > div {
    width: calc(100% - 1rem);
    margin: 0.5rem auto;
  }

  .tier:not(.tier-unranked) {
    grid-template-columns: 3rem minmax(0, 1fr);
  }

  .tier:not(.tier-unranked) .tier-label {
    font-size: 1.1rem;
  }
}
