/* ============================================================================
   SHIPIFY — css/legal.css
   Owned by the LEGAL cell. Styles terms.html, privacy.html, 404.html.
   Consumes tokens.css + shared.css. Adds no new brand colours: every value
   here is a token, or derived from one.

   The idea: a legal document is a filed manifest. Calm typography, generous
   measure, and the label mechanism kept to the HEADERS only — a black service
   band ordinal, a dotted leader, a perforated tear at the end of the document.
   No jokes near the law. 404 is the one place Zip is allowed to be funny.
   ========================================================================== */

.lg {
  /* derived-only local palette */
  --lg-rule: rgb(var(--sy-shadow) / .22);
  --lg-leader: rgb(var(--sy-shadow) / .3);
  --lg-measure: 66ch;
}

/* ------------------------------------------------------- 1. draft banner */
.lg-draft {
  position: relative;
  background: var(--accent);
  color: var(--accent-ink);
  border-bottom: 2px solid var(--line);
}
/* hazard edge — document-control tape, decorative */
.lg-draft::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 6px;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    -45deg,
    var(--line) 0 6px,
    transparent 6px 12px
  );
  opacity: .55;
}

.lg-draft__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-200) var(--sp-300);
  padding-block: var(--sp-200) var(--sp-300);
}

.lg-draft__stamp {
  flex: 0 0 auto;
  padding: var(--sp-050) var(--sp-200);
  border: 3px solid var(--accent-ink);
  border-radius: 7px 5px 8px 4px;
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: rotate(-2.5deg);
}

.lg-draft__text {
  margin: 0;
  max-width: 68ch;
  font-size: var(--fs-base);
  line-height: 1.5;
}
.lg-draft__text b { font-weight: 700; }
.lg-draft__text span {
  display: block;
  margin-top: var(--sp-050);
  font-size: var(--fs-sm);
  opacity: .92;
}

/* --------------------------------------------------------- 2. docket head */
.lg-head { padding-block: clamp(var(--sp-600), 7vw, var(--sp-800)) var(--sp-400); }

.lg-head__title { margin-bottom: var(--sp-200); }
.lg-head__lede { margin-bottom: var(--sp-300); }

/* the filing card — quotes the label's dotted-leader rows, kept calm */
.lg-docket {
  display: grid;
  gap: 0 var(--sp-300);
  grid-template-columns: 1fr;
  max-width: 520px;
  margin: 0;
  padding: var(--sp-200);
  background: var(--sy-stock);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}
.lg-docket__row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-100);
  padding-block: var(--sp-050);
}
.lg-docket__row::before {
  content: "";
  order: 2;
  flex: 1 1 auto;
  align-self: center;
  height: 0;
  border-bottom: 2px dotted var(--lg-leader);
  transform: translateY(2px);
}
.lg-docket__row dt {
  order: 1;
  flex: 0 0 auto;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.lg-docket__row dd {
  order: 3;
  flex: 0 0 auto;
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* a value that is genuinely not decided yet — we say so instead of inventing it */
.lg-tbd {
  display: inline-block;
  padding: 0 var(--sp-100);
  border: 2px dashed var(--sy-ink-danger);
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--sy-ink-danger);
  white-space: nowrap;
}

/* ------------------------------------------------------ 3. document layout */
.lg-doc {
  display: grid;
  gap: var(--sp-600);
  grid-template-columns: 1fr;
  padding-bottom: clamp(var(--sp-600), 8vw, var(--sp-1200));
}
@media (min-width: 1000px) {
  .lg-doc {
    grid-template-columns: 232px minmax(0, 1fr);
    gap: var(--sp-800);
    align-items: start;
  }
}

/* ------------------------------------------------------------ 4. contents */
.lg-toc { min-width: 0; }
.lg-toc__title {
  margin: 0 0 var(--sp-150);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.lg-toc__list {
  display: flex;
  gap: var(--sp-100);
  list-style: none;
  margin: 0;
  padding: 0 0 var(--sp-150);
  /* mobile: the sections come off the roll sideways */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.lg-toc__list li { flex: 0 0 auto; }
.lg-toc__list a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: var(--sp-100) var(--sp-200);
  border: 2px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--sy-stock);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: .04em;
  text-decoration: none;
  white-space: nowrap;
}
.lg-toc__list a:hover { background: var(--surface); border-color: var(--accent); }

@media (min-width: 1000px) {
  .lg-toc {
    position: sticky;
    top: calc(var(--sy-nav-h) + var(--sp-300));
    max-height: calc(100vh - var(--sy-nav-h) - var(--sp-600));
    overflow-y: auto;
    padding-right: var(--sp-100);
  }
  .lg-toc__list {
    display: block;
    overflow-x: visible;
    padding-bottom: 0;
    border-left: 2px solid var(--lg-rule);
  }
  .lg-toc__list li { flex: initial; }
  .lg-toc__list li + li { margin-top: 2px; }
  .lg-toc__list a {
    display: block;
    min-height: 0;
    border: 0;
    border-left: 3px solid transparent;
    border-radius: 0;
    background: transparent;
    padding: var(--sp-100) var(--sp-150);
    margin-left: -2px;
    font-size: var(--fs-sm);
    font-weight: 400;
    letter-spacing: 0;
    white-space: normal;
    line-height: 1.35;
    color: var(--ink-muted);
  }
  .lg-toc__list a:hover {
    background: transparent;
    border-left-color: var(--accent);
    color: var(--ink);
  }
}

/* ------------------------------------------------------------ 5. sections */
.lg-body { min-width: 0; max-width: var(--lg-measure); }

.lg-sec + .lg-sec { margin-top: var(--sp-600); }
.lg-sec { scroll-margin-top: calc(var(--sy-nav-h) + var(--sp-300)); }

.lg-sec__head {
  display: flex;
  align-items: center;
  gap: var(--sp-150);
  margin-bottom: var(--sp-200);
}
/* the service band, shrunk to a filing ordinal */
.lg-sec__no {
  flex: 0 0 auto;
  padding: 2px var(--sp-100);
  background: var(--line);
  color: var(--bg);
  border-radius: var(--r-none);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .14em;
  line-height: 1.6;
}
.lg-sec__title { flex: 0 1 auto; }
/* the label's dotted leader, run out to the end of the header */
.lg-sec__head::after {
  content: "";
  flex: 1 1 var(--sp-400);
  min-width: var(--sp-300);
  height: 0;
  border-bottom: 2px dotted var(--lg-leader);
  transform: translateY(2px);
}

.lg-body p { max-width: var(--lg-measure); text-wrap: pretty; }
.lg-body ul, .lg-body ol { max-width: var(--lg-measure); margin: 0 0 var(--sp-200); padding-left: var(--sp-300); }
.lg-body li { margin-bottom: var(--sp-100); }
.lg-body li:last-child { margin-bottom: 0; }
.lg-body li::marker { color: var(--accent); font-weight: 700; }
.lg-body h3 {
  margin: var(--sp-300) 0 var(--sp-100);
  font-size: var(--fs-lg);
}
.lg-body a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
.lg-body a:hover { background: var(--surface); }
.lg-body dfn { font-style: normal; font-weight: 700; }

/* plain-English gloss beside the legal sentence */
.lg-plain {
  margin: var(--sp-200) 0 0;
  padding: var(--sp-150) var(--sp-200);
  background: var(--surface);
  border-left: 6px solid var(--kraft);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: var(--fs-sm);
  color: var(--ink-muted);
}
.lg-plain strong {
  display: block;
  margin-bottom: 2px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink);
}

/* a short summary table (privacy "what we collect") */
.lg-defs { margin: 0 0 var(--sp-200); }
.lg-defs > div {
  padding: var(--sp-150) 0;
  border-top: 1px solid var(--lg-rule);
}
.lg-defs > div:last-child { border-bottom: 1px solid var(--lg-rule); }
.lg-defs dt {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink);
}
.lg-defs dd { margin: var(--sp-050) 0 0; color: var(--ink-muted); font-size: var(--fs-sm); }

/* ---------------------------------------------------- 6. end of document */
.lg-end {
  position: relative;
  max-width: var(--lg-measure);
  margin-top: var(--sp-600);
  padding: var(--sp-300) var(--sp-300) var(--sp-400);
  background: var(--sy-stock);
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: 0 1px 0 var(--line);
}
/* perforated tear-off foot, same geometry as the label */
.lg-end::after {
  content: "";
  position: absolute;
  left: -2px; right: -2px; bottom: -2px;
  height: 14px;
  background-image: radial-gradient(circle at 50% 100%, var(--bg) 0 6px, transparent 6.5px);
  background-size: 16px 14px;
  background-repeat: repeat-x;
}
.lg-end__title {
  margin: 0 0 var(--sp-100);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* ============================================================== 7. 404 == */
.lg-404 { padding-block: clamp(var(--sp-600), 10vw, var(--sp-1200)); }
.lg-404__grid { align-items: center; }

.lg-404__zip {
  width: clamp(190px, 30vw, 300px);
  margin-inline: auto;
}
@media (min-width: 900px) { .lg-404__zip { margin-inline: 0; } }

.lg-404__code { margin-bottom: var(--sp-200); }
.lg-404__actions { margin-top: var(--sp-300); }
.lg-404__note { margin-top: var(--sp-300); max-width: 46ch; }

.lg-404__links {
  list-style: none;
  margin: var(--sp-300) 0 0;
  padding: 0;
  max-width: 46ch;
}
.lg-404__links li { border-top: 1px solid var(--lg-rule); }
.lg-404__links li:last-child { border-bottom: 1px solid var(--lg-rule); }
.lg-404__links a {
  display: flex;
  align-items: baseline;
  gap: var(--sp-150);
  padding: var(--sp-150) 0;
  color: var(--ink);
  text-decoration: none;
}
.lg-404__links a:hover .lg-404__linkname { text-decoration: underline; text-decoration-thickness: 2px; text-decoration-color: var(--accent); }
.lg-404__linkname { font-family: var(--font-display); font-weight: 600; flex: 0 0 auto; }
.lg-404__linkwhat { font-size: var(--fs-sm); color: var(--ink-muted); text-align: right; margin-left: auto; }

/* --- the jam: a label that came off the roll wrong ----------------------- */
/* extra foot room so the VOID stamp lands clear of the small print */
/* the VOID stamp lands across the barcode, never across the small print */
.lg-jam { transform: rotate(-1.4deg); padding-bottom: var(--sp-400); }
.lg-jam .sy-label__head { position: relative; }
/* the head band prints short, as if the ribbon ran out mid-line */
.lg-jam .sy-label__head::after {
  content: "";
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 34%;
  background: var(--sy-stock);
  background-image: repeating-linear-gradient(
    90deg,
    var(--line) 0 1px,
    transparent 1px 5px
  );
  /* the ribbon thins out rather than stopping dead */
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 26%);
  mask-image: linear-gradient(90deg, transparent 0, #000 26%);
}
.lg-jam .sy-label__title { position: relative; z-index: 1; }
/* one line prints crooked and faint */
.lg-jam .lg-jam__skew { transform: skewX(-6deg) translateX(6px); opacity: .55; }
/* the barcode smears where the stock slipped */
.lg-jam__bars {
  display: block;
  width: 100%;
  height: 48px;
  color: var(--ink);
  transform: skewX(-3deg);
}
.lg-jam__code { text-decoration: line-through; text-decoration-color: var(--accent); }

/* ---------------------------------------------------- 8. reduced motion */
@media (prefers-reduced-motion: reduce) {
  .lg-draft__stamp,
  .lg-jam,
  .lg-jam .lg-jam__skew,
  .lg-jam__bars { transform: none; }
}

/* ------------------------------------------------------------- 9. print */
@media print {
  .lg-toc, .lg-404__links { display: none !important; }
  .lg-doc { display: block; }
  .lg-draft { background: transparent; color: var(--ink); border-bottom: 2px solid var(--line); }
  .lg-draft::after { display: none; }
  .lg-draft__stamp { border-color: var(--ink); transform: none; }
  .lg-body, .lg-end { max-width: none; }
  .lg-sec { break-inside: avoid; }
}
