/* ==========================================================================
   zinereader-2p.css
   Two-page spread reader. Standalone dark styling: this page does not use the
   desktop chrome. Falls back to one page per screen on narrow viewports.
   ========================================================================== */

:root {
  --zine-bg: #121212;
  --zine-fg: #e0e0e0;
}

* { box-sizing: border-box; }

body {
  background-color: var(--zine-bg);
  color: var(--zine-fg);
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  font-family: sans-serif;
  font-size: 1rem;
}

:focus-visible { outline: 2px solid #ffffff; outline-offset: 3px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- Top navigation --- */
.top-nav {
  position: absolute;
  top: 24px;
  left: 24px;
  display: flex;
  gap: 16px;
  z-index: 20;
}

.nav-button {
  color: #ffffff;
  opacity: 0.75;
  transition: opacity 0.2s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}

.nav-button:hover,
.nav-button:focus-visible { opacity: 1; }

.nav-button svg { transform-origin: center; pointer-events: none; }
.nav-button:hover svg { animation: shake 0.4s ease-in-out 1; }

@keyframes shake {
  0%   { transform: rotate(0deg); }
  25%  { transform: rotate(-15deg); }
  50%  { transform: rotate(15deg); }
  75%  { transform: rotate(-15deg); }
  100% { transform: rotate(0deg); }
}

/* Tooltips are decoration; every control also has a real accessible name. */
.nav-button::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 100%;
  margin-top: 8px;
  background-color: #ffffff;
  color: #000000;
  border: 1px solid #000000;
  padding: 4px 8px;
  font-size: 0.875rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.nav-button:hover::after,
.nav-button:focus-visible::after { opacity: 1; }

/* --- Layout --- */
.zine-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

.zine-page-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  height: 100%;
  max-width: calc(100vw - 200px);
}

.zine-page-wrapper img {
  height: 100vh;
  height: 100dvh;
  max-width: 50%;
  object-fit: contain;
  transition: opacity 0.15s ease-in-out;
  opacity: 1;
}

#zineImageLeft { object-position: right center; }
#zineImageRight { object-position: left center; }
.zine-page-wrapper img.fade { opacity: 0; }

/* --- Page controls --- */
#prevBtn, #nextBtn {
  background-color: transparent;
  color: #ffffff;
  border: none;
  cursor: pointer;
  font-size: 3rem;
  margin: 16px;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  z-index: 10;
  transition: opacity 0.2s ease;
}
#prevBtn:hover:not(:disabled), #nextBtn:hover:not(:disabled) { opacity: 0.6; }
#prevBtn:disabled, #nextBtn:disabled { visibility: hidden; cursor: default; }

.zine-status {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8125rem;
  letter-spacing: 1px;
  color: var(--zine-fg);
  opacity: 0.75;
  z-index: 20;
}

.zine-error {
  position: absolute;
  inset: auto 24px 64px 24px;
  text-align: center;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--zine-fg);
  border: 1px dashed var(--zine-fg);
  padding: 12px;
  display: none;
}
.zine-error.show { display: block; }

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  /* visibility, not just opacity: an invisible overlay must also leave the
     tab order while it is closed. */
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0s linear 0s;
}

.modal-content {
  background-color: var(--zine-bg);
  border: 1px solid var(--zine-fg);
  padding: 40px;
  position: relative;
  color: var(--zine-fg);
  max-width: 640px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-content h2 {
  margin: 0 0 8px 0;
  font-size: 1.125rem;
  font-weight: normal;
  letter-spacing: 1px;
}
.modal-content h3 { font-size: 0.875rem; margin: 0 0 10px 0; font-weight: normal; }
.modal-content p { font-size: 0.875rem; line-height: 1.6; margin: 0 0 12px 0; }
.modal-content p:last-child { margin-bottom: 0; }
.modal-content a { color: #ffffff; }

.source-list { list-style: none; margin: 0; padding: 0; }
.source-list li { font-size: 0.8125rem; line-height: 1.6; margin-bottom: 12px; }

.dashed-divider {
  border: none;
  border-top: 1px dashed var(--zine-fg);
  margin: 20px 0;
}

.transcript-drawer { margin-top: 20px; }
.transcript-drawer summary { cursor: pointer; font-size: 0.875rem; }
.transcript-drawer .transcript-body { font-size: 0.8125rem; line-height: 1.7; margin-top: 12px; }

.close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background-color: var(--zine-bg);
  color: var(--zine-fg);
  border: 1px solid var(--zine-fg);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  min-width: 44px;
  min-height: 44px;
  padding: 4px 8px;
  transition: background-color 0.2s, color 0.2s;
}
.close-btn:hover { background-color: var(--zine-fg); color: var(--zine-bg); }

/* --- One page at a time on narrow or short screens --- */
@media (max-width: 900px), (orientation: portrait) {
  body { overflow: auto; }
  .zine-container { height: auto; min-height: 100dvh; padding: 72px 0 56px; }
  .zine-page-wrapper { max-width: calc(100vw - 96px); }
  .zine-page-wrapper img { height: auto; max-height: 80dvh; max-width: 100%; }
  .zine-page-wrapper img[hidden] { display: none; }
  #prevBtn, #nextBtn { font-size: 2rem; margin: 4px; }
  .modal-content { padding: 56px 20px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
