/* --- Utilities --- */

/* spinner */
.spin {
  display: inline-block;
  animation-name: spin;
  animation-duration: 1s;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* blinker */
.blink {
  display: inline-block;
  animation-name: blink;
  animation-duration: 700ms;
  animation-iteration-count: infinite;
  animation-timing-function: linear;
}
@keyframes blink {
  from {
    opacity: 0.2;
  }
  to {
    opacity: 1;
  }
}

/* --- End Utilities --- */

/* Navbar */
nav {
  background-color: var(--bg-black);
  padding: 0 var(--body-padding);
  display: flex;
}
nav > * {
  margin: var(--body-padding) 0;
}
.nav--logo {
  margin-right: var(--body-padding);
  flex: 0 0 150px;
  display: flex;
  align-items: center;
}
.nav--logo--img,
.nav--logo--favicon {
  max-width: 100%;
  display: block;
}
.nav--logo--favicon {
  display: none;
}
.nav--search-form {
  display: inline-flex;
  align-items: stretch;
}
.nav--search-form > input {
  width: 15rem;
  border-radius: var(--border-radius) 0 0 var(--border-radius);
}
.nav--search-form > button {
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}
.nav--greeting {
  color: white;
  align-items: center;
  margin-left: auto;
  margin-top: auto;
  margin-bottom: auto;
  display: flex;
  padding: 0.5rem 0 0.5rem 0.5rem;
  text-align: right;
}
.nav--greeting > button {
  margin-left: 0.5rem;
}
.nav--link {
  color: white;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  padding: 0 0.5rem;
  line-height: 1.5rem;
}
.nav--link:hover {
  color: black;
  background-color: white;
  border-radius: 4px;
}
.nav--link:last-child {
  margin-left: auto;
}
.nav--link i {
  margin-right: 0.3rem;
}

@media (max-width: 749px) {
  .nav--search-form {
    flex-basis: 100%;
  }
  .nav--search-form > input {
    width: 5rem;
    flex-grow: 1;
    flex-shrink: 1;
  }
  .nav--greeting > span b {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70px;
  }
  .nav--link:last-child {
    margin-left: 0.5rem;
  }
}

@media (max-width: 539px) {
  .nav--greeting > button > i {
    margin: 0;
  }
  .nav--greeting > button > span {
    display: none;
  }
  .nav--logo--img {
    display: none;
  }
  .nav--logo--favicon {
    display: inline;
  }
  .nav--logo {
    flex: 0 0 43px;
    margin-top: auto;
    margin-bottom: auto;
  }
}

/* Route content common styling */
#spa-root {
  display: flex;
  flex-direction: column;
}
.content {
  padding: var(--body-padding);
  flex-grow: 1;
}
.content > * {
  display: block;
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Sticky footer */
footer {
  padding: var(--body-padding);
  line-height: 1.5em;
  opacity: 0.7;
  border-top: 1px solid #ccc;
  background-color: #eee;
}
footer a {
  color: inherit;
}
html,
body {
  height: 100%;
}
body {
  display: flex;
  flex-direction: column;
}
#spa-root {
  flex: 1 0 auto;
}
footer {
  flex-shrink: 0;
}

/* Authentication route */

.auth.content {
  display: flex;
  flex-wrap: wrap;
  max-width: 700px;
  margin: auto;
  justify-content: space-evenly;
}
.auth--form {
  display: inline-flex;
  flex-direction: column;
  margin: 0.5rem;
  width: 300px;
  max-width: 100%;
}
.auth--form > * {
  margin-bottom: 0.8rem;
}
.auth--form > h1 {
  margin-bottom: 1.5rem;
}
.auth--checkbox-label {
  display: flex;
}
#auth--remember {
  margin-right: 0.3rem;
}
.auth--form--message-success {
  color: green;
}
.auth--form--message-error {
  color: red;
}

/* Follows route */

.follows.content {
  display: flex;
  flex-wrap: wrap;
}
.follows--title {
  display: flex;
  flex-direction: row;
  margin-bottom: var(--body-padding);
}
.follows--title.non-empty {
  flex-basis: 100%;
  background-color: #efefef;
}
.follows--title.empty {
  display: inline-flex;
  flex-grow: 1;
}
.follows--title.empty .chapters {
  display: none;
}

.follows--cover {
  border: 1px solid #777;
  margin-right: 0.5rem;
  max-width: 150px;
}
.follows--cover:hover {
  box-shadow: 0 0 3px black;
}

.follows--chapters {
  padding: 0.5rem 0.5rem 0.5rem 0;
}

.follows--group {
  font-size: 0.9em;
  background-color: #ddd;
  border-radius: 3px;
  white-space: nowrap;
  padding: 2px 5px;
}

@media (max-width: 399px) {
  .follows--title {
    flex-direction: column;
  }
  .follows--cover {
    border: none;
    margin: 0.5rem;
    margin-bottom: 0;
    max-width: 100%;
    max-height: 250px;
  }
  .follows--chapters {
    padding: 0.5rem;
  }
}

/* Search route */
.search--site-heading {
  text-transform: capitalize;
}
.search--results {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}
.search--result {
  display: inline-flex;
  flex-direction: column;
  border: 1px solid var(--bg-black);
  margin: 0 1rem 1rem 0;
  background-color: var(--bg-black);
  color: white;
  text-decoration: none;
  max-width: 150px;
}
.search--result span {
  padding: 0.5rem;
  width: 0;
  min-width: 100%;
}

.search--result-text {
  margin-bottom: 1rem;
}

/* Title route */
.title--cover {
  max-width: min(100%, 400px);
  border: 1px solid black;
}

.title--details {
  margin: 1rem 0;
  display: flex;
}
.title--details > * {
  margin-right: 0.3rem;
  flex-shrink: 1;
}

.title--descriptions {
  background-color: #eee;
  padding: 0.5em;
}
.title--descriptions details + br {
  display: none;
  /* Mangadex tweak:
   *
   * Their "spoiler" implementation is an inline button which doesn't naturally
   * have a line break, so description writers usually compensate by 2 <brs>.
   *
   * Ours is a bog standard <details> tag which already causes a natural line
   * break, adding to the 2 <br>s causing too much vertical whitespace. This
   * selector practically throws out the first <br> to make it look the same as
   * kissmanga's.
   *
   * Maybe the <br> should be removed in mangadex source site logic instead.
   * TODO: revisit this choice when a new source site with rich text
   * description is implemented.
   */
}

.title--chapter-row {
  display: flex;
  flex-direction: vertical;
}
.title--chapter-row > button {
  margin-bottom: 0.5rem;
  margin-right: 0.2rem;
}

@media (max-width: 399px) {
  .title--details {
    flex-direction: column;
  }
  .title--details > * {
    margin: 0 0 0.3rem 0;
  }
}

@media (min-width: 400px) and (max-width: 500px) {
  .title--details i {
    display: none;
  }
}

/* Chapter route */
.chapter.content {
  padding: var(--body-padding) 0;
  text-align: center;
  background-color: #444;
  color: white;
}

.chapter--page-container {
  transition-duration: 0.2s;
  margin: 0 auto 0.7rem auto;
  display: flex;
  justify-content: center;
}
.chapter--pages.chapter--webtoon img {
  margin: 0 auto;
}

.chapter--buttons {
  display: flex;
  flex-direction: row;
  justify-content: center;
}
.chapter--buttons > a,
.chapter--buttons > button {
  margin-right: 0.5rem;
  margin-top: 0.2rem;
  margin-bottom: 0.2rem;
}
.chapter--buttons > a:last-child,
.chapter--buttons > button:last-child {
  margin-right: 0;
}

@media (max-width: 349px) {
  .chapter--buttons > a,
  .chapter--buttons > button {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

/* Components defined in utils */
.utils--chapter {
  margin-bottom: 0.5rem;
}
.utils--chapter.read > a:before {
  content: "🗹";
  color: green;
  margin-right: 0.4rem;
  font-weight: bold;
}
.utils--chapter > a {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}
.utils--chapter--group {
  font-size: 0.7rem;
  line-height: 0.8rem;
  padding: 0.2rem;
  margin-left: 0.3rem;
  border-radius: 2px;
  border: 1px solid #aaa;
  background-color: #eee;
}
.utils--chapter--read-icon {
  color: green;
}

/* Tachiyomi importer */
input[type="file"].importer--filepicker {
  border: 2px solid black;
  border-radius: var(--border-radius);
  margin: 1rem 0;
}
.importer--success {
  color: green;
}
.importer--failure {
  color: red;
}
