:root {
  --body-color: #212529;
  --move-btn-width: 60px;
  --move-btn-height: 34px;
  --focus-ring: 0 0 0 0.2rem var(--bs-focus-ring-color);
  --focus-ring-error: 0 0 0 0.2rem rgba(var(--bs-danger-rgb), 0.4);

  accent-color: var(--bs-primary);
  font-size: 14px;
}

:not(:defined) {
  display: none !important;
}

body {
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

a:focus-visible,
details summary:focus-visible {
  outline: 0;
  border-radius: var(--bs-border-radius);
  box-shadow: var(--focus-ring);
  transition: box-shadow 0.15s ease-in-out;
}

.container {
  max-width: 1500px;
}

.site-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  row-gap: 0.5rem;
  margin: 3rem 0.5rem;
  text-align: center;
}

.page-title {
  font-weight: 300;
  margin-bottom: 0;
}

.form-control:out-of-range {
  border-color: var(--bs-form-invalid-border-color);
  color: var(--bs-form-invalid-color);
}

.form-control:out-of-range:focus {
  box-shadow: var(--focus-ring-error);
}

/* Canvas */
.canvas {
  display: block;
  max-width: 100%;
}

/* Inputs */
.textboxes-container input[type="color"],
.settings-button,
.duplicate-button {
  min-width: 30px;
  width: 30px;
  height: 30px;
  margin: 0 2px;
  padding: 0;
  line-height: 1;
  cursor: pointer;
}

.textboxes-container .meme-text {
  min-width: 0;
  min-height: calc(1.5em + 0.75rem + 2px);
  max-height: 60px;
  margin: 0.5rem;
  overflow-x: hidden; /* Fix for Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=33654 */
  scrollbar-width: thin;
  field-sizing: content;
}

#maxImageDimensionsForm select:disabled {
  text-indent: -9999px;
  opacity: 0.7;
}

/* Buttons */
.settings-button {
  background-image: url(../assets/icons/gear.svg);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 64%;
}

.clear-canvas-button {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem;
  transition: opacity 0.15s ease-in-out, visibility 0.15s ease-in-out;
}

@media (hover: hover) {
  .clear-canvas-button {
    opacity: 0;
    visibility: hidden;
  }

  .dropzone:hover .clear-canvas-button {
    opacity: 1;
    visibility: visible;
  }
}

/* Misc */
.textboxes-container {
  flex: 1;
}

.textboxes-container:empty {
  display: none;
}

.instructions {
  display: flex;
  flex-direction: column;
  row-gap: 1rem;
  justify-content: center;
  align-items: center;
  min-height: 200px;
  height: 100%;
  padding: 1rem;
  text-align: center;
  text-wrap: balance;
  background-color: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
}

.instructions__image {
  width: 60px;
  height: 60px;
  background-size: 100%;
  background-repeat: no-repeat;
  background-image: url(../assets/icons/add-image-light.svg);
}

:root[data-bs-theme="dark"] .instructions__image {
  content: url(../assets/icons/add-image-dark.svg);
}

.errors-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1051;
  pointer-events: none;
}

.errors-container .alert {
  pointer-events: all;
}

details > summary {
  transition: margin 0.1s ease-out;
}

details[open] > summary {
  margin-bottom: 0.5rem;
}

button[data-button="duplicate-text-box"],
button[data-button="delete-text-box"] {
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  margin-inline-start: 0.5rem;
  background-repeat: no-repeat;
  background-size: 90%;
  background-position: center;
}

button[data-button="duplicate-text-box"] {
  background-image: url(../assets/icons/duplicate-light.svg);
  background-size: 70%;
}

:root[data-bs-theme="dark"] button[data-button="duplicate-text-box"] {
  background-image: url(../assets/icons/duplicate-dark.svg);
}

button[data-button="delete-text-box"] {
  background-image: url(../assets/icons/trash.svg);
  margin-inline-start: 0.25rem;
}

/* Gallery */
.gallery {
  display: flex;
  gap: 0.5rem;
  margin: 0;
  padding: 0.25rem 0;
  overflow-x: auto;
  min-height: 112px;
  scroll-behavior: smooth;
}

.gallery > button {
  padding: 0;
  cursor: pointer;
}

.gallery > button > img {
  display: block;
  min-width: 88px;
  height: 88px;
  border-radius: var(--bs-border-radius);
  object-fit: cover;
}

.gallery__no-results {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  text-align: center;
}

/* Move text actions */
.move-text-actions {
  position: relative;
  width: calc(var(--move-btn-width) * 3);
  height: calc(var(--move-btn-height) * 2);
  margin: 0 auto;
}

.move-text-actions > button {
  position: absolute;
  width: var(--move-btn-width);
  height: var(--move-btn-height);
  background-position: center;
  background-repeat: no-repeat;
}

/* UP */
.move-text-actions > [aria-label="Up"] {
  top: -1px;
  left: var(--move-btn-width);
  background-image: url(../assets/icons/chevron-up.svg);
}

/* DOWN */
.move-text-actions > [aria-label="Down"] {
  top: calc(var(--move-btn-height) + 1px);
  left: var(--move-btn-width);
  background-image: url(../assets/icons/chevron-down.svg);
}

/* LEFT */
.move-text-actions > [aria-label="Left"] {
  top: calc(var(--move-btn-height) / 2);
  left: -2px;
  background-image: url(../assets/icons/chevron-left.svg);
}

/* RIGHT */
.move-text-actions > [aria-label="Right"] {
  top: calc(var(--move-btn-height) / 2);
  left: calc(var(--move-btn-width) * 2 + 2px);
  background-image: url(../assets/icons/chevron-right.svg);

}

/* capture-photo */
capture-photo {
  position: relative;
  overflow: hidden;
}

capture-photo::part(capture-button) {
  display: none;
}

capture-photo::part(video) {
  width: 100%;
  border-radius: calc(var(--bs-border-radius) / 2);
}

capture-photo[loading]::part(video) {
  background-color: #000000;
  background-image: url(../assets/icons/spinner.svg);
  background-size: 60px;
  background-position: center center;
  background-repeat: no-repeat;
}

capture-photo [slot="actions"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem;
}

capture-photo[loading] [slot="actions"] {
  display: none !important;
}

/* Modal */

modal-element {
  --me-width: fit-content;
  --me-border-radius: var(--bs-border-radius);
  --me-border-width: 1px;
  --me-border-color: var(--bs-border-color);
  --me-box-shadow: 0 0 1rem 0 rgba(0, 0, 0, 0.30);
  --me-backdrop-background: rgba(0, 0, 0, 0.7);
  --me-backdrop-filter: blur(2px);
}

#videoModal {
  --me-width: 600px;
}

#videoModal::part(footer) {
  padding-block: 0;
}

#videoModal:has(capture-photo[loading]) #capturePhotoButton {
  pointer-events: none;
  opacity: 0.7;
}

#downloadModal {
  --me-width: 800px;
}

modal-element::part(base):focus-visible {
  outline: 0;
}

modal-element [slot="header"] {
  margin: 0;
  color: var(--bs-body-color);
}

modal-element::part(close) {
  color: var(--bs-body-color);
  border-radius: var(--bs-border-radius);
  transition: box-shadow 0.15s ease-in-out;
}

modal-element::part(close):focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

modal-element::part(body) {
  padding-block: 0;
}

modal-element [slot="footer"] {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
  text-align: center;
}

/* Files dropzone */
.dropzone {
  --dropzone-border-color: var(--bs-secondary);
  --dropzone-border-color-hover: var(--bs-primary);
  --dropzone-border-color-dragover: var(--bs-primary);
  --dropzone-background-color-hover: var(--bs-light);
  --dropzone-background-color-dragover: var(--bs-light);
  --dropzone-focus-box-shadow: var(--focus-ring);

  position: relative;
  height: 100%;
}

@media screen and (min-width: 768px) {
  .meme-column {
    border-inline-end: 1px solid var(--bs-border-color);
  }

  .dropzone {
    position: sticky;
    top: 0.25rem;
  }
}

.dropzone:not(.dropzone--accepted) {
  max-height: 41rem;
}

.dropzone--accepted {
  width: fit-content;
  height: fit-content;
}

.dropzone::part(dropzone) {
  height: 100%;
  padding: 0;
}

.dropzone[disabled]::part(dropzone) {
  opacity: 1;
  cursor: default;
}

/* Emoji picker */
.emoji-picker-details {
  margin-bottom: 0.5rem;
  background-color: var(--bs-body-bg);
  border-radius: var(--bs-border-radius);
  border: 1px solid var(--bs-border-color);
}

.emoji-picker-details > summary {
  padding: 0.5rem 1rem;
  background-color: var(--bs-body-bg);
  border-radius: var(--bs-border-radius);
  cursor: pointer;
}

.emoji-picker-details[open] > summary {
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

emoji-picker {
  --border-color: var(--bs-border-color);
  --background: var(--bs-bg);
  --input-border-color: var(--bs-border-color);
  --input-border-radius: var(--bs-border-radius);
  --input-padding: 0.375rem 0.75rem;
  --outline-color: #0d6efd40;
  --outline-size: 4px;
  --indicator-color: var(--bs-primary);
  --button-hover-background: var(--bs-gray-300);
  --input-font-color: var(--bs-body-color);

  width: 100%;
  height: 255px;
  padding: 0 0.5rem 0.5rem 0.5rem;
}

/* Theme toggle */
theme-toggle {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

theme-toggle::part(base) {
  padding: 0.5rem;
  border-radius: var(--bs-border-radius);
  font-size: 1.1429rem;
  transition: background-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

theme-toggle::part(base):focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

/* Utils */

.text-underline {
  text-decoration: underline;
}
