/* ==========================================================================
   ELAUR — catalog flipbook (catalog.html)
   Tokens follow the ELAUR design system (design system.txt).
   ========================================================================== */

@font-face {
  font-family: "Jost";
  font-style: normal;
  font-weight: 300 500;
  font-display: swap;
  src: url("assets/fonts/jost-normal-latin.woff2") format("woff2");
}

:root {
  --ivory-100: #F7F3EC;
  --ink-900: #1A1714;
  --ink-800: #24201C;
  --gold-300: #DCC398;
  --muted: rgb(247 243 236 / 0.72);
  --hairline: rgb(247 243 236 / 0.18);

  --font-body: "Jost", "Futura", "Century Gothic", system-ui, sans-serif;
  --label-size: 0.75rem;
  --label-tracking: 0.14em;
  --gutter: clamp(16px, 3.2vw, 40px);
  --bar-h: 64px;

  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-hover: 160ms;
}

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

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--ink-900);
  color: var(--ivory-100);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

img,
svg { display: block; max-width: 100%; }

button,
input { font: inherit; color: inherit; }

button,
input,
a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
p { margin: 0; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--ivory-100);
  outline-offset: 2px;
}

/* ---------- Frame: bars top and bottom, the book fills the rest ---------- */

.reader {
  position: fixed;
  inset: 0;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding:
    env(safe-area-inset-top)
    env(safe-area-inset-right)
    env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.bar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--bar-h);
  padding: 0 var(--gutter);
}
.bar--top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  border-bottom: 1px solid var(--hairline);
}
.bar--bottom {
  justify-content: center;
  border-top: 1px solid var(--hairline);
}

.bar__home img { width: auto; height: 34px; }

.bar__title,
.sheet__title,
.jump {
  font-size: var(--label-size);
  font-weight: 500;
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
}
.bar__title { color: var(--muted); white-space: nowrap; }

.bar__tools {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.tool {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgb(247 243 236 / 0.4);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: border-color var(--dur-hover) var(--ease-standard),
              color var(--dur-hover) var(--ease-standard);
}
.tool:hover { border-color: var(--ivory-100); color: var(--gold-300); }
.tool:disabled { opacity: 0.35; cursor: default; }
.tool:disabled:hover { border-color: rgb(247 243 236 / 0.4); color: inherit; }

.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Section tabs ---------- */

/* One row that scrolls sideways when the tabs don't fit; the edges fade to hint at more. */
.sections {
  position: relative;          /* offsetLeft of tabs is measured from here */
  display: flex;
  gap: 4px;
  padding: 0 var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-padding-inline: var(--gutter);
  border-bottom: 1px solid var(--hairline);
  mask-image: linear-gradient(to right, transparent 0, #000 var(--gutter), #000 calc(100% - var(--gutter)), transparent 100%);
}
.sections::-webkit-scrollbar { display: none; }
@media (min-width: 1100px) {
  .sections { justify-content: center; }
}

.section-tab {
  flex: none;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-bottom: 1px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: var(--label-tracking);
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-hover) var(--ease-standard),
              border-color var(--dur-hover) var(--ease-standard);
}
.section-tab:hover { color: var(--ivory-100); }
.section-tab[aria-current="true"] {
  color: var(--gold-300);
  border-bottom-color: var(--gold-300);
}

/* ---------- Page counter ---------- */

.jump {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.jump__input {
  width: 5.5em;
  height: 36px;
  padding: 0 6px;
  border: 1px solid rgb(247 243 236 / 0.4);
  border-radius: 2px;
  background: transparent;
  color: var(--ivory-100);
  text-align: center;
  font-size: 1rem;          /* ≥16px stops iOS from zooming on focus */
  letter-spacing: 0;
}
.jump__input:focus-visible { border-color: var(--ivory-100); outline: none; }

/* ---------- The book ---------- */

.stage {
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3dvh, 32px) var(--gutter);
  overflow: hidden;
}

.stage__status {
  position: absolute;
  color: var(--muted);
  font-size: 0.875rem;
}
.stage__status:empty { display: none; }

/* The book fills the stage; catalog.js sizes the spread inside it (--pw, --ph: one page). */
.book {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  perspective: 2600px;
  touch-action: pan-y;        /* horizontal swipes turn pages */
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

.spread {
  position: relative;
  width: calc(var(--pw) * 2);
  height: var(--ph);
  transform-style: preserve-3d;
}
.spread.is-portrait { width: var(--pw); }

.slot,
.turn {
  position: absolute;
  top: 0;
  width: var(--pw);
  height: var(--ph);
}
.slot--left { left: 0; }
.slot--right { left: var(--pw); }
.is-portrait .slot--left { display: none; }
.is-portrait .slot--right,
.is-portrait .turn--right { left: 0; }

.slot:not(.is-empty) { box-shadow: 0 14px 40px rgb(0 0 0 / 0.35); }

/* A soft fold at the spine, on open spreads only (not on the closed cover). */
.spread:not(.is-portrait):not(:has(.slot.is-empty)) .slot::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
.spread:not(.is-portrait) .slot--left::after { background: linear-gradient(to left, rgb(0 0 0 / 0.1), transparent 6%); }
.spread:not(.is-portrait) .slot--right::after { background: linear-gradient(to right, rgb(0 0 0 / 0.1), transparent 6%); }

/* The turning page: two faces back to back, rotating about the spine. */
.turn {
  z-index: 2;
  transform-style: preserve-3d;
  will-change: transform;
}
.turn--right { left: var(--pw); transform-origin: left center; }
.turn--left { left: 0; transform-origin: right center; }

.face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.face--back { transform: rotateY(180deg); }

.shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--ink-900);
  opacity: 0;
  pointer-events: none;
}

/* A page: its small preview shows at once, the full image fades in over it when it lands. */
.leaf {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #fff no-repeat center / 100% 100%;
}
.leaf img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 200ms var(--ease-standard);
  user-select: none;
  -webkit-user-drag: none;
}
.leaf img.is-loaded { opacity: 1; }

/* Divider leaf: opens a section that would otherwise start beside the previous one. */
.leaf--divider { background: var(--ivory-100); }
.divider {
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 8% 10%;
  color: var(--ink-900);
  container-type: size;
}
.divider__label {
  font-weight: 300;
  font-size: 7cqw;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.2;
}
.divider__label:empty { visibility: hidden; }
.divider__label::after {
  content: "";
  display: block;
  width: 12cqw;
  height: 1px;
  margin: 6cqw auto 0;
  background: #B48F5B;
}
.divider__brand {
  font-weight: 500;
  font-size: 2.6cqw;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #7C5C33;
}

/* ---------- Sheets: all pages, zoom ---------- */

.sheet {
  width: min(1200px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: var(--ink-800);
  color: var(--ivory-100);
}
.sheet::backdrop { background: rgb(26 23 20 / 0.72); }
.sheet[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--bar-h);
  padding: env(safe-area-inset-top) var(--gutter) 0;
  border-bottom: 1px solid var(--hairline);
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 20px 14px;
  margin: 0;
  padding: 20px var(--gutter) calc(32px + env(safe-area-inset-bottom));
  overflow-y: auto;
  list-style: none;
}
.thumbs button {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.75rem;
  cursor: pointer;
}
.thumbs img {
  width: 100%;
  aspect-ratio: var(--page-ratio, 612 / 792);
  object-fit: contain;
  background: #fff;
  outline: 1px solid transparent;
  outline-offset: 2px;
  transition: outline-color var(--dur-hover) var(--ease-standard);
}
.thumbs button:hover { color: var(--ivory-100); }
.thumbs button:hover img,
.thumbs [aria-current="page"] img { outline-color: var(--gold-300); }

.zoom {
  overflow: auto;
  padding: 16px var(--gutter) calc(32px + env(safe-area-inset-bottom));
}
.zoom img {
  width: min(1100px, 200vw);
  max-width: none;
  margin: 0 auto 16px;
  background: #fff;
}

/* ---------- Small screens ---------- */

@media (max-width: 600px) {
  :root { --bar-h: 56px; }
  .bar { gap: 10px; }
  .bar--top { grid-template-columns: auto 1fr auto; }
  .bar__home img { height: 26px; }
  .bar__title { display: none; }
  #btn-full { display: none; }   /* phones: the browser already fills the screen */
}

@media (pointer: coarse) {
  .tool { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
