/* Legal pages (polityka prywatności, regulamin, …): calm hero, sticky table
   of contents on the left, long-form text in a readable measure on the right.
   Load after upright.css. Uses only the shared design tokens.

   Markup contract:
   section.legal-hero > .container.legal-layout > .page-hero-copy
   .legal-body > .container.legal-layout
       > aside.legal-aside > div > (.toc-title, nav.toc > ol > li > a[href="#id"])
       > details.toc-mobile > (summary, nav.toc …)      — phones / tablets
       > article.legal-text > section.legal-section#id > h2.legal-h, p, ol.legal-points, ul.legal-list */

/* ---------- Grid: TOC column · text column · breathing room ---------- */
.legal-layout {
  display: grid;
  grid-template-columns: minmax(200px, 1.3fr) minmax(0, 680px) minmax(0, .7fr);
  column-gap: 48px;
}
.legal-layout > .page-hero-copy,
.legal-layout > .legal-text { grid-column: 2; grid-row: 1; }

/* ---------- Hero ---------- */
.legal-hero { position: relative; overflow: hidden; margin-top: -64px; padding: calc(64px + 112px) 0 0; }
.legal-hero > .container { position: relative; z-index: 1; }
.legal-hero .glow-warm { width: 640px; height: 520px; right: -180px; top: -140px; opacity: .5; }
.legal-hero .glow-lilac { width: 520px; height: 460px; right: 260px; top: -100px; opacity: .4; }
.page-hero-copy {
  display: flex; flex-direction: column; align-items: flex-start; gap: 20px;
  padding-bottom: 56px; border-bottom: 1px solid var(--hairline);
}
.page-hero-copy .h-lg { margin-top: 4px; }
.page-hero-copy .lead { max-width: 620px; }
.page-hero-copy .link-arrow { font-size: 17px; margin-top: 4px; }
.legal-meta { font-size: 15px; color: var(--slate); }

/* ---------- Body ---------- */
.legal-body { padding: 64px 0 var(--section); }

/* sticky table of contents (active link set by upright.js → .toc a.is-active) */
.legal-aside { grid-column: 1; grid-row: 1; }
.legal-aside > div { position: sticky; top: 104px; max-height: calc(100vh - 136px); overflow-y: auto; padding: 4px 8px 4px 0; scrollbar-width: thin; }
.toc-title { font-size: 14px; color: var(--slate); margin-bottom: 14px; }
.toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; border-left: 1px solid var(--hairline); }
.toc a {
  display: grid; grid-template-columns: 1.5em minmax(0, 1fr);
  margin-left: -1px; padding: 6px 0 6px 16px;
  border-left: 1px solid transparent;
  font-size: 14px; line-height: 1.4; color: var(--slate);
  transition: color .2s, border-color .2s;
}
.toc a:hover { color: var(--ink); }
.toc a.is-active { color: var(--ink); border-left-color: var(--ink); }
.toc a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.toc-n { font-variant-numeric: tabular-nums; }

/* collapsible TOC for narrow screens */
.toc-mobile { display: none; }

/* ---------- Long-form text ---------- */
.legal-text { font-size: 17px; line-height: 1.6; color: var(--ink); overflow-wrap: anywhere; min-width: 0; }
.legal-section { scroll-margin-top: 104px; }
.legal-section + .legal-section { margin-top: 64px; }
.legal-section > * + * { margin-top: 16px; }
.legal-h {
  font-family: var(--font-serif); font-weight: 400; font-optical-sizing: auto;
  font-size: clamp(26px, 2.5vw, 32px); line-height: 1.2; letter-spacing: -0.01em;
  text-wrap: balance; overflow-wrap: normal;
}
.legal-section > .legal-h + * { margin-top: 20px; }
.legal-hn { color: var(--slate); font-variant-numeric: tabular-nums; }

/* numbered points: hanging numbers */
.legal-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.legal-points > li { display: grid; grid-template-columns: 2em minmax(0, 1fr); }
.legal-n { color: var(--slate); font-variant-numeric: tabular-nums; }

/* bulleted sub-lists */
.legal-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.legal-list > li { position: relative; padding-left: 22px; }
.legal-list > li::before {
  content: ""; position: absolute; left: 4px; top: .78em;
  width: 5px; height: 5px; border-radius: 50%; background: var(--slate);
}
.legal-block > p + .legal-list { margin-top: 10px; }

/* inline links: always underlined (not colour alone), darker on hover */
.legal-text a {
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  text-decoration-color: var(--ash);
  transition: text-decoration-color .2s;
}
.legal-text a:hover { text-decoration-color: var(--ink); text-decoration-thickness: 2px; }
.legal-text a:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .legal-layout { column-gap: 40px; grid-template-columns: minmax(190px, 1fr) minmax(0, 680px) 0; }
}
@media (max-width: 900px) {
  .legal-layout { grid-template-columns: minmax(0, 1fr); column-gap: 0; }
  .legal-layout > .page-hero-copy,
  .legal-layout > .legal-text { grid-column: 1; grid-row: auto; }
  .legal-aside { display: none; }
  .legal-hero { padding-top: calc(64px + 80px); }
  .legal-body { padding-top: 40px; }

  .toc-mobile { display: block; margin-bottom: 48px; background: var(--card); border-radius: var(--radius-small); }
  .toc-mobile summary {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 16px 20px; font-size: 16px; font-weight: 450; cursor: pointer; list-style: none;
    border-radius: var(--radius-small);
  }
  .toc-mobile summary::-webkit-details-marker { display: none; }
  .toc-mobile summary::after { content: "+"; font-size: 22px; line-height: 1; color: var(--slate); transition: transform .2s var(--ease); }
  .toc-mobile[open] summary::after { transform: rotate(45deg); }
  .toc-mobile summary:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
  .toc-mobile .toc { padding: 0 20px 14px; }
  .toc-mobile .toc ol { border-left: 0; border-top: 1px solid var(--hairline); padding-top: 8px; }
  .toc-mobile .toc a { padding: 8px 0; margin-left: 0; border-left: 0; font-size: 15px; }
}
@media (max-width: 640px) {
  .legal-hero { padding-top: calc(64px + 56px); }
  .page-hero-copy { padding-bottom: 40px; gap: 16px; }
  .page-hero-copy .lead { font-size: 18px; }
  .legal-section + .legal-section { margin-top: 48px; }
  .legal-points > li { grid-template-columns: 1.75em minmax(0, 1fr); }
}

/* ---------- Print: just the document ---------- */
@media print {
  .nav, .mobile-menu, .legal-aside, .toc-mobile, .footer, .glow, .page-hero-copy .link-arrow { display: none !important; }
  .legal-hero { margin-top: 0; padding-top: 0; }
  .legal-layout { display: block; }
  .legal-body { padding: 24px 0 0; }
  .motion .reveal, .motion .split .w { opacity: 1 !important; transform: none !important; }
  .legal-text a { text-decoration: none; }
}
