/* Skal styles, loaded after site.css */
:root {
  /* Width of the comic, the archive and the author notes */
  --comic-width: 900px;
  --reading-controls-width: 4.5rem;
}

body {
  max-width: none;
  margin: 0;
}

.site-header img {
  display: block;
}

h2 {
  margin-top: 2rem;
}

.menu {
  width: 98%;
}

#showComic,
header {
  font-family: var(--font-body);
}

.writePageTitle h1 {
  font-style: italic;
  font-weight: 700;
}

/* Content pages and archive */
header {
  text-align: center;
}

#authorNotes {
  font-family: var(--font-body);
  font-size: large;
  line-height: 1.55;
}

.archivePage {
  width: var(--comic-width);
  max-width: 100%;
  margin: 0 auto 1rem;
  padding: 1.5rem;
  border: 1px solid var(--content-border);
  border-radius: var(--corner-radius);
  background: var(--panel-background);
  text-align: center;
}

/* Archive navigation */
#nav {
  font-size: 20px;
  width: 98%;
  margin: auto;
}

#showComic {
  width: var(--comic-width);
  max-width: 98%;
  text-align: center;
  margin: 0 auto 1rem;
  padding: 1.5rem;
  border: 1px solid var(--content-border);
  border-radius: var(--corner-radius);
  background: var(--panel-background);
}

#showComic #authorNotes {
  width: 100%;
  max-width: none;
  margin: 1rem 0 0;
  padding: 0;
}

.comicNav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  padding: 10px 0px;
}

.comic-nav-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 var(--control-size);
  width: var(--control-size);
  height: var(--control-size);
  border: 1px solid var(--accent-color);
  border-radius: 50%;
  color: var(--on-accent-color);
  background: var(--accent-color);
  font-size: 1rem;
  line-height: 1;
  text-decoration: none;
  transition:
    background-color var(--transition-fast) ease,
    color var(--transition-fast) ease,
    transform var(--transition-fast) ease;
}

.site-icon {
  display: inline-block;
}

.comic-nav-button:hover {
  color: var(--accent-color);
  background: var(--panel-background);
  transform: scale(1.05);
}

.comic-nav-button[aria-pressed="true"] {
  color: var(--accent-color);
  background: var(--panel-background);
}

.comic-nav-button.is-disabled {
  opacity: 0.35;
  cursor: default;
}

.comicPage img {
  width: var(--comic-width);
  max-width: 98%;
  height: auto;
}

/* Reading mode */
#showComic.is-height-fitted .comicPage img {
  width: auto;
  max-width: calc(100vw - 20px);
  height: calc(100svh - 20px);
  max-height: calc(100svh - 20px);
  object-fit: contain;
}

body:has(#showComic.is-height-fitted) {
  overflow: hidden;
}

body:has(#showComic.is-height-fitted) .writeHeader,
body:has(#showComic.is-height-fitted) .writeFooter,
body:has(#showComic.is-height-fitted) .writePageTitle,
body:has(#showComic.is-height-fitted) .writeNav,
body:has(#showComic.is-height-fitted) #authorNotes {
  display: none;
}

.readingControls {
  display: none;
}

/* Reading mode controls */
body:has(#showComic.is-height-fitted) .readingControls {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  z-index: 2;
  display: flex;
  width: var(--reading-controls-width);
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.reading-controls-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.readingControls [data-key] {
  position: relative;
}

.readingControls [data-key]::after {
  position: absolute;
  top: 50%;
  left: calc(100% + 0.5rem);
  padding: 0.15rem 0.35rem;
  border: 1px solid var(--content-border);
  border-radius: 0.2rem;
  color: var(--ink-color);
  background: var(--panel-background);
  content: attr(data-key);
  font-family: var(--font-body);
  font-size: 0.8rem;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(-0.25rem);
  transition:
    opacity var(--transition-fast) ease,
    transform var(--transition-fast) ease;
}

.readingControls [data-key]:hover::after,
.readingControls [data-key]:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.reading-mode-exit {
  margin: 0;
}

.reading-page-indicator {
  width: 100%;
  margin-top: 0.15rem;
  color: var(--ink-color);
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

#showComic.is-height-fitted {
  display: grid;
  grid-template-columns:
    minmax(var(--reading-controls-width), 1fr)
    auto
    minmax(var(--reading-controls-width), 1fr);
  width: 100%;
  max-width: none;
  min-height: 100svh;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#showComic.is-height-fitted .writePageClickable {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

#showComic.is-height-fitted .comicPage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-height: 100svh;
  padding: 10px;
}

#showComic.is-height-fitted .comicPage a {
  display: contents;
}

/* Spreads: two pages on wide screens, one on mobile */
.comic-spread-page {
  display: contents;
}

.reading-spread-page {
  display: none;
}

#showComic.is-height-fitted .comic-spread-page,
#showComic.is-height-fitted .reading-spread-page {
  display: flex;
  flex: 0 1 100%;
  min-width: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

#showComic.is-height-fitted
  .comicPage:has(.reading-spread-page)
  .comic-spread-page,
#showComic.is-height-fitted
  .comicPage:has(.reading-spread-page)
  .reading-spread-page {
  flex-basis: 50%;
  max-width: 50%;
}

#showComic.is-height-fitted .comicPage:has(.reading-spread-page) {
  flex-direction: row;
}

#showComic.is-height-fitted
  .comicPage:has(.reading-spread-page)
  .comic-spread-page {
  align-items: flex-end;
}

#showComic.is-height-fitted
  .comicPage:has(.reading-spread-page)
  .reading-spread-page {
  align-items: flex-start;
}

#showComic.is-height-fitted .comic-spread-page img,
#showComic.is-height-fitted .reading-spread-page img {
  display: block;
  width: auto;
  height: calc(100svh - 20px);
  max-width: 100%;
  max-height: calc(100svh - 20px);
  object-fit: contain;
}

@media (max-width: 700px) {
  #showComic.is-height-fitted {
    display: block;
  }

  body:has(#showComic.is-height-fitted) .readingControls {
    position: fixed;
    top: auto;
    right: 50%;
    bottom: 10px;
    width: auto;
    flex-direction: column;
    pointer-events: auto;
    transform: translateX(50%);
  }

  body:has(#showComic.is-height-fitted) .reading-controls-buttons {
    flex-direction: row;
  }

  #showComic.is-height-fitted .comicPage {
    min-height: 100svh;
    padding: 10px 10px 76px;
  }

  #showComic.is-height-fitted .reading-spread-page {
    display: none;
  }

  #showComic.is-height-fitted .comicPage:has(.reading-spread-page) {
    flex-direction: column;
  }

  #showComic.is-height-fitted
    .comicPage:has(.reading-spread-page)
    .comic-spread-page {
    flex-basis: 100%;
    max-width: 100%;
    align-items: center;
  }

  #showComic.is-height-fitted .comic-spread-page img {
    height: calc(100svh - 152px);
    max-height: calc(100svh - 152px);
  }
}

#authorNotes h2 {
  margin: 0 0 0.25rem;
}

#authorNotes .writeAuthorNotes > :first-child {
  margin-top: 0;
}

/* Chapter archive grid and clickable pages. */
.archiveGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2.5rem 1.5rem;
  margin-top: 1.5rem;
}

.archiveSpread {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 150px);
  min-width: 0;
  gap: 0;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--content-border);
  justify-self: center;
}

.archiveSpreadSingle {
  grid-template-columns: 1fr;
}

.archiveCard {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
  color: var(--ink-color);
  text-align: left;
  text-decoration: none;
}

.archiveCardImage {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 2 / 3;
  border: 1px solid var(--content-border);
  background: #eee8df;
}

.archiveCardWide .archiveCardImage {
  aspect-ratio: 4 / 3;
}

.archiveCardWide .archiveCardImage img {
  object-fit: contain;
}

.archiveCardImage img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: cover;
}

.archiveCardPage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--on-accent-color);
  background: color-mix(in srgb, var(--accent-color) 80%, transparent);
  font-family: var(--font-heading);
  font-size: 2rem;
  font-style: italic;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.archiveCard:hover .archiveCardPage,
.archiveCard:focus-visible .archiveCardPage {
  opacity: 1;
}

.archiveCard:focus-visible {
  outline: 3px solid var(--accent-color);
  outline-offset: 3px;
}

.archiveCardMeta {
  display: flex;
  min-height: 3.5rem;
  flex-direction: column;
  gap: 0.15rem;
  padding-top: 0.45rem;
  font-size: 0.95rem;
  line-height: 1.2;
}

.archiveCardMeta time {
  color: #716960;
  font-size: 0.8rem;
}

@media (max-width: 700px) {
  /* Two columns on mobile */
  .archiveGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem 0.75rem;
  }

  .archiveSpread {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
}

/* Footer */
footer.site-footer {
  margin: 1rem 0;
  padding: 0.75rem 0;
  color: var(--ink-color);
  width: 100%;
  text-align: center;
}

footer.site-footer p {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  line-height: 1.55;
}

footer.site-footer a {
  color: inherit;
}

footer.site-footer img {
  display: inline-block;
}
