/* ==========================================================================
   Legal pages template (Terms of Use, Privacy Policy, Refund Policy).
   No Figma screen: layout inspired by the reference the user chose, built with the site's
   tokens (Manrope, Cinza / Glass, 12-20px radii). Pages are generated by scripts/build-legal.js.
   ========================================================================== */

.legal-hero {
  position: relative;
  isolation: isolate;
  padding: 160px var(--page-gutter) 64px;
}
/* Same gradient as the other heroes, fading into the page */
.legal-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: linear-gradient(201.304deg, rgb(10, 10, 10) 12.876%, rgb(18, 27, 32) 20.301%, rgb(10, 10, 10) 26.161%, rgb(18, 27, 32) 33.69%, rgb(10, 10, 10) 44.234%);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 0%, #000 45%, transparent 100%);
}

.legal-hero__wrapper {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.legal-hero__wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
}
.legal-hero__updated {
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--glass-10);
  border-radius: 17px;
  background: var(--glass-5);
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-400);
}
.legal-hero__updated time { color: var(--gray-50); }
.legal-hero__title {
  margin: 0;
  font-size: 56px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -1.12px;
  color: var(--gray-50);
}
.legal-hero__intro {
  max-width: 620px;
  margin: 0;
  font-size: 18px;
  line-height: 1.5;
  color: var(--gray-400);
}

/* ---- Content + sidebar ---------------------------------------------------- */
.legal {
  display: grid;
  grid-template-columns: 320px minmax(0, 760px);
  justify-content: space-between;
  align-items: start;
  gap: 64px;
  max-width: calc(1200px + 2 * var(--page-gutter));
  margin: 0 auto;
  padding: 0 var(--page-gutter) 120px;
}

.legal-section {
  padding: 48px 0;
  border-top: 1px solid var(--glass-10);
  scroll-margin-top: calc(var(--top-offset) + 24px);
}
.legal-section:last-child { border-bottom: 1px solid var(--glass-10); }
.legal-section__title {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 20px;
  font-size: 28px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.28px;
  color: var(--gray-50);
}
.legal-section__num {
  flex: none;
  min-width: 40px;
  padding: 6px 10px;
  border: 1px solid var(--glass-10);
  border-radius: 16px;
  background: var(--glass-5);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--gray-50);
}
.legal-toc__num {
  flex: none;
  width: 18px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--gray-500);
}
.legal-section__body {
  padding-left: 56px; /* lines up with the title, after the number pill */
  font-size: 16px;
  line-height: 1.7;
  color: var(--gray-400);
}
.legal-section__body p { margin: 0 0 16px; }
.legal-section__body > :last-child { margin-bottom: 0; }
.legal-section__body strong { font-weight: 600; color: var(--gray-50); }
.legal-section__body a {
  color: var(--gray-50);
  text-decoration: underline;
  text-decoration-color: var(--glass-10);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.2s ease;
}
.legal-section__body a:hover { text-decoration-color: var(--gray-50); }
.legal-section__body ul {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}
.legal-section__body li {
  position: relative;
  padding-left: 20px;
}
.legal-section__body li::before {
  content: "";
  position: absolute;
  top: 0.75em;
  left: 2px;
  width: 6px;
  height: 6px;
  margin-top: -3px;
  border-radius: 50%;
  background: var(--gray-600);
}

/* Data still to be filled in, e.g. [CONTACT EMAIL] */
.legal-placeholder {
  padding: 1px 6px;
  border: 1px dashed rgba(230, 90, 52, 0.6);
  border-radius: 6px;
  background: rgba(230, 90, 52, 0.08);
  font-size: 0.9em;
  color: #f0a48f;
  white-space: nowrap;
}

/* ---- Sidebar card (sticky) --------------------------------------------- */
.legal__aside {
  order: -1; /* left column (the text stays first in the HTML) */
  position: sticky;
  top: calc(var(--top-offset) + 24px);
}
.legal-nav {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - var(--top-offset) - 48px);
  padding: 8px;
  border: 1px solid var(--glass-10);
  border-radius: 20px;
  background: var(--gray-950);
}

.legal-nav__policies {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px solid var(--glass-10);
}
.legal-nav__policy,
.legal-toc__link {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-400);
  transition: background-color 0.2s ease, color 0.2s ease;
}
.legal-nav__policy:hover,
.legal-toc__link:hover { background: var(--glass-5); color: var(--gray-50); }
.legal-nav__policy.is-current,
.legal-toc__link.is-active {
  background: var(--glass-5);
  color: var(--gray-50);
}
/* Small white bar on the left of the current item */
.legal-nav__policy.is-current::before,
.legal-toc__link.is-active::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 2px;
  height: 16px;
  margin-top: -8px;
  border-radius: 2px;
  background: var(--gray-50);
}
.legal-toc__link.is-active .legal-toc__num { color: var(--gray-50); }

.legal-toc {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}
.legal-toc__summary { display: none; }
.legal-toc__list {
  /* <details> ignores flex sizing, so the list gets its own height: viewport minus header,
     sticky offsets, the policy switcher and "Back to top" */
  max-height: calc(100vh - var(--top-offset) - 48px - 236px);
  min-height: 120px;
  margin: 0;
  padding: 8px 0;
  list-style: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(180deg, #000 0, #000 calc(100% - 40px), transparent 100%);
  mask-image: linear-gradient(180deg, #000 0, #000 calc(100% - 40px), transparent 100%);
}
.legal-toc__list::-webkit-scrollbar { display: none; }

.legal-nav__top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
  padding: 14px 12px 8px;
  border: 0;
  border-top: 1px solid var(--glass-10);
  background: none;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-400);
  transition: color 0.2s ease;
}
.legal-nav__top:hover { color: var(--gray-50); }
.legal-nav__top img { width: 14px; height: 14px; }

/* ---- Responsive ---------------------------------------------------------- */
@media (max-width: 1100px) {
  .legal { grid-template-columns: 280px minmax(0, 1fr); gap: 40px; }
}

/* One column: the sidebar moves above the text, contents collapse into "On this page" */
@media (max-width: 900px) {
  .legal { display: flex; flex-direction: column; gap: 32px; }
  .legal__aside { position: static; order: -1; width: 100%; }
  .legal-nav { max-height: none; }
  .legal-nav__policies { flex-direction: row; flex-wrap: wrap; }
  .legal-nav__policy { padding: 8px 12px; }
  .legal-nav__policy.is-current::before { display: none; }
  .legal-toc__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    color: var(--gray-50);
    cursor: pointer;
    list-style: none;
  }
  .legal-toc__summary::-webkit-details-marker { display: none; }
  .legal-toc__summary::after {
    content: "";
    width: 14px;
    height: 14px;
    background: url("../assets/icons/chevron-down.svg") center / contain no-repeat;
    transition: transform 0.2s ease;
  }
  .legal-toc[open] .legal-toc__summary::after { transform: rotate(180deg); }
  .legal-toc__list { max-height: 50vh; -webkit-mask-image: none; mask-image: none; }
  .legal-nav__top { display: none; }
}

@media (max-width: 600px) {
  .legal-hero { padding-top: 128px; padding-bottom: 40px; }
  .legal-hero__title { font-size: 40px; letter-spacing: -0.8px; }
  .legal-hero__intro { font-size: 16px; }
  .legal { padding-bottom: 80px; }
  .legal-section { padding: 36px 0; }
  .legal-section__title { gap: 12px; font-size: 22px; }
  .legal-section__num { min-width: 36px; padding: 5px 8px; }
  .legal-section__body { padding-left: 0; }
  .legal-placeholder { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .legal-nav *, .legal-section__body a { transition: none !important; }
}

/* Policy pages: plain black background for now (no hero gradient) */
.legal-hero::before { display: none; }
