:root {
  --background: #202028;
  --text: white;
  --accent: #A040FF;
  --accent-border: 0.3rem solid var(--accent);
  --input: #00000090;
  --dropdown: #35353FF0;
  --box: #101012;
  --code-spacing: 0.2em;
  --content-max-width: 800px;
  --rounded-radius: 10px;
  --small-gap: 2px;
  --control-button-size: 95px;
}

html, body {
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 14pt;
  font-family: 'Ubuntu', -apple-system, BlinkMacSystemFont, 'Roboto', 'Helvetica Neue', 'Nanum Gothic', sans-serif;
  color: var(--text);
  background-color: var(--background);
  transition: background-color 0.5s;
  /* Prevent the stupid blue boxes on Android */
  -webkit-tap-highlight-color: transparent;
  /* Prevent double-tap zoom on iOS */
  touch-action: pan-y;
}

.monospace {
  font-family: 'Liberation Mono', 'Roboto Mono', 'SF Mono', monospace;
}

body {
  overflow-y: auto;
}

.root {
  display: flex;
  box-sizing: border-box;
  flex-direction: column;
  align-items: center;
  justify-content: stretch;
  padding: 20px 30px;
  max-width: var(--content-max-width);
  height: 100%;
  /* looks bad until queue box height is also animated
  transition: width 0.2s ease-in-out;
  */
  width: 400px;
}

.queue-has-items .root {
  width: 100%;
}

@media (max-width: 520px) {
  .root {
    width: 100%;
  }
}

.background-flash {
  background-color: var(--accent);
  transition: none;
}

.h-box {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: var(--small-gap);
}

.v-box {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

input, button, .fake-button {
  all: unset;
  box-sizing: border-box;
  background-color: var(--input);
  border-radius: var(--rounded-radius);
  border-style: none;
  padding: 5px;
}

input {
  flex-grow: 1;
  min-width: 2em;
}

::placeholder {
  color: var(--text);
  opacity: 0.4;
}

:focus::placeholder {
  opacity: 0.5;
}

a {
  color: #60D0FF;
  text-decoration: none;
}

p {
  margin: auto 0;
}

button, .fake-button {
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  user-select: none;
  text-align: center;
  text-decoration: none;
  flex-grow: 0;
  padding: 12px 14px;
  transition: all 0.05s;
  flex-shrink: 0;
}

.go-btn {
  min-width: 2em;
  min-height: 40px;
  font-size: 16pt;
  transform: scale(1);
}

.control-icon {
  height: 1.5em;
}

.button-icon {
  height: 1em;
}

.dropdown-menu {
  display: flex;
  flex-direction: column;
  /* this will get set by javascript when shown, but setting it here prevents a ghost scroll bar appearing in the
   * android webview */
  top: 0;
  left: 0;
  position: absolute;
  background: var(--dropdown);
  transition: opacity 0.06s, transform 0.06s;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-20px);
  min-width: 150px;
  border-radius: var(--rounded-radius);
  overflow: hidden;
  border-top-right-radius: 0;
}

.dropdown-menu > * {
  border-radius: 0;
  font-size: 15pt;
}

.active > .dropdown-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.dropdown-menu > button, .dropdown-menu > .fake-button {
  padding: 10px 10px;
  background: none;
  white-space: nowrap;
}

.go-btn:focus-visible,
.dropdown-menu > button:hover,
.dropdown-menu > .fake-button:hover,
.dropdown-menu > :focus-visible ,
.selectable-item:hover,
.selectable-item:focus-visible {
  background: var(--accent);
  outline: none;
}

.selectable-item:has(button:hover) {
  background: initial;
}

.list-box {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  background: var(--box);
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
}

.scroll-box, .queue-box {
  overflow-y: auto;
  flex-shrink: 1;
}

.page-spacer {
  flex-basis: 30px;
  transition: all 0.2s ease-out;
  flex-grow: 0;
  flex-shrink: 2;
}

.rounded {
  border-radius: var(--rounded-radius);
}

/* stretch out control on touch screens to make the play/pause buttons easier to reach */
@media (pointer: coarse) {
  .page-spacer {
    flex-basis: 0;
    transition: all 0.3s ease-in;
    flex-grow: 1;
  }
}

.queue-box {
  display: none;
  padding: 12px 0;
  gap: 8px;
}

.queue-has-items .queue-box {
  display: flex;
}

.queue-box > * {
  margin-left: 14px;
  margin-right: 12px;
}

.queue-item {
  font-size: 16pt;
  display: flex;
  align-items: center;
  gap: 12px;
}

#queue-item-buttons {
  display: flex;
  min-width: min-content;
  gap: var(--small-gap);
  overflow: hidden;
  border-radius: var(--rounded-radius);
}

#queue-item-buttons .go-btn {
  border-radius: 0;
}

.queue-item-name {
  font-size: 14pt;
  display: flex;
  flex-grow: 1;
  flex-shrink: 1;
  overflow: hidden;
}

/* On touch devices, hover is emulated (poorly) and so it becomes sticky.
 * This prevents that */
@media (hover: hover) {
  .go-btn:hover {}
  .control:hover {}
}

.control-box, .control {
  min-width: var(--control-button-size);
  min-height: var(--control-button-size);
  flex-basis: calc(var(--control-button-size) + 80px);
  flex-shrink: 2;
}

.control-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

#tv-controls {
  --accent: var(--text);
}

.control {
  align-items: center;
  justify-content: center;
  border-radius: var(--control-button-size);
  font-size: calc(var(--control-button-size) / 2);
  width: var(--control-button-size);
  height: var(--control-button-size);
  background-color: transparent;
  border-color: var(--accent);
  color: var(--accent);
  transition: all 0.1s;
  transform: scale(1);
}

.control:after,
.control:before {
  content: "";
  display: block;
  border-radius: var(--control-button-size);
  position: absolute;
  left: 10%;
  top: 10%;
  width: 80%;
  height: 80%;
  opacity: 0;
}

.control:after {
  transition: all 0.3s, background-color 0s;
  box-shadow: 0 0 0.8em 0.3em var(--accent);
  background-color: color-mix(in srgb, var(--accent) 70%, transparent);
}

.control:before {
  background-color: color-mix(in srgb, var(--accent) 20%, transparent);
}

.control.fake-active:after {
  box-shadow: 0 0 0 0 var(--accent);
  opacity: 1;
  transition: all 0s;
}

.control:focus-visible:before {
  opacity: 1;
  transition: opacity 0s;
}

/* On touch devices give feedback for press before click is released */
@media (pointer: coarse) {
  .control:active:before {
    opacity: 0.5;
    transition: opacity 0s;
  }
}


.not-connected .only-when-connected,
.is-connected .only-when-disconnected,
.autoconnect-is-possible-or-connected .only-when-autoconnect-impossible,
.autoconnect-not-possible-or-connected .only-when-autoconnect-possible {
  display: none;
}

#peer-id-div {
  border-bottom: var(--accent-border);
  border-radius: var(--rounded-radius) var(--rounded-radius) 0 0;
  overflow: hidden;
  flex-shrink: 0;
}

.pairing-elem {
  border-radius: 0;
}

#peer-id-input {
  text-transform: uppercase;
  text-align: center;
  flex-grow: 0;
  flex-basis: 0;
  width: 0;
  min-width: 5em;
  letter-spacing: var(--code-spacing);
  /* we have to indent by the same amount as letter-spacing to make centering work,
   * because first char doesn't have spacing applied to left side. */
  text-indent: var(--code-spacing);
}

.is-connected #peer-id-input {
  border-style: none;
  line-height: 0;
}

.pairing-elem {
  font-size: 22pt;
  height: 2em;
}

.is-connected .pairing-elem {
  font-size: 20pt;
}

.status-box {
  position: relative; /* for positioning the #status-overlay */
  width: 100%;
  margin: 0 30px;
  margin-top: 10px;
  transition: margin 0.05s;
}

.not-connected .status-box {
  margin-top: 40px;
}

.status {
  text-align: center;
  font-size: 18pt;
  width: 100%;
}

#status-overlay {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
}

#queue-media-div {
  width: 100%;
  max-height: 100%;
  gap: var(--small-gap);
  border-radius: var(--rounded-radius);
}

/* It seems we can't make the queue scroll without the media div (including the buttons) getting completely shrunk if
 * there isn't enough space. To fix that we set explicit minimum sizes depending on if there are items in the queue or
 * not. However sometimes these sizes will be a bit biffer than the actual media div contents. If we set the explicit
 * sizes on the media div we would lose the rounded corners it provides in this case, so we wrap it in a container and
 * set the size on that.
 */
#queue-media-container {
  --button-height: 40px;
  width: 100%;
  min-height: var(--button-height);
  overflow: hidden;
}

.queue-has-items #queue-media-container {
  min-height: calc(var(--button-height) + 90px);
}

#queue-media-div > *, #media-input {
  border-radius: 0;
}

#media-div {
  width: 100%;
  height: var(--button-height);
  flex-shrink: 0;
}

.add-media-btn {
  flex-grow: 1;
  font-size: 20pt;
  border-radius: 0;
}

.progress-hitbox {
  width: calc(100% - 4px); /* congrats, you'll never be able to un-see this, but it makes it look better */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 0;
  margin-top: 0;
  opacity: 0;
  /* transition: height 0.07s ease-in, margin-top 0.07s ease-in, opacity 0.07s; */
  flex-shrink: 0;
}

.progress-hitbox.shown {
  height: 40px;
  margin-top: -15px;
  opacity: 1;
}

.progress-container {
  background: var(--input);
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar {
  background: var(--accent);
  border-radius: 10px;
  height: 10px;
  width: 0;
}

.full-page-shade {
  flex-direction: column;
  position: fixed;
  align-items: center;
  pointer-events: none;
  background: var(--input);
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: clip;
  justify-content: center;
}

#popup-container {
  display: flex;
  pointer-events: auto;
}

#popup-container::before {
  content: "";
  flex-grow: 1;
}

#popup-container::after {
  content: "";
  flex-grow: 2;
}

.popup-body {
  display: flex;
  flex-direction: column;
  margin: 20px;
  padding: 10px;
  padding-bottom: 8px;
  gap: 8px;
  overflow: hidden;
  max-width: min(var(--content-max-width), 85vw);
  background: var(--background);
  border-radius: 1em;
}

.error-message {
  margin: 10px
}

.selectable-item {
  display: flex;
  cursor: pointer;
  flex-direction: row;
  padding: 5px 7px;
  gap: 7px;
}

.file-browser-container {
  width: min(calc(var(--content-max-width) - 200px), 85vw);
  gap: var(--small-gap);
  border-radius: var(--rounded-radius);
  overflow: hidden;
}

.file-browser-header {
  justify-content: start;
  min-height: 45px;
}

.file-browser-header-buttons {
  flex-shrink: 0;
  border-top-right-radius: var(--rounded-radius);
  overflow: hidden;
}

.file-browser-header button,
.file-browser-header input {
  border-radius: 0;
}

.file-browser-header > p {
  margin-left: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

#file-browser-item-list.no-search-bar {
  border-top-right-radius: var(--rounded-radius);
}

#file-browser-item-icon {
  font-size: 26pt;
}

#file-browser-item-name {
  font-size: 12pt;
}

#track-list {
  min-width: 210px;
  border-radius: var(--rounded-radius);
}

#track-type {
  margin: 5px 2px 10px 2px;
}

.retry-btn-div {
  flex-basis: 200px;
  margin-top: 30px;
  flex-shrink: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.dismiss-div {
  position: absolute;
  background: transparent;
  top: 0;
  width: 100%;
  height: 100%;
}
