/*
 * A page that is still loading (docs/site-overlay.md, js/site-loading.js): a spinner in the entry pane's
 * message and a placeholder in the empty list. Sizes are in px: the fork's root font size is 10px. Written
 * with logical properties, as the fork's mirrored .rtl.css does not cover this folder.
 */

@keyframes site-loading-spin {
  to {
    transform: rotate(1turn);
  }
}

/* The message is a table cell, so the spinner is an inline box beside the text rather than a flex item. */
.site-loading-message {
  text-align: center;
  font-size: 18px;
}

.site-loading-message::before {
  content: "";
  display: inline-block;
  inline-size: 18px;
  block-size: 18px;
  margin-inline-end: 10px;
  vertical-align: middle;
  border: 2px solid currentcolor;
  border-block-start-color: transparent;
  border-radius: 50%;
  opacity: 0.7;
  animation: site-loading-spin 0.8s linear infinite;
}

.site-loading-message--stopped::before {
  display: none;
}

/* The list is empty until the fork has fetched the data and built the rows. */
:root[data-site-loading] #listcontainer .list:empty::before {
  content: "در حال بارگذاری فهرست…";
  display: block;
  padding: 24px 12px;
  text-align: center;
  opacity: 0.7;
}

@media (prefers-reduced-motion: reduce) {
  .site-loading-message::before {
    animation-duration: 3s;
  }
}

/*
 * What the service worker's page script says (sw-injector.js): the reader is offline and asked for something never
 * opened, or a preload ended. Above the fork's windows, below nothing; it removes itself.
 */
.site-offline-notice {
  position: fixed;
  inset-block-end: 16px;
  inset-inline: 16px;
  z-index: 10000;
  max-inline-size: 520px;
  margin-inline: auto;
  padding: 10px 16px;
  border-radius: 6px;
  background: #2b2f36;
  color: #f2f2f2;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  box-shadow: 0 2px 10px rgb(0 0 0 / 40%);
}

/*
 * The lost connection to the site (sw-injector.js). In the page's place, under the navbar, when the page could not
 * load what it needs: what it drew is held back, so a half-drawn page is not taken for the page. As a bar at the foot
 * over a page that has loaded. It stays until the site answers again.
 */
/* Unlayered, so it wins over the fork's styles, which are all in `@layer vetools`. */
[data-site-held] {
  display: none;
}

.site-connection {
  color: var(--rgb-font);
  line-height: 1.7;
}

.site-connection > strong {
  display: block;
  font-size: 1.15em;
}

.site-connection > p {
  margin: 4px 0 0;
}

.site-connection__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-block-start: 12px;
}

.site-connection--page {
  max-inline-size: 640px;
  margin: 48px auto;
  padding: 24px;
  border: 1px solid var(--rgb-border--statblock);
  border-radius: 6px;
  background: var(--rgb-bg--alt);
}

.site-connection--bar {
  position: fixed;
  inset-block-end: 0;
  inset-inline: 0;
  z-index: 10000;
  padding: 10px 16px calc(10px + var(--safe-area-inset-bottom, 0px));
  border-block-start: 2px solid var(--rgb-border--statblock);
  background: var(--rgb-bg--alt);
  box-shadow: 0 -2px 10px rgb(0 0 0 / 30%);
}

.site-connection--bar > p {
  display: inline;
  margin-inline-start: 8px;
}

.site-connection--bar > strong {
  display: inline;
  font-size: 1em;
}

.site-connection--bar .site-connection__actions {
  display: inline-flex;
  margin-block-start: 0;
  margin-inline-start: 12px;
  vertical-align: middle;
}

@media screen and (width <= 768px) {
  .site-connection--page {
    margin: 24px 16px;
  }

  .site-connection--bar .site-connection__actions {
    display: flex;
    margin-block-start: 8px;
    margin-inline-start: 0;
  }
}

/*
 * A deployed build ready behind the page (sw-injector.js): offered at the top, where upstream's toast was, and kept
 * until the reader updates or closes it. Clear of the foot, where the connection bar and the notices are.
 */
.site-update {
  position: fixed;
  inset-block-start: 16px;
  inset-inline: 16px;
  z-index: 10000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
  max-inline-size: 560px;
  margin-inline: auto;
  padding: 10px 16px;
  border: 1px solid var(--rgb-border--statblock);
  border-radius: 6px;
  background: var(--rgb-bg--alt);
  color: var(--rgb-font);
  line-height: 1.7;
  box-shadow: 0 2px 10px rgb(0 0 0 / 30%);
}

.site-update > p {
  margin: 0;
}

.site-update__actions {
  display: flex;
  gap: 8px;
}

/* The reader's contents stay in place as chapters change. The same action sits inside the contents sheet on phones. */
.site-volume-download {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65em;
  position: relative;
  margin: 6px 4px;
  padding: 9px 12px;
  min-block-size: 44px;
  flex-shrink: 0;
  border: 1px solid var(--rgb-border--statblock);
  border-radius: 5px;
  color: inherit;
  background: var(--rgb-bg--alt);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
}

.site-volume-download[hidden] {
  display: none;
}

.site-volume-download:hover:enabled,
.site-volume-download:focus-visible {
  border-color: currentColor;
}

.site-volume-download:disabled {
  cursor: default;
}

.site-volume-download[data-state="downloading"]::after {
  content: "";
  position: absolute;
  inset-block-end: 0;
  inset-inline-start: 0;
  inline-size: var(--volume-progress);
  block-size: 3px;
  background: currentColor;
}
