/* =========================================================
   The Money Book — landing page
   Built to match "Money Book Website Design.pdf" and
   "Money Book Arabic Website Design.pdf" (390px wide mobile designs).
   Every size and gap below is measured from those files.
   ========================================================= */

:root {
  /* Palette (sampled from the designs) */
  --ink: #121212;
  --grey: #707070;
  --teal: #0F7173;
  --cream: #FBF8F2;
  --white: #FFFFFF;
  --card-line: #CFCFCF;
  --divider: #E6E6E6;
  --dot: #D4D4D4;
  --footer-muted: #8A8A8A;
  --footer-link: #B5B5B5;
  --focus: #0F7173;

  --font: Arial, Helvetica, "Liberation Sans", sans-serif;
  --font-quote: var(--font);
  --pad: 16px;                 /* page side padding */
  --content: 640px;            /* column width on screens wider than the design */

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --flip: 1;                   /* 1 in LTR, -1 in RTL */
  --drawer-off: 100%;
  --menu-off: -100%;
}
[dir="rtl"] { --flip: -1; --drawer-off: -100%; --menu-off: 100%; }

/* Arabic: Noto Sans Arabic for Arabic letters; digits and Latin fall back to Arial, as in the design */
[lang="ar"] {
  --font: "Noto Sans Arabic", Arial, Helvetica, sans-serif;
  --font-quote: "Noto Naskh Arabic", "Noto Sans Arabic", Arial, serif;
}
[lang="en"] { --font: Arial, Helvetica, "Liberation Sans", sans-serif; --font-quote: var(--font); }
[lang] { font-family: var(--font); }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 56px; }
html:has(dialog[open]) { overflow: hidden; }
body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-size: 13px;
  line-height: 18px;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
h1, h2, h3, p, figure, blockquote, dl, dd, ol { margin: 0; }
h1, h2, h3 { font-weight: 400; }
ol { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
a { color: inherit; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.announce :focus-visible, .footer :focus-visible { outline-color: var(--white); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; inset-inline-start: 16px; top: -100px; z-index: 100;
  background: var(--ink); color: var(--white); padding: 12px 16px; text-decoration: none;
}
.skip-link:focus { top: 16px; }

.wrap { width: 100%; max-width: calc(var(--content) + 2 * var(--pad)); margin-inline: auto; padding-inline: var(--pad); }
.sep { margin-inline: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 52px; padding: 0 16px;
  background: var(--ink); color: var(--white);
  border: 0; border-radius: 0;
  font-family: var(--font); font-size: 15px; line-height: 1;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color 150ms var(--ease);
}
.btn:hover { background: #000; }
.btn:active { background: #2a2a2a; }
.btn--pill { width: 170px; height: 34px; border-radius: 17px; font-size: 12px; }
.btn--sm { width: auto; height: 44px; padding: 0 24px; font-size: 14px; }
.btn--outline { background: var(--white); color: var(--ink); border: 1px solid var(--ink); }
.btn--outline:hover { background: var(--ink); color: var(--white); }

.text-link {
  background: none; border: 0; padding: 13px 0; margin: -13px 0; /* 44px tap area, no layout change */
  font-family: var(--font); font-size: 12px; line-height: 18px; color: var(--ink); cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 1px;
}
.text-link--muted { color: var(--grey); font-size: 13px; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  background: none; border: 0; color: var(--ink); cursor: pointer;
}

/* ---------- Announcement bar ---------- */
.announce {
  height: 32px; padding: 6px var(--pad) 0;
  background: var(--ink); color: var(--white);
  font-size: 11px; line-height: 16px; text-align: center; white-space: nowrap; overflow: hidden;
}

/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: 40;
  background: var(--white); border-bottom: 1px solid var(--divider);
}
.header__inner {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 48px; padding: 0 4px 2px;
  max-width: calc(var(--content) + 2 * var(--pad)); margin-inline: auto;
}
.header__start { display: flex; align-items: center; justify-self: start; }
.cart-btn { justify-self: end; }

/* Language switch next to the menu button: shows the other language */
.lang-switch {
  display: inline-grid; place-items: center;
  height: 44px; padding: 0; margin-inline-start: 2px;
  background: none; border: 0; cursor: pointer; color: var(--ink);
}
.lang-switch span {
  display: block; height: 26px; padding: 0 9px;
  border: 1px solid var(--card-line);
  font-size: 12px; line-height: 24px; white-space: nowrap;
}
.lang-switch span[lang="ar"] { font-family: "Noto Sans Arabic", Arial, sans-serif; font-size: 13px; }
.lang-switch span[lang="en"] { font-family: Arial, Helvetica, sans-serif; }
.lang-switch:hover span { border-color: var(--ink); }
.lang-switch:focus-visible { outline: none; }
.lang-switch:focus-visible span { outline: 2px solid var(--focus); outline-offset: 2px; }
.wordmark {
  justify-self: center; position: relative; top: -1.5px;
  font-size: 12px; line-height: 12px; text-decoration: none; white-space: nowrap;
}
[lang="ar"] .wordmark { font-size: 12px; }
.cart-btn__badge {
  position: absolute; top: 3px; inset-inline-end: 3px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--teal); color: var(--white);
  font: 10px/16px Arial, sans-serif; text-align: center;
}

/* ---------- Hero ---------- */
.hero__media {
  display: flex; justify-content: center;
  padding: 16px var(--pad); background: var(--cream);
}
/* 358px tall like the design. The cover shows at 240 × 358 (as designed);
   the square preview cards use the full width so their text stays readable. */
.slides {
  position: relative; overflow: hidden;
  width: min(100%, 358px); height: 358px;
  touch-action: pan-y; cursor: grab;
}
.slides__slide--card { cursor: zoom-in; }
.slides__track {
  --i: 0;
  display: flex; height: 100%;
  transform: translateX(calc(var(--i) * -100% * var(--flip)));
  transition: transform 420ms var(--ease);
}
.slides__track.is-dragging { transition: none; cursor: grabbing; }
.slides__slide { flex: 0 0 100%; height: 100%; }
.slides__slide img { width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }

/* the design's dots sit 2.5px left of centre and 3.6px apart */
.dots { display: flex; justify-content: center; height: 20px; margin-top: 5px; padding-right: 5px; }
.dot {
  width: 11.6px; height: 20px; padding: 0; border: 0; background: none; cursor: pointer;
  display: grid; place-items: center;
}
.dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }
.dot[aria-current="true"]::before { background: var(--ink); }

.eyebrow { font-size: 11px; line-height: 13px; color: var(--teal); text-transform: uppercase; }
.hero__copy .eyebrow { margin-top: -0.6px; }
.title { margin-top: 6px; font-size: 24px; line-height: 28px; }
.lede { margin-top: 10px; color: var(--grey); }
.price-line { display: flex; flex-wrap: wrap; align-items: baseline; margin-top: 15px; line-height: 22px; }
.price { font-size: 18px; white-space: nowrap; }
.price-line__specs { margin-inline-start: 5.5px; font-size: 11px; line-height: 15px; color: var(--grey); }
.hero__copy .btn { margin-top: 16px; }
.hero__note { margin-top: 15px; font-size: 12px; text-align: center; }
.hero__peek { margin-top: 4px; text-align: center; }

/* Arabic copy carries the design's line breaks as "\n" */
.title, .lede, .section-sub, .part__body { white-space: pre-line; }

/* ---------- Sections ---------- */
.h2 { font-size: 17px; line-height: 22px; text-align: center; }
.section-sub { margin-top: 6px; color: var(--grey); text-align: center; }
/* Video ("Peek inside the book" scrolls here) — placeholder until the video is set */
.video { padding-top: 56px; }
.video__frame {
  position: relative; margin-top: 24px; aspect-ratio: 16 / 9;
  max-height: 80vh; margin-inline: auto;
  background: var(--cream); border: 1px solid var(--card-line); overflow: hidden;
}
.video__frame video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.video__placeholder {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  color: var(--grey); font-size: 12px;
}
.video__play {
  display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  background: var(--ink); color: var(--white); padding-left: 4px; /* optical centre; the triangle is never mirrored */
}

.inside { padding-top: 62px; }
.details { padding-top: 62px; }
.reviews { padding: 56px 0 18px; }
.faq { padding: 42px 0 26px; }

/* What's inside */
.parts { display: grid; gap: 8px; margin-top: 17.6px; }
.part {
  height: 104px; padding: 13px 11px 0;
  border: 1px solid var(--card-line);
}
.part__num { display: block; font-size: 10px; line-height: 12px; color: var(--teal); }
.part__title { margin-top: 5px; font-size: 14px; line-height: 18px; }
.part__body { margin-top: 6px; max-width: 316px; font-size: 11px; line-height: 15px; color: var(--grey); }
.btn--after-cards { margin-top: 20px; }

/* Book details */
.specs { margin-top: 19px; }
.specs__row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  height: 38px; padding-top: 11.4px;
  border-bottom: 1px solid var(--divider);
  line-height: 18px;
}
.specs__row:last-child { border-bottom: 0; }
.specs dt { font-size: 11px; color: var(--grey); }
.specs dd { font-size: 12px; text-align: end; }
.btn--after-specs { margin-top: 13px; }

/* Reviews */
.quotes { display: grid; gap: 8px; margin-top: 24px; }
.quote { height: 86px; padding: 15px 15px 0; border: 1px solid var(--card-line); }
.quote blockquote { min-height: 36px; font-family: var(--font-quote); font-style: italic; color: var(--grey); }
[lang="ar"] .quote blockquote { font-style: normal; font-size: 12.4px; }
.quote figcaption { margin-top: 6.5px; font-size: 11px; line-height: 15px; }

/* About the author */
.about { padding: 78px 0 22px; background: var(--cream); }
.about__top { display: grid; grid-template-columns: 144px minmax(0, 1fr); column-gap: 22px; align-items: start; }
.about__photo { width: 144px; height: auto; aspect-ratio: 431 / 546; object-fit: cover; }
.about__name { margin-top: 6px; font-size: 22px; line-height: 26px; }
.about__sub { margin-top: 7px; }
.about__body { margin-top: 18px; font-size: 12px; color: var(--grey); min-height: 90px; }
/* the Arabic design sets the portrait 5px higher and 5.5px in from the edge */
[lang="ar"] .about__photo { translate: -5.5px -5.3px; }
.about__credit { margin-top: 18px; font-size: 11px; line-height: 15px; color: var(--grey); }
.about .btn--pill { margin-top: 12.4px; }

/* Questions (all answers shown, as in the design) */
.qa-list { margin-top: 7px; }
.qa { height: 80px; padding-top: 11px; border-bottom: 1px solid var(--divider); }
.qa:last-child { height: auto; border-bottom: 0; }
.qa__q { font-size: 13px; line-height: 18px; }
.qa__a { margin-top: 4px; font-size: 11px; line-height: 15px; color: var(--grey); }
.btn--after-faq { margin-top: 23px; }

/* Final CTA */
.final { padding: 50px 0 52.4px; background: var(--cream); text-align: center; }
.final__title { font-size: 22px; line-height: 28px; }
.final__price { margin-top: 45px; font-size: 18px; line-height: 22px; }
.final .btn { margin-top: 17px; }
.final__trust { margin-top: 18.5px; font-size: 11px; line-height: 15px; color: var(--grey); }
.final__trust .sep { margin-inline: 5.4px; }

/* Footer */
.footer { padding: 47px 0 48.4px; background: var(--ink); text-align: center; font-size: 11px; line-height: 15px; }
.footer__brand { color: var(--white); font-size: 12px; }
.footer__tag { margin-top: 4.7px; color: var(--footer-muted); }
.footer__nav { margin-top: 45px; color: var(--footer-link); }
.footer__nav a { text-decoration: none; padding: 14px 0; margin: -14px 0; }
.footer__nav a:hover { color: var(--white); text-decoration: underline; }
.footer__copy { margin-top: 25px; color: var(--footer-muted); }

/* =========================================================
   Overlays: menu, cart drawer, peek viewer, language chooser
   ========================================================= */
dialog { padding: 0; border: 0; color: var(--ink); background: var(--white); max-width: none; max-height: none; }
/* JS adds .is-open after showModal() and removes it before close(), so both directions animate */
dialog::backdrop { background: rgba(0, 0, 0, 0); transition: background-color 320ms var(--ease); }
dialog.is-open::backdrop { background: rgba(0, 0, 0, 0.5); }

/* Menu: slides in from the start edge (left in English, right in Arabic) */
.menu {
  position: fixed; inset-block: 0; inset-inline-start: 0; inset-inline-end: auto; margin: 0;
  width: min(320px, 86vw); height: 100dvh;
  flex-direction: column;
  transform: translateX(var(--menu-off));
  transition: transform 320ms var(--ease);
}
.menu[open] { display: flex; }
.menu.is-open { transform: none; }
.menu__head {
  display: flex; align-items: center; justify-content: space-between;
  height: 49px; padding-inline: var(--pad) 4px; border-bottom: 1px solid var(--divider);
}
.menu__title { font-size: 12px; text-transform: uppercase; color: var(--grey); }
.menu__nav { display: grid; }
.menu__nav a {
  display: flex; align-items: center; min-height: 52px; padding: 0 var(--pad);
  border-bottom: 1px solid var(--divider); text-decoration: none; font-size: 15px;
}
.menu__nav a:hover { background: var(--cream); }
.menu__lang { display: grid; gap: 8px; padding: 24px var(--pad); }
.menu__label { font-size: 11px; color: var(--grey); text-transform: uppercase; }
.menu__lang-btn {
  height: 44px; padding: 0 14px; text-align: start; cursor: pointer;
  background: var(--white); border: 1px solid var(--card-line); font-size: 15px;
}
.menu__lang-btn[lang="en"] { font-family: Arial, Helvetica, sans-serif; }
.menu__lang-btn[lang="ar"] { font-family: "Noto Sans Arabic", Arial, sans-serif; }
.menu__lang-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--white); }

/* Cart drawer: slides in from the end edge */
.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; inset-inline-start: auto; margin: 0;
  width: min(420px, 100vw); height: 100dvh;
  flex-direction: column;
  transform: translateX(var(--drawer-off));
  transition: transform 320ms var(--ease);
}
.drawer[open] { display: flex; }
.drawer.is-open { transform: none; }
.drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  height: 49px; padding-inline: var(--pad) 4px; border-bottom: 1px solid var(--divider);
}
.drawer__title { font-size: 17px; line-height: 22px; }
.drawer__body { flex: 1; overflow-y: auto; padding: 20px var(--pad); display: grid; align-content: start; gap: 24px; }
.line { display: flex; gap: 16px; align-items: center; }
.line__thumb { width: 64px; height: auto; aspect-ratio: 718 / 1072; object-fit: cover; }
.line__title { font-size: 15px; }
.line__meta { color: var(--grey); font-size: 12px; }
.line__price { margin-top: 4px; font-size: 13px; }

.editions__legend { padding: 0; margin-bottom: 8px; font-size: 11px; color: var(--grey); text-transform: uppercase; }
.editions__opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
[lang="ar"] .pill--ar { order: -1; } /* Arabic site lists the Arabic edition first */
.pill { position: relative; display: flex; cursor: pointer; }
.pill input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.pill span {
  display: flex; align-items: center; justify-content: center; width: 100%;
  height: 44px; padding: 0 8px;
  border: 1px solid var(--card-line); background: var(--white); font-size: 13px;
}
.pill:hover span { border-color: var(--ink); }
.pill input:checked + span { border-color: var(--ink); background: var(--ink); color: var(--white); }
.pill input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

.qty-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.qty-row__label { margin-inline-end: auto; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--ink); }
.stepper__btn { width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; cursor: pointer; }
.stepper__btn:disabled { color: var(--card-line); cursor: not-allowed; }
.stepper__val { min-width: 32px; text-align: center; font-variant-numeric: tabular-nums; font-family: Arial, sans-serif; }

.summary { border-top: 1px solid var(--ink); }
.summary__row { display: flex; justify-content: space-between; gap: 16px; padding-block: 12px; border-bottom: 1px solid var(--divider); }
.summary dt { color: var(--grey); }
.summary__row--total { border-bottom: 0; }
.summary__row--total dt, .summary__row--total dd { color: var(--ink); font-size: 17px; line-height: 22px; }

.drawer__empty { justify-items: start; gap: 12px; }
.drawer__empty .btn { width: auto; height: 44px; padding: 0 20px; font-size: 13px; }
.drawer__empty-title { font-size: 17px; }
.muted { color: var(--grey); }
.drawer__foot { padding: 16px var(--pad) calc(20px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--divider); display: grid; gap: 12px; }
.drawer__note:empty { display: none; }
.drawer__note { font-size: 12px; padding: 10px 12px; background: var(--cream); border-inline-start: 2px solid var(--ink); }
.drawer__trust { font-size: 11px; line-height: 15px; color: var(--grey); text-align: center; }

/* Peek viewer */
.modal {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  flex-direction: column;
  opacity: 0; transform: translateY(8px);
  transition: opacity 240ms var(--ease), transform 240ms var(--ease);
}
.modal[open] { display: flex; }
.modal.is-open { opacity: 1; transform: none; }
.modal__head {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 4px 8px var(--pad); border-bottom: 1px solid var(--divider);
}
[dir="rtl"] .modal__head { padding: 8px var(--pad) 8px 4px; }
.modal__head > div:first-child { flex: 1; min-width: 0; }
.modal__title { font-size: 17px; line-height: 22px; }
.modal__sub { font-size: 11px; line-height: 15px; color: var(--grey); }
.viewer {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 52px minmax(0, 1fr) 52px; align-items: center;
  padding: 16px 4px; background: var(--cream);
}
.viewer__stage { justify-self: center; height: min(62dvh, 600px); aspect-ratio: 1 / 1; max-width: 100%; }
.viewer__stage img { width: 100%; height: 100%; object-fit: contain; }
.viewer__stage.is-turning { animation: turn 240ms var(--ease); }
@keyframes turn { from { opacity: 0.2; } }
.viewer__nav {
  width: 44px; height: 44px; justify-self: center; display: grid; place-items: center;
  background: var(--white); border: 1px solid var(--ink); border-radius: 50%; cursor: pointer;
}
.viewer__nav:disabled { opacity: 0.3; cursor: not-allowed; }
.viewer[dir="rtl"] .viewer__nav svg { transform: scaleX(-1); }
.modal__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px var(--pad); border-top: 1px solid var(--divider); }
.viewer__count { font-size: 12px; color: var(--grey); }

@media (max-width: 599.98px) {
  .modal { width: 100vw; height: 100dvh; max-height: 100dvh; }
  .viewer { grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr) auto; gap: 16px; }
  .viewer__stage { grid-column: 1 / -1; grid-row: 1; height: auto; width: 100%; max-height: 100%; }
  .viewer__nav--prev { grid-row: 2; grid-column: 1; }
  .viewer__nav--next { grid-row: 2; grid-column: 2; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
