/* ===================== BASE ===================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background-color: #f6f1e7; /* Warm paper */
  color: #1c1c1c;
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
  line-height: 1.5;
}

/* FIX: This stops the blue link color and the white bottom scroll issue */
a { color: inherit; text-decoration: none; }

/* ===================== LAYOUT ===================== */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.home-layout { grid-template-columns: 1fr; }

/* ===================== SIDEBAR ===================== */
.sidebar {
  padding: 40px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-right: 1px solid rgba(0,0,0,0.05);
  position: sticky; top: 0; height: 100vh;
}
.sidebar li { list-style: none; margin-bottom: 1rem; opacity: 0.5; }
.sidebar a:hover { opacity: 1; }

/* ===================== YOUR ORIGINAL GRIDS ===================== */
.forms-grid, .collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
  margin-top: 2rem;
}

.form-card, .collection-card {
  border: 1px solid rgba(0,0,0,0.1);
  padding: 25px;
  background: transparent;
  transition: 0.2s;
}

.form-card:hover { border-color: #1c1c1c; }

/* ===================== POEM PAGE ===================== */
.poem-content { padding: 60px 10%; max-width: 800px; }
h1 { font-weight: normal; font-size: 2.5rem; margin-bottom: 2rem; }

.poem-text { 
  font-size: 1.25rem; 
  white-space: pre; /* Keeps your PRE formatting exactly */
  margin-bottom: 3rem;
}

/* Subtle annotation style */
.highlight {
  background-color: rgba(0,0,0,0.05);
  border-bottom: 1px dotted #888;
  cursor: pointer;
}

/* ===================== ANNOTATION SIDEBAR ===================== */
#annotationSidebar {
  position: fixed; top: 0; right: -400px;
  width: 400px; height: 100%;
  background: #f6f1e7; border-left: 1px solid rgba(0,0,0,0.1);
  padding: 60px 40px; z-index: 2000;
  transition: right 0.3s ease;
}
#annotationSidebar.show { right: 0; }

/* ===================== DARK MODE ===================== */
html.dark-mode, body.dark-mode { 
  background-color: #121212 !important; 
  color: #e0d9cc; 
}
body.dark-mode .sidebar { border-right-color: #222; }
body.dark-mode .form-card { border-color: #333; }
body.dark-mode #annotationSidebar { background-color: #1a1a1a; border-left-color: #333; }

/* ===================== UTILS ===================== */
.copyright { position: fixed; bottom: 20px; left: 20px; font-size: 0.6rem; opacity: 0.3; text-transform: uppercase; }
.mode-toggle { position: fixed; top: 20px; right: 20px; z-index: 3000; }
.mode-toggle button { background: none; border: none; cursor: pointer; color: inherit; font-size: 1.2rem; }

/* ===================== TOP NAV (for pages that use floating nav) ===================== */
/* Use .no-sidebar on the body to hide the sidebar and enable the floating nav.
   The nav is positioned by JS in the page so it lines up with .collection-content.
   If you don't use floating nav, this block is harmless. */
.top-nav {
  position: fixed;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  opacity: 0;
  animation: fadeIn 0.9s ease forwards 0.35s;
  transition: transform 0.12s ease;
  will-change: top, left;
}

/* Link styles for top-nav: subtle non-active, full opacity for active */
.top-nav a {
  color: inherit;
  text-decoration: none;
  opacity: 0.65;
  transition: opacity 0.18s ease, transform 0.18s ease;
  display: inline-block;
  padding: 0 2px;
}
.top-nav a:hover { opacity: 0.95; transform: translateX(2px); }

/* Active style: arrow + full opacity (Poems I-C look) */
.top-nav a.active { opacity: 1; font-weight: 400; transform: none; }

/* Underline only for non-active links on hover (thin and subtle) */
.top-nav a:not(.active)::after {
  content: '';
  display: block;
  height: 1px;
  width: 0%;
  background: currentColor;
  transition: width 0.22s ease;
  margin-top: 2px;
}
.top-nav a:not(.active):hover::after { width: 100%; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===================== COLLECTION CONTENT (consistent width) ===================== */
/* Ensure collection pages use the same max-width as 1-100 for consistent alignment */
.collection-content {
  position: relative;
  z-index: 1;
  max-width: 900px; /* match 1-100 */
  margin: 0 auto;
  padding: 12vh 60px 10vh;
  opacity: 0;
  animation: fadeInUp 1s ease forwards 0.45s;
}
@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

/* ===================== GRID & CARD TWEAKS ===================== */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.8em;
  margin-top: 3rem;
}
.poem-card, .collection-card {
  background: transparent;
  border: 1px solid rgba(0,0,0,0.1);
  padding: 1em;
  text-align: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.poem-card:hover, .collection-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 14px rgba(0,0,0,0.08);
}
.poem-number {
  font-weight: 700;
  margin-bottom: 0.35em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  opacity: 0.7;
  letter-spacing: 0.04em;
}
.poem-title { font-style: italic; color: #555; font-size: 1rem; }
.empty-msg { text-align: center; font-style: italic; opacity: 0.5; padding: 3rem 0; grid-column: 1 / -1; }

/* ===================== FOOTER + TOGGLE ===================== */
copyright { position: fixed; bottom: 20px; left: 20px; font-size: 0.6rem; opacity: 0.3; text-transform: uppercase; }
.mode-toggle { position: fixed; top: 28px; right: 28px; z-index: 100; }
.mode-toggle button {
  background: none; border: 1px solid rgba(28,28,28,0.12); color: inherit; width: 44px; height: 44px; border-radius: 50%;
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: transform 0.18s ease, border-color 0.18s ease;
}
.mode-toggle button:hover { transform: rotate(8deg) scale(1.03); border-color: rgba(28,28,28,0.28); }

/* Dark mode card tweaks */
body.dark-mode .poem-card, body.dark-mode .collection-card { background: #222; border-color: #3a3a3a; color: #efe9df; }
body.dark-mode .poem-title { color: #efe9df; }

/* ===================== MOBILE SCROLL OPTIMIZATIONS (paste at end of style.css) ===================== */
@media (max-width: 768px) {
  /* Prefer native smooth scrolling on iOS */
  html, body, main {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
    touch-action: pan-y;
  }

  /* Disable heavy background texture on small screens to avoid constant repaints */
  body::before {
    display: none !important;
    /* fallback: if you want it visible but cheaper, use opacity: 0.06 and no animation */
  }

  /* Reduce animations and avoid layout-triggering properties */
  .hero, .home-nav, .collection-card, .form-card, .genre-card, .range-card {
    will-change: transform, opacity;
    backface-visibility: hidden;
    transform: translateZ(0); /* promote to its own layer */
  }

  /* Reduce box-shadows / expensive paint on hover for mobile */
  .collection-card:hover,
  .form-card:hover,
  .genre-card:hover,
  .range-card:hover {
    box-shadow: none;
    transform: none;
  }

  /* Make fixed controls smaller and less intrusive */
  .mode-toggle {
    top: 10px;
    right: 10px;
    z-index: 2000;
  }
  .mode-toggle button {
    width: 40px;
    height: 40px;
  }

  .home-link {
    top: 10px;
    left: 10px;
    z-index: 2000;
    /* increase tap target area without affecting layout */
    padding: 6px 8px;
    background: transparent;
  }

  copyright { bottom: 8px; left: 8px; font-size: 0.5rem; z-index: 2000; max-width: 70px; word-break: break-word; }

  /* Avoid expensive :hover styling being applied to touch devices */
  :root { --hover-enabled: none; }

  /* Give vertical spacing so content doesn't get hidden under fixed elements while scrolling */
  .hero { padding-top: calc(env(safe-area-inset-top, 0px) + 68px); padding-bottom: 80px; }

  /* Reduce repaint area for grids */
  .collections-grid, .genres-grid, .ranges-grid, .forms-grid { gap: 0.6rem; }
}

/* Respect user motion preference */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}

/* ===================== NOTES & TUNING ===================== */
/*
  1) To make a page use the floating top-nav (and hide the sidebar), add class "no-sidebar"
     to the <body> element. Example:
       <body class="no-sidebar"> ... </body>

  2) The floating .top-nav is positioned by JS in the page so it lines up with .collection-content.
     If you still see a few pixels of difference between pages, tweak the JS constants:
       - navTopOffsetPx (vertical nudge)
       - horizontalGapPx (space between nav and content)

  3) If you want the top-nav to always sit at a fixed pixel position instead of being computed,
     you can add explicit top/left values to .top-nav here. I recommend using the JS approach
     so it remains consistent across different global CSS or body margins.
*/

.empty-placeholder {
  min-height: 1.5rem;
}

