/* ============================================================
   Beton Chimie Middle East - Digital Catalog
   Layers (z-index): ambient 0 / app 1 / scrim 40 / toc 50 /
   zoom 60 / toast 70 / intro 80
   ============================================================ */

/* Two font files only (Regular, Bold); 500 and 800 reuse them to keep the first load small */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 800;
  font-display: swap;
}
/* Phosphor Icons (Bold), MIT license, vendored locally so the catalog works offline.
   The font is cut down to only the icons listed below (.ph-* rules) to keep it tiny. */
@font-face {
  font-family: "Phosphor-Bold";
  src: url("../fonts/Phosphor-Bold.woff2") format("woff2");
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

/* ---------- Tokens ---------- */
:root {
  --font: "Vazirmatn", Tahoma, sans-serif;

  --green: #2F7340;
  --green-strong: #245A32;
  --green-on: #FFFFFF;
  --red: #B41E24;

  --bg: #E4E7E2;
  --bg-deep: #D5D9D3;
  --surface: rgba(246, 248, 245, 0.74);
  --surface-solid: #F4F6F3;
  --surface-hover: rgba(47, 115, 64, 0.09);
  --line: rgba(24, 38, 28, 0.10);
  --line-strong: rgba(24, 38, 28, 0.18);
  --text: #16201A;
  --muted: #56635A;
  --paper: #FFFFFF;
  --paper-shadow: rgba(22, 44, 30, 0.30);
  --grain-opacity: 0.55;
  --lattice-opacity: 0.16;
  --glow-green: 0.20;
  --glow-red: 0.07;
  --scrim: rgba(18, 26, 21, 0.38);

  --radius: 10px;
  --radius-lg: 14px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-flip: cubic-bezier(0.5, 0.05, 0.25, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --green: #4FA866;
    --green-strong: #64BC7A;
    --green-on: #0D140F;
    --red: #E0484E;
    --bg: #101411;
    --bg-deep: #0B0E0C;
    --surface: rgba(24, 30, 26, 0.72);
    --surface-solid: #171C18;
    --surface-hover: rgba(79, 168, 102, 0.14);
    --line: rgba(220, 235, 224, 0.09);
    --line-strong: rgba(220, 235, 224, 0.18);
    --text: #E6ECE7;
    --muted: #96A39A;
    --paper-shadow: rgba(0, 0, 0, 0.6);
    --grain-opacity: 0.35;
    --lattice-opacity: 0.14;
    --glow-green: 0.22;
    --glow-red: 0.08;
    --scrim: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --green: #4FA866;
  --green-strong: #64BC7A;
  --green-on: #0D140F;
  --red: #E0484E;
  --bg: #101411;
  --bg-deep: #0B0E0C;
  --surface: rgba(24, 30, 26, 0.72);
  --surface-solid: #171C18;
  --surface-hover: rgba(79, 168, 102, 0.14);
  --line: rgba(220, 235, 224, 0.09);
  --line-strong: rgba(220, 235, 224, 0.18);
  --text: #E6ECE7;
  --muted: #96A39A;
  --paper-shadow: rgba(0, 0, 0, 0.6);
  --grain-opacity: 0.35;
  --lattice-opacity: 0.14;
  --glow-green: 0.22;
  --glow-red: 0.08;
  --scrim: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.4s ease, color 0.4s ease;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.ph {
  font-family: "Phosphor-Bold" !important;
  font-style: normal;
  font-weight: normal;
  line-height: 1;
  speak: never;
  display: inline-block;
  -webkit-font-smoothing: antialiased;
}
.ph-caret-right::before { content: "\e13a"; }
.ph-caret-left::before { content: "\e138"; }
.ph-squares-four::before { content: "\e464"; }
.ph-magnifying-glass-plus::before { content: "\e310"; }
.ph-magnifying-glass-minus::before { content: "\e30e"; }
.ph-arrows-out::before { content: "\e0a2"; }
.ph-arrows-in::before { content: "\e09a"; }
.ph-download-simple::before { content: "\e20c"; }
.ph-share-network::before { content: "\e408"; }
.ph-sun::before { content: "\e472"; }
.ph-moon::before { content: "\e330"; }
.ph-x::before { content: "\e4f6"; }
.ph-arrow-counter-clockwise::before { content: "\e038"; }
.ph-phone::before { content: "\e3b8"; }
.ph-globe-simple::before { content: "\e28e"; }
.ph-envelope-simple::before { content: "\e218"; }
.ph-instagram-logo::before { content: "\e2d0"; }
.ph-map-pin::before { content: "\e316"; }
.ph-check::before { content: "\e182"; }
.ph-music-notes::before { content: "\e340"; }
.ph-speaker-slash::before { content: "\e45a"; }

/* ---------- Ambient background: concrete + molecular lattice ---------- */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 40%, var(--bg-deep) 100%),
    var(--bg);
  transition: background-color 0.4s ease;
}

/* Hexagon lattice (benzene rings) fading out behind the book */
.ambient__lattice {
  position: absolute;
  inset: 0;
  -webkit-mask-image: radial-gradient(70% 70% at 50% 50%, transparent 30%, #000 85%);
  mask-image: radial-gradient(70% 70% at 50% 50%, transparent 30%, #000 85%);
  opacity: var(--lattice-opacity);
}
.ambient__lattice::before {
  content: "";
  position: absolute;
  inset: -120px;
  background-color: var(--green);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cpath d='M28 66L0 50L0 16L28 0L56 16L56 50L28 66L28 100' fill='none' stroke='%23000' stroke-width='1.2'/%3E%3Cpath d='M28 0L28 34L0 50L0 84L28 100L56 84L56 50L28 34' fill='none' stroke='%23000' stroke-width='1.2'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='100' viewBox='0 0 56 100'%3E%3Cpath d='M28 66L0 50L0 16L28 0L56 16L56 50L28 66L28 100' fill='none' stroke='%23000' stroke-width='1.2'/%3E%3Cpath d='M28 0L28 34L0 50L0 84L28 100L56 84L56 50L28 34' fill='none' stroke='%23000' stroke-width='1.2'/%3E%3C/svg%3E");
  -webkit-mask-size: 56px 100px;
  mask-size: 56px 100px;
  animation: lattice-drift 80s linear infinite alternate;
  will-change: transform;
}

.ambient__glow {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  will-change: transform;
}
.ambient__glow--green {
  top: -30vmax;
  right: -20vmax;
  background: radial-gradient(closest-side, var(--green), transparent);
  opacity: var(--glow-green);
  animation: glow-drift-a 34s ease-in-out infinite alternate;
}
.ambient__glow--red {
  bottom: -38vmax;
  left: -24vmax;
  background: radial-gradient(closest-side, var(--red), transparent);
  opacity: var(--glow-red);
  animation: glow-drift-b 42s ease-in-out infinite alternate;
}

/* Concrete grain: fine pores + cloudy mottling */
.ambient__grain {
  position: absolute;
  inset: 0;
  opacity: var(--grain-opacity);
  mix-blend-mode: soft-light;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='900'%3E%3Cfilter id='m'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.006' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23m)'/%3E%3C/svg%3E");
  background-size: 240px 240px, 900px 900px;
}

@keyframes lattice-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(56px, 100px, 0); }
}
@keyframes glow-drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-12vmax, 10vmax, 0) scale(1.15); }
}
@keyframes glow-drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.1); }
  to { transform: translate3d(14vmax, -8vmax, 0) scale(0.95); }
}

/* ---------- App shell ---------- */
.app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-rows: 64px 1fr auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  position: relative;
}
.topbar::before {
  content: "";
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 3px;
  background: linear-gradient(to left, var(--green) 0 82%, var(--red) 82% 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
}
.brand__mark {
  width: 36px;
  height: 36px;
  flex: none;
}
.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}
.brand__text strong {
  font-weight: 800;
  font-size: 15px;
  color: var(--green);
  white-space: nowrap;
}
.brand__text span {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.tools {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tool {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-size: 19px;
  text-decoration: none;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}
.tool:hover {
  background: var(--surface-hover);
  color: var(--green);
}
.tool:active {
  transform: scale(0.94);
}
.tool[hidden] {
  display: none;
}

@media (hover: hover) {
  .tool[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translate(-50%, -4px);
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--text);
    color: var(--bg);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s var(--ease-out);
    z-index: 5;
  }
  .tool[data-tip]:hover::after {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Music button: three small bars move while music plays */
.tool--sound .eq {
  position: absolute;
  bottom: 7px;
  right: 7px;
  display: none;
  align-items: flex-end;
  gap: 1.5px;
  height: 8px;
}
.tool--sound.is-playing .eq {
  display: flex;
}
.tool--sound .eq span {
  width: 2px;
  height: 100%;
  border-radius: 1px;
  background: var(--green);
  transform-origin: bottom;
  animation: eq 1.1s ease-in-out infinite;
}
.tool--sound .eq span:nth-child(2) {
  animation-delay: -0.4s;
  animation-duration: 0.9s;
}
.tool--sound .eq span:nth-child(3) {
  animation-delay: -0.7s;
  animation-duration: 1.3s;
}
.tool--sound.is-playing {
  color: var(--green);
}
@keyframes eq {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

/* ---------- Stage & book ---------- */
.stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  perspective: 1800px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.book {
  position: relative;
  width: calc(var(--pw, 300px) * var(--cols, 2));
  height: var(--ph, 420px);
}

.book__shift {
  position: absolute;
  inset: 0;
  perspective: 2400px;
  transform-style: preserve-3d;
}

.book__shadow {
  position: absolute;
  inset: 0;
  border-radius: 4px;
  box-shadow:
    0 40px 70px -30px var(--paper-shadow),
    0 12px 24px -12px var(--paper-shadow);
  transform-origin: left center;
}

.slot {
  position: absolute;
  top: 0;
  width: var(--pw, 300px);
  height: var(--ph, 420px);
}
.slot--left {
  left: 0;
}
.slot--right {
  left: var(--pw, 300px);
}
.book[data-mode="single"] .slot--right {
  display: none;
}
.slot__holder {
  position: absolute;
  inset: 0;
}
.slot__cast {
  position: absolute;
  inset: 0;
  background: #0B140E;
  opacity: 0;
  pointer-events: none;
}
/* Soft shadow thrown by the turning sheet onto the page below */
.slot__fold {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 120px;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}
.slot {
  overflow: visible;
}
.slot__holder {
  overflow: hidden;
}

/* Page stack edges on the outer sides */
.slot--left:not(.is-empty)::before,
.slot--right:not(.is-empty)::before {
  content: "";
  position: absolute;
  top: 3px;
  bottom: 3px;
  width: 5px;
  background: repeating-linear-gradient(to right, #F2F3F1 0 1px, #D9DCD8 1px 2px);
  border-radius: 1px;
}
.slot--left:not(.is-empty)::before {
  left: -4px;
}
.slot--right:not(.is-empty)::before {
  right: -4px;
}
.book[data-mode="single"] .slot--left::before {
  display: none;
}

.page {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--paper);
  cursor: pointer;
}
.page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}
.page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.page--left {
  border-radius: 3px 0 0 3px;
}
.page--left::after {
  background: linear-gradient(to left, rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0.04) 4%, transparent 9%);
}
.page--right {
  border-radius: 0 3px 3px 0;
}
.page--right::after {
  background: linear-gradient(to right, rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0.04) 4%, transparent 9%);
}
.page--single {
  border-radius: 3px;
}
.page--single::after {
  background: linear-gradient(to left, rgba(0, 0, 0, 0.08), transparent 4%);
}

/* Loading skeleton */
.page.is-loading img {
  opacity: 0;
}
.page.is-loading img,
.page img {
  transition: opacity 0.35s ease;
}
.book.is-dragging,
.book.is-dragging .page {
  cursor: grabbing;
}
.book.is-waiting .page {
  cursor: progress;
}
.page.is-loading {
  background:
    linear-gradient(100deg, transparent 30%, rgba(47, 115, 64, 0.07) 50%, transparent 70%) 0 0 / 250% 100%,
    linear-gradient(#FFFFFF, #FFFFFF);
  animation: shimmer 1.4s linear infinite;
}
.page.is-loading::before {
  content: "";
  position: absolute;
  top: 9%;
  inset-inline: 10%;
  height: 4%;
  border-radius: 4px;
  background: #EEF1ED;
  box-shadow:
    0 calc(var(--ph, 420px) * 0.1) 0 #F3F5F2,
    0 calc(var(--ph, 420px) * 0.16) 0 #F3F5F2,
    0 calc(var(--ph, 420px) * 0.22) 0 #F3F5F2;
}
@keyframes shimmer {
  from { background-position: 150% 0, 0 0; }
  to { background-position: -100% 0, 0 0; }
}

/* Thumbnail placeholder: the small preview fills the page until the full image arrives */
.page.has-thumb,
.page.has-thumb.is-loading {
  background-color: var(--paper);
  background-position: 0 0;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  animation: none;
}
.page.has-thumb.is-loading::before {
  display: none;
}

/* Error state */
.page.is-error {
  display: grid;
  place-items: center;
  background: #FFFFFF;
}
.page.is-error img {
  display: none;
}
.page.is-error::before {
  content: attr(data-error);
  padding: 24px;
  text-align: center;
  font-size: 13px;
  line-height: 1.8;
  color: #9F2F2D;
  white-space: pre-line;
}

/* Per-page zoom button */
.page__zoom {
  position: absolute;
  top: 10px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.92);
  color: #1D2A21;
  font-size: 17px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s var(--ease-out), background-color 0.2s ease;
}
.page--left .page__zoom,
.page--single .page__zoom {
  left: 10px;
}
.page--right .page__zoom {
  right: 10px;
}
.page__zoom:hover {
  background: #FFFFFF;
  color: #2F7340;
}
@media (hover: hover) {
  .slot .page:hover .page__zoom {
    opacity: 1;
    transform: translateY(0);
  }
}
.leaf .page__zoom {
  display: none;
}

/* Turning sheet: chained strips that bend like paper */
.leaf {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--pw, 300px);
  height: var(--ph, 420px);
  transform-style: preserve-3d;
  pointer-events: none;
  z-index: 3;
}
.leaf--bwd {
  left: var(--pw, 300px);
}
.strip {
  position: absolute;
  top: 0;
  height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
}
.leaf--fwd .strip,
.leaf--single .strip {
  transform-origin: right center;
}
.leaf--bwd .strip {
  transform-origin: left center;
}
.strip__face {
  position: absolute;
  inset: 0;
  background-color: var(--paper);
  background-repeat: no-repeat;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  outline: 1px solid transparent;
}
.strip__face--back {
  transform: rotateY(180deg);
}
.strip__face--blank {
  background: linear-gradient(to left, #E6E8E4, #F3F4F1 30%, #F7F8F5);
}
.strip__shade {
  position: absolute;
  inset: 0;
  background: #0B140E;
  opacity: 0;
}

/* Side navigation */
.side-nav {
  position: absolute;
  top: 50%;
  z-index: 4;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 20px;
  transform: translateY(-50%);
  transition: background-color 0.2s ease, color 0.2s ease, opacity 0.3s ease, transform 0.2s var(--ease-out);
}
.side-nav--prev {
  inset-inline-start: 20px;
}
.side-nav--next {
  inset-inline-end: 20px;
}
.side-nav:hover:not(:disabled) {
  background: var(--green);
  border-color: var(--green);
  color: var(--green-on);
}
.side-nav--prev:hover:not(:disabled) {
  transform: translateY(-50%) translateX(3px);
}
.side-nav--next:hover:not(:disabled) {
  transform: translateY(-50%) translateX(-3px);
}
.side-nav:disabled,
.step:disabled {
  opacity: 0.28;
  cursor: default;
}

/* Empty state */
.empty {
  max-width: 420px;
  padding: 32px;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.empty img {
  width: 56px;
  height: 56px;
  opacity: 0.85;
}
.empty h2 {
  margin: 16px 0 8px;
  font-size: 18px;
}
.empty p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}
.empty code {
  font-family: Consolas, "SF Mono", monospace;
  font-size: 12.5px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-hover);
  direction: ltr;
  display: inline-block;
}

/* ---------- Bottom bar ---------- */
.bottombar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  width: min(760px, 100% - 32px);
  margin: 0 auto 16px;
  margin-bottom: max(16px, env(safe-area-inset-bottom));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
}

.step {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius);
  background: var(--green);
  color: var(--green-on);
  font-size: 19px;
  transition: background-color 0.2s ease, transform 0.15s ease;
}
.step:hover:not(:disabled) {
  background: var(--green-strong);
}
.step:active:not(:disabled) {
  transform: scale(0.95);
}

.progress {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.progress__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.progress__title {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress__num {
  flex: none;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.progress__range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  --p: 0%;
}
.progress__range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(to left, var(--green) var(--p), var(--line-strong) var(--p));
}
.progress__range::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(to left, var(--green) var(--p), var(--line-strong) var(--p));
}
.progress__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  border: 3px solid var(--surface-solid);
  background: var(--green);
  box-shadow: 0 0 0 1px var(--green);
  transition: transform 0.15s ease;
}
.progress__range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid var(--surface-solid);
  background: var(--green);
  box-shadow: 0 0 0 1px var(--green);
}
.progress__range:active::-webkit-slider-thumb {
  transform: scale(1.2);
}

/* ---------- Table of contents ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.toc {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  z-index: 50;
  width: min(440px, 92vw);
  display: flex;
  flex-direction: column;
  background: var(--surface-solid);
  border-inline-end: 1px solid var(--line);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.5s var(--ease-out), visibility 0s linear 0.5s;
}
.toc.is-open {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.5s var(--ease-out), visibility 0s;
}

.toc__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  padding-top: max(16px, env(safe-area-inset-top));
}
.toc__head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.toc__grid {
  list-style: none;
  margin: 0;
  padding: 8px 20px 24px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px 16px;
  overflow-y: auto;
  flex: 1;
  overscroll-behavior: contain;
}

.toc__item {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: right;
  opacity: 0;
  transform: translateY(12px);
}
.toc.is-open .toc__item {
  animation: rise 0.6s var(--ease-out) forwards;
  animation-delay: calc(var(--i) * 45ms + 120ms);
}
.toc__thumb {
  position: relative;
  aspect-ratio: var(--ratio, 0.707);
  border-radius: 6px;
  overflow: hidden;
  background: #FFFFFF;
  border: 1px solid var(--line);
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s ease, border-color 0.2s ease;
}
.toc__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.toc__item:hover .toc__thumb {
  transform: translateY(-3px);
  box-shadow: 0 10px 22px -12px var(--paper-shadow);
}
.toc__item.is-current .toc__thumb {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green);
}
.toc__label {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 13px;
  line-height: 1.5;
}
.toc__num {
  flex: none;
  min-width: 26px;
  padding: 0 6px;
  border-radius: 9999px;
  background: var(--surface-hover);
  color: var(--green);
  font-weight: 700;
  font-size: 11.5px;
  text-align: center;
}
.toc__item.is-current .toc__num {
  background: var(--green);
  color: var(--green-on);
}
.toc__title {
  font-weight: 500;
}

.toc__contact {
  border-top: 1px solid var(--line);
  padding: 16px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  font-size: 13px;
}
.toc__contact:empty {
  display: none;
}
.toc__contact a,
.toc__contact span {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.toc__contact a:hover {
  color: var(--green);
}
.toc__contact i {
  color: var(--green);
  font-size: 16px;
}
.toc__contact .ltr {
  direction: ltr;
  unicode-bidi: isolate;
}
.toc__phones {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Zoom viewer ---------- */
.zoom {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg-deep) 94%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
.zoom.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0s;
}
.zoom__canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
}
.zoom__canvas::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--green), transparent) 0 0 / 40% 100% no-repeat;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.zoom__canvas.is-sharpening::after {
  opacity: 1;
  animation: sharpen-line 1.1s linear infinite;
}
@keyframes sharpen-line {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}
.zoom__canvas.is-dragging {
  cursor: grabbing;
}
.zoom__img {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  background: #FFFFFF;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.5);
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.zoom__img.is-ready {
  opacity: 1;
}
.zoom__img.is-animating {
  transition: transform 0.35s var(--ease-out), opacity 0.25s ease;
}

.zoom__bar {
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-solid);
  transform: translate(-50%, 16px);
  opacity: 0;
  transition: transform 0.45s var(--ease-out), opacity 0.3s ease;
}
.zoom.is-open .zoom__bar {
  transform: translate(-50%, 0);
  opacity: 1;
}
.zoom__label {
  min-width: 92px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
.zoom__sep {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: var(--line-strong);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 110px;
  z-index: 70;
  padding: 10px 16px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 500;
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.35s var(--ease-out);
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Intro ---------- */
.intro {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 22px;
  transition: opacity 0.6s ease, transform 0.8s var(--ease-out);
}
.intro.is-done {
  opacity: 0;
  transform: scale(1.06);
  pointer-events: none;
}
.intro__mark {
  position: relative;
  width: 132px;
  height: 132px;
}
.intro__mark img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.intro__ring {
  opacity: 0;
  transform: scale(0.7) rotate(-40deg);
  animation: ring-in 0.9s var(--ease-out) 0.1s forwards;
}
.intro__liquid {
  clip-path: inset(85% 0 0 0);
  transform-origin: 50% 70%;
  animation:
    fill 1.1s cubic-bezier(0.45, 0, 0.2, 1) 0.55s forwards,
    slosh 1.2s ease-in-out 1.45s;
}
.intro__name {
  display: grid;
  justify-items: center;
  gap: 2px;
  opacity: 0;
  transform: translateY(12px);
  animation: rise 0.7s var(--ease-out) 0.95s forwards;
}
.intro__brand {
  font-size: 22px;
  font-weight: 800;
  color: var(--green);
}
.intro__latin {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.22em;
  color: var(--muted);
  direction: ltr;
}

@keyframes ring-in {
  to {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}
@keyframes fill {
  from { clip-path: inset(85% 0 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
@keyframes slosh {
  0% { transform: rotate(0); }
  30% { transform: rotate(-4deg); }
  60% { transform: rotate(2.5deg); }
  100% { transform: rotate(0); }
}

/* App entrance after intro */
.app .topbar,
.app .bottombar,
.app .book,
.app .side-nav {
  opacity: 0;
}
.app.is-ready .topbar {
  animation: from-top 0.7s var(--ease-out) forwards;
}
.app.is-ready .bottombar {
  animation: from-bottom 0.7s var(--ease-out) 0.15s forwards;
}
.app.is-ready .book {
  animation: book-in 1.1s var(--ease-out) 0.05s forwards;
}
.app.is-ready .side-nav {
  animation: fade-in 0.6s ease 0.5s forwards;
}
.app.is-ready .side-nav:disabled {
  animation-name: fade-in-dim;
}

@keyframes from-top {
  from { opacity: 0; transform: translateY(-14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes from-bottom {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes book-in {
  from { opacity: 0; transform: translateY(48px) rotateX(16deg) scale(0.96); }
  to { opacity: 1; transform: translateY(0) rotateX(0) scale(1); }
}
@keyframes fade-in {
  to { opacity: 1; }
}
@keyframes fade-in-dim {
  to { opacity: 0.28; }
}
@keyframes nudge-next {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  50% { transform: translateY(-50%) translateX(-6px); }
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  z-index: 90;
  background: var(--bg);
  font-size: 15px;
}

/* ---------- Responsive ---------- */
.step__label {
  display: none;
}

/* Phone pager (data-layout="phone" is set by the viewer for screens whose
   shortest side is under 600px, in portrait and landscape) */
.pager {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: pan-y;
}
.pager[hidden] {
  display: none;
}
.pager__track {
  position: absolute;
  inset: 0;
  will-change: transform;
  transition: opacity 0.17s ease;
}
.pager__track.is-animating {
  transition-property: transform;
  transition-timing-function: cubic-bezier(0.22, 0.8, 0.3, 1);
}
.pager__track.is-fading {
  opacity: 0;
}
.pager__slide {
  position: absolute;
  inset: 0;
}
.pager__scroll {
  position: absolute;
  inset: 0;
  display: grid;
  justify-items: center;
  align-content: safe center;
  padding: 10px 0;
  overflow-x: hidden;
  overflow-y: hidden;
  overscroll-behavior: contain;
  scrollbar-width: none;
}
.pager__scroll.is-scrolling {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-content: start;
  padding-bottom: 24px;
}
.pager__scroll::-webkit-scrollbar {
  display: none;
}
.pager__paper {
  position: relative;
  border-radius: 3px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 16px 34px -18px var(--paper-shadow), 0 2px 6px -3px var(--paper-shadow);
}
.pager__paper .page {
  cursor: default;
}
.pager__paper .page__zoom {
  display: none;
}

[data-layout="phone"] .stage {
  touch-action: pan-y;
}
[data-layout="phone"] .side-nav {
  display: none;
}
[data-layout="phone"] .tool--fs,
[data-layout="phone"] .tools [data-action="theme"] {
  display: none;
}
[data-layout="phone"] .app {
  grid-template-rows: 56px 1fr auto;
}
[data-layout="phone"] .topbar {
  padding: 0 10px;
}
[data-layout="phone"] .brand__text span {
  display: none;
}
[data-layout="phone"] .brand__mark {
  width: 32px;
  height: 32px;
}
[data-layout="phone"] .tool {
  width: 42px;
  height: 42px;
  font-size: 20px;
}

/* Bottom bar: big labelled buttons within thumb reach, position in the middle */
[data-layout="phone"] .bottombar {
  position: relative;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  width: calc(100% - 16px);
  padding: 8px;
  margin-bottom: max(8px, env(safe-area-inset-bottom));
}
[data-layout="phone"] .bottombar::before {
  content: "";
  position: absolute;
  top: 0;
  right: 14px;
  left: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--green);
  transform: scaleX(var(--pr, 0));
  transform-origin: right center;
  transition: transform 0.35s var(--ease-out);
}
[data-layout="phone"] .bottombar .step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  min-width: 92px;
  height: 48px;
  padding: 0 14px;
  font-size: 15px;
  font-weight: 700;
  touch-action: manipulation;
}
[data-layout="phone"] .step__label {
  display: inline;
}
[data-layout="phone"] .step--prev {
  background: transparent;
  color: var(--green);
  box-shadow: inset 0 0 0 1.5px var(--green);
}
[data-layout="phone"] .step--prev:hover:not(:disabled) {
  background: var(--surface-hover);
}
[data-layout="phone"] .progress__range {
  display: none;
}
[data-layout="phone"] .progress__meta {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  text-align: center;
  cursor: pointer;
}
[data-layout="phone"] .progress__title {
  max-width: 100%;
  font-size: 13px;
  line-height: 1.5;
}
[data-layout="phone"] .progress__num {
  font-size: 12px;
}

@media (max-width: 720px) {
  .ambient__grain {
    mix-blend-mode: normal;
    opacity: calc(var(--grain-opacity) * 0.3);
  }
  .ambient__lattice::before,
  .ambient__glow {
    animation: none;
  }
  .toc__grid {
    gap: 16px 12px;
    padding-inline: 16px;
  }
}

@media (max-width: 360px) {
  [data-layout="phone"] .bottombar .step {
    min-width: 0;
    padding: 0 10px;
  }
  [data-layout="phone"] .tool {
    width: 38px;
  }
  .brand__text strong {
    font-size: 13.5px;
  }
}

/* Short screens: phones held sideways */
@media (max-height: 520px) {
  .app,
  [data-layout="phone"] .app {
    grid-template-rows: 48px 1fr auto;
  }
  [data-layout="phone"] .bottombar {
    padding: 4px 6px;
    margin-bottom: max(4px, env(safe-area-inset-bottom));
    width: min(560px, calc(100% - 16px));
  }
  [data-layout="phone"] .bottombar .step {
    height: 40px;
  }
  .bottombar {
    margin-bottom: 6px;
    padding: 6px 8px;
  }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .ambient__lattice::before,
  .ambient__glow {
    animation: none !important;
  }
  .intro {
    display: none;
  }
}

/* ---------- Never wider than the screen ----------
   The page itself must not scroll sideways on phones: the app column is
   clamped to the viewport and the brand name gives way before the tools. */
html {
  overflow: hidden;
}
.app {
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  overflow: hidden;
}
.topbar {
  min-width: 0;
}
.brand {
  flex: 1 1 auto;
}
.brand__text strong,
.brand__text span {
  overflow: hidden;
  text-overflow: ellipsis;
}
.tools {
  flex: none;
}
[data-layout="phone"] .tools {
  gap: 2px;
}
@media (max-width: 380px) {
  [data-layout="phone"] .tool {
    width: 38px;
    height: 40px;
    font-size: 19px;
  }
}
/* Phones: download lives in the page list, so the brand name fits in the top bar */
[data-layout="phone"] #downloadBtn {
  display: none;
}
.toc__download {
  font-weight: 700;
}
