/* ============================================================
   Eden's Rise — Illustrations Magazine Layout
   ============================================================ */

/* Prevent body scroll — layout is viewport-locked */
body {
  overflow: hidden;
}

/* Magazine spread fills the viewport below the nav */
.magazine-spread {
  display: flex;
  height: calc(100vh - 57px); /* viewport minus nav height */
  overflow: hidden;
}

/* Left page — image side */
.magazine-page-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  position: relative;
  overflow: hidden;
}

/* Right page — text side */
.magazine-page-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 3.5rem 4rem;
  position: relative;
  overflow: hidden;
}

/* Center spine divider */
.magazine-spread::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 57px; /* below nav */
  bottom: 0;
  width: 1px;
  background: var(--border);
  pointer-events: none;
}

/* Image with white border (like a mounted print) */
.illustration-frame {
  max-height: calc(100vh - 57px - 10rem); /* leave room for nav + padding + button */
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 8px solid #ffffff;
  box-shadow: 0 4px 24px rgba(0, 0, 0, calc(var(--img-shadow-alpha, 0.3)));
}

/* Text styling — Georgia serif, magazine feel */
.magazine-title {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: clamp(1.3rem, 2vw, 1.75rem);
  font-weight: normal;
  font-style: italic;
  letter-spacing: 0.01em;
  line-height: 1.3;
  margin-bottom: 1.5rem;
  color: var(--ice);
  flex-shrink: 0;
}

.magazine-body {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: clamp(1rem, 1.4vw, 1.4rem);
  line-height: 1.6;
  color: var(--text-body);
  max-width: 600px;
  flex: 1;
  min-height: 0; /* allow flex child to shrink for overflow */
  overflow-y: auto;
  padding-right: 0.75rem;
  text-align: justify;
}

/* Subtle scrollbar styling */
.magazine-body::-webkit-scrollbar {
  width: 4px;
}

.magazine-body::-webkit-scrollbar-track {
  background: transparent;
}

.magazine-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.magazine-body p {
  margin-bottom: 0.25rem;
}

.magazine-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* First paragraph: no indent */
.magazine-body p:first-child {
  text-indent: 0;
}

/* Subsequent paragraphs: indented */
.magazine-body p + p {
  text-indent: 2em;
}

/* Illustrator credit */
.illustrator-credit {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-muted);
  text-align: left;
  padding-top: 1.25rem;
  flex-shrink: 0;
}

.illustrator-credit a {
  color: var(--glacier);
  text-decoration: none;
  transition: color 0.2s ease;
}

.illustrator-credit a:hover {
  color: var(--accent);
}

/* Wide spread — horizontal image spanning both pages */
.magazine-spread-wide {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 57px);
  overflow: hidden;
  padding: 2.5rem;
}

.magazine-spread-wide .illustration-frame {
  max-height: calc(100vh - 57px - 5rem);
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  margin: auto; /* Safari fix: flex centering doesn't work on img elements */
  border: 8px solid #ffffff;
  box-shadow: 0 4px 24px rgba(0, 0, 0, calc(var(--img-shadow-alpha, 0.3)));
}

/* Side navigation arrows */
.magazine-nav-arrow {
  position: fixed;
  top: calc(50% + 28px); /* offset for nav height */
  transform: translateY(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 80px;
  text-decoration: none;
  color: var(--text-muted);
  transition: color 0.25s ease, background 0.25s ease;
  cursor: pointer;
}

.magazine-nav-arrow:hover {
  color: var(--accent);
}

.magazine-nav-arrow svg {
  width: 70px;
  height: 70px;
  stroke-width: 2.5;
}

.magazine-nav-arrow.nav-prev {
  left: 1rem;
}

.magazine-nav-arrow.nav-next {
  right: 1rem;
}

.magazine-nav-arrow.invisible {
  visibility: hidden;
  pointer-events: none;
}

/* Page indicator */
.page-indicator {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-label);
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
}

/* Hidden on desktop, shown on mobile via media query */
.sheet-handle {
  display: none;
}

.sheet-chevrons {
  display: none;
}

.sheet-header {
  display: contents; /* on desktop, header wrapper is transparent */
}

/* ===== Medium screens ===== */
@media (max-width: 1200px) {
  .magazine-body {
    font-size: clamp(0.95rem, 1.3vw, 1.25rem);
  }

  .magazine-page-right {
    padding: 3rem 3rem;
  }
}

/* ===== Small screens: TikTok/Shorts-style bottom sheet ===== */
@media (max-width: 900px) {
  body {
    overflow: hidden;
    background-color: #0f1419;
    background-image: none;
  }

  .magazine-spread {
    flex-direction: column;
    height: calc(100vh - 57px);
    position: relative;
    overflow: hidden;
    background: #0f1419; /* always dark behind the image */
  }

  .magazine-spread::after {
    display: none; /* hide spine */
  }

  /* Image fills viewport area without cropping */
  .magazine-page-left {
    position: absolute;
    inset: 0;
    padding: 0;
    overflow: hidden;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;       /* horizontally centered */
    justify-content: flex-start; /* top-aligned */
  }

  .illustration-frame {
    width: auto;
    height: auto;
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }

  /* Text panel: bottom sheet overlay */
  .magazine-page-right {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 10;
    height: 90%; /* max expandable height */
    padding: 0;
    overflow: hidden;
    /* Default position: showing ~45% of viewport */
    transform: translateY(var(--sheet-y, 55%));
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
    touch-action: none; /* prevent browser scroll interference */
  }

  /* No transition during active drag */
  .magazine-page-right.dragging {
    transition: none;
  }

  /* Force dark-mode colors on the overlay regardless of theme */
  .magazine-page-right {
    --sheet-bg: rgba(15, 20, 25, 0.65);
    --ice: #c8dff0;
    --glacier: #7aadcc;
    --accent: #22d3ee;
    --text-body: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(30, 41, 59, 0.6);
  }

  /* Background: semi-transparent with blur for depth */
  .magazine-page-right::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to bottom, transparent 0%, var(--sheet-bg) 100%);
    pointer-events: none;
    z-index: 1;
  }

  .magazine-page-right::after {
    content: '';
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--sheet-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 0;
  }

  /* Drag handle */
  .sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0 8px;
    cursor: grab;
    z-index: 2;
    position: relative;
    flex-shrink: 0;
  }

  .sheet-handle::before {
    content: '';
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--text-muted);
    opacity: 0.5;
  }

  .sheet-handle:active {
    cursor: grabbing;
  }

  /* Inner content area */
  .sheet-content {
    position: relative;
    z-index: 2;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 1.75rem 2rem;
    -webkit-overflow-scrolling: touch;
  }

  /* Subtle scrollbar for sheet */
  .sheet-content::-webkit-scrollbar {
    width: 3px;
  }
  .sheet-content::-webkit-scrollbar-track {
    background: transparent;
  }
  .sheet-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
  }

  /* Header row: title + chevrons on one line */
  .sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-shrink: 0;
  }

  .magazine-title {
    font-size: 1.2rem;
    margin-bottom: 0; /* header row handles spacing */
    flex: 1;
    min-width: 0;
  }

  /* Chevron controls */
  .sheet-chevrons {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    margin-left: 0.75rem;
  }

  .sheet-chevron {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--glacier);
    transition: color 0.2s ease, opacity 0.2s ease;
    line-height: 0;
  }

  .sheet-chevron:hover {
    color: var(--accent);
  }

  .sheet-chevron svg {
    width: 28px;
    height: 28px;
    stroke-width: 2.5;
  }

  .sheet-chevron.disabled {
    opacity: 0.25;
    pointer-events: none;
  }

  .magazine-body {
    font-size: 0.95rem;
    line-height: 1.55;
    overflow-y: visible;
    max-width: none;
    padding-right: 0;
    color: var(--ice); /* match title brightness for readability over transparent bg */
  }

  .illustrator-credit {
    padding-top: 1rem;
    font-size: 0.75rem;
  }

  /* Nav arrows: overlay on the image, above the sheet */
  .magazine-nav-arrow {
    position: absolute;
    top: 35%;
    transform: translateY(-50%);
    z-index: 5; /* above image, below sheet */
    width: 44px;
    height: 60px;
    /* Subtle background for visibility over images */
    background: rgba(0, 0, 0, 0.15);
    border-radius: 6px;
  }

  .magazine-nav-arrow svg {
    width: 32px;
    height: 32px;
    stroke-width: 2.5;
    color: rgba(255, 255, 255, 0.85);
  }

  .magazine-nav-arrow:hover svg {
    color: #fff;
  }

  .magazine-nav-arrow.nav-prev {
    left: 0.5rem;
  }

  .magazine-nav-arrow.nav-next {
    right: 0.5rem;
  }

  .page-indicator {
    position: absolute;
    bottom: auto;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  }

  /* Wide spread on mobile — horizontal image fills screen */
  .magazine-spread-wide {
    height: calc(100vh - 57px);
    padding: 0;
    background: #0f1419;
  }

  .magazine-spread-wide .illustration-frame {
    max-height: 100%;
    max-width: 100%;
    border: none;
    box-shadow: none;
    border-radius: 0;
  }
}

/* ===== Title Card (illustrator transition pages) ===== */
.title-card {
  display: flex;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 57px);
  overflow: hidden;
  position: relative;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.title-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg);
  opacity: 0.7;
  z-index: 0;
}

.title-card > div {
  position: relative;
  z-index: 1;
}

.title-card h1 {
  position: relative;
  z-index: 1;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: normal;
  font-style: italic;
  letter-spacing: 0.02em;
  line-height: 1.4;
  color: var(--ice);
  text-align: center;
  padding: 2rem;
}

.title-card p {
  position: relative;
  z-index: 1;
}

.title-card-subtitle {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: clamp(1.1rem, 2vw, 1.6rem);
  font-style: italic;
  color: var(--glacier);
  text-align: center;
  margin-top: 0.5rem;
}

@media (max-width: 900px) {
  .title-card::before {
    background: #0f1419;
  }

  .title-card h1 {
    color: #c8dff0;
  }

  .title-card p {
    color: #7aadcc;
  }
}

/* ===== Illustration Thumbnail Nav ===== */
.ill-nav {
  display: flex;
  align-items: center;
  height: 57px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 50;
}

.ill-nav-icon {
  position: absolute;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 57px;
  color: var(--text-muted);
  transition: color 0.2s ease;
  z-index: 2;
  background: var(--bg);
}

.ill-nav-home { left: 0; }
.ill-nav-close { right: 0; }

.ill-nav-icon:hover {
  color: var(--accent);
}

.ill-nav-thumbs {
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: 0 52px;
  position: relative;
}

.ill-nav-thumbs-track {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  width: max-content;
}

.ill-thumb {
  flex-shrink: 0;
  width: 37px;
  height: 37px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
  display: block;
}

.ill-thumb:hover {
  opacity: 0.75;
}

.ill-thumb.active {
  opacity: 1;
  box-shadow: 0 0 0 2px var(--accent);
}

.ill-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}

/* Title card / transition slide placeholder thumbnails */
.ill-thumb-label {
  width: 37px;
  height: 37px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Georgia', serif;
  font-size: 10px;
  font-style: italic;
  color: var(--ice);
  background: rgba(100, 116, 139, 0.35);
  letter-spacing: 0.03em;
}

/* Mobile: icons overlay the thumbnail strip */
@media (max-width: 900px) {
  .ill-nav {
    background: #0f1419;
    border-bottom-color: rgba(30, 41, 59, 0.6);
  }

  .ill-nav-icon {
    background: #0f1419;
    color: rgba(255, 255, 255, 0.7);
  }

  .ill-nav-icon:hover {
    color: #fff;
  }

  .ill-thumb-label {
    color: #c8dff0;
  }

  .ill-thumb.active {
    box-shadow: 0 0 0 2px #22d3ee;
  }
}
