/* ==========================================================================
   Pertimm — policy pages: legal.html, privacy.html, accessibility.html
   Shared layout + the legal page's set piece (the company plate).
   Components come from base.css; this file only composes them.

   Signature moments
   1. Document tabs: the three policies read as one legal centre. The active
      tab is cut from the paper chapter below it and lit by a spectral edge.
   2. Reading beam: a thin spectral light travels down the table-of-contents
      rail as you read (legal.js writes --read, 0 → 1).
   ========================================================================== */

/* ---------------------------------------------------------------- Hero */
.policy-hero { padding-bottom: 0; border-bottom: 0; }
.policy-hero::after {                     /* the hairline the active tab sits on */
  content: ""; position: absolute; inset: auto 0 0; height: 1px; background: var(--line-2); pointer-events: none;
}
.policy-hero .page-hero__inner { gap: var(--space-m); }
.policy-hero .page-hero__title { max-width: 15ch; }
.policy-hero .page-hero__lead { max-width: 52ch; }

.policy-facts { justify-self: stretch; width: 100%; max-width: 62rem; margin-top: var(--space-2xs); }
.policy-facts dd { overflow-wrap: anywhere; }
.policy-facts a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: .22em; }
.policy-facts a:hover { text-decoration-color: var(--fg); }
.policy-facts .badge { margin-top: .1rem; }
.policy-facts .meta-list__row { align-content: start; }
@media (max-width: 639px) {
  .policy-facts { grid-template-columns: 1fr; }
  .policy-facts .meta-list__row { grid-template-columns: 7.25rem minmax(0, 1fr); gap: 1rem; padding: .6rem 0; }
  .policy-facts .meta-list__row:last-child { border-bottom: 1px solid var(--line); }
}


/* Document tabs (navigation between the three policies, not ARIA tabs) */
.policy-tabs { justify-self: stretch; margin-top: var(--space-l); position: relative; z-index: 1; }
.policy-tabs__list { display: flex; gap: .35rem; list-style: none; padding: 0; }
.policy-tab {
  --cut: 10px;
  position: relative; display: inline-flex; align-items: center; gap: .55rem;
  min-height: 3.1rem; padding: .85rem 1.3rem .8rem;
  font-size: var(--step--1); font-weight: 540; line-height: 1.2; color: var(--fg-2); text-decoration: none; white-space: nowrap;
  background: rgb(240 237 247 / .045);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  transition: color var(--dur-1), background-color var(--dur-2) var(--ease-out);
}
.policy-tab::before {                     /* spectral edge: light only on the active document */
  content: ""; position: absolute; left: 0; top: 0; height: 1px; width: calc(100% - var(--cut));
  background: var(--spectrum); box-shadow: 0 0 12px var(--glow);
  transform: scaleX(0); transform-origin: left; transition: transform var(--dur-3) var(--ease-out);
}
.policy-tab:hover { color: var(--fg); background: rgb(240 237 247 / .08); }
.policy-tab:hover::before { transform: scaleX(.35); }
.policy-tab[aria-current="page"] { color: #07102b; background: var(--paper); }
.policy-tab[aria-current="page"]::before { transform: none; box-shadow: none; }
.policy-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -5px; border-radius: 0; }
.policy-tab[aria-current="page"]:focus-visible { outline-color: var(--violet); }
/* when the document opens onto an ink section (privacy "At a glance"), the active tab is cut from ink */
.policy-tabs--ink .policy-tab[aria-current="page"] { color: var(--fg); background: var(--ink); }
.policy-tabs--ink .policy-tab[aria-current="page"]::before { box-shadow: 0 0 12px var(--glow); }
.policy-tabs--ink .policy-tab[aria-current="page"]:focus-visible { outline-color: var(--focus); }
.policy-tab__short { display: none; }
@media (max-width: 719px) {
  .policy-tabs__list { gap: .25rem; }
  .policy-tab { padding-inline: .85rem; min-height: 2.9rem; }
  .policy-tab__long { display: none; }
  .policy-tab__short { display: inline; }
}

/* ---------------------------------------------------------------- Body */
.policy-body { padding-top: clamp(2.5rem, 1.5rem + 4vw, 5.5rem); }
.policy-layout { align-items: start; }
@media (min-width: 1000px) {
  .policy-layout { grid-template-columns: minmax(13rem, 17rem) minmax(0, 1fr); column-gap: clamp(3rem, 1rem + 5vw, 7.5rem); }
}

/* Table of contents: always visible on desktop, collapsible on small screens */
.policy-toc { --read: 0; }
.policy-toc__summary { display: none; }
.policy-toc .toc__list { position: relative; counter-reset: toc; }
.policy-toc .toc__list li { counter-increment: toc; }
.policy-toc .toc__list a { display: grid; grid-template-columns: 1.9rem minmax(0, 1fr); align-items: baseline; padding-block: .42rem; }
.policy-toc .toc__list a::before {
  content: counter(toc, decimal-leading-zero); content: counter(toc, decimal-leading-zero) / "";
  font-size: var(--step--2); font-stretch: 112%; color: var(--fg-3); letter-spacing: .02em;
}
.policy-toc .toc__list a[aria-current="true"]::before { color: var(--accent-text); }
/* the reading beam: light travels down the rail as the document is read */
.policy-toc .toc__list::before {
  content: ""; position: absolute; left: -1px; top: 0; width: 1px; height: 100%; pointer-events: none;
  background: linear-gradient(180deg, #a13fc4, #5b3fd6 55%, #1f6fb2);
  transform-origin: top; transform: scaleY(var(--read));
}
.policy-toc .toc__list::after {
  content: ""; position: absolute; left: -4px; top: calc(var(--read) * 100%); width: 7px; height: 8px; pointer-events: none;
  clip-path: var(--hex); background: var(--violet); translate: 0 -50%;
  opacity: clamp(0, calc(var(--read) * 40), 1);
  box-shadow: 0 0 0 4px rgb(91 63 214 / .18);
}
.policy-toc__related { margin-top: var(--space-l); padding-top: var(--space-m); border-top: 1px solid var(--line); }
.policy-toc__related .toc__title { margin-bottom: .35rem; }
.policy-toc__related ul { display: grid; gap: .1rem; }
.policy-toc__related a { display: inline-flex; align-items: center; gap: .4rem; min-height: 2rem; color: var(--fg-2); text-decoration: none; }
.policy-toc__related a:hover { color: var(--fg); text-decoration: underline; text-decoration-color: var(--accent); }
.policy-toc__related svg { width: .85em; height: .85em; flex: none; }

@media (max-width: 999px) {
  .policy-toc { padding: 0; }
  .policy-toc > .toc__title, .policy-toc__related { display: none; }
  .policy-toc__summary {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    min-height: 3.25rem; padding: .8rem 1.1rem; cursor: pointer; list-style: none;
    color: var(--fg); font-weight: 560;
  }
  .policy-toc__summary::-webkit-details-marker { display: none; }
  .policy-toc__summary::after {
    content: ""; flex: none; width: .55rem; height: .55rem; margin-right: .2rem;
    border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
    transform: translateY(-25%) rotate(45deg); transition: transform var(--dur-2) var(--ease-out);
  }
  .policy-toc__details[open] > .policy-toc__summary::after { transform: translateY(20%) rotate(-135deg); }
  .policy-toc__summary:focus-visible { outline-offset: -3px; }
  .policy-toc__count { margin-left: auto; color: var(--fg-3); font-weight: 450; font-size: var(--step--1); }
  .policy-toc__details .toc__list { margin: 0 1.1rem 1rem; }
  .policy-toc .toc__list::before, .policy-toc .toc__list::after { display: none; }
}

/* Long-form text */
.policy-prose { counter-reset: sec; max-width: 72ch; }
.policy-prose > h2 { counter-increment: sec; padding-top: 1.35rem; border-top: 1px solid var(--line); margin-top: 2.1em; }
.policy-prose > h2::before {
  content: counter(sec, decimal-leading-zero); content: counter(sec, decimal-leading-zero) / "";
  display: block; width: fit-content; margin-bottom: .7rem;
  font-size: var(--step--1); font-weight: 400; font-stretch: 118%; letter-spacing: .04em; line-height: 1;
  background: var(--text-spectrum); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.policy-prose > .policy-meta + h2 { margin-top: 1.6rem; }
.policy-prose h3 { font-size: var(--step-1); letter-spacing: -.012em; }
.policy-prose .policy-fr { color: var(--fg-3); font-weight: 340; }
.policy-prose h2 .policy-fr { font-size: .82em; }
@media (max-width: 719px) { .policy-prose h2 .policy-fr { display: block; margin-top: .3rem; font-size: .72em; } }
.policy-prose ul li::marker { color: var(--accent); }
.policy-prose .meta-list { margin-top: 1.1em; }
.policy-prose .meta-list dd { overflow-wrap: anywhere; }
.policy-prose address { font-style: normal; }
.policy-prose .table-scroll { margin-top: 1.4em; }

/* Last-updated line + print */
.policy-meta {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem;
  font-size: var(--step--1); color: var(--fg-3);
}
.policy-meta p { display: inline-flex; align-items: center; gap: .55rem; }
.policy-meta p svg { width: 1rem; height: 1rem; color: var(--accent); }
.policy-meta time { color: var(--fg); font-weight: 540; }
.policy-print { font-size: var(--step--1); min-height: 2.25rem; }

/* Key-point callout inside the prose */
.policy-note {
  position: relative; padding: 1.1rem 1.25rem 1.1rem 1.4rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); color: var(--fg-2);
}
.policy-note::before { content: ""; position: absolute; left: -1px; top: 1rem; bottom: 1rem; width: 2px; background: var(--spectrum-deep); }
.policy-note strong { color: var(--fg); }

/* Responsive tables: rows become labelled blocks on small screens */
.policy-table th[scope="row"] { color: var(--fg); font-weight: 560; }
.policy-table td, .policy-table th { font-size: var(--step--1); line-height: 1.55; }
.policy-table thead th { font-size: var(--step--2); color: var(--fg-3); font-weight: 540; letter-spacing: .02em; border-bottom-color: var(--line-2); }
.policy-table .nowrap { white-space: nowrap; }
@media (max-width: 719px) {
  .policy-table, .policy-table tbody, .policy-table tr, .policy-table th, .policy-table td { display: block; width: 100%; }
  .policy-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .policy-table tr { padding: .9rem 0; border-bottom: 1px solid var(--line); }
  .policy-table th, .policy-table td { padding: .2rem 0; border: 0; }
  .policy-table th[scope="row"] { font-size: var(--step-0); margin-bottom: .35rem; }
  .policy-table td[data-label]::before { content: attr(data-label) " — "; color: var(--fg-3); font-weight: 540; }
}

/* ---------------------------------------------------------------- Legal: company plate (signature) */
.id-plate { display: grid; gap: var(--space-m); margin-top: 1.6em !important; }
.id-plate__head { display: grid; gap: .55rem; }
.id-plate__name { font-size: var(--step-3); line-height: 1.02; letter-spacing: -.02em; font-weight: 560; font-stretch: 112%; color: var(--fg); overflow-wrap: anywhere; }
.id-plate__form { color: var(--fg-2); }
.id-plate__siren { display: grid; gap: .5rem; padding-block: var(--space-m); border-block: 1px solid var(--line-2); }
.id-plate__label { font-size: var(--step--1); color: var(--fg-3); }
.id-plate__row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; }
.id-plate__num {
  font-size: clamp(2.3rem, 1.4rem + 3vw, 3.9rem); font-weight: 250; font-stretch: 118%; line-height: .95; letter-spacing: -.035em;
  background: var(--text-spectrum); -webkit-background-clip: text; background-clip: text; color: transparent;
  white-space: nowrap;
}
.id-plate__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr)); column-gap: 1.75rem; margin: 0; }
.id-plate__cell { display: grid; gap: .2rem; align-content: start; padding: .85rem 0; border-bottom: 1px solid var(--line); }
.id-plate__cell dt { font-size: var(--step--1); color: var(--fg-3); }
.id-plate__cell dd { color: var(--fg); margin: 0; overflow-wrap: anywhere; }
.id-plate__cell dd .copy { margin-top: .4rem; }
.id-plate__cell--inline dd { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem; }
.id-plate__cell--inline dd .copy { margin-top: 0; }
.id-plate a { color: var(--fg); }
.id-plate .copy { min-height: 2.25rem; padding-block: .25rem; }

/* ---------------------------------------------------------------- CTA band aside */
.policy-cta .cta-band__title { max-width: 16ch; }
.policy-cta .contact-line__value { font-size: var(--step-1); }

/* ---------------------------------------------------------------- Print: the document only */
@media print {
  .policy-tabs, .policy-toc, .policy-print, .policy-cta, .policy-hero::after, .breadcrumb { display: none !important; }
  .policy-hero { padding-top: 0 !important; }
  .prose-layout { display: block !important; }
  .policy-prose { max-width: none; }
  .policy-prose a[href^="http"]::after, .policy-prose a[href^="mailto"]::after { content: " (" attr(href) ")"; font-size: .85em; }
  .slab { box-shadow: none; border: 1px solid #999; }
  .id-plate__num { color: #000 !important; background: none !important; }
}
