/* ==========================================================================
   legal.css: the Terms, Privacy and Community Guidelines pages.
   Loads after tokens.css + base.css (never page.css, so the homepage can
   change without breaking these). Top to bottom:
     1. Top bar + footer (same look as the homepage)   2. Page head + Rua
     3. Page switcher   4. "The short version" card   5. Contents + layout
     6. Section cards and legal text   7. Contact card   8. Wider screens
     9. Print
   Mobile first.
   ========================================================================== */

/* ===================== 1. Top bar + footer ===================== */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: min(100% - 2 * var(--gutter), var(--max));
  margin: 0 auto;
  padding-top: max(16px, env(safe-area-inset-top));
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; }
.brand__icon {
  width: 46px; height: 46px; border-radius: 14px;
  border: var(--line-sm) solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
  rotate: -4deg;
}
.brand__name { font-family: var(--font-display); font-weight: 800; font-size: 2rem; line-height: 1; padding-top: 4px; }
.topbar__home { font-size: 1rem; }

.footer {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  margin-top: 64px;
  padding: 0 var(--gutter) max(40px, env(safe-area-inset-bottom));
}
.footer__rua { display: block; width: 150px; }
.footer__line { margin-top: 6px; font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; }
.socials { display: flex; gap: 12px; margin-top: 12px; }
.footer__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px; margin-top: 28px; font-weight: 800; }
.footer__links a { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.footer__links a[aria-current="page"] { text-decoration-color: var(--tangerine); }
.footer__copy { margin-top: 8px; font-size: 0.9rem; color: var(--ink-soft); }

/* Rua's boil: 3 stacked frames, legal.js flicks data-frame 0/1/2 */
.boil { display: grid; }
.boil > img { grid-area: 1 / 1; width: 100%; height: auto; visibility: hidden; }
.boil:not([data-frame]) > img:nth-child(1),
.boil[data-frame="0"] > img:nth-child(1),
.boil[data-frame="1"] > img:nth-child(2),
.boil[data-frame="2"] > img:nth-child(3) { visibility: visible; }

/* ===================== 2. Page head ===================== */
.legal-head {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  width: min(100% - 2 * var(--gutter), var(--max));
  margin: 18px auto 0;
}
.legal-head__rua { width: min(68vw, 270px); animation: hop-in 800ms var(--ease-spring) both; }
.legal-head__rua--wide { width: min(80vw, 330px); }
.legal-head__title {
  margin-top: 6px;
  font-size: clamp(2.6rem, 11.5vw, 4.6rem);
  color: var(--white);
  -webkit-text-stroke: 0.15em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 0.08em 0 var(--ink);
  position: relative; z-index: 0;
}
.legal-head__meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 18px; }
.pill--cream { background: var(--cream); box-shadow: 0 3px 0 var(--border-soft), 0 3px 0 var(--line-sm) var(--ink); }
.pill time { font: inherit; }

/* ===================== 3. Page switcher ===================== */
.switcher {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  margin-top: 22px;
}
.switcher a {
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 8px 16px 7px;
  border: var(--line-sm) solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--cream);
  box-shadow: 0 4px 0 var(--border-soft), 0 4px 0 var(--line-sm) var(--ink);
  font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; line-height: 1.1;
  text-decoration: none;
  transition: transform 160ms var(--ease-out);
}
.switcher a:active { transform: translateY(3px); }
.switcher a[aria-current="page"] { background: var(--sunny); box-shadow: 0 4px 0 var(--sunny-lip), 0 4px 0 var(--line-sm) var(--ink); }

/* Shared sticker card: thick ink outline + hard offset lip */
.card {
  background: var(--cream);
  border: var(--line) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: 0 var(--lift) 0 var(--border-soft), 0 var(--lift) 0 var(--line) var(--ink);
}

/* ===================== 4. The short version ===================== */
.summary {
  position: relative;
  width: min(100% - 2 * var(--gutter), 860px);
  margin: 40px auto 0;
  padding: 26px 22px 24px;
  background: var(--sunny-soft);
  box-shadow: 0 var(--lift) 0 var(--sunny-lip), 0 var(--lift) 0 var(--line) var(--ink);
}
.summary__top { padding-right: 112px; min-height: 40px; }
.summary__title { font-family: var(--font-display); font-weight: 800; font-size: clamp(1.7rem, 6.5vw, 2.2rem); line-height: 1; }
.summary__rua { position: absolute; right: 6px; top: -44px; width: 118px; height: auto; rotate: 4deg; }
.summary__list { margin-top: 16px; display: grid; gap: 12px; }
.summary__list li {
  position: relative;
  padding-left: 34px;
  font-weight: 700; font-size: 1.06rem; line-height: 1.45;
}
.summary__list li::before {
  content: "";
  position: absolute; left: 0; top: 0.18em;
  width: 22px; height: 22px; border-radius: 8px;
  border: var(--line-sm) solid var(--ink);
  background: var(--tangerine);
  rotate: -6deg;
}
.summary__list li:nth-child(2n)::before { background: var(--mint); rotate: 5deg; }
.summary__list li:nth-child(3n)::before { background: var(--sky); rotate: -2deg; }
.summary__note { margin-top: 16px; font-size: 0.95rem; color: var(--ink-soft); font-weight: 700; }

/* ===================== 5. Contents + layout ===================== */
.legal {
  width: min(100% - 2 * var(--gutter), 860px);
  margin: 36px auto 0;
}
.toc { padding: 20px 18px 18px; }
.toc__title { font-family: var(--font-display); font-weight: 800; font-size: 1.35rem; line-height: 1; }
.toc__list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; counter-reset: toc; }
.toc__list a {
  counter-increment: toc;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 6px 12px 5px 6px;
  border: 2px solid var(--ink);
  border-radius: var(--radius-pill);
  background: var(--white);
  box-shadow: 0 3px 0 var(--ink);
  font-weight: 800; font-size: 0.95rem; line-height: 1.2;
  text-decoration: none;
  transition: transform 160ms var(--ease-out), background-color 160ms var(--ease-out);
}
.toc__list a::before {
  content: counter(toc);
  display: inline-grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--cocoa-soft);
  font-family: var(--font-display); font-weight: 800; font-size: 0.9rem; line-height: 1;
  padding-top: 2px;
}
.toc__list a:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.toc__list a.is-current { background: var(--sunny); }
.toc__list a.is-current::before { background: var(--white); }
@media (hover: hover) and (pointer: fine) {
  .toc__list a:hover { background: var(--sunny-soft); }
}

/* ===================== 6. Sections + legal text ===================== */
.sections { display: grid; gap: 22px; margin-top: 26px; counter-reset: sec; }
.sec {
  counter-increment: sec;
  padding: 22px 20px 20px;
  scroll-margin-top: 20px;
}
.sec h2 {
  display: flex; align-items: flex-start; gap: 12px;
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(1.45rem, 5.6vw, 1.85rem); line-height: 1.08;
  text-wrap: balance;
}
.sec h2::before {
  content: counter(sec);
  display: inline-grid; place-items: center; flex: none;
  width: 38px; height: 38px; margin-top: -2px;
  border: var(--line-sm) solid var(--ink);
  border-radius: 12px;
  background: var(--sec-fill, var(--sunny));
  box-shadow: 0 3px 0 var(--ink);
  font-size: 1.15rem; padding-top: 3px;
  rotate: -4deg;
}
.sec:nth-child(5n+2) { --sec-fill: var(--tangerine); }
.sec:nth-child(5n+3) { --sec-fill: var(--mint); }
.sec:nth-child(5n+4) { --sec-fill: var(--bubblegum); }
.sec:nth-child(5n+5) { --sec-fill: var(--lagoon); }

.prose { max-width: 65ch; font-size: 1.0625rem; line-height: 1.68; color: var(--ink); }
.prose > * + * { margin-top: 14px; }
.sec h2 + .prose, .sec h2 + * { margin-top: 14px; }
.prose ul, .prose ol { padding-left: 0; display: grid; gap: 10px; }
.prose ul > li { position: relative; padding-left: 26px; }
.prose ul > li::before {
  content: "";
  position: absolute; left: 4px; top: 0.62em;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--tangerine);
  border: 2px solid var(--ink);
}
.prose ol { list-style: none; counter-reset: step; }
.prose ol > li { counter-increment: step; position: relative; padding-left: 34px; }
.prose ol > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 0.12em;
  display: grid; place-items: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--sunny); border: 2px solid var(--ink);
  font-family: var(--font-display); font-weight: 800; font-size: 0.85rem; line-height: 1; padding-top: 2px;
}
.prose strong { font-weight: 800; }
.prose a {
  font-weight: 800; color: var(--ink);
  text-decoration: underline; text-decoration-color: var(--tangerine);
  text-decoration-thickness: 3px; text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
.prose a[href^="tel:"], .prose a[href^="sms:"] { white-space: nowrap; }
.prose a:hover { text-decoration-color: var(--ink); }
.prose h3 {
  margin-top: 22px;
  font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; line-height: 1.15;
}
/* A soft box inside a section, for "how to" steps and key callouts */
.callout {
  padding: 14px 16px;
  border: var(--line-sm) solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--cocoa-soft);
}
.callout--mint { background: var(--mint-soft); border-color: var(--mint-lip); }
.callout--sky { background: var(--sky-soft); border-color: var(--sky-lip); }

/* ===================== 7. Contact card ===================== */
.contact {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  margin-top: 8px; padding: 22px 20px 26px;
  background: var(--mint-soft);
  box-shadow: 0 var(--lift) 0 var(--mint-lip), 0 var(--lift) 0 var(--line) var(--ink);
}
.contact__rua { width: 150px; height: auto; }
.contact__title { margin-top: 6px; font-family: var(--font-display); font-weight: 800; font-size: 1.7rem; line-height: 1; }
.contact p { margin-top: 10px; max-width: 46ch; font-weight: 700; color: var(--ink-soft); }
.contact .btn { margin-top: 18px; font-size: 1.12rem; white-space: normal; text-align: center; overflow-wrap: anywhere; }
.contact__small { font-size: 0.95rem; }
.contact__small a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* Back to top: a small sticker that appears once you're well down the page */
.to-top {
  position: fixed; right: 16px; bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 20;
  display: grid; place-items: center;
  width: 52px; height: 52px; border-radius: 50%;
  border: var(--line-sm) solid var(--ink);
  background: var(--sunny);
  box-shadow: 0 4px 0 var(--sunny-lip), 0 4px 0 var(--line-sm) var(--ink);
  opacity: 0; translate: 0 12px; pointer-events: none;
  transition: opacity 220ms var(--ease-out), translate 220ms var(--ease-out);
}
.to-top svg { width: 22px; height: 22px; }
.to-top.is-shown { opacity: 1; translate: 0 0; pointer-events: auto; }

/* ===================== 8. Wider screens ===================== */
@media (min-width: 720px) {
  .legal-head { flex-direction: row; justify-content: center; gap: 28px; text-align: left; margin-top: 26px; }
  .legal-head__rua { width: 250px; flex: none; }
  .legal-head__rua--wide { width: 320px; }
  .legal-head__meta, .switcher { justify-content: flex-start; }
  .summary { padding: 30px 34px 30px; }
  .summary__top { padding-right: 190px; }
  .summary__rua { width: 180px; top: -70px; right: 18px; }
  .summary__list { grid-template-columns: 1fr 1fr; gap: 14px 30px; }
  .sec { padding: 30px 34px 30px; }
  .toc { padding: 22px 24px; }
}

/* Desktop: contents become a sticky column on the left */
@media (min-width: 1100px) {
  .summary { width: min(100% - 2 * var(--gutter), 1080px); }
  .legal {
    width: min(100% - 2 * var(--gutter), 1080px);
    display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 34px; align-items: start;
  }
  .toc { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
  .toc__list { flex-direction: column; flex-wrap: nowrap; }
  .toc__list a { width: 100%; }
  .sections { margin-top: 0; }
  .sec { scroll-margin-top: 24px; }
}

/* ===================== Motion ===================== */
@keyframes hop-in {
  from { opacity: 0; transform: translateY(18px) scale(0.94); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .legal-head__rua { animation: none; }
  .to-top { transition: none; }
}

/* ===================== 9. Print ===================== */
@media print {
  @page { margin: 18mm 16mm; }
  body { background: none; font-size: 11pt; color: #000; }
  .topbar, .switcher, .toc, .to-top, .footer, .skip-link,
  .legal-head__rua, .summary__rua, .contact__rua, .contact .btn { display: none !important; }
  .legal-head, .summary, .legal { width: auto; margin: 0; display: block; text-align: left; }
  .legal-head__title { color: #000; -webkit-text-stroke: 0; text-shadow: none; font-size: 24pt; }
  .pill { border: 0; box-shadow: none; padding: 0; background: none; }
  .card, .summary, .contact {
    box-shadow: none !important; background: none !important;
    border: 1px solid #999; border-radius: 6px;
    padding: 10pt 12pt; margin-top: 12pt;
  }
  .sections { display: block; }
  .sec { break-inside: auto; }
  .sec h2 { break-after: avoid; font-size: 15pt; }
  .sec h2::before { box-shadow: none; background: none; border: 1px solid #000; rotate: 0deg; width: 24px; height: 24px; font-size: 11pt; }
  .summary__list { display: block; }
  .summary__list li { margin-top: 6pt; }
  .summary__list li::before, .prose ul > li::before, .prose ol > li::before { background: none; }
  .prose { max-width: none; font-size: 11pt; line-height: 1.5; }
  .prose a { text-decoration: underline; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-weight: 400; font-size: 9pt; }
  .callout { background: none; }
  .contact { align-items: flex-start; text-align: left; }
}
