@font-face { font-family: "Montserrat"; font-weight: 500; font-display: swap; src: url(montserrat-medium.woff2) format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 600; font-display: swap; src: url(montserrat-semibold.woff2) format("woff2"); }

:root {
  --navy: #20306C;
  --sky: #92B8D2;
  --leaf: #B8D779;
  --cream: #f2efe7;
  --paper: #e8e4d9;
  --ink-60: rgba(32, 48, 108, .62);
  --ink-12: rgba(32, 48, 108, .12);
  --ink-06: rgba(32, 48, 108, .06);
  --bar: 52px;
  --foot: 58px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Montserrat", sans-serif;
  font-weight: 500;
  color: var(--navy);
  background: var(--cream);
  display: grid;
  grid-template-rows: var(--bar) minmax(0, 1fr) var(--foot);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums lining-nums;
}
button { font: inherit; color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Top bar ---------- */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(28px, env(safe-area-inset-right)) 0 max(28px, env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--navy); text-decoration: none; }
.brand img { display: block; width: 20px; height: auto; }
.brand-name { font-weight: 600; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; }
.brand-sub {
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-60);
  padding-left: 12px; border-left: 1px solid var(--ink-12);
}
.btn {
  display: inline-flex; align-items: center; gap: 9px; height: 36px; padding: 0 14px;
  border: 0; border-radius: 999px; background: transparent; cursor: pointer;
  font-size: 10.5px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--navy); text-decoration: none; white-space: nowrap;
  transition: background-color .25s var(--ease), color .25s var(--ease), opacity .25s var(--ease);
}
.btn svg { width: 14px; height: 14px; flex: none; }
.btn:hover { background: var(--ink-06); }
.btn:focus-visible, .turn:focus-visible, .progress:focus-visible { outline: 1.5px solid var(--navy); outline-offset: 2px; }
.btn-icon { width: 36px; padding: 0; justify-content: center; }
.btn[disabled] { opacity: .25; pointer-events: none; }

/* ---------- Stage + book ---------- */
.stage {
  position: relative; display: flex; align-items: center; justify-content: center;
  padding: 4px 64px 0; min-height: 0;
}
.book-wrap {
  position: relative;
  transition: transform .9s var(--ease), opacity .8s var(--ease);
  will-change: transform;
}
body.loading .book-wrap { opacity: 0; transform: translateY(10px); }
.book { margin: 0 auto; }
/* Soft drop shadow under the paper (follows the page silhouettes, incl. cover-only state) */
.stf__block { filter: drop-shadow(0 22px 28px rgba(32, 48, 108, .16)) drop-shadow(0 2px 4px rgba(32, 48, 108, .10)); }

.page { background: var(--paper); overflow: hidden; }
.page img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .5s var(--ease);
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.page img.in { opacity: 1; }
/* Reverse of a turning sheet (one-page view): the print seen through the paper */
.page.back { background: var(--cream); }
.page.back img { transform: scaleX(-1); opacity: .3 !important; filter: saturate(.85) blur(.3px); }
.page.back::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: rgba(241, 239, 231, .16);
}
/* Matte, uncoated stock: paper grain + gutter fold shading (no gloss highlights) */
.page::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: url(paper.webp) 0 0 / 256px; mix-blend-mode: multiply;
}
.stf__item.--left::after {
  background:
    linear-gradient(to left, rgba(40, 34, 24, .22) 0, rgba(40, 34, 24, .08) 1.2%, rgba(40, 34, 24, .025) 4%, transparent 9%),
    url(paper.webp) 0 0 / 256px;
}
.stf__item.--right::after {
  background:
    linear-gradient(to right, rgba(40, 34, 24, .20) 0, rgba(40, 34, 24, .07) 1.2%, rgba(40, 34, 24, .02) 4%, transparent 9%),
    url(paper.webp) 0 0 / 256px;
}
/* Single-page (phone) view: lighter spine, it reads as a folded magazine */
.--portrait .stf__item.--right::after {
  background: linear-gradient(to right, rgba(40, 34, 24, .12) 0, rgba(40, 34, 24, .04) 1.6%, transparent 6%), url(paper.webp) 0 0 / 256px;
}
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* Side turn buttons (pointer devices) */
.turn {
  position: absolute; top: 50%; z-index: 5; width: 52px; height: 52px; margin-top: -26px;
  display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent;
  color: var(--navy); cursor: pointer; transition: background-color .25s var(--ease), opacity .3s var(--ease);
}
.turn svg { width: 22px; height: 22px; stroke-width: 1.1; }
.turn:hover { background: var(--ink-06); }
.turn[disabled] { opacity: 0; pointer-events: none; }
.turn-prev { left: 8px; }
.turn-next { right: 8px; }

/* ---------- Footer ---------- */
.foot { position: relative; display: flex; flex-direction: column; justify-content: center; padding: 0 28px env(safe-area-inset-bottom); }
.progress {
  position: absolute; top: 6px; left: 50%; width: min(360px, 60vw); transform: translateX(-50%);
  height: 15px; cursor: pointer; touch-action: none;
}
.progress::before, .progress span { content: ""; position: absolute; left: 0; top: 7px; height: 1px; }
.progress::before { right: 0; background: var(--ink-12); }
.progress span { width: 0; background: var(--navy); transition: width .6s var(--ease); }
.foot-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 10px; }
.foot-arrow { display: none; }
.counter { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 220px; text-align: center; }
.count { font-size: 11px; font-weight: 600; letter-spacing: .18em; white-space: nowrap; }
.count-of { color: var(--ink-60); font-weight: 500; }
.count-title { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-60); }

.noscript { position: fixed; inset: auto 0 40% 0; text-align: center; font-size: 13px; }
.noscript a { color: var(--navy); }

/* ---------- Touch / small screens ---------- */
@media (hover: none), (max-width: 760px) {
  .turn { display: none; }
  .stage { padding: 6px 14px 2px; }
  .foot-arrow { display: inline-flex; }
}
@media (max-width: 760px) {
  :root { --bar: 52px; --foot: 64px; }
  .bar { padding: 0 max(16px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left)); }
  .brand-sub { display: none; }
  .counter { min-width: 0; flex: 1; }
  .foot { padding: 0 12px env(safe-area-inset-bottom); }
}
/* ---------- Phones ---------- */
.rotate { display: none; }
.phone.tall:not(.portrait-ok) .rotate {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 32px; text-align: center; background: var(--cream);
}
.rotate-phone { width: 76px; height: 76px; stroke-width: 1.2; margin-bottom: 14px; animation: tilt 2.8s var(--ease) infinite; }
@keyframes tilt { 0%, 25% { transform: rotate(0); } 55%, 85% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }
.rotate-title { margin: 0; font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; }
.rotate-sub { margin: 0 0 18px; font-size: 12px; color: var(--ink-60); letter-spacing: .02em; }
.rotate .btn { color: var(--ink-60); }

/* Phone held sideways: one slim bar, counter in the middle, page as large as possible */
.phone.land { --bar: 38px; }
.phone.land body { grid-template-rows: var(--bar) minmax(0, 1fr) 0; }
.phone.land .bar { padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.phone.land .brand-sub, .phone.land .progress, .phone.land .count-title, .phone.land .foot-arrow { display: none; }
.phone.land .foot { position: fixed; top: 0; right: max(16px, env(safe-area-inset-right)); height: var(--bar); padding: 0; z-index: 3; }
.phone.land .foot-row { margin: 0; }
.phone.land .counter { min-width: 0; }
.phone.land .stage { padding: 0 0 max(4px, env(safe-area-inset-bottom)); overflow: hidden; }
/* The turned sheet, lying face-down to the left: its back = previous page mirrored, on matte stock */
.verso { display: none; }
.phone.land .verso.on {
  display: block; position: absolute; top: 0; bottom: 0; right: 100%; width: 100%; overflow: hidden;
  background: var(--cream); box-shadow: 0 22px 28px rgba(32, 48, 108, .14);
  cursor: grab; touch-action: none; user-select: none;
}
.verso img { pointer-events: none; }
.verso img { display: block; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); opacity: .3; filter: saturate(.85) blur(.3px); }
.verso::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(to left, rgba(40, 34, 24, .24) 0, rgba(40, 34, 24, .08) 1.5%, transparent 8%),
    url(paper.webp) 0 0 / 256px;
  mix-blend-mode: multiply;
}
.phone.land .turn { display: grid; width: 40px; height: 40px; margin-top: -20px; background: none; box-shadow: none; color: rgba(242, 239, 231, .75); filter: drop-shadow(0 0 3px rgba(0, 0, 0, .25)); }
.phone.land .turn svg { width: 18px; height: 18px; stroke-width: 1; }
.phone.land .turn-prev { z-index: 6; }
.phone.land .turn-prev { left: max(6px, env(safe-area-inset-left)); }
.phone.land .turn-next { right: max(6px, env(safe-area-inset-right)); }

@media (prefers-reduced-motion: reduce) {
  .book-wrap { transition: none; }
}

/* Matte stock: the library paints a white highlight band on turning sheets (gloss).
   Multiply keeps its shading but drops the highlight. */
.stf__innerShadow, .stf__hardInnerShadow { mix-blend-mode: multiply; }

/* One-page view, back cover: closed magazine, spine shading on the right edge */
.--portrait .stf__item.is-back::after {
  background: linear-gradient(to left, rgba(40, 34, 24, .14) 0, rgba(40, 34, 24, .04) 1.6%, transparent 6%), url(paper.webp) 0 0 / 256px;
}
