/*
 * SPDX-FileCopyrightText: 2023-2025 Legadilo contributors
 *
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

:root {
  --content-footer-height: 104px;
  --content-mobile-footer-height: 248px;
  --content-header-height: 56px;
}

html {
  scroll-padding-top: var(--content-header-height);
}

.content-body {
  display: grid;
  grid-template: "main" 1fr "footer" var(--content-mobile-footer-height) / 1fr;
  min-height: 100vh;
}

.content-footer {
  height: var(--content-mobile-footer-height);
  background-color: var(--bs-dark);
}

[data-bs-theme="dark"] .content-footer {
  background-color: var(--bs-tertiary-bg);
}

.content-body > .content-main-container {
  grid-area: main;
  padding-bottom: 2rem;
}

.content-body > .content-footer {
  grid-area: footer;
}

.bi {
  display: inline-block;
  vertical-align: -0.125em;
  fill: currentcolor;
}

.btn-primary img.bi,
.btn-danger img.bi {
  filter: invert(1) !important;
}

[data-bs-theme="dark"] img.bi {
  filter: invert(0.715);
}

.htmx-indicator,
.icon-indicator .indicator {
  display: none;
  opacity: 0;
}

.htmx-request.htmx-indicator,
.htmx-request .icon-indicator .indicator {
  display: inline;
  opacity: 1;
  transition: opacity 200ms ease-in;
}

.htmx-request.icon-indicator .bi {
  display: none;
}

.htmx-request.htmx-indicator,
.htmx-request.icon-indicator .indicator {
  display: inline;
  opacity: 1;
  transition: opacity 200ms ease-in;
}

.infinite-scrolling-icon-indicator {
  height: 60px;
  text-align: center;
}

.infinite-scrolling-icon-indicator img {
  max-height: 100%;
}

.read-on-scroll-even-bottom {
  height: 100vh;
}

.article-card-container.htmx-swapping {
  opacity: 0;
  max-height: 0;
  transition:
    opacity 1s ease-out,
    max-height 1s ease-out;
}

.refresh-btn {
  right: 0.5rem;
  bottom: 0.5rem;
  width: max-content;
  margin-left: auto;
  display: block;
}

.sticky-md-top {
  top: calc(var(--content-header-height) + 0.5rem);
}

@media (width >= 768px) {
  .article-card-container {
    max-height: 500px;
  }

  .article-summary {
    max-height: 200px;
    overflow-y: hidden;
  }

  .article-summary img {
    max-height: 200px;
  }
}

@media (width >= 768px) {
  .content-body {
    grid-template: "main" 1fr "footer" var(--content-footer-height) / 1fr;
  }

  .content-footer {
    height: var(--content-footer-height);
  }
}

/* Style details/summary elements like Bootstrap accordions */
details {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  margin-bottom: 0.25rem;
}

details[name] + details[name] {
  margin-top: -1px;
  margin-bottom: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

details[name]:has(+ details[name]) {
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

details > summary {
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  background-color: var(--bs-tertiary-bg);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
}

details[open] > summary {
  border-bottom: 1px solid var(--bs-border-color);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background-color: var(--bs-primary-bg-subtle);
}

details > summary.p-2 {
  padding: 0.5rem !important;
}

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

details > summary::after {
  content: "";
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23212529'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-size: 1.25rem;
  transition: transform 0.2s ease-in-out;
  flex-shrink: 0;
}

details[open] > summary::after {
  transform: rotate(-180deg);
}

details > summary:hover {
  background-color: var(--bs-secondary-bg);
}

details > summary:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgb(var(--bs-primary-rgb), 0.25);
  background-color: var(--bs-secondary-bg);
  border-color: rgb(var(--bs-primary-rgb), 0.25);
}

[data-bs-theme="dark"] details > summary::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23dee2e6'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

/* For the theme switcher */
svg.bi {
  width: 1rem;
  height: 1rem;
}

.bd-navbar .dropdown-menu .active .bi {
  display: block !important;
}

/* Native dialog styling */
@keyframes dialog-fade-in {
  from {
    opacity: 0;
    transform: translateY(-1rem);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes dialog-fade-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-1rem);
  }
}

@keyframes backdrop-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes backdrop-fade-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

dialog {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
  padding: 0;
  min-width: min(500px, 90vw);
  animation: dialog-fade-in 0.2s ease-out;
}

dialog.closing {
  animation: dialog-fade-out 0.2s ease-in forwards;
}

dialog::backdrop {
  background-color: rgb(0 0 0 / 50%);
  animation: backdrop-fade-in 0.2s ease-out;
}

dialog.closing::backdrop {
  animation: backdrop-fade-out 0.2s ease-in forwards;
}

dialog .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--bs-border-color);
}

dialog .modal-body {
  padding: 1rem;
}

dialog .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--bs-border-color);
}

/* For the honeypot field */
input[name="email_address_confirmation"] {
  position: absolute;
  width: 0;
  height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
