/*
 * Legal & help pages: privacy.html, terms.html, shipping-returns.html.
 *
 * Layout: a summary label, a table of contents and the long-form .prose body.
 * On wide screens the contents sit in a sticky left column next to the text.
 * Section numbers (01, 02 …) are generated by CSS, so sections can be added,
 * removed or reordered in the HTML without renumbering anything by hand —
 * just keep the contents list in the same order as the headings.
 */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ------------------------------------------------------------ page head */

.legal-meta {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-5);
  color: var(--graphite);
}
.legal-meta::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  background: var(--cobalt);
}

/* --------------------------------------------------------------- layout */

/* Columns are capped at 72ch (measured in body text) so the summary label,
   the contents and the text all share one comfortable reading width. */
.legal-layout {
  display: grid;
  grid-template-columns: minmax(0, 72ch);
  grid-template-areas:
    'summary'
    'toc'
    'body';
  gap: var(--s-6);
  padding-top: clamp(32px, 5vw, 56px);
}
.legal-summary {
  grid-area: summary;
}
.legal-toc {
  grid-area: toc;
}
.legal-body {
  grid-area: body;
  min-width: 0;
}

@media (min-width: 1000px) {
  .legal-layout {
    grid-template-columns: 240px minmax(0, 72ch);
    grid-template-rows: auto 1fr;
    grid-template-areas:
      'toc summary'
      'toc body';
    column-gap: var(--s-7);
    row-gap: var(--s-7);
  }
  .legal-toc {
    position: sticky;
    top: calc(var(--header-h) + var(--s-5));
    align-self: start;
    max-height: calc(100vh - var(--header-h) - var(--s-7));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}
@media (min-width: 1200px) {
  .legal-layout {
    grid-template-columns: 280px minmax(0, 72ch);
    column-gap: clamp(64px, 6vw, 104px);
  }
}

/* -------------------------------------------------------- summary label */
/* Sits on .care-label: the sewn-in white label with a stitched inset. */

.legal-summary {
  padding: var(--s-5) var(--s-5) var(--s-6);
}
@media (min-width: 560px) {
  .legal-summary {
    padding: var(--s-6) var(--s-6) var(--s-6);
  }
}
.legal-summary .care-label__title {
  margin-bottom: var(--s-4);
  line-height: 1.3;
}
.legal-points {
  display: grid;
  gap: var(--s-3);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--ink);
}
.legal-points li {
  position: relative;
  padding-left: calc(8px + var(--s-3));
}
.legal-points li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 8px;
  height: 8px;
  background: var(--cobalt);
}
.legal-summary__note {
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: 1px dashed var(--line);
  color: var(--graphite);
  font-size: var(--fs-xs);
}

/* "At a glance" spec list (shipping & returns) — mono, like a care label. */
.legal-glance {
  display: grid;
  margin: 0;
}
.legal-glance > div {
  display: grid;
  gap: 2px;
  padding-block: 10px;
  border-bottom: 1px dashed var(--line);
}
@media (min-width: 560px) {
  .legal-glance > div {
    grid-template-columns: 10.5rem minmax(0, 1fr);
    gap: var(--s-4);
    align-items: baseline;
  }
}
.legal-glance > div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.legal-glance dt {
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--graphite);
}
.legal-glance dd {
  margin: 0;
  color: var(--ink);
}

/* ------------------------------------------------------ table of contents */
/* Sits on the shared .toc box; numbers match the section numbers in the text. */

.legal-toc__title {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.3;
  text-transform: uppercase;
  color: var(--graphite);
}
.legal-toc ol {
  counter-reset: legal-toc;
  list-style: none;
  padding-left: 0;
  gap: 0;
}
.legal-toc li {
  counter-increment: legal-toc;
  break-inside: avoid;
}
/* Block links with the number hung in the left padding, so any inline markup
   inside a link wraps like normal text. */
.legal-toc a {
  --toc-pad: 5px;
  position: relative;
  display: block;
  padding: var(--toc-pad) 0 var(--toc-pad) 30px;
  color: var(--ink-soft);
  line-height: 1.35;
  text-decoration: none;
}
.legal-toc a::before {
  content: counter(legal-toc, decimal-leading-zero);
  content: counter(legal-toc, decimal-leading-zero) / '';
  position: absolute;
  left: 0;
  top: var(--toc-pad);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: calc(var(--fs-sm) * 1.35);
  color: var(--graphite);
}
.legal-toc a:hover {
  color: var(--cobalt);
  text-decoration: underline;
}
.legal-toc a:hover::before {
  color: var(--cobalt);
}

/* Phones and tablets: full-height rows so every link is an easy 44px target. */
@media (max-width: 999px) {
  .legal-toc ol {
    margin-top: var(--s-2);
  }
  .legal-toc a {
    --toc-pad: 12px;
    min-height: 44px;
  }
  .legal-toc li + li {
    border-top: 1px solid var(--line);
  }
}

/* Tablet widths: two columns so the list doesn't push the text too far down. */
@media (min-width: 560px) and (max-width: 999px) {
  .legal-toc ol {
    display: block;
    columns: 2;
    column-gap: var(--s-6);
  }
  .legal-toc li,
  .legal-toc li + li {
    border-top: 0;
    border-bottom: 1px solid var(--line);
  }
}

/* Keeps short compounds like "sign-ups" from breaking at the hyphen. */
.legal-nowrap {
  white-space: nowrap;
}

/* ------------------------------------------------------------ the text */

.legal-body .prose {
  counter-reset: legal-section;
}
.legal-body .prose > h2 {
  counter-increment: legal-section;
  padding-top: var(--s-5);
  border-top: 1px solid var(--line);
  /* html already pads anchor jumps for the sticky header */
  scroll-margin-top: var(--s-3);
}
.legal-body .prose > h2:first-child {
  margin-top: 0;
}
.legal-body .prose > h2::before {
  content: counter(legal-section, decimal-leading-zero);
  content: counter(legal-section, decimal-leading-zero) / '';
  display: block;
  margin-bottom: var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--cobalt);
}
/* The section you jumped to from the contents gets a cobalt rule. */
.legal-body .prose > h2:target {
  border-top-color: var(--cobalt);
  box-shadow: inset 0 1px 0 var(--cobalt);
}
.legal-body .prose h3 {
  margin-top: var(--s-5);
}
.legal-body .prose h3 + p {
  margin-top: var(--s-2);
}
.legal-body .prose ol {
  padding-left: 1.5em;
}
.legal-body .prose li::marker {
  color: var(--graphite);
}

/* Definition list: what's stored in the browser, and similar lists. */
.legal-dl {
  display: grid;
  border-top: 1px solid var(--line);
}
.legal-dl > div {
  display: grid;
  gap: 4px;
  padding-block: var(--s-4);
  border-bottom: 1px solid var(--line);
}
@media (min-width: 700px) {
  .legal-dl > div {
    grid-template-columns: 10.5rem minmax(0, 1fr);
    gap: var(--s-5);
  }
}
.legal-dl dt {
  font-weight: 600;
  color: var(--ink);
  line-height: 1.5;
}
.legal-dl dd {
  margin: 0;
}
.legal-where {
  display: block;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--graphite);
}

/* Shipping rates table (filled from config.js by site.js). The table scrolls
   sideways inside its frame on narrow screens; edge shadows show there's more. */
.legal-rates .table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(to right, var(--white) 30%, transparent) left center / 48px 100% no-repeat local,
    linear-gradient(to left, var(--white) 30%, transparent) right center / 48px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(18, 20, 23, 0.16), transparent) left center / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(18, 20, 23, 0.16), transparent) right center / 14px 100% no-repeat scroll,
    var(--white);
}
.legal-rates .table {
  color: var(--ink);
}
.legal-rates .table thead th {
  background: transparent;
}
.legal-rates .table th,
.legal-rates .table td {
  padding: 12px 16px;
}
.legal-rates .table tbody tr:last-child > * {
  border-bottom: 0;
}

/* Shown under the rates table only where the table is wider than the screen. */
.legal-body .prose > .legal-scroll-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--s-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  color: var(--graphite);
}
.legal-scroll-hint .icon {
  width: 14px;
  height: 14px;
}
@media (min-width: 680px) {
  .legal-body .prose > .legal-scroll-hint {
    display: none;
  }
}
.no-js .legal-body .prose > .legal-scroll-hint {
  display: none;
}

/* Returns address (only shown when contact.returnsAddress is set in config.js). */
.legal-address {
  font-style: normal;
  white-space: pre-line;
  color: var(--ink);
}

/* ------------------------------------------------------ questions band */
/* A woven label stretched into a band (same signature as the logo). */

.legal-help.woven {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-5);
  max-width: 72ch;
  margin-top: var(--s-8);
  padding: var(--s-6);
  border-radius: var(--radius);
  font-stretch: 100%;
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.5;
  text-transform: none;
}
.legal-help.woven::after {
  inset: 6px;
}
.legal-help__body {
  flex: 1 1 280px;
  min-width: 0;
}
.legal-help__title {
  font-size: var(--fs-xl);
  font-stretch: 125%;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}
.legal-help__text {
  margin-top: var(--s-3);
  color: var(--cobalt-tint);
}
.legal-help__text a {
  color: var(--white);
  overflow-wrap: anywhere;
}
.legal-help__text a:hover {
  color: var(--white);
  text-decoration-thickness: 2px;
}
.legal-help .btn {
  position: relative;
  z-index: 1;
  flex: none;
}
@media (max-width: 559px) {
  .legal-help.woven {
    padding: var(--s-6) var(--s-5);
  }
  .legal-help .btn {
    width: 100%;
  }
}

/* ---------------------------------------------------------------- print */

@media print {
  .legal-toc {
    display: none;
  }
  .legal-layout {
    display: block;
  }
  .legal-summary {
    margin-bottom: var(--s-6);
  }
  .legal-help {
    display: none !important;
  }
}
