/* ═══════════════════════════════════════
   TMME DESIGN TOKENS + BASE RESET
   Theology Matters Middle East
   ═══════════════════════════════════════ */

/* Selawik — Microsoft's open-source Segoe UI metric-compatible clone (OFL-1.1).
   Self-hosted from /assets/fonts/selawik/. Weight mapping:
     300 → Light       (selawkl.woff2)        — used by book author/translator/meta values
     400 → Semilight   (selawksl.woff2)       — homepage-agreed body weight (lighter than Regular)
     500 → Medium      (selawk-medium.woff2)  — locally interpolated (Regular ↔ Bold midpoint); used by CTAs, meta labels, currency
     700 → Semibold    (selawksb.woff2)       — homepage-agreed bold weight (lighter than full Bold) */
@font-face {
    font-family: 'Selawik';
    font-weight: 300;
    font-style: normal;
    font-display: swap;
    src: url('/assets/fonts/selawik/selawkl.woff2') format('woff2');
}
@font-face {
    font-family: 'Selawik';
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    src: url('/assets/fonts/selawik/selawksl.woff2') format('woff2');
}
@font-face {
    font-family: 'Selawik';
    font-weight: 500;
    font-style: normal;
    font-display: swap;
    src: url('/assets/fonts/selawik/selawk-medium.woff2') format('woff2');
}
@font-face {
    font-family: 'Selawik';
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    src: url('/assets/fonts/selawik/selawksb.woff2') format('woff2');
}

@layer reset, tokens, base, components, pages, utilities;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  a { text-decoration: none; }
  ul { list-style: none; }
  button, input { font: inherit; border: none; background: none; cursor: pointer; }
}

@layer tokens {
  :root {
    /* ── Primitive colours ── */
    --color-neutral-100: #f6f5f3;
    --color-neutral-200: #e0e0e0;
    --color-neutral-400: #b0b0b0;
    --color-neutral-500: #9a9a9a;
    --color-neutral-600: #6b6b6b;
    --color-neutral-900: #1a1a1a;
    --color-dark-100:   #2e2e2e;
    --color-dark-200:   #1c1c1c;
    --color-dark-muted: #5a5a5a;
    --color-dark-text:  #888888;

    /* ── Semantic colours ── */
    --tmme-ink:           var(--color-neutral-900);
    --tmme-ink-muted:     var(--color-neutral-600);
    --tmme-ink-faint:     var(--color-neutral-500);
    --tmme-border:        var(--color-neutral-200);
    --tmme-surface:       #ffffff;
    --tmme-surface-alt:   var(--color-neutral-100);

    --tmme-footer-bg:     #000;
    --tmme-footer-border: var(--color-dark-100);
    --tmme-footer-label:  #ffffff;
    --tmme-footer-text:   var(--color-dark-text);
    --tmme-footer-copy:   var(--color-dark-muted);

    /* ── Typography ── */
    --tmme-font-display: 'Cormorant Garamond', Georgia, serif;
    --tmme-font-body:    'Selawik', 'Segoe UI', system-ui, sans-serif;

    /* ── Spacing ── */
    --tmme-space-xs:  8px;
    --tmme-space-sm: 16px;
    --tmme-space-md: 24px;
    --tmme-space-lg: 48px;
    --tmme-space-xl: 72px;
    --tmme-gap:      48px;
  }
}

@layer base {
  html {
    font-family: var(--tmme-font-body);
    color: var(--tmme-ink);
  }
  body {
    background: var(--tmme-surface);
  }
  /* Note: a slight negative letter-spacing on Selawik is applied only where it's
     needed (homepage product cards — see product-card.css). It was previously
     declared on `body` here, but that scope was wrong: it doesn't help titles
     (they set their own letter-spacing which overrides inheritance) and it could
     affect Cormorant Garamond display headings, Freight serif, and future RTL/
     Arabic content where letter-spacing breaks cursive ligatures. */

  /* Visually hidden utility */
  .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 */
  .skip-link {
    position: absolute;
    left: -9999px;
    top: 16px;
    padding: 8px 16px;
    background: var(--tmme-ink);
    color: #fff;
    font-size: 13px;
    border-radius: 4px;
    z-index: 100;
  }
  .skip-link:focus {
    left: 16px;
  }
}

/* Title tile for books the shop has no picture of (_includes/cover.njk).
   Unlayered on purpose: it must sit on top of the per-page cover rules. */
.cover-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 188 / 286;
  padding: 12%;
  background: var(--tmme-surface-alt, #f6f5f3);
  border: 1px solid var(--tmme-border, #e0e0e0);
  text-align: center;
}
.cover-missing__title {
  font-family: var(--tmme-font-display, "Cormorant Garamond", Georgia, serif);
  font-size: 20px;
  line-height: 1.25;
  color: var(--tmme-ink-muted, #6b6b6b);
  overflow-wrap: anywhere;
}
.product-figure .cover-missing { width: auto; height: 100%; max-width: 272px; }
.book-card__image .cover-missing { height: 100%; }
.hero__cover .cover-missing { position: relative; z-index: 1; width: 284px; max-width: 100%; height: auto; }
.hero__cover .cover-missing__title { font-size: 28px; }

/* Header cart count. js/cart.js fills every [data-cart-count] and hides it when the cart is empty. */
a[href="/cart/"] { position: relative; }
.cart-count {
  position: absolute;
  top: -7px;
  right: -9px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--tmme-ink, #1a1a1a);
  color: #fff;
  font-family: var(--tmme-font-body, sans-serif);
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  pointer-events: none;
}
.cart-count[hidden] { display: none; }

/* Cart beside the menu button on phones and tablets (owner's pick, option A, 14 Nov 2026). It shows only
   while the menu button does: book and other pages at <=1100px, the homepage at <=920px. Count badge to
   menu lines is 16px everywhere, as on the homepage phone version the owner preferred (book pages: the
   menu lines start at the button's left edge; homepage <=576px: the row adds its own 8px gap). */
.header-cart {
  display: none;
  position: relative;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  color: #000;
}
.header-cart svg { display: block; }
.header-cart .cart-count { top: 3px; right: 0; }
@media (max-width: 1100px) {
  .site-header__inner > .header-cart { display: flex; margin-left: auto; margin-right: 16px; }
}
@media (max-width: 920px) {
  .header-body__inner > .header-cart { display: flex; order: 2; margin-left: auto; margin-right: 16px; }
  .header-body__inner > .nav-burger { order: 3; }
}
@media (max-width: 576px) {
  .header-body__inner > .header-cart { margin-right: 8px; }
}

/* "Coming soon" note on Sign In, Register and the account icon (owner, 16 Nov 2026). Hover and keyboard focus
   show it; js/coming-soon.js adds .is-soon-open on a click or tap and .soon-dismissed on Escape. */
[data-soon] { position: relative; }
[data-soon]::after {
  content: "Coming soon";
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 9px;
  border-radius: 3px;
  background: var(--tmme-ink, #1a1a1a);
  color: #fff;
  font-family: var(--tmme-font-body, sans-serif);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: 0.02em;
  text-transform: none;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0s linear 0.15s;
  z-index: 300;
}
[data-soon]:focus-visible::after,
[data-soon].is-soon-open::after {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.15s ease, visibility 0s;
}
/* Pointer hover only: a phone keeps a tapped link "hovered", which would keep the note up after the tap's
   2.5 seconds are over */
@media (hover: hover) {
  [data-soon]:hover::after {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.15s ease, visibility 0s;
  }
}
[data-soon].soon-dismissed::after { opacity: 0; visibility: hidden; }
/* In the phone menu's account rows the note sits at the row's right end, inside the scrolling list. */
.sticky-nav-account [data-soon]::after {
  top: 50%;
  left: auto;
  right: 20px;
  transform: translateY(-50%);
}
@media (prefers-reduced-motion: reduce) {
  [data-soon]::after { transition: none; }
}

/* Phone menu panels (js/nav-panels.js; owner, 17 Nov 2026: "state of the art design here, not messiness").
   .nav-list--panels is set only while a menu is the phone drawer, so none of this reaches the computer menus.
   The selectors start with .nav-list.nav-list--panels to win over the older drawer rules in responsive.css
   (homepage, loads last) and book-header.css. */
.nav-panel__bar { display: none; }

/* A chevron tells the visitor each item opens more */
.nav-list.nav-list--panels > li > a.has-dropdown { position: relative; }
.nav-list.nav-list--panels > li > a.has-dropdown::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 26px;
  width: 7px;
  height: 7px;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
  opacity: 0.5;
}

/* An open panel replaces the whole list: other items, search and icons step aside */
.nav-list.nav-list--panels:has(> li.is-expanded) > li:not(.is-expanded) { display: none; }
.nav-list.nav-list--panels > li.is-expanded:not(.nav-mobile-search):not(.nav-mobile-icons) > a { display: none; }

.nav-list.nav-list--panels > li.is-expanded > .nav-dropdown {
  display: flex;
  flex-direction: column;
  position: static;
  width: 100%;
  margin: 0;
  padding: 0 0 28px;
  background: var(--tmme-surface);
  animation: nav-panel-in 260ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Back | BOOKS */
.nav-list.nav-list--panels > li.is-expanded > .nav-dropdown > .nav-panel__bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding: 0 88px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}
.nav-panel__back {
  position: absolute;
  top: 50%;
  left: 8px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 12px;
  font-family: var(--tmme-font-body);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--tmme-ink-muted);
}
.nav-panel__back svg { display: block; flex-shrink: 0; }
.nav-panel__back:hover { color: var(--tmme-ink); }
.nav-panel__back:focus-visible { outline: 2px solid var(--tmme-ink); outline-offset: -4px; }
.nav-panel__title {
  font-family: var(--tmme-font-body);
  font-size: 13px;
  letter-spacing: 3.3px;
  text-transform: uppercase;
  color: var(--tmme-ink);
  text-align: center;
}

/* "See all topics" leads the panel as an outlined button (js/nav-panels.js moves it under the bar) */
.nav-list.nav-list--panels > li.is-expanded > .nav-dropdown > .nav-dropdown__all {
  display: flex;
  align-items: center;
  justify-content: center;
  height: auto;
  min-height: 48px;
  margin: 24px 24px 0;
  padding: 0 16px;
  border: 1px solid var(--tmme-ink);
  font-family: var(--tmme-font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--tmme-ink);
}
.nav-list.nav-list--panels > li.is-expanded > .nav-dropdown > .nav-dropdown__all:active { background: var(--tmme-surface-alt); }

/* One column: small heading, then full-width rows with hairlines */
.nav-list.nav-list--panels > li.is-expanded .nav-groups { display: block; padding: 0; }
.nav-list.nav-list--panels > li.is-expanded .nav-group { min-width: 0; padding: 0; }
.nav-list.nav-list--panels > li.is-expanded .nav-group__heading {
  display: block;
  margin: 0;
  padding: 28px 24px 6px;
  font-family: var(--tmme-font-body);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  text-align: left;
  color: var(--tmme-ink-muted);
}
.nav-list.nav-list--panels > li.is-expanded .nav-group__list { display: block; width: auto; margin: 0; padding: 0; }
.nav-list.nav-list--panels > li.is-expanded .nav-group__list li {
  display: block;
  width: auto;
  height: auto;
  margin: 0 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}
.nav-list.nav-list--panels > li.is-expanded .nav-group__list li:last-child { border-bottom: 0; }
.nav-list.nav-list--panels > li.is-expanded .nav-group__list a {
  display: flex;
  align-items: center;
  min-height: 50px;
  padding: 12px 0;
  font-family: var(--tmme-font-body);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.35;
  letter-spacing: 0.01em;
  text-transform: none;
  text-align: left;
  white-space: normal;
  text-decoration: none;
  color: var(--tmme-ink);
}
.nav-list.nav-list--panels > li.is-expanded .nav-group__list a:active { color: var(--tmme-ink-muted); }
.nav-list.nav-list--panels > li.is-expanded .nav-group__list a:focus-visible { outline: 2px solid var(--tmme-ink); outline-offset: 2px; }

/* Inside the book pages' sticky header the drawer scrolls by itself (js/nav-panels.js sets its height) */
#sticky-header .nav-list.nav-list--panels.is-open { overflow-y: auto; overscroll-behavior: contain; }

/* Panel slides in from the right; Back slides the list in from the left */
.nav-list.nav-list--panels.nav-list--back > li { animation: nav-panel-back 260ms cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes nav-panel-in { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes nav-panel-back { from { opacity: 0; transform: translateX(-18px); } to { opacity: 1; transform: none; } }
@keyframes nav-panel-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .nav-list.nav-list--panels > li.is-expanded > .nav-dropdown,
  .nav-list.nav-list--panels.nav-list--back > li { animation-name: nav-panel-fade; }
}
