/* Booklet wizard (/book): progress, four steps, 3D book, page-flip viewer, bottom navigation.
   Loaded after home.css (uses its --star-pattern, .hero-pattern, buttons). */
.book-page .site-bar select { margin-left: auto; }
.wizard-head {
  position: relative; overflow: hidden;
  background:
    radial-gradient(700px 300px at 0% 0%, #fde3ec 0%, transparent 65%),
    radial-gradient(700px 300px at 100% 0%, var(--tint-2) 0%, transparent 65%),
    var(--cream);
  border-bottom: 1px solid #efe4d2;
}
.wizard-head .hero-pattern { opacity: .22; }
.wizard-head-inner { position: relative; max-width: 1100px; margin: 0 auto; padding: 22px 16px 18px; text-align: center; }
.wizard-head h1 { font-family: 'PT Serif', serif; font-size: clamp(24px, 3.4vw, 34px); margin: 0 0 16px; color: #2a1d1a; }
.wizard-head h1 .accent { color: var(--rose); }

/* Progress: four dots joined by a line; done steps teal, current one ringed. */
.progress { list-style: none; margin: 0 auto; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); max-width: 620px; }
.progress li { position: relative; }
.progress li + li::before {
  content: ''; position: absolute; top: 17px; right: 50%; width: 100%; height: 3px; background: #e6dccb;
}
.progress li.done::before, .progress li.current::before { background: var(--accent); }
.progress button {
  position: relative; z-index: 1; display: grid; justify-items: center; gap: 6px; width: 100%;
  background: none; border: 0; cursor: pointer; font: inherit; color: var(--muted); padding: 0;
}
.progress .dot {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: #fff; border: 2px solid #e6dccb; font-weight: 700; color: var(--muted); transition: all .2s ease;
}
.progress li.done .dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.progress li.current .dot { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 5px rgba(var(--accent-rgb), .15); }
.progress li.current .lbl { color: var(--ink); font-weight: 600; }
.progress .lbl { font-size: 13px; }

.wizard { max-width: 1100px; margin: 0 auto; padding: 26px 16px 28px; }
.wstep { animation: step-in .35s ease; }
@keyframes step-in { from { opacity: 0; transform: translateY(8px); } }
.wstep-head { text-align: center; margin: 0 auto 22px; max-width: 640px; }
.wstep-head h2 { font-family: 'PT Serif', serif; font-size: clamp(22px, 3vw, 30px); margin: 0 0 6px; }
.wstep-head p { margin: 0; color: var(--muted); }

.pick-check {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700; opacity: 0; transform: scale(.6); transition: all .2s ease;
  box-shadow: 0 4px 10px rgba(var(--accent-rgb), .35);
}
.selected > .pick-check { opacity: 1; transform: none; }

/* Step 1: big cover cards */
.cover-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 20px; max-width: 900px; margin: 0 auto; }
.cover-pick {
  position: relative; display: grid; gap: 10px; padding: 12px; border-radius: 18px; cursor: pointer; font: inherit; color: inherit;
  background: #fff; border: 2px solid var(--line); transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.cover-pick:hover { transform: translateY(-4px); box-shadow: 0 14px 30px rgba(60, 35, 20, .12); }
.cover-pick.selected { border-color: var(--accent); box-shadow: 0 14px 30px rgba(var(--accent-rgb), .18); }
.cover-pick-img { width: 100%; aspect-ratio: 1; }
.cover-pick-img .thumb { box-shadow: none; border-radius: 10px; }
.cover-pick-name { font-family: 'PT Serif', serif; font-weight: 700; font-size: 17px; }

/* Step 2: live cover + name form */
.name-layout { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 32px; align-items: center; max-width: 960px; margin: 0 auto; }
.name-cover { width: 100%; max-width: 380px; aspect-ratio: 1; }
.name-cover .thumb { transform: rotate(-2deg); box-shadow: 0 24px 50px rgba(60, 35, 20, .22); border-radius: 10px; }
.name-form { width: 100%; display: grid; gap: 10px; }
.big-label { font-weight: 600; font-size: 15px; }
.ui input.big-input { font-size: 22px; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--line); margin-bottom: 10px; }
.ui input.big-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .12); }
.book-page .font-options { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.book-page .font-option { min-height: 60px; border-radius: 12px; }

/* Step 3: dua tiles */
.dua-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; max-width: 620px; margin: 0 auto 12px; }
.choice-row { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: block; text-align: center; padding: 8px 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-size: 14px; }
.choice input:checked + span { border-color: var(--accent); background: var(--tint); color: var(--accent); font-weight: 600; }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.book-page .status { max-width: 760px; margin: 0 auto 20px; border-radius: 14px; background: #fffaf1; border-color: #efe0bf; text-align: center; }
.book-page .status .chips { justify-content: center; }

.dua-grid, .tile-chain { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(190px, 46%), 1fr)); gap: 16px; }
.dua-tile {
  position: relative; display: grid; gap: 8px; padding: 8px 8px 10px; border-radius: 16px; cursor: pointer; font: inherit; color: inherit; text-align: center;
  background: #fff; border: 2px solid var(--line); transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.dua-tile:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(60, 35, 20, .1); }
.dua-tile-img { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 10px; background: #f6eedf; transition: filter .2s ease; }
.dua-tile-img > .card { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.dua-tile-title { font-size: 14px; font-weight: 600; line-height: 1.25; }
.dua-tile:not(.selected) .dua-tile-img { filter: saturate(.55) opacity(.75); }
.dua-tile.selected { border-color: var(--accent); background: var(--tint); }
.tile-chain {
  grid-column: 1 / -1; padding: 12px; border: 2px dashed rgba(var(--accent-rgb), .45); border-radius: 18px; background: var(--tint);
}
.tile-chain-title { grid-column: 1 / -1; margin: 0; color: var(--accent); font-weight: 600; font-size: 14px; }

/* Step 4: 3D book + summary, then a page-flip viewer */
.result { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 36px; align-items: center; max-width: 980px; margin: 0 auto 36px; }
.result-book { display: flex; justify-content: center; perspective: 1400px; padding: 10px 0 20px; }
.book3d { position: relative; width: min(300px, 70vw); aspect-ratio: 1; transform: rotateY(-22deg) rotateX(4deg); transform-style: preserve-3d; transition: transform .6s ease; }
.book3d:hover { transform: rotateY(-8deg) rotateX(2deg); }
.book3d .thumb { border-radius: 3px 8px 8px 3px; box-shadow: 18px 24px 40px rgba(60, 35, 20, .28); }
/* Spine on the left, page edges on the right */
.book3d::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 22px; transform-origin: left; transform: rotateY(90deg);
  background: linear-gradient(90deg, #8f6b2e, #d9b26a 45%, #8f6b2e);
}
.book3d::after {
  content: ''; position: absolute; top: 4px; bottom: 4px; right: 0; width: 18px; transform-origin: right; transform: rotateY(-90deg);
  background: repeating-linear-gradient(90deg, #fffdf8 0 2px, #e9e1d2 2px 3px);
}
.result-info h2 { font-family: 'PT Serif', serif; font-size: clamp(24px, 3.2vw, 34px); margin: 4px 0 6px; }
.result-summary { color: var(--muted); margin: 0 0 18px; }
.result-info .actions { display: grid; gap: 10px; }
.result-info .btn.big { width: 100%; text-align: center; }
.print-tip { margin: 2px 0 0; padding: 10px 12px; border-radius: 10px; background: #f4f1ec; color: #5d5249; font-size: 13px; text-align: left; }
.cta-kicker.gold { color: #9a7428; }
.edit-links { margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.edit-links .link { font-size: 14px; }

.spread-viewer {
  position: relative; max-width: 980px; margin: 0 auto; padding: 22px 16px 18px; border-radius: 22px; overflow: hidden;
  background: linear-gradient(180deg, #efe6d6, #e6dac6);
}
.spread-viewer::before { content: ''; position: absolute; inset: 0; background-image: var(--star-pattern); background-size: 96px; opacity: .18; }
.spread-head { position: relative; display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.spread-head h3 { margin: 0; font-family: 'PT Serif', serif; font-size: 20px; }
.spread-stage { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; }
.spread { display: flex; justify-content: center; min-height: 120px; }
.spread .thumb { border-radius: 0; box-shadow: 0 16px 30px rgba(60, 35, 20, .25); }
.spread .thumb[hidden] { display: none; }
/* The right-hand page of an open spread gets a soft gutter shadow. */
.spread:not(.single) .thumb:not([hidden]) ~ .thumb:not([hidden])::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, .22), transparent 12%);
}
.spread:not(.single) .thumb:not([hidden]):has(~ .thumb:not([hidden]))::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(270deg, rgba(0, 0, 0, .14), transparent 10%);
}
.spread-arrow {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer; font-size: 28px; line-height: 1;
  background: #fff; color: var(--accent); box-shadow: 0 6px 16px rgba(60, 35, 20, .15);
}
.spread-arrow:disabled { opacity: .35; cursor: default; }
.spread-label { position: relative; text-align: center; margin: 14px 0 0; color: #5d5249; font-size: 14px; }

/* Step navigation: centred right under the step content; on phones it sticks to the bottom. */
.wizard-nav {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 12px;
  max-width: 1100px; margin: 4px auto 40px; padding: 0 16px;
}
.wizard-nav .btn.big { padding: 13px 24px; }
.wizard-nav #forward { padding: 15px 40px; font-size: 17px; box-shadow: 0 10px 26px rgba(var(--accent-rgb), .28); }
.wizard-nav .btn[hidden] { display: none; }
.nav-hint { flex-basis: 100%; order: 3; text-align: center; font-size: 14px; color: var(--muted); }
.nav-hint:empty { display: none; }
.nav-hint.warn { color: var(--warn); }

@media (max-width: 760px) {
  .name-layout { grid-template-columns: 1fr; justify-items: center; }
  .result { grid-template-columns: 1fr; text-align: center; }
  .wizard-nav {
    position: sticky; bottom: 0; z-index: 15; margin: 0 auto; padding: 12px 16px;
    background: rgba(246, 242, 236, .95); backdrop-filter: blur(6px); border-top: 1px solid #e8dfcf;
    flex-wrap: nowrap;
  }
  .wizard-nav #back { flex: none; padding: 12px 14px; }
  .wizard-nav #forward { flex: 1; max-width: 360px; padding: 13px 16px; font-size: 16px; }
}
@media (max-width: 520px) {
  .cover-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .cover-pick { padding: 8px; border-radius: 14px; }
  .cover-pick-name { font-size: 14px; }
  .pick-check { width: 26px; height: 26px; top: 8px; right: 8px; }
  /* Arrows float over the spread so the pages can use the full width. */
  .spread-stage { gap: 0; }
  .spread-arrow { position: absolute; z-index: 2; top: 50%; transform: translateY(-50%); opacity: .92; }
  .spread-arrow:disabled { opacity: 0; pointer-events: none; }
  #prev { left: -6px; }
  #next { right: -6px; }
  .spread-viewer { padding: 18px 10px 14px; }
  .progress .lbl { font-size: 12px; }
  .wizard-nav .btn.big { padding: 11px 14px; font-size: 15px; }
  .nav-hint { display: none; }
  .spread-arrow { width: 38px; height: 38px; font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .wstep { animation: none; }
  .book3d { transition: none; }
}

/* Font picker: a big sample of the name plus a small caption. */
.book-page .font-options { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.book-page .font-option {
  display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 86px; padding: 8px 10px;
  border-radius: 14px; white-space: normal;
}
.font-sample { color: #6d28d9; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-label { font: 12px system-ui, sans-serif; color: var(--muted); }
.font-option.selected .font-label { color: var(--accent); font-weight: 600; }

/* Brochure meter on the duas step */
.book-page .status { padding: 16px 18px; display: grid; gap: 10px; justify-items: center; }
.book-page .status p { margin: 0; }
.book-page .status.gaps { background: #fff7e6; border-color: #f1d9a6; }
.book-page .status.full { background: #effaf6; border-color: #bfe5d8; }
.meter-head { display: grid; gap: 4px; }
.meter-title { font-family: 'PT Serif', serif; font-weight: 700; font-size: 19px; color: #6b4a12; }
.meter-title.ok { color: var(--ok); }
.meter-title.warn { color: var(--warn); font-family: inherit; font-size: 16px; }
.meter-sub { font-size: 14px; color: #6d6153; }
.meter { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 14px; }
.meter-sheet { display: grid; justify-items: center; gap: 3px; }
.meter-pages { display: flex; gap: 3px; padding: 4px; border-radius: 8px; background: rgba(255, 255, 255, .7); border: 1px solid #eadfcb; }
.pg {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 5px;
  font: 600 11px system-ui, sans-serif; color: #fff;
}
.pg.cover, .pg.back { background: #c9a24a; }
.pg.toc { background: #9aa3a0; }
.pg.dua { background: var(--accent); }
.pg.free {
  background: #fff; color: #c58a12; border: 2px dashed #e0b45a; font-size: 16px;
  animation: pulse-free 1.6s ease-in-out infinite;
}
@keyframes pulse-free { 50% { background: #fff1d1; } }
.meter-sheet-label { font-size: 11px; color: var(--muted); }
.meter-hint { font-size: 13px; color: #6d6153; font-weight: 600; }
.meter-foot { font-size: 13px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .pg.free { animation: none; } }
@media (max-width: 520px) {
  .pg { width: 24px; height: 24px; font-size: 10px; }
  .meter-title { font-size: 17px; }
}

/* Step 4 order: heading → big page-flip viewer → 3D book with download buttons. */
.result-head { margin-bottom: 18px; }
.result-head h2 { margin: 4px 0 6px; }
.result-head .result-summary { margin: 0; }
.spread-viewer { max-width: 1140px; padding: 22px 20px 20px; margin-bottom: 36px; }
.spread-stage { gap: 14px; }
.spread .thumb { box-shadow: 0 22px 44px rgba(60, 35, 20, .28); }
.result { margin-bottom: 8px; padding: 26px; border-radius: 22px; background: #fff; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(60, 35, 20, .06); }
.download-title { margin: 0 0 14px; font-family: 'PT Serif', serif; font-size: 22px; }
.book3d { width: min(240px, 60vw); }

/* Step 1: series switch above the cover grid */
.cover-series { margin-top: 14px; }
.book-page .cover-grid { grid-template-columns: repeat(auto-fill, minmax(min(200px, 46%), 1fr)); gap: 16px; max-width: 1000px; }
.book-page .cover-pick-name { font-size: 15px; }

/* Step 4: two clear download options */
.dl-option {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer; font: inherit;
  padding: 14px 16px; border-radius: 16px; border: 2px solid var(--accent); background: #fff; color: var(--ink);
  transition: transform .15s ease, box-shadow .15s ease;
}
.dl-option:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(var(--accent-rgb), .18); }
.dl-option.primary { background: var(--accent); color: #fff; }
.dl-option.busy { opacity: .8; cursor: progress; }
.dl-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; flex: none; background: rgba(var(--accent-rgb), .1); color: var(--accent); }
.dl-option.primary .dl-icon { background: rgba(255, 255, 255, .18); color: #fff; }
.dl-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dl-text { display: grid; gap: 2px; }
.dl-text b { font-size: 17px; }
.dl-text small { font-size: 13px; opacity: .85; line-height: 1.35; }

.print-help { margin-top: 14px; border: 1px solid var(--line); border-radius: 14px; background: #faf7f2; text-align: left; }
.print-help summary { cursor: pointer; padding: 12px 16px; font-weight: 600; color: var(--accent); list-style: none; }
.print-help summary::-webkit-details-marker { display: none; }
.print-help summary::before { content: '＋'; display: inline-block; width: 20px; }
.print-help[open] summary::before { content: '－'; }
.print-help ol { margin: 0; padding: 0 16px 6px 16px; list-style: none; counter-reset: s; display: grid; gap: 10px; }
.print-help li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; font-size: 14px; line-height: 1.45; }
.print-help li::before {
  content: counter(s); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
}
.print-help-tip { margin: 6px 16px 14px; padding: 10px 12px; border-radius: 10px; background: #fff7e6; color: #6b4a12; font-size: 13px; }

.edit-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; font-size: 14px; color: var(--muted); }
.edit-row .chip { font-size: 14px; padding: 5px 12px; }
@media (max-width: 760px) { .edit-row { justify-content: center; } }
/* Print steps: number on the left, the sentence (with its bold words) flows normally on the right. */
.print-help li { display: block; position: relative; padding-left: 38px; min-height: 26px; }
.print-help li::before { position: absolute; left: 0; top: -2px; }

/* Meter cells grow for longer abbreviations in other languages. */
.pg { width: auto; min-width: 30px; padding: 0 5px; }
@media (max-width: 520px) { .pg { min-width: 24px; padding: 0 3px; } }

/* Step 3 on wide screens: tiles on the left; the side column (background choice, select all/none,
   page meter) sticks on the right so it stays in view while choosing. Phones: side column on top. */
@media (min-width: 1000px) {
  .duas-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 24px; align-items: start; }
  .duas-layout #duas { grid-column: 1; grid-row: 1; }
  .duas-side {
    grid-column: 2; grid-row: 1; position: sticky; top: 76px; display: grid; gap: 12px;
    max-height: calc(100vh - 96px); overflow-y: auto;
  }
  .duas-side .dua-toolbar { flex-direction: column; align-items: stretch; max-width: none; margin: 0; gap: 8px; }
  .duas-side .choice-row { display: grid; grid-template-columns: 1fr; }
  .duas-side .links { text-align: center; }
  .duas-side #status { max-width: none; margin: 0; }
  .duas-layout .meter { flex-direction: column; align-items: center; gap: 8px; }
  .duas-layout .meter-title { font-size: 17px; }
  .duas-layout .status .chips { flex-direction: column; align-items: stretch; }
}
@media (max-width: 999px) { .duas-side .dua-toolbar { justify-content: center; } }
