/* Back Deck Pondering — Archival Ozarks Devotional Keepsake
   Palette tokens grounded in weathered cedar, pine-linen binding, cotton rag paper, and iron-gall ink */

:root {
  --cloth: #232b26;
  --cloth-deep: #1b221e;
  --cloth-edge: rgba(250, 248, 243, 0.12);
  --paper: #faf8f3;
  --paper-plate: #f6f3eb;
  --paper-rule: #ded8ca;
  --ink: #1f2420;
  --muted-ink: #5a625b;
  --moss: #3b5b45;
  --moss-soft: rgba(59, 91, 69, 0.09);
  --ochre: #8c6239;
  --ochre-ribbon: #93643b;

  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --reading-size: 1.08rem;
  --reading-leading: 1.78;
}

body.is-large-text {
  --reading-size: 1.24rem;
  --reading-leading: 1.84;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background-color: var(--cloth);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background-color: var(--cloth);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(250, 248, 243, 0.055), transparent 62%),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.012) 0px,
      rgba(255, 255, 255, 0.012) 1px,
      transparent 1px,
      transparent 3px
    );
}

/* Top bar */
.desk-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 clamp(14px, 3vw, 40px) clamp(24px, 4vw, 44px);
}

.site-bar {
  width: 100%;
  max-width: 1260px;
  margin: 0 auto;
  padding: 18px 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.brand-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 500;
  color: #f6f3eb;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-author {
  font-size: 0.88rem;
  color: rgba(246, 243, 235, 0.62);
  font-weight: 400;
}

.bar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tool-btn,
.seg-btn {
  appearance: none;
  border: 1px solid rgba(250, 248, 243, 0.18);
  background: rgba(250, 248, 243, 0.05);
  color: rgba(250, 248, 243, 0.88);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.tool-btn:hover,
.seg-btn:hover {
  background: rgba(250, 248, 243, 0.12);
  border-color: rgba(250, 248, 243, 0.3);
}

.tool-btn:focus-visible,
.seg-btn:focus-visible,
.turn-btn:focus-visible,
.style-pill:focus-visible,
.close-btn:focus-visible,
.toc-btn:focus-visible {
  outline: 2px solid #d7c099;
  outline-offset: 2px;
}

.segmented {
  display: inline-flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(250, 248, 243, 0.18);
  background: rgba(250, 248, 243, 0.04);
}

.segmented .seg-btn {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 7px 11px;
}

.segmented .seg-btn + .seg-btn {
  border-left: 1px solid rgba(250, 248, 243, 0.14);
}

.segmented .seg-btn.is-active {
  background: rgba(250, 248, 243, 0.92);
  color: var(--ink);
}

.seg-btn--lg {
  font-weight: 600;
}

/* Open Book Stage */
.book-stage {
  flex: 1;
  width: 100%;
  max-width: 1260px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}

.book-volume {
  position: relative;
  border-radius: 8px;
  box-shadow:
    0 28px 60px rgba(10, 14, 11, 0.55),
    0 4px 12px rgba(10, 14, 11, 0.35),
    0 0 0 1px rgba(250, 248, 243, 0.08);
  background: var(--paper);
}

/* Subtle stacked page edges on left & right */
.book-pages-edge {
  position: absolute;
  top: 6px;
  bottom: 6px;
  width: 8px;
  pointer-events: none;
  z-index: 1;
}

.book-pages-edge--left {
  left: -6px;
  border-radius: 4px 0 0 4px;
  background: repeating-linear-gradient(
    90deg,
    #d8d2c3 0px,
    #ece7da 1px,
    #cec7b6 2px
  );
  box-shadow: -2px 4px 10px rgba(0, 0, 0, 0.25);
}

.book-pages-edge--right {
  right: -6px;
  border-radius: 0 4px 4px 0;
  background: repeating-linear-gradient(
    90deg,
    #cec7b6 0px,
    #ece7da 1px,
    #d8d2c3 2px
  );
  box-shadow: 2px 4px 10px rgba(0, 0, 0, 0.25);
}

.book-spread {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) 1px minmax(0, 1.06fr);
  min-height: min(76vh, 780px);
  border-radius: 8px;
  overflow: hidden;
  transition: opacity 220ms ease;
}

.book-spread.is-turning {
  opacity: 0.35;
}

.page {
  position: relative;
  padding: clamp(24px, 3.4vw, 48px) clamp(24px, 3.8vw, 56px);
  display: flex;
  flex-direction: column;
}

.page--left {
  background: var(--paper-plate);
  box-shadow: inset -28px 0 36px -22px rgba(25, 31, 26, 0.18);
  justify-content: space-between;
}

.page--right {
  background: var(--paper);
  box-shadow: inset 28px 0 36px -22px rgba(25, 31, 26, 0.16);
}

.book-spine {
  background: linear-gradient(
    180deg,
    rgba(31, 36, 32, 0.18) 0%,
    rgba(31, 36, 32, 0.28) 50%,
    rgba(31, 36, 32, 0.18) 100%
  );
}

/* Signature brass-ochre ribbon bookmark */
.ribbon-bookmark {
  position: absolute;
  top: 0;
  right: clamp(28px, 4vw, 52px);
  width: 22px;
  height: 44px;
  background: linear-gradient(180deg, #7d5330 0%, var(--ochre-ribbon) 75%, #845834 100%);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
  box-shadow: 0 3px 6px rgba(31, 36, 32, 0.2);
}

/* Running book folio headers */
.page-folio {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  font-style: italic;
  color: var(--muted-ink);
  padding-bottom: 14px;
  border-bottom: 1px solid var(--paper-rule);
  margin-bottom: 24px;
}

.page-folio--right {
  padding-right: 34px;
}

.page-folio time {
  font-style: normal;
  font-weight: 500;
  color: var(--ink);
}

/* Left Page Artwork Plate */
.art-plate {
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.art-frame {
  width: 100%;
  max-width: 470px;
  aspect-ratio: 3 / 4;
  border-radius: 3px;
  overflow: hidden;
  background: #f6f3eb;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8), 0 12px 30px -18px rgba(31, 36, 32, 0.25);
}

.art-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  mix-blend-mode: multiply;
  transition: opacity 220ms ease;
}

.art-caption {
  max-width: 44ch;
  text-align: center;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--muted-ink);
  margin: 0;
}

/* Optional Art Style comparison bar (Entry 1 preview) */
.style-compare {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--paper-rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.style-compare[hidden] {
  display: none;
}

.style-compare-label {
  font-size: 0.8rem;
  color: var(--muted-ink);
  font-weight: 500;
}

.style-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.style-pill {
  appearance: none;
  border: 1px solid var(--paper-rule);
  background: #ffffff;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.style-pill:hover {
  border-color: var(--moss);
}

.style-pill.is-active {
  background: var(--moss);
  border-color: var(--moss);
  color: #faf8f3;
}

/* Right Page Devotion Typography */
.devotion-header {
  margin-bottom: 18px;
}

.devotion-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 2.6vw, 2.35rem);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.scripture-callout {
  margin: 0 0 24px;
  padding: 12px 18px;
  border-left: 2.5px solid var(--moss);
  background: var(--moss-soft);
  border-radius: 0 4px 4px 0;
}

.scripture-quote {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.02rem;
  line-height: 1.58;
  color: var(--ink);
}

.scripture-ref {
  display: block;
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--moss);
}

.devotion-body {
  font-family: var(--font-serif);
  font-size: var(--reading-size);
  line-height: var(--reading-leading);
  color: var(--ink);
  max-width: 62ch;
}

.devotion-body p {
  margin: 0 0 1.05em;
}

.devotion-body p:first-child::first-letter {
  font-size: 2.95em;
  line-height: 0.84;
  float: left;
  padding: 0.08em 0.14em 0 0;
  font-weight: 500;
  color: var(--moss);
}

.devotion-body.is-original p:first-child::first-letter {
  font-size: inherit;
  line-height: inherit;
  float: none;
  padding: 0;
  color: inherit;
}

.devotion-body.is-original p {
  white-space: pre-wrap;
}

.devotion-signoff {
  margin-top: auto;
  padding-top: 22px;
  border-top: 1px solid var(--paper-rule);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-serif);
}

.signoff-name {
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--ink);
}

.signoff-place {
  font-size: 0.88rem;
  font-style: italic;
  color: var(--muted-ink);
}

/* Page-Turn Controls */
.turn-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.turn-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(250, 248, 243, 0.22);
  background: rgba(250, 248, 243, 0.06);
  color: #faf8f3;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.turn-btn:hover:not(:disabled) {
  background: rgba(250, 248, 243, 0.14);
  border-color: rgba(250, 248, 243, 0.36);
}

.turn-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #f6f3eb;
  font-size: 0.9rem;
  font-weight: 500;
}

.preview-note {
  font-size: 0.76rem;
  color: rgba(246, 243, 235, 0.56);
  font-weight: 400;
}

/* Contents Drawer */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 17, 0.62);
  z-index: 40;
}

.index-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: var(--paper);
  color: var(--ink);
  z-index: 50;
  padding: 28px 24px;
  box-shadow: -16px 0 42px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.drawer-backdrop[hidden],
.index-drawer[hidden] {
  display: none;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--paper-rule);
}

.drawer-head h2 {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 500;
}

.drawer-sub {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted-ink);
}

.close-btn {
  appearance: none;
  border: 1px solid var(--paper-rule);
  background: transparent;
  color: var(--ink);
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.toc-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toc-btn {
  width: 100%;
  text-align: left;
  appearance: none;
  border: 1px solid var(--paper-rule);
  background: #ffffff;
  border-radius: 6px;
  padding: 12px;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.toc-btn:hover {
  border-color: var(--moss);
}

.toc-btn.is-current {
  border-color: var(--moss);
  background: var(--moss-soft);
}

.toc-thumb {
  width: 56px;
  height: 74px;
  border-radius: 3px;
  object-fit: cover;
  background: var(--paper-plate);
}

.toc-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.toc-date {
  font-size: 0.78rem;
  color: var(--moss);
  font-weight: 600;
}

.toc-title {
  font-family: var(--font-serif);
  font-size: 1.06rem;
  font-weight: 500;
  color: var(--ink);
}

.toc-scripture {
  font-size: 0.8rem;
  color: var(--muted-ink);
}

/* Responsive stacking for tablet & phone */
@media (max-width: 960px) {
  .book-pages-edge {
    display: none;
  }

  .book-spread {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .book-spine {
    height: 1px;
    width: 100%;
  }

  .page--left {
    box-shadow: inset 0 -18px 24px -18px rgba(25, 31, 26, 0.14);
  }

  .page--right {
    box-shadow: inset 0 18px 24px -18px rgba(25, 31, 26, 0.12);
  }

  .art-frame {
    max-width: 390px;
  }
}

@media (max-width: 560px) {
  .site-bar {
    padding: 14px 0 12px;
  }

  .turn-btn span {
    display: none;
  }

  .turn-btn {
    padding: 10px 14px;
  }

  .ribbon-bookmark {
    width: 18px;
    height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .book-spread,
  .art-frame img,
  .tool-btn,
  .seg-btn,
  .turn-btn,
  .style-pill,
  .toc-btn {
    transition: none;
  }
}

/* Print as keepsake booklet spread */
@media print {
  body {
    background: #ffffff;
  }

  .site-bar,
  .turn-bar,
  .style-compare,
  .book-pages-edge,
  .ribbon-bookmark {
    display: none !important;
  }

  .book-volume {
    box-shadow: none;
  }

  .page--left,
  .page--right {
    box-shadow: none;
    background: #ffffff;
  }
}
