:root {
  --table: #0d2b2b;
  --table-2: #061718;
  --paper: #fbf7ee;
  --paper-2: #f1e9d8;
  --ink: #23302f;
  --ink-soft: #5f6b69;
  --rule: #ddd2bb;
  --gold: #c9a55a;
  --gold-2: #e8cf8f;
  --cover: #123c3b;
  --cover-2: #0a2626;
  --wa: #1fa855;
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --sans: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bar-h: 52px;
  --ctl-h: 56px;
  --rib-h: 34px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 50% 40%, #174a49 0%, transparent 70%),
    radial-gradient(800px 500px at 50% 120%, #0b3030 0%, transparent 70%),
    linear-gradient(var(--table), var(--table-2));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; }

/* ---------- top bar ---------- */
.bar {
  height: var(--bar-h);
  flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: env(safe-area-inset-top) 16px 0;
  color: #e9f1ef;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-family: var(--serif); font-size: 1.05rem; }
.brand em { font-style: normal; color: var(--gold-2); }
.icon-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 14px;
  border-radius: 999px; border: 1px solid rgb(255 255 255 / 25%); background: rgb(255 255 255 / 8%);
  color: #fff; cursor: pointer;
}
.icon-btn:hover { background: rgb(255 255 255 / 16%); }
@media (max-width: 480px) { .brand em { display: none; } .icon-btn span { display: none; } .icon-btn { padding: 6px 10px; } }

/* ---------- stage & book ---------- */
.stage {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 12px;
  position: relative;
}
/* Book width is chosen so the whole book fits the screen height. --pages = 2 for spreads, 1 on phones. */
.book-wrap {
  --avail-h: calc(100dvh - var(--bar-h) - var(--ctl-h) - var(--rib-h) - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  width: min(100%, calc(var(--avail-h) * 0.7 * 2), 1240px);
  position: relative;
}
@media (max-width: 760px) {
  .book-wrap { width: min(100%, calc(var(--avail-h) * 0.7), 560px); }
}
.book { margin: 0 auto; }
.book.ready { filter: drop-shadow(0 18px 30px rgb(0 0 0 / 45%)); }

/* ---------- ribbon bookmarks ---------- */
.ribbons {
  transition: opacity .3s;
  height: var(--rib-h);
  display: flex; align-items: flex-end; justify-content: center; gap: 4px;
  position: relative; z-index: 2;
  width: min(100%, 1240px);
  padding: 0 4%;
  margin-bottom: -6px; /* ribbons tuck behind the book's top edge */
}
.ribbon {
  --c: var(--gold);
  position: relative;
  border: 0; cursor: pointer;
  background: var(--c);
  color: #fff;
  font-weight: 700; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
  padding: 6px 10px 14px;
  min-width: 0; max-width: 120px; flex: 0 1 auto;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% calc(100% - 7px), 0 100%);
  transform: translateY(6px);
  transition: transform .25s ease, filter .25s ease;
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / 15%);
  text-shadow: 0 1px 1px rgb(0 0 0 / 30%);
}
.ribbon:hover, .ribbon:focus-visible { transform: translateY(2px); filter: brightness(1.1); }
.ribbon.active { transform: translateY(-2px); padding-bottom: 18px; }
.ribbon.toc { --c: #8a6d2e; }
@media (max-width: 520px) {
  .ribbons { gap: 2px; padding: 0 2px; }
  .ribbon { font-size: .6rem; padding: 6px 5px 13px; letter-spacing: 0; }
}

/* ---------- controls ---------- */
.controls {
  height: var(--ctl-h); flex: none;
  display: flex; align-items: center; justify-content: center; gap: 18px;
  padding-bottom: env(safe-area-inset-bottom);
  color: #dfe9e7;
}
.nav-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 25%); background: rgb(255 255 255 / 8%);
  color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.nav-btn:hover { background: rgb(255 255 255 / 18%); }
.nav-btn:disabled { opacity: .3; cursor: default; }
.page-ind { min-width: 110px; text-align: center; font-size: .9rem; font-variant-numeric: tabular-nums; }

/* ---------- pages ---------- */
.page {
  background: var(--paper);
  overflow: hidden;
  container-type: size;
}
.page-inner {
  position: absolute; inset: 0;
  padding: 6cqh 7cqw 5cqh;
  display: flex; flex-direction: column;
  font-size: clamp(9px, 2.55cqw, 15px);
  line-height: 1.4;
  background:
    linear-gradient(90deg, transparent 88%, rgb(120 95 50 / 10%) 100%),
    radial-gradient(120% 90% at 50% 40%, var(--paper) 60%, var(--paper-2) 100%);
}
.page.right .page-inner {
  background:
    linear-gradient(270deg, transparent 88%, rgb(120 95 50 / 12%) 100%),
    radial-gradient(120% 90% at 50% 40%, var(--paper) 60%, var(--paper-2) 100%);
}
.folio {
  position: absolute; bottom: 2.4cqh; left: 0; right: 0;
  text-align: center; font-family: var(--serif); font-size: clamp(9px, 2.2cqw, 13px); color: var(--ink-soft);
}
.kicker { font-size: .78em; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--c, var(--ink-soft)); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0; line-height: 1.12; color: var(--ink); }
.rule { height: 1px; background: var(--rule); margin: 1.6cqh 0; border: 0; }
.ornament { text-align: center; color: var(--gold); letter-spacing: .5em; margin: 1.5cqh 0; }

/* cover */
.page.cover, .page.back {
  background:
    radial-gradient(120% 80% at 30% 20%, #1b5352 0%, transparent 60%),
    repeating-linear-gradient(45deg, rgb(255 255 255 / 1.5%) 0 2px, transparent 2px 6px),
    linear-gradient(160deg, var(--cover), var(--cover-2));
  color: #f4ecd8;
}
.cover-frame {
  position: absolute; inset: 4.5cqw;
  border: 2px solid var(--gold); outline: 1px solid rgb(201 165 90 / 45%); outline-offset: -8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 8cqw;
}
.cover-frame .crest { width: 30cqw; height: 30cqw; margin-bottom: 4cqh; }
.cover-frame .shop { font-family: var(--serif); font-size: clamp(14px, 5.2cqw, 30px); color: var(--gold-2); letter-spacing: .04em; }
.cover-frame h1 { color: #fff7e2; font-size: clamp(24px, 10cqw, 60px); margin: 2.5cqh 0; text-shadow: 0 2px 10px rgb(0 0 0 / 35%); }
.cover-frame .sub { font-size: clamp(10px, 3.3cqw, 18px); letter-spacing: .18em; text-transform: uppercase; color: #d9cfb5; }
.cover-frame .edition { margin-top: 6cqh; font-size: clamp(9px, 2.8cqw, 14px); color: var(--gold-2); letter-spacing: .1em; }
.cover-frame .hint { position: absolute; bottom: 4cqh; font-size: clamp(9px, 2.5cqw, 13px); color: #b9c9c4; animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(6px); } }
.back .cover-frame { justify-content: space-between; padding-block: 10cqh; }
.back .cover-frame p { margin: 0; font-size: clamp(10px, 3.2cqw, 17px); color: #e4dbc4; }
.back .wa-btn { font-size: clamp(11px, 3.3cqw, 17px); }

/* contents */
.toc-list { list-style: none; padding: 0; margin: 2cqh 0 0; display: grid; gap: .3em; }
.toc-list button {
  all: unset; cursor: pointer; display: flex; align-items: baseline; gap: .5em; width: 100%;
  padding: .45em 0; border-bottom: 1px dotted var(--rule); font-family: var(--serif); font-size: 1.15em;
}
.toc-list button:hover { color: var(--c); }
.toc-list .num { color: var(--c); font-weight: 700; width: 1.6em; }
.toc-list .dots { flex: 1; }
.toc-list .pg { font-family: var(--sans); font-size: .85em; color: var(--ink-soft); }
.toc-sub { font-family: var(--sans); font-size: .75em; color: var(--ink-soft); display: block; }

/* welcome */
.lede { font-size: 1.05em; color: var(--ink); margin: 1.5cqh 0 0; }
.sizes { width: 100%; border-collapse: collapse; margin-top: 1.5cqh; font-size: .92em; }
.sizes th, .sizes td { text-align: left; padding: .35em .3em; border-bottom: 1px solid var(--rule); }
.sizes th { font-size: .82em; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); font-weight: 700; }
.sizes td:first-child { font-weight: 700; white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: .5em 1.2em; margin-top: 1.5cqh; font-size: .9em; color: var(--ink-soft); }
.note { font-size: .82em; color: var(--ink-soft); margin-top: auto; padding-top: 1.5cqh; font-style: italic; }

/* photos */
.photo {
  --c: #2f8f4e;
  position: absolute; inset: 0;
  background:
    radial-gradient(80% 60% at 50% 35%, color-mix(in srgb, var(--c) 55%, #fff) 0%, transparent 70%),
    linear-gradient(170deg, color-mix(in srgb, var(--c) 70%, #0b2222), #0b2222);
  display: flex; align-items: center; justify-content: center;
}
.photo .ph { color: rgb(255 255 255 / 55%); text-align: center; font-size: clamp(10px, 3cqw, 16px); }
.photo .ph svg { width: 22cqw; height: 22cqw; display: block; margin: 0 auto 1em; opacity: .7; }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo::after { /* soft vignette + page-edge shading */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgb(0 0 0 / 0%) 55%, rgb(0 0 0 / 65%) 100%);
}
.photo-cap {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  padding: 0 7cqw 7cqh; color: #fff;
}
.photo-cap .kicker { color: var(--gold-2); }
.photo-cap h2 { color: #fff; font-size: clamp(20px, 8cqw, 46px); text-shadow: 0 2px 12px rgb(0 0 0 / 50%); margin-top: .2em; }
.photo-cap .meta { font-size: clamp(10px, 3cqw, 16px); opacity: .9; margin-top: .4em; }
.photo-cap .credit { font-size: clamp(8px, 2cqw, 11px); opacity: .7; margin-top: 1.2em; }
.size-badge {
  position: absolute; top: 5cqh; right: 6cqw; z-index: 1;
  background: rgb(255 255 255 / 92%); color: var(--ink); border-radius: 999px;
  padding: .35em .9em; font-weight: 700; font-size: clamp(10px, 3cqw, 16px);
  box-shadow: 0 2px 8px rgb(0 0 0 / 25%);
}
.chapter-no { font-family: var(--serif); font-style: italic; color: var(--gold-2); font-size: clamp(12px, 4cqw, 22px); }

/* chapter intro (right page) */
.chapter h2 { font-size: clamp(20px, 7.5cqw, 40px); margin-top: .3em; }
.chapter .points { margin: 2cqh 0 0; padding: 0; list-style: none; display: grid; gap: .45em; }
.chapter .points li { padding-left: 1.3em; position: relative; }
.chapter .points li::before { content: '◆'; position: absolute; left: 0; color: var(--c); font-size: .8em; top: .15em; }
.in-chapter { margin-top: auto; }
.in-chapter h3 { font-size: 1em; font-family: var(--sans); text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); margin-bottom: .4em; }
.in-chapter button {
  all: unset; cursor: pointer; display: grid; grid-template-columns: 4.6em 1fr auto; gap: .6em; width: 100%;
  padding: .42em 0; border-top: 1px solid var(--rule); align-items: baseline;
}
.in-chapter button:hover b { color: var(--c); }
.in-chapter .sz { font-weight: 700; color: var(--c); }
.in-chapter .pg { color: var(--ink-soft); font-size: .85em; }

/* setup details (right page) */
.details h2 { font-size: clamp(18px, 6.6cqw, 36px); margin-top: .15em; }
.details .tagline { font-family: var(--serif); font-style: italic; color: var(--ink-soft); margin: .4em 0 0; font-size: 1.02em; }
.specs { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4em; margin: 1.8cqh 0 1.4cqh; }
.spec { background: #fff; border: 1px solid var(--rule); border-radius: 8px; padding: .45em .3em; text-align: center; }
.spec b { display: block; font-size: 1.05em; color: var(--ink); white-space: nowrap; }
.spec span { font-size: .72em; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.cols { columns: 2; column-gap: 5cqw; flex: 1; min-height: 0; }
.blk { margin-bottom: 1.3cqh; break-inside: avoid; }
.blk h3 {
  font-family: var(--sans); font-size: .76em; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--c); border-bottom: 1px solid var(--rule); padding-bottom: .2em; margin-bottom: .35em;
}
.blk ul { list-style: none; margin: 0; padding: 0; }
.blk li { display: flex; justify-content: space-between; gap: .5em; padding: .08em 0; }
.blk li .n { font-weight: 700; color: var(--ink); white-space: nowrap; }
.blk dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .1em .6em; }
.blk dt { color: var(--ink-soft); }
.blk dd { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: .3em; }
.tags span { background: color-mix(in srgb, var(--c) 10%, #fff); border: 1px solid color-mix(in srgb, var(--c) 25%, #fff); border-radius: 999px; padding: .05em .55em; font-size: .9em; }
.details-foot { display: flex; align-items: center; justify-content: space-between; gap: .8em; margin-top: .6em; padding-bottom: 2.6cqh; }
.diff { font-size: .85em; color: var(--ink-soft); }
.dots { letter-spacing: .1em; color: var(--c); }
.wa-btn {
  display: inline-flex; align-items: center; gap: .5em; text-decoration: none;
  background: var(--wa); color: #fff; font-weight: 700; border-radius: 999px; padding: .5em 1em; font-size: .95em;
  box-shadow: 0 2px 6px rgb(0 0 0 / 15%);
}
.wa-btn:hover { filter: brightness(1.08); }
.wa-btn svg { width: 1.2em; height: 1.2em; }

/* single-page (phone) layout: stack the columns */
@container (max-width: 420px) {
  .page-inner { font-size: clamp(8.5px, 2.85cqw, 12px); padding: 5cqh 5.5cqw 4.5cqh; }
  .details .page-inner, .page-inner.details { line-height: 1.3; }
  .specs { gap: .3em; margin: 1.2cqh 0 1cqh; }
  .spec { padding: .35em .2em; }
  .cols { column-gap: 4cqw; }
  .blk { margin-bottom: .9cqh; }
  .tags span { font-size: .85em; }
  .details-foot { padding-bottom: 3cqh; }
}

/* credits & contact */
.credits { font-size: .82em; columns: 2; column-gap: 5cqw; margin-top: 1.5cqh; }
.credits p { margin: 0 0 .5em; break-inside: avoid; }
.credits a { color: var(--ink-soft); }
.contact p { margin: .6em 0; }

/* ---------- search ---------- */
.search {
  width: min(640px, calc(100vw - 24px)); max-height: min(80vh, 720px);
  border: 0; border-radius: 16px; padding: 0; background: var(--paper); color: var(--ink);
  box-shadow: 0 20px 60px rgb(0 0 0 / 50%);
}
.search[open] { display: flex; flex-direction: column; }
.search::backdrop { background: rgb(4 18 18 / 70%); backdrop-filter: blur(2px); }
.search-head { display: flex; gap: 8px; padding: 14px 14px 8px; }
.search-head input {
  flex: 1; font: inherit; font-size: 1.05rem; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--rule); background: #fff; color: var(--ink);
}
.search .close { color: var(--ink); border-color: var(--rule); background: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.chip {
  --c: var(--ink-soft);
  border: 1px solid var(--rule); background: #fff; color: var(--ink); border-radius: 999px;
  padding: 4px 12px; font-size: .85rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: #fff; }
.results { list-style: none; margin: 0; padding: 0 8px 12px; overflow: auto; }
.results button {
  all: unset; box-sizing: border-box; cursor: pointer; width: 100%;
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  padding: 8px; border-radius: 10px;
}
.results button:hover, .results button:focus-visible { background: #fff; outline: 2px solid var(--gold); }
.results .thumb { width: 64px; height: 44px; border-radius: 6px; background: var(--c); overflow: hidden; }
.results .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.results b { display: block; font-family: var(--serif); font-size: 1.02rem; }
.results small { color: var(--ink-soft); }
.results .pg { color: var(--ink-soft); font-size: .85rem; }
.results mark { background: #f6e3a6; color: inherit; border-radius: 3px; }
.results .empty { padding: 24px; text-align: center; color: var(--ink-soft); }

.noscript { color: #fff; text-align: center; padding: 40px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.ribbons.hidden { opacity: 0; pointer-events: none; }

.ribbon .short { display: none; }
@media (max-width: 400px) {
  .ribbons { gap: 1px; padding: 0; }
  .ribbon { font-size: .56rem; padding: 6px 3px 13px; flex: 1 1 0; max-width: none; text-overflow: clip; }
  .ribbon.toc { flex: 0 0 30px; }
  .ribbon .full { display: none; }
  .ribbon .short { display: inline; font-size: 1.3em; }
}
