/* ============================================================
   Daily Sketchbook — Viewer Styles
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400;600;700&family=Inter:wght@300;400;500&display=swap');

/* ---- Reset & Base ---- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  background: #1a1a1a;
  color: #c8bfb0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-x: hidden;
}

/* ---- Sketchbook Container ---- */
.sketchbook {
  max-width: 860px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}



/* ---- Page Wrapper (The "Paper") ---- */
.page-wrapper {
  position: relative;
  background: #f5f0e8;
  border-radius: 2px 6px 6px 2px;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 8px 32px rgba(0, 0, 0, 0.25),
    inset 0 0 60px rgba(0, 0, 0, 0.03);
  overflow: hidden;
  cursor: default;
}

/* Paper grain texture overlay (inline SVG noise — no external image needed) */
.page-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.12'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 200px 200px;
  opacity: 0.5;
  pointer-events: none;
  z-index: 2;
  mix-blend-mode: multiply;
}

/* Binding edge */
.page-binding {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 22px;
  background: linear-gradient(
    to right,
    #2c1e14 0%,
    #4a3425 40%,
    #3d2b1f 70%,
    #2c1e14 100%
  );
  border-radius: 2px 0 0 2px;
  z-index: 3;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.15);
}

/* Binding stitching detail */
.page-binding::after {
  content: '';
  position: absolute;
  right: 4px;
  top: 20px;
  bottom: 20px;
  width: 1px;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 8px,
    rgba(200, 180, 150, 0.3) 8px,
    rgba(200, 180, 150, 0.3) 14px
  );
}

/* ---- Sketch Container ---- */
.sketch-container {
  padding: 28px 32px 28px 48px;
  position: relative;
  z-index: 1;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.sketch-container.flip-out-right {
  opacity: 0;
  transform: translateX(-12px);
}

.sketch-container.flip-out-left {
  opacity: 0;
  transform: translateX(12px);
}

.sketch-container svg {
  width: 100%;
  height: auto;
  display: block;
}

/* ---- Page Footer (inside the page) ---- */
.page-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0 32px 16px 48px;
  position: relative;
  z-index: 1;
}

.page-number-stamp {
  font-family: 'Caveat', cursive;
  font-size: 1.1rem;
  color: #b0a090;
  opacity: 0.6;
}

/* ---- Navigation Controls ---- */
.nav-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 32px;
  padding: 20px 0 8px;
}

.nav-btn {
  background: transparent;
  border: 1px solid rgba(160, 144, 128, 0.25);
  color: #a09080;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 1px;
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
}

.nav-btn:hover:not(:disabled) {
  background: rgba(160, 144, 128, 0.1);
  border-color: rgba(160, 144, 128, 0.4);
  color: #c8bfb0;
}

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

.page-counter {
  font-family: 'Caveat', cursive;
  font-size: 1.3rem;
  color: #706050;
  min-width: 80px;
  text-align: center;
}

/* ---- TOC Button ---- */
.toc-toggle {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

.toc-btn {
  background: transparent;
  border: none;
  color: #605040;
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  padding: 6px 16px;
  transition: color 0.2s ease;
}

.toc-btn:hover {
  color: #a09080;
}

/* ---- Table of Contents Overlay ---- */
.toc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 14, 12, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.toc-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 700px;
  margin-bottom: 32px;
}

.toc-title {
  font-family: 'Caveat', cursive;
  font-size: 2rem;
  color: #c8bfb0;
}

.toc-close {
  background: transparent;
  border: 1px solid rgba(160, 144, 128, 0.3);
  color: #a09080;
  font-size: 0.8rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s ease;
}

.toc-close:hover {
  background: rgba(160, 144, 128, 0.1);
  border-color: rgba(160, 144, 128, 0.5);
}

.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 700px;
}

.toc-item {
  background: rgba(245, 240, 232, 0.05);
  border: 1px solid rgba(160, 144, 128, 0.15);
  border-radius: 6px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toc-item:hover {
  background: rgba(245, 240, 232, 0.1);
  border-color: rgba(160, 144, 128, 0.35);
  transform: translateY(-2px);
}

.toc-item-number {
  font-family: 'Caveat', cursive;
  font-size: 1.8rem;
  color: #706050;
  line-height: 1;
  margin-bottom: 6px;
}

.toc-item-title {
  font-family: 'Caveat', cursive;
  font-size: 1.1rem;
  color: #c8bfb0;
  margin-bottom: 4px;
}

.toc-item-date {
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  color: #605040;
  letter-spacing: 1px;
}

/* ---- Progress indicator ---- */
.progress-bar {
  width: 100%;
  max-width: 860px;
  padding: 16px 28px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-track {
  flex: 1;
  height: 2px;
  background: rgba(160, 144, 128, 0.15);
  border-radius: 1px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: rgba(160, 144, 128, 0.4);
  border-radius: 1px;
  transition: width 0.4s ease;
}

.progress-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.65rem;
  color: #504030;
  letter-spacing: 1px;
  white-space: nowrap;
}

/* ---- Loading State ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: #605040;
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  body {
    padding: 12px 8px;
  }



  .sketch-container {
    padding: 16px 18px 16px 34px;
  }

  .page-footer {
    padding: 0 18px 12px 34px;
  }

  .nav-controls {
    gap: 16px;
  }

  .nav-btn {
    padding: 6px 14px;
    font-size: 0.75rem;
  }

  .toc-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

@media (max-width: 400px) {
  .page-binding {
    width: 14px;
  }

  .sketch-container {
    padding: 12px 12px 12px 24px;
  }
}
