/* Reset and base styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-color: #000000;
  --text-color: #e0e0e0;
  --text-muted: rgba(255, 255, 255, 0.5);
  --accent-color: #8b0000;
  --accent-light: #c41e3a;
  --accent-dark: #6a0000;
  --header-height: 60px;
  --mobile-nav-height: 50px;
  --slider-height: 32px;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  user-select: none;
  -webkit-user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* Header */
#header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.6), transparent);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.4s ease;
}

#header h1 {
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.25em;
  color: var(--accent-light);
  text-transform: uppercase;
}

#page-indicator {
  font-size: 0.8rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}

#page-indicator #current-page {
  color: var(--text-color);
}

/* Main viewer */
#viewer {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background-color: var(--bg-color);
}

/* Navigation buttons - Minimal circle style */
.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  z-index: 250;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.nav-btn:hover {
  background: rgba(139, 0, 0, 0.3);
  border-color: rgba(196, 30, 58, 0.5);
  color: rgba(255, 255, 255, 0.9);
  opacity: 1;
  transform: translateY(-50%) scale(1.05);
}

.nav-btn:active {
  transform: translateY(-50%) scale(0.95);
}

.nav-btn:disabled {
  opacity: 0 !important;
  cursor: default;
  pointer-events: none;
}

.nav-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.5;
}

#prev-btn {
  left: 20px;
}

#next-btn {
  right: 20px;
}

/* Nav buttons slightly visible by default, more visible on hover */
.nav-btn:not(:disabled) {
  opacity: 0.3;
}

#viewer:hover .nav-btn:not(:disabled) {
  opacity: 0.6;
}

/* Page container */
#page-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.page-image {
  position: absolute;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.page-image.loading {
  opacity: 0.3;
}

/* Loading spinner - More subtle */
#loading-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#loading-spinner.hidden {
  display: none;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 1.5px solid rgba(139, 0, 0, 0.2);
  border-top-color: var(--accent-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Mobile navigation - Minimal style */
#mobile-nav {
  display: none;
  height: var(--mobile-nav-height);
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.mobile-nav-btn {
  padding: 8px 20px;
  background: transparent;
  border: 1px solid rgba(139, 0, 0, 0.4);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 20px;
  transition: all 0.2s ease;
}

.mobile-nav-btn:active {
  background: rgba(139, 0, 0, 0.3);
  color: var(--text-color);
  border-color: var(--accent-color);
}

.mobile-nav-btn:disabled {
  opacity: 0.2;
  cursor: default;
}

#mobile-page-indicator {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

#mobile-page-indicator #mobile-current {
  color: var(--text-color);
}

/* Page slider - Refined minimal style */
#slider-container {
  height: var(--slider-height);
  padding: 0 24px;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  display: flex;
  align-items: center;
  position: relative;
}

#page-slider {
  width: 100%;
  height: 2px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(139, 0, 0, 0.3);
  border-radius: 1px;
  cursor: pointer;
  outline: none;
}

#page-slider::-webkit-slider-runnable-track {
  height: 2px;
  background: rgba(139, 0, 0, 0.3);
  border-radius: 1px;
}

#page-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 3px;
  height: 12px;
  background: var(--accent-light);
  border-radius: 1px;
  cursor: pointer;
  margin-top: -5px;
  transition: all 0.15s ease;
  box-shadow: 0 0 8px rgba(196, 30, 58, 0.4);
}

#page-slider::-webkit-slider-thumb:hover {
  height: 16px;
  margin-top: -7px;
  box-shadow: 0 0 12px rgba(196, 30, 58, 0.6);
}

#page-slider::-moz-range-track {
  height: 2px;
  background: rgba(139, 0, 0, 0.3);
  border-radius: 1px;
  border: none;
}

#page-slider::-moz-range-thumb {
  width: 3px;
  height: 12px;
  background: var(--accent-light);
  border: none;
  border-radius: 1px;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(196, 30, 58, 0.4);
}

#page-slider::-moz-range-thumb:hover {
  height: 16px;
  box-shadow: 0 0 12px rgba(196, 30, 58, 0.6);
}

/* Touch area for swipe */
#page-container {
  touch-action: pan-y;
}

/* Responsive design */
@media (max-width: 768px) {
  #header {
    height: 50px;
    padding: 0 16px;
  }

  #header h1 {
    font-size: 0.85rem;
    letter-spacing: 0.2em;
  }

  #page-indicator {
    font-size: 0.75rem;
  }

  .nav-btn {
    display: none;
  }

  #mobile-nav {
    display: flex;
  }

  #page-container {
    padding: 5px;
  }

  #slider-container {
    padding: 0 16px;
    height: 28px;
  }
}

/* Desktop: hide mobile nav, show desktop nav */
@media (min-width: 769px) {
  #mobile-nav {
    display: none;
  }

  #page-container {
    height: calc(100vh - var(--slider-height));
  }
}

/* Large screens - slightly larger nav buttons */
@media (min-width: 1200px) {
  .nav-btn {
    width: 44px;
    height: 44px;
  }

  .nav-btn svg {
    width: 20px;
    height: 20px;
  }

  #prev-btn {
    left: 32px;
  }

  #next-btn {
    right: 32px;
  }
}

/* Fullscreen mode adjustments */
:fullscreen #header,
:-webkit-full-screen #header {
  position: fixed;
}

:fullscreen #slider-container,
:-webkit-full-screen #slider-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}

/* Hide UI when idle */
body.hide-cursor {
  cursor: none;
}

body.hide-cursor #header {
  opacity: 0;
}

body.hide-cursor .nav-btn {
  opacity: 0 !important;
}

body.hide-cursor #slider-container {
  opacity: 0.3;
}

/* Smooth transitions for idle state */
#slider-container {
  transition: opacity 0.4s ease;
}

/* Hide UI on cover page */
.cover-hidden {
  display: none !important;
}

/* Page content base styles */
.page-content {
  opacity: 1;
  transform: translateY(0);
}

.page-content.hidden {
  display: none !important;
}

/* Disable interactions during animation */
body.animating {
  pointer-events: none;
}

body.animating #slider-container {
  pointer-events: none;
}

/* ========================================
   HTML Cover Page (Page 1) - Minimalist Design
   ======================================== */

#cover-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  z-index: 200;
  overflow: hidden;
}

#cover-page.hidden {
  display: none;
}

/* Geometric shape - small square accent */
.cover-geometric {
  position: absolute;
  width: 12vw;
  height: 12vw;
  min-width: 80px;
  min-height: 80px;
  max-width: 140px;
  max-height: 140px;
  background: var(--accent-color);
  right: 8vw;
  bottom: 8vh;
}

/* Text content container */
.cover-content {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  padding: 8vh 6vw;
  display: flex;
  flex-direction: column;
}

/* Tagline - top */
.cover-tagline {
  font-family: 'Inter', sans-serif;
  font-size: clamp(8px, 1vw, 11px);
  font-weight: 300;
  letter-spacing: 0.3em;
  color: var(--accent-dark);
  text-transform: uppercase;
  align-self: flex-start;
}

/* Title wrapper - centered */
.cover-title-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 0 2vw;
}

/* Main title - single line, stretched */
.cover-title {
  font-family: 'Inter', sans-serif;
  font-size: clamp(36px, 10vw, 120px);
  font-weight: 100;
  letter-spacing: 0.35em;
  color: var(--accent-dark);
  text-transform: uppercase;
  white-space: nowrap;
  transform: scaleX(1.3);
  margin: 0;
  text-indent: 0.35em;
}

/* Subtitle - below title */
.cover-subtitle {
  font-family: 'Inter', sans-serif;
  font-size: clamp(9px, 1.2vw, 13px);
  font-weight: 200;
  letter-spacing: 0.4em;
  color: var(--accent-dark);
  text-transform: uppercase;
  opacity: 0.6;
  margin-top: 4vh;
  text-indent: 0.4em;
}

/* Author name - bottom left */
.cover-author {
  font-family: 'Inter', sans-serif;
  font-size: clamp(8px, 0.9vw, 10px);
  font-weight: 300;
  letter-spacing: 0.3em;
  color: var(--accent-dark);
  text-transform: uppercase;
  opacity: 0.5;
  align-self: flex-start;
}

/* Responsive adjustments for cover */
@media (max-width: 768px) {
  .cover-content {
    padding: 6vh 5vw;
  }

  .cover-geometric {
    width: 18vw;
    height: 18vw;
    right: 6vw;
    bottom: 6vh;
  }

  .cover-title {
    font-size: clamp(28px, 11vw, 60px);
    letter-spacing: 0.25em;
    transform: scaleX(1.2);
    text-indent: 0.25em;
  }

  .cover-subtitle {
    margin-top: 3vh;
    letter-spacing: 0.3em;
    text-indent: 0.3em;
  }
}

/* ========================================
   HTML Blessing Page (Page 2) - Double Page Spread
   ======================================== */

#blessing-page {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#blessing-page.hidden {
  display: none;
}

.blessing-spread {
  display: flex;
  max-width: 1200px;
  max-height: 85vh;
  height: min(127vw, 85vh);
}

.blessing-left,
.blessing-right {
  /* Each page is half of a spread, aspect ratio ~0.707 (A4-ish) */
  width: min(45vw, 42vh * 0.707);
  height: 100%;
  max-width: 420px;
  background: #7a0000;
}

.blessing-left {
  /* Left page - blank red */
}

.blessing-right {
  /* Right page - with text */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 28%;
}

.blessing-text {
  font-family: 'Arvo', Georgia, serif;
  font-size: clamp(9px, 1.4vw, 14px);
  font-weight: 700;
  letter-spacing: 0.25em;
  color: #5a0000;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Responsive - stack pages on mobile */
@media (max-width: 768px) {
  .blessing-spread {
    flex-direction: column;
    height: auto;
    max-height: none;
  }

  .blessing-left {
    display: none; /* Hide left page on mobile */
  }

  .blessing-right {
    width: 90vw;
    height: calc(90vw * 1.414);
    max-width: none;
    max-height: 80vh;
    padding-top: 25%;
  }

  .blessing-text {
    font-size: clamp(8px, 2.5vw, 12px);
  }
}

/* ========================================
   HTML Back Cover (Page 73) - Minimalist Design
   ======================================== */

#back-cover {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  z-index: 200;
  overflow: hidden;
}

#back-cover.hidden {
  display: none;
}

/* Geometric shape - vertical rectangle, off-center */
.back-geometric {
  position: absolute;
  width: 4vw;
  height: 12vw;
  min-width: 25px;
  min-height: 75px;
  max-width: 45px;
  max-height: 135px;
  background: var(--accent-color);
  left: 8vw;
  top: 8vh;
}

/* Back cover content - diagonal to rectangle */
.back-content {
  position: absolute;
  bottom: 8vh;
  right: 8vw;
  text-align: right;
}

.back-credit {
  font-family: 'Inter', sans-serif;
  font-size: clamp(7px, 0.8vw, 9px);
  font-weight: 300;
  letter-spacing: 0.3em;
  color: var(--accent-dark);
  text-transform: uppercase;
  opacity: 0.5;
  margin-bottom: 1vh;
}

.back-year {
  font-family: 'Inter', sans-serif;
  font-size: clamp(7px, 0.8vw, 9px);
  font-weight: 200;
  letter-spacing: 0.2em;
  color: var(--accent-dark);
  opacity: 0.4;
}

/* Responsive adjustments for back cover */
@media (max-width: 768px) {
  .back-geometric {
    width: 6vw;
    height: 18vw;
    left: 6vw;
    top: 6vh;
  }

  .back-content {
    bottom: 6vh;
    right: 6vw;
  }
}
