/* ============================================================
   LEGAL GLASS — the policy pages (terms-and-conditions, shipping-policy,
   refund-policy, privacy-notice). The text is read on a sheet of frosted
   glass floating over the brand's green silk, with gold light drifting
   behind it. legal-glass.js adds the contents chips, numbered sections,
   the policy switcher, the pointer glare and the reading progress.

   Loaded after each page's own <style>, so it overrides .legal-content.
   ============================================================ */

/* ---------- The stage ---------- */
.legal-stage {
  position: relative; isolation: isolate;
  margin: 0 clamp(10px, 1.6vw, 24px) clamp(10px, 1.6vw, 24px);
  padding: clamp(1.6rem, 3.5vw, 2.8rem) 5% clamp(3rem, 7vw, 5.5rem);
  border-radius: 26px; overflow: hidden;
  background: #0E2216 url('/colophon-bg.jpg') center / cover no-repeat;
  box-shadow: inset 0 0 0 1px rgba(229, 198, 151, 0.18);
}
.legal-backdrop { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.lg-orb { position: absolute; border-radius: 50%; will-change: transform; }
.lg-orb--a { width: 46vw; max-width: 720px; aspect-ratio: 1; top: -12%; left: -10%; background: radial-gradient(closest-side, rgba(229, 198, 151, 0.55), rgba(229, 198, 151, 0)); }
.lg-orb--b { width: 40vw; max-width: 640px; aspect-ratio: 1; top: 30%; right: -12%; background: radial-gradient(closest-side, rgba(120, 160, 120, 0.5), rgba(120, 160, 120, 0)); }
.lg-orb--c { width: 34vw; max-width: 520px; aspect-ratio: 1; bottom: -10%; left: 22%; background: radial-gradient(closest-side, rgba(196, 150, 96, 0.42), rgba(196, 150, 96, 0)); }
.lg-leaves {
  position: absolute; top: -6%; right: -6%; width: max(420px, 42%); aspect-ratio: 1.4; transform-origin: 100% 0;
  background: var(--gold-light, #E5C697); opacity: 0.12;
  -webkit-mask: url('/dx-leaves.webp') no-repeat center / contain; mask: url('/dx-leaves.webp') no-repeat center / contain;
}
.lg-lines { position: absolute; left: 0; bottom: 4%; width: 100%; height: 46%; opacity: 0.5; }
.lg-lines path { fill: none; stroke: var(--gold-light, #E5C697); stroke-width: 1; vector-effect: non-scaling-stroke; }
.lg-lines path:nth-child(2) { opacity: 0.6; }
.lg-lines path:nth-child(3) { opacity: 0.35; }

/* Breadcrumb on the dark stage */
.legal-stage .page-intro-crumb-wrap { max-width: 860px; padding: 0 0 0 4px; }
.legal-stage .page-intro-crumb { color: rgba(250, 249, 246, 0.6); }
.legal-stage .page-intro-crumb a { color: var(--gold-light, #E5C697); }

/* ---------- The glass sheet ---------- */
.legal-content.legal-glass {
  --gx: 30%; --gy: 0%;
  position: relative; max-width: 860px; margin: 0 auto;
  padding: clamp(2rem, 5vw, 3.8rem) clamp(1.4rem, 5.5vw, 4.2rem) clamp(2.2rem, 5vw, 3.6rem);
  border-radius: 28px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.9) 0%, rgba(250, 247, 240, 0.84) 45%, rgba(244, 239, 228, 0.8) 100%);
  -webkit-backdrop-filter: blur(28px) saturate(1.5);
  backdrop-filter: blur(28px) saturate(1.5);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 0 0 1px rgba(229, 198, 151, 0.22),
    inset 0 -24px 48px -30px rgba(145, 117, 81, 0.25),
    0 50px 90px -40px rgba(0, 0, 0, 0.75),
    0 18px 40px -24px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
/* Light catching the glass where the pointer is. */
.legal-glass::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(560px circle at var(--gx) var(--gy), rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 45%);
  opacity: 0.7; transition: opacity 600ms ease;
}
/* A gold rim along the top edge, like the lip of a glass plate. */
.legal-glass::after {
  content: ''; position: absolute; left: 8%; right: 8%; top: 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, rgba(229, 198, 151, 0), rgba(229, 198, 151, 0.9), rgba(255, 255, 255, 1), rgba(229, 198, 151, 0.9), rgba(229, 198, 151, 0));
}
.legal-glass > * { position: relative; z-index: 1; }
.lg-sheen {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(112deg, rgba(255, 255, 255, 0) 35%, rgba(255, 255, 255, 0.65) 48%, rgba(255, 255, 255, 0) 60%);
  transform: translateX(-120%);
}

/* ---------- Type on glass ---------- */
.legal-kicker {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gold-dark, #917551);
  margin-bottom: 1.1rem;
}
.legal-kicker::before { content: ''; width: 26px; height: 1px; background: var(--gold-dark, #917551); }
.legal-glass .legal-title { font-size: clamp(2.1rem, 4.4vw, 3.2rem); line-height: 1.1; margin-bottom: 1rem; }
.legal-glass .legal-updated {
  display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  margin-bottom: 0.6rem; padding: 0.42rem 0.95rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 500; color: #3E5045;
  background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(145, 117, 81, 0.22);
}
.legal-glass .lg-read {
  display: inline-flex; align-items: center; gap: 0.45rem; margin: 0 0 1.8rem 0.4rem; padding: 0.42rem 0.95rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 600; color: var(--gold-dark, #917551);
  background: rgba(229, 198, 151, 0.2); border: 1px solid rgba(145, 117, 81, 0.22);
}
.legal-glass .lg-read::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--gold-dark, #917551); }

.legal-glass p, .legal-glass li { color: #3E5045; font-size: 0.97rem; }
.legal-glass strong { color: var(--dark-green, #0C1E14); }
.legal-glass a { color: #7A5F3D; text-decoration-color: rgba(145, 117, 81, 0.45); text-underline-offset: 3px; transition: color 300ms ease, text-decoration-color 300ms ease; }
.legal-glass a:hover { color: var(--dark-green, #0C1E14); text-decoration-color: var(--gold-dark, #917551); }
.legal-glass ul { list-style: none; margin-left: 0; padding-left: 0; }
.legal-glass li { position: relative; padding-left: 1.5rem; }
.legal-glass li::before {
  content: ''; position: absolute; left: 0.2rem; top: 0.72em; width: 7px; height: 7px; transform: rotate(45deg);
  background: linear-gradient(135deg, var(--gold-light, #E5C697), var(--gold-dark, #917551)); border-radius: 1px;
}

/* Contents chips */
.legal-toc { display: flex; flex-wrap: wrap; gap: 0.45rem; margin: 0 0 2.6rem; padding-bottom: 2rem; border-bottom: 1px solid rgba(145, 117, 81, 0.18); }
.legal-toc[hidden] { display: none; }
.legal-toc-label { width: 100%; font-size: 10px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: rgba(62, 80, 69, 0.7); margin-bottom: 0.2rem; }
.legal-toc a {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.45rem 0.85rem; border-radius: 999px; text-decoration: none;
  font-size: 0.78rem; font-weight: 500; color: var(--dark-green, #0C1E14);
  background: rgba(255, 255, 255, 0.55); border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 14px -10px rgba(12, 30, 20, 0.45);
  transition: background-color 300ms ease, border-color 300ms ease, transform 300ms cubic-bezier(0.16, 1, 0.3, 1), color 300ms ease;
}
.legal-toc a span { font-size: 0.68rem; font-weight: 700; color: var(--gold-dark, #917551); }
.legal-toc a:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.9); border-color: rgba(145, 117, 81, 0.35); color: var(--dark-green, #0C1E14); }
.legal-toc a.is-active { background: var(--dark-green, #0C1E14); border-color: var(--dark-green, #0C1E14); color: #FAF9F6; }
.legal-toc a.is-active span { color: var(--gold-light, #E5C697); }

/* Numbered sections */
.lg-sec { padding: 0.2rem 0 0.6rem; scroll-margin-top: 110px; }
.lg-sec + .lg-sec { margin-top: 1.4rem; padding-top: 1.8rem; border-top: 1px solid rgba(145, 117, 81, 0.14); }
.legal-glass .lg-sec h2 { display: flex; align-items: baseline; gap: 0.9rem; margin: 0 0 0.9rem; font-size: clamp(1.3rem, 2vw, 1.55rem); }
.lg-num {
  flex: none; font-family: 'Montserrat', sans-serif; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em;
  color: var(--gold-dark, #917551); padding: 0.28rem 0.5rem; border-radius: 6px;
  background: rgba(229, 198, 151, 0.22); border: 1px solid rgba(145, 117, 81, 0.25);
  transform: translateY(-0.2em);
}

/* The other policies, as glass tabs at the foot of the sheet */
.legal-switch { margin-top: 2.8rem; padding-top: 2rem; border-top: 1px solid rgba(145, 117, 81, 0.18); }
.legal-switch-label { display: block; font-size: 10px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; color: rgba(62, 80, 69, 0.7); margin-bottom: 0.9rem; }
.legal-switch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.7rem; }
.legal-glass .legal-switch a {
  display: flex; flex-direction: column; gap: 0.25rem; padding: 0.95rem 1.1rem; border-radius: 16px; text-decoration: none;
  background: rgba(255, 255, 255, 0.5); border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 10px 22px -16px rgba(12, 30, 20, 0.5);
  transition: transform 400ms cubic-bezier(0.16, 1, 0.3, 1), background-color 300ms ease, border-color 300ms ease;
}
.legal-switch a strong { font-family: 'Playfair Display', serif; font-weight: 400; font-size: 1.02rem; color: var(--dark-green, #0C1E14); }
.legal-switch a small { font-size: 0.74rem; color: #5A6D60; line-height: 1.45; }
.legal-glass .legal-switch a:hover { transform: translateY(-3px); background: rgba(255, 255, 255, 0.85); border-color: rgba(145, 117, 81, 0.35); }
.legal-switch a[aria-current="page"] { display: none; }

/* Reading progress, a gold thread across the top of the window */
.legal-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 1200; pointer-events: none; }
.legal-progress span {
  display: block; height: 100%; width: 100%; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--gold-dark, #917551), var(--gold-light, #E5C697));
  box-shadow: 0 0 10px rgba(229, 198, 151, 0.7);
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  .lg-orb--a { animation: lg-drift-a 24s ease-in-out infinite alternate; }
  .lg-orb--b { animation: lg-drift-b 30s ease-in-out infinite alternate; }
  .lg-orb--c { animation: lg-drift-c 36s ease-in-out infinite alternate; }
  .lg-leaves { animation: lg-sway 11s ease-in-out infinite alternate; }
  .lg-lines path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: lg-draw 3.2s 400ms cubic-bezier(0.65, 0, 0.35, 1) forwards, lg-wave 14s 3.6s ease-in-out infinite alternate; }
  .lg-lines path:nth-child(2) { animation-delay: 700ms, 3.9s; }
  .lg-lines path:nth-child(3) { animation-delay: 1000ms, 4.2s; }

  .legal-glass { animation: lg-rise 1100ms cubic-bezier(0.16, 1, 0.3, 1) both; }
  .lg-sheen { animation: lg-sheen 1800ms 700ms cubic-bezier(0.45, 0, 0.2, 1) forwards; }
  .legal-stage .page-intro-crumb-wrap { animation: lg-fade 900ms ease both; }

  /* Sections clear like fogged glass as they scroll in. */
  .lg-sec.lg-pending { opacity: 0; filter: blur(6px); transform: translateY(18px); }
  .lg-sec { transition: opacity 900ms cubic-bezier(0.16, 1, 0.3, 1), filter 900ms cubic-bezier(0.16, 1, 0.3, 1), transform 900ms cubic-bezier(0.16, 1, 0.3, 1); }
}
@keyframes lg-drift-a { to { transform: translate(14%, 18%) scale(1.15); } }
@keyframes lg-drift-b { to { transform: translate(-18%, -10%) scale(0.9); } }
@keyframes lg-drift-c { to { transform: translate(20%, -16%) scale(1.2); } }
@keyframes lg-sway { from { transform: rotate(-2deg); } to { transform: rotate(2.5deg) translate(-12px, 10px); } }
@keyframes lg-draw { to { stroke-dashoffset: 0; } }
@keyframes lg-wave { to { transform: translateY(-14px); } }
@keyframes lg-rise { from { opacity: 0; transform: translateY(40px) scale(0.98); filter: blur(10px); } to { opacity: 1; transform: none; filter: blur(0); } }
@keyframes lg-sheen { to { transform: translateX(120%); } }
@keyframes lg-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Small screens ---------- */
@media (max-width: 700px) {
  .legal-stage { border-radius: 18px; padding-left: 12px; padding-right: 12px; }
  .legal-stage .page-intro-crumb-wrap { padding-left: 8px; }
  .legal-content.legal-glass { border-radius: 20px; -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4); }
  .legal-toc { flex-wrap: nowrap; overflow-x: auto; margin-left: -4px; margin-right: -4px; padding: 0 4px 1.6rem; scrollbar-width: none; }
  .legal-toc::-webkit-scrollbar { display: none; }
  .legal-toc-label { display: none; }
  .legal-kicker { letter-spacing: 0.16em; font-size: 9.5px; }
  .legal-glass .lg-read { margin-left: 0; }
  .legal-toc a { flex: none; }
  .lg-orb--a, .lg-orb--b, .lg-orb--c { width: 90vw; }
}
@media print {
  .legal-stage { background: none; margin: 0; padding: 0; }
  .legal-backdrop, .legal-toc, .legal-switch, .legal-progress, .lg-sheen { display: none; }
  .legal-content.legal-glass { box-shadow: none; border: 0; background: none; backdrop-filter: none; }
}
