/* Ghalina website: the light and dark palettes, the light/dark button and the fade between them.
   Every page loads this file; each page stylesheet maps its own tokens to these (home.css, site.css, the inline
   styles of privacy.html and delete-account.html). Reusable by any new page (design/help-hub): use the --g-* tokens.
   Light is the default for everyone; assets/js/theme.js puts data-theme="dark" on <html> when the visitor chose dark.
   Dark is Ghalina's plum leather, never black: deep aubergine page, slightly lighter plum cards with a gold rim,
   ivory and champagne text, gold accents. No lilac, no beige fills. All text pairs pass WCAG AA (NOTES in
   design/dark-mode/NOTES.md). */

:root {
  --hv-in: 120ms;
  --hv-out: 200ms;
  --g-bg: #f2e9d6;            /* page */
  --g-bg-2: #eadfc6;          /* alternate band */
  --g-surface: #f8f1e1;       /* card */
  --g-surface-2: #f3ead7;     /* card inside a card, input */
  --g-line: #dbcaab;          /* hairline */
  --g-rim: rgb(203 166 115 / 0.55);  /* gold rim */
  --g-text: #221420;          /* body text */
  --g-muted: #56455a;         /* secondary text */
  --g-link: #4a2545;          /* links, plum words */
  --g-link-soft: #6b3a63;
  --g-gold-text: #7a5a33;     /* small gold words */
  --g-plum: #4a2545;          /* plum fills (buttons, leather bands) */
  --g-on-plum: #fff6e8;
  --g-gold: #d4af6a;
  --g-on-gold: #2a1c05;
  --g-focus: #4a2545;
  --g-hover: rgb(74 37 69 / 0.07);   /* hover wash */
  --g-shadow: 60 25 55;       /* rgb() of shadows */
  --g-media-rim: 0 0 0 0 transparent; /* images on the page */
  --g-hairline: rgb(160 120 62 / 0.62);          /* gold dividers and card outlines */
  --g-hairline-line: linear-gradient(90deg, #a9824b, #d3b47a 50%, #a9824b); /* a stronger divider (1.5px) */
}

[data-theme="dark"] {
  --g-bg: #1e0f1b;
  --g-bg-2: #26131f;
  --g-surface: #32192d;
  --g-surface-2: #3c2037;
  --g-line: rgb(212 175 106 / 0.24);
  --g-rim: rgb(212 175 106 / 0.5);
  --g-text: #f7ecd9;          /* ivory: 15.6:1 on bg, 13.5:1 on surface */
  --g-muted: #dccab2;         /* champagne: 11:1 on bg, 9.5:1 on surface */
  --g-link: #ecd29c;          /* gold-champagne: 12:1 on bg */
  --g-link-soft: #e6c98d;
  --g-gold-text: #e2c48a;     /* 10.5:1 on bg */
  --g-plum: #4a2545;
  --g-on-plum: #fff6e8;
  --g-gold: #d4af6a;
  --g-on-gold: #2a1c05;
  --g-focus: #e9cf9a;
  --g-hairline: rgb(212 175 106 / 0.24);
  --g-hairline-line: linear-gradient(90deg, rgb(212 175 106 / 0.3), rgb(233 207 154 / 0.42) 50%, rgb(212 175 106 / 0.3));
  --g-hover: rgb(233 207 154 / 0.14);
  --g-shadow: 8 2 7;
  --g-media-rim: 0 0 0 1px rgb(212 175 106 / 0.35), 0 18px 40px -18px rgb(0 0 0 / 0.7);
  color-scheme: dark;
}

/* The fade (theme.js adds .theme-fade for 320 ms; never with reduced motion). */
html.theme-fade,
html.theme-fade *,
html.theme-fade *::before,
html.theme-fade *::after {
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease, fill 0.25s ease,
    stroke 0.25s ease, box-shadow 0.25s ease, outline-color 0.25s ease !important;
}
@media (prefers-reduced-motion: reduce) {
  html.theme-fade, html.theme-fade *, html.theme-fade *::before, html.theme-fade *::after { transition: none !important; }
}

/* The light/dark button: a round 44 px icon button, moon in light (go dark), sun in dark (go light). */
.theme-toggle {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--g-link);
  box-shadow: inset 0 0 0 1.5px var(--g-rim);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--hv-out) ease-out, box-shadow var(--hv-out) ease-out, color var(--hv-out) ease-out;
}
.theme-toggle:hover, .theme-toggle:focus-visible, .theme-toggle:active { transition-duration: var(--hv-in); }
.theme-toggle:hover { background: var(--g-hover); box-shadow: inset 0 0 0 1.5px var(--g-link); }
.theme-toggle:focus-visible { outline: 3px solid var(--g-focus); outline-offset: 2px; }
.theme-toggle svg { grid-area: 1 / 1; width: 22px; height: 22px; transition: opacity 0.25s ease, transform 0.4s cubic-bezier(0.32, 0.72, 0, 1); }
.theme-toggle .theme-toggle__sun { opacity: 0; transform: rotate(-60deg) scale(0.6); }
[data-theme="dark"] .theme-toggle .theme-toggle__sun { opacity: 1; transform: none; }
[data-theme="dark"] .theme-toggle .theme-toggle__moon { opacity: 0; transform: rotate(60deg) scale(0.6); }
@media (prefers-reduced-motion: reduce) { .theme-toggle svg { transition: none; } }

/* With a word next to the icon (the mobile menu). */
.theme-toggle--wide {
  width: auto;
  min-height: 52px;
  padding: 0 20px 0 16px;
  border-radius: 999px;
  grid-auto-flow: column;
  gap: 10px;
  font: inherit;
  font-weight: 700;
}
.theme-toggle--wide .theme-toggle__icons { display: grid; place-items: center; }
.theme-toggle--wide .theme-toggle__icons svg { grid-area: 1 / 1; }

/* ---------- Spacing for small controls (owner 2026-10-21: never cramped) ---------- */
:root {
  --g-pad-pill: 6px 14px;       /* chips and tags */
  --g-pad-control: 10px 18px;   /* buttons, selects, inputs */
  --g-gap-label: 12px;          /* between a label and its control */
  --g-radius-control: 14px;
}

/* ---------- Dropdown (button + listbox), reusable: <div class="dd"> .dd__btn + ul.dd__list[role=listbox] ----------
   Every menu rolls down (clip + fade, 220 ms) and rolls back up when it closes; every option has a fading
   champagne-gold wash under the pointer or the keyboard, and the chosen one a gold tick. */
.dd { position: relative; display: inline-block; }
.dd__btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-width: 15rem;
  max-width: 100%;
  min-height: 48px;
  padding: var(--g-pad-control);
  padding-inline-end: 14px;
  border: 0;
  border-radius: var(--g-radius-control);
  background: var(--g-surface);
  box-shadow: inset 0 0 0 1.5px var(--g-rim);
  color: var(--g-text);
  font: inherit;
  font-weight: 700;
  text-align: start;
  cursor: pointer;
  transition: background-color var(--hv-out) ease-out, box-shadow var(--hv-out) ease-out;
}
.dd__btn:hover, .dd__btn:focus-visible, .dd__btn:active { transition-duration: var(--hv-in); }
.dd__btn:hover { background: var(--g-surface-2); box-shadow: inset 0 0 0 1.5px var(--g-link), 0 0 0 4px var(--g-hover); }
.dd__btn:focus-visible { outline: 3px solid var(--g-focus); outline-offset: 2px; }
.dd__chev { flex: none; width: 20px; height: 20px; color: var(--g-gold-text); transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1); }
.dd.is-open .dd__chev { transform: rotate(180deg); }
.dd__list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  inset-inline-start: 0;
  min-width: 100%;
  max-height: min(320px, 60vh);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
  border-radius: 16px;
  background: var(--g-surface);
  box-shadow: inset 0 0 0 1px var(--g-rim), 0 24px 48px -20px rgb(var(--g-shadow) / 0.55);
  text-align: start;
  clip-path: inset(0 0 100% 0 round 16px);
  opacity: 0;
  transition: clip-path 0.22s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.22s ease;
}
.dd.is-open .dd__list { clip-path: inset(0 0 0 0 round 16px); opacity: 1; }
.dd__list:focus { outline: none; }
.dd__list:focus-visible { box-shadow: inset 0 0 0 2px var(--g-focus), 0 24px 48px -20px rgb(var(--g-shadow) / 0.55); }
.dd__opt {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 18px;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--g-text);
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: background-color var(--hv-out) ease-out, color var(--hv-out) ease-out;
}
.dd__opt:hover, .dd__opt.is-active { transition-duration: var(--hv-in); }
.dd__opt.is-active { background: rgb(212 175 106 / 0.2); }
.dd__opt[aria-selected="true"] { color: var(--g-link); font-weight: 800; }
.dd__code { color: var(--g-muted); font-size: 0.875em; font-weight: 700; }
.dd__tick { width: 18px; height: 18px; color: var(--g-gold-text); opacity: 0; transition: opacity var(--hv-out) ease-out; }
.dd__opt[aria-selected="true"] .dd__tick { opacity: 1; }
[data-theme="dark"] .dd__opt.is-active { background: rgb(233 207 154 / 0.16); }
@media (prefers-reduced-motion: reduce) {
  .dd__list, .dd__opt, .dd__chev, .dd__tick { transition: none; }
}

/* Dark only: tiny, distant gold dust that twinkles in and out over the WHOLE page (theme.js builds it once). Round soft
   points only (a 1 to 3 px core with a soft glow; no stars, crosses or rays). Fixed, behind the content, opacity and a
   tiny scale only. With "reduce motion" they stay still and faint. */
.glints { display: none; }
[data-theme="dark"] .glints { display: block; position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.glints i {
  position: absolute; display: block; opacity: 0; will-change: opacity, transform;
  width: calc(var(--d, 2) * 1px); height: calc(var(--d, 2) * 1px); margin: calc(var(--d, 2) * -0.5px) 0 0 calc(var(--d, 2) * -0.5px);
  border-radius: 50%;
  background: #f6e3b4;
  box-shadow: 0 0 calc(var(--d, 2) * 2px) calc(var(--d, 2) * 0.6px) rgb(240 217 168 / 0.45);
}
@media (prefers-reduced-motion: no-preference) {
  .glints i { animation: glint 6s ease-in-out infinite; }
}
@media (prefers-reduced-motion: reduce) { .glints i { opacity: calc(var(--o, 0.6) * 0.5); } }
@keyframes glint {
  0%, 100% { opacity: 0; transform: scale(0.8); }
  50% { opacity: var(--o, 0.6); transform: scale(1.15); }
}
@media (max-width: 700px) { .glints i:nth-child(n+36) { display: none; } }
/* The field drifts slowly up and to the right at 45 degrees, forever: 2x2 identical square tiles (each the larger
   side of the screen), moved by exactly one tile per loop, so the loop has no seam (owner 2026-10-23). */
.glints__drift { position: absolute; left: -100vmax; top: 0; width: 200vmax; height: 200vmax; will-change: translate; }
.glints__tile { position: absolute; width: 50%; height: 50%; }
@media (prefers-reduced-motion: no-preference) {
  .glints__drift { animation: glints-drift 240s linear infinite; }
}
@keyframes glints-drift { from { translate: 0 0; } to { translate: 100vmax -100vmax; } }
/* the page colour lives on <html> so the glints (z-index -1) show above it and under the content */
html[data-theme="dark"] { background-color: var(--g-bg); }
html[data-theme="dark"] body { background-color: transparent; }

/* ---------- Plum leather skin (owner-approved "A2", 2026-10-23) ----------
   Three seamless layers blended with soft-light over the plum gradient: tone (soft patches, drawn 1900 px; a blur, so it
   may be scaled), folds (1360 px, natural size), pebble grain (1024 px, natural size). Their periods share no small
   multiple, so no repeat shows. Use: `background: var(--skin), var(--leather); background-blend-mode: var(--skin-bm), normal;`
   Give each surface its own `--lx/--ly` (offset on the hide) so neighbours never show the same spot.
   Generator: design/brand/leather/make_site_leather.py. Defined on every element so each one resolves its own --lx/--ly. */
:root { --skin-bm: soft-light, soft-light, soft-light; }
*, *::before, *::after {
  --skin:
    url("/assets/img/leather-tone.webp?v=2") var(--lx, 0px) var(--ly, 0px) / 1900px auto,
    url("/assets/img/leather-crease.webp?v=1") calc(var(--lx, 0px) * -1.7) calc(var(--ly, 0px) * 1.3) / 1060px auto,
    url("/assets/img/leather-grain.webp?v=2") calc(var(--lx, 0px) * 0.6) calc(var(--ly, 0px) * -0.8) / 800px auto;
}

/* Top-bar "Download the beta" button: like tilting a metal button in the sun. Two background layers: the base metal never
   moves (the --metal colours with the bright ivory band flattened into the neighbouring gold) and, on top, only the
   light band glides: from its rest spot out to the bottom-right, back in from the top-left, then rest (about 1.2 s
   every 10 s, 135 degrees, the same in Arabic). The band layer is written twice, one length apart, and slid by --cta-shine from
   0 to 100 percent; at --cta-shine 0 the button looks like the plain --metal one. No motion with reduced motion
   (owner 2026-10-23). The colours are copies of --metal in home.css. */
@property --cta-shine { syntax: "<percentage>"; inherits: false; initial-value: 0%; }
.btn--gold.nav__cta {
  background:
    linear-gradient(135deg,
      transparent calc(var(--cta-shine) - 55%), rgb(248 234 208) calc(var(--cta-shine) - 32%), transparent var(--cta-shine),
      transparent calc(var(--cta-shine) + 45%), rgb(248 234 208) calc(var(--cta-shine) + 68%), transparent calc(var(--cta-shine) + 100%)),
    linear-gradient(135deg, #8c6a44 0%, #eed6aa 22%, #cba673 45%, #bd9866 68%, #aa8655 100%);
}
@media (prefers-reduced-motion: no-preference) {
  .btn--gold.nav__cta { animation: nav-cta-shine 10s linear 2s infinite; }
}
@keyframes nav-cta-shine {
  0% { --cta-shine: 0%; animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1); }
  12% { --cta-shine: 100%; }
  100% { --cta-shine: 100%; }
}
