/* ==========================================================================
   The legal & trust documents — Privacy, Terms, Refunds, Security
   ==========================================================================

   One stylesheet, written once and copied verbatim into
   `assets/css/marketing/{privacy,terms,refunds,trust}.css`.

   ── why four identical files ───────────────────────────────────────────────

   `head.php` loads `assets/css/marketing/<route>.css` and only that, so a
   shared file would need a fifth `<link>` nobody is allowed to add. The four
   pages are one document class and must not drift apart, so the content is
   identical by construction rather than by discipline: change one, copy it to
   the other three.

   ── why the layout lives here and not in class attributes ─────────────────

   `tools/build-css.php` emits only the Tailwind utilities it finds already in
   use somewhere in the tree, and `.env` has `ROS_CSS=compiled`. A utility that
   has never been typed before compiles to nothing at all — no error, no
   warning, correct-looking markup, wrong page. So every measurement on these
   four pages is a real class in this file, where it either exists or does not.

   ── the one rule everything else serves ───────────────────────────────────

   These are documents. Somebody reads them end to end, often because a
   payment gateway or a lawyer told them to, and the only thing the design owes
   them is that it gets out of the way. So: one reading column at the measure
   typography has agreed on for four centuries, a heading scale with obvious
   hierarchy, line-height that survives a long paragraph, links that are
   visibly links, and a champagne hairline where one section ends and the next
   begins. No tilt, no sheen, no reveal-on-scroll prose.

   Colours are tokens from `ros.css` exclusively, so the light skin at
   `:root[data-skin="light"]` is inherited rather than re-stated.
   ========================================================================== */

:root {
  /*
   * The measure: 68–72 characters of Inter, the band in which a reader's eye
   * finds the start of the next line reliably.
   *
   * The figure is 54 and not 70 because `ch` is the advance of "0", and in
   * Inter a "0" is markedly WIDER than the average lowercase letter — 10px
   * against 7.67px at 16px. Setting `70ch` therefore buys about 90 characters
   * of text, not 70, which is well past the point the eye starts losing the
   * line. Measured on the rendered page rather than reasoned about: 54ch is
   * 540px is ~70 characters.
   */
  --legal-measure: 54ch;

  /* The column the panels and tables may use. Wider than the prose, because a
     two-column card at the prose measure is two very narrow cards. */
  --legal-column: 62ch;

  /* The TOC rail, and the gutter between it and the document. */
  --legal-rail: 220px;
  --legal-gutter: 3rem;
}

/* ==========================================================================
   Page frame
   ========================================================================== */

.legal-hero {
  padding: 7.5rem 1.25rem 3.5rem;
}

.legal-main {
  padding: 0 1.25rem 6rem;
}

/*
 * `width: 100%` is load-bearing. `layouts/blank.php` wraps the page in
 * `.stage`, which carries `flex flex-col`, so a wrapper at the top level of
 * the page is a FLEX ITEM in a column container -- and auto margins on the
 * cross axis cancel the default stretch, leaving the item sized by its own
 * content. Measured on the About page before this line existed: a 1180px
 * wrapper rendered at 870px and 722px. No error, nothing in the console, just
 * two blocks narrower than the rest of the page.
 */
.legal-hero-inner,
.legal-layout {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
}

.legal-layout {
  display: grid;
  gap: var(--legal-gutter);
}

/* ==========================================================================
   Masthead
   ========================================================================== */

.legal-kicker {
  margin-bottom: 1.15rem;
}

/*
 * The title, on `.display`.
 *
 * `.display` is built for a marketing hero and sets `line-height: .96`, which
 * collides with itself the moment a title wraps — and "Refund & cancellation
 * policy" wraps on a phone. The size is deliberately well below the home
 * page's: a document title announces a document, it does not sell one.
 */
.legal-title {
  font-size: clamp(2rem, 4.4vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.022em;
  color: var(--warm-100);
  max-width: 24ch;
  margin-bottom: 1.1rem;
  text-wrap: balance;
}

.legal-lede {
  color: var(--warm-500);
  max-width: 48ch;
}

/* ==========================================================================
   The section rail (table of contents)
   ==========================================================================

   Only on the pages that already declare a `$sections` list — all four do,
   and every entry points at an `id` that exists on the page.
   ========================================================================== */

.legal-toc {
  /*
   * On a phone the rail is a panel above the document rather than a bare list
   * that reads as the first section. It carries the champagne edge on the left
   * so it is visibly navigation and not prose.
   */
  border-left: 1px solid var(--line-gold);
  padding: 0.2rem 0 0.2rem 1rem;
  margin-bottom: 0.5rem;
}

.legal-toc-title {
  margin-bottom: 0.85rem;
}

.legal-toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.legal-toc-link {
  display: inline-block;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--warm-500);
  text-decoration: none;
  border-radius: 4px;
  transition: color var(--t-base) var(--ease-out);
}

.legal-toc-link:hover,
.legal-toc-link:focus-visible {
  color: var(--warm-100);
}

/* ==========================================================================
   The document column
   ========================================================================== */

.legal-doc {
  min-width: 0;
  max-width: var(--legal-column);
}

.legal-sec {
  max-width: 100%;
}

/*
 * Anchor targets clear the fixed header.
 *
 * `ros_legal_nav()` pins a 64px shell 12px from the top, so a jump from the
 * rail would otherwise land the heading underneath it. `scroll-margin-top` is
 * the whole fix and needs no script.
 */
.legal-sec[id],
.legal-doc [id] {
  scroll-margin-top: 6.5rem;
}

/* ── headings ────────────────────────────────────────────────────────────── */

.legal-h2 {
  font-size: clamp(1.3rem, 2.1vw, 1.6rem);
  line-height: 1.25;
  letter-spacing: -0.012em;
  color: var(--warm-100);
  margin-bottom: 0.9rem;
  text-wrap: balance;
}

/* A label inside the prose that is a heading in rank but not in size. */
.legal-subhead {
  margin: 2.25rem 0 0.8rem;
}

/* ── prose ───────────────────────────────────────────────────────────────── */

.legal-p {
  font-size: 1rem;
  line-height: 1.78;
  color: var(--warm-300);
  max-width: var(--legal-measure);
  margin-bottom: 1.15rem;
}

.legal-p:last-child {
  margin-bottom: 0;
}

/* The small print: a qualification on the paragraph above it, not a new one. */
.legal-note {
  font-size: 0.8125rem;
  line-height: 1.75;
  color: var(--warm-500);
  max-width: 52ch;
}

.legal-note-sep {
  margin-top: 1.5rem;
}

.legal-small {
  font-size: 0.8125rem;
  line-height: 1.72;
  color: var(--warm-500);
  max-width: 52ch;
}

/*
 * Small print still needs air between two of it.
 *
 * These paragraphs used to carry their own `mb-3`/`mb-4` and several carried
 * nothing, so the gap depended on which utility the author happened to type.
 * Spacing the siblings and zeroing the last one gives every panel the same
 * rhythm whether it holds one paragraph or four -- and inside the tone panels,
 * where three of them stack, the alternative was two sentences touching.
 */
.legal-note:not(:last-child),
.legal-small:not(:last-child),
.legal-micro:not(:last-child) {
  margin-bottom: 0.9rem;
}

.legal-note:last-child,
.legal-small:last-child,
.legal-micro:last-child {
  margin-bottom: 0;
}

/* The same size, raised to body ink — for a tone panel, where the wash behind
   the text eats some of the contrast the tertiary colour was measured at. */
.legal-small-strong {
  color: var(--warm-300);
}

.legal-micro {
  font-size: 0.75rem;
  line-height: 1.65;
  color: var(--warm-700);
}

/* An emphasis inside a paragraph. `<strong>` already carries the weight; this
   only lifts it to primary ink so it reads as emphasis and not as a link. */
.legal-strong {
  color: var(--warm-100);
}

.legal-p em,
.legal-small em,
.legal-note em {
  font-style: italic;
}

/* ── the champagne rule between sections ─────────────────────────────────── */

.legal-rule {
  margin: 3.5rem 0;
  max-width: var(--legal-column);
}

/* ── links ───────────────────────────────────────────────────────────────── */

/*
 * A link in a legal document has to be unmistakably a link.
 *
 * Colour alone fails WCAG 1.4.1 and fails it worst here, where a clause is
 * read quickly and a cross-reference to another policy is the thing the reader
 * most needs to notice. So: underlined always, offset far enough that the rule
 * does not sit on the descenders, and thickened rather than removed on hover.
 */
.legal-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 0.22em;
  border-radius: 3px;
  transition: color var(--t-base) var(--ease-out),
              text-decoration-color var(--t-base) var(--ease-out);
}

.legal-link:hover {
  color: var(--warm-100);
  text-decoration-thickness: 2px;
  text-decoration-color: currentColor;
}

.legal-link:focus-visible,
.legal-toc-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* A published address, which must be allowed to break rather than overflow. */
.legal-link-mail {
  display: inline-block;
  font-size: 0.9375rem;
  margin-bottom: 1.5rem;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   Panels — `.card` and `.well` from ros.css, measured here
   ========================================================================== */

.legal-panel,
.legal-card {
  padding: 1.5rem;
  max-width: var(--legal-column);
}

.legal-panel {
  margin-bottom: 1.5rem;
}

.legal-panel-top {
  margin-top: 1.5rem;
}

.legal-well {
  padding: 1.25rem;
  max-width: var(--legal-column);
}

/* A panel constrained to the prose measure rather than the column. */
.legal-measure {
  max-width: var(--legal-measure);
}

.legal-panel-head {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
}

.legal-panel-label {
  margin-bottom: 0.6rem;
}

.legal-panel-p {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--warm-100);
  margin-bottom: 0.75rem;
}

/* Two panels side by side, one each for the two halves of a distinction. */
.legal-pair {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
  max-width: var(--legal-column);
}

/* ==========================================================================
   Rows — term and definition, inside a panel
   ========================================================================== */

.legal-row {
  display: grid;
  gap: 0.25rem 1.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.legal-row:last-child {
  border-bottom: 0;
}

.legal-row-term {
  font-size: 0.84375rem;
  line-height: 1.5;
  color: var(--warm-100);
  min-width: 0;
}

.legal-row-desc {
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--warm-500);
  min-width: 0;
}

/* ==========================================================================
   Items — a marker, a term, and a note beneath both
   ========================================================================== */

.legal-item {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.legal-item:last-child {
  border-bottom: 0;
}

.legal-item-head {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  margin-bottom: 0.4rem;
}

.legal-item-head-wrap {
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.legal-item-term {
  font-size: 0.84375rem;
  line-height: 1.55;
  color: var(--warm-100);
  min-width: 0;
}

.legal-item-term-block {
  display: block;
  margin-bottom: 0.4rem;
}

/* The note sits under the term, indented past the marker so the two columns
   of text share a left edge. */
.legal-item-note {
  font-size: 0.78125rem;
  line-height: 1.72;
  color: var(--warm-500);
  margin-left: 1.5rem;
}

/* The marker itself: an icon that must never shrink or wrap. */
.legal-mark {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  margin-top: 0.1rem;
}

.legal-mark-yes { color: var(--mint-400); }
.legal-mark-no  { color: var(--warm-700); }

/* ==========================================================================
   Bulleted lists — used where the item is a sentence, not a term
   ========================================================================== */

.legal-bullets {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.legal-bullet {
  display: flex;
  gap: 0.625rem;
}

.legal-bullet-mark {
  flex-shrink: 0;
  font-size: 0.8125rem;
  line-height: 1.72;
  font-variant-numeric: tabular-nums;
}

.legal-bullet-mark-plus  { color: var(--mint-400); }
.legal-bullet-mark-minus { color: var(--rose-400); }

/* ==========================================================================
   The retention table
   ==========================================================================

   The one block on these four pages that is genuinely tabular: a thing, the
   period it lives for, and why. It is built from divs rather than a <table>,
   so it is given a scroll container of its own anyway — `overflow-x: auto`
   costs nothing when the content fits and is the difference between a scroll
   bar and a broken page when it does not.
   ========================================================================== */

.legal-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  max-width: var(--legal-column);
}

.legal-retention-row {
  display: grid;
  gap: 0.25rem 1.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}

.legal-retention-row:last-child {
  border-bottom: 0;
}

.legal-row-period {
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--warm-500);
  min-width: 0;
}

.legal-row-why {
  font-size: 0.75rem;
  line-height: 1.65;
  color: var(--warm-700);
  min-width: 0;
}

.legal-arrow {
  color: var(--warm-700);
}

/* ==========================================================================
   Rate limits — a label and a figure on one baseline
   ========================================================================== */

.legal-limit-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin-bottom: 0.3rem;
}

.legal-limit-value {
  font-size: 0.8125rem;
  color: var(--accent);
  margin-left: auto;
}

/* ==========================================================================
   Feature cards — Security's four "getting in" panels
   ========================================================================== */

.legal-feature-icon {
  display: inline-block;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.legal-feature-title {
  font-size: 0.84375rem;
  line-height: 1.5;
  color: var(--warm-100);
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   Pills
   ========================================================================== */

.legal-pill {
  font-size: 0.625rem;
  margin-left: auto;
}

/* ==========================================================================
   Nothing on these pages may overflow sideways
   ==========================================================================

   A legal page is the one place a reader pinches and zooms, and a horizontal
   scroll bar on a phone makes a long document unreadable rather than merely
   untidy. `overflow-wrap` is set on the prose itself because the content
   includes GSTINs, environment-variable names and email addresses, none of
   which have a break opportunity in them.
   ========================================================================== */

.legal-p,
.legal-note,
.legal-small,
.legal-micro,
.legal-row-term,
.legal-row-desc,
.legal-item-term,
.legal-item-note,
.legal-panel-p,
.legal-feature-title {
  overflow-wrap: break-word;
}

/* ==========================================================================
   Wider than a phone
   ========================================================================== */

@media (min-width: 640px) {
  .legal-pair {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .legal-row {
    grid-template-columns: minmax(0, 15rem) minmax(0, 1fr);
  }

  /*
   * Thing, lifetime, reason. The reason is the column that makes the table
   * honest, so it keeps a full row of its own rather than being squeezed into
   * a third of the width.
   */
  .legal-retention-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .legal-row-why {
    grid-column: 1 / -1;
  }
}

@media (min-width: 1280px) {
  .legal-layout {
    grid-template-columns: var(--legal-rail) minmax(0, 1fr);
  }

  /* The rail follows the reader down the document. */
  .legal-toc {
    position: sticky;
    top: 6rem;
    align-self: start;
    margin-bottom: 0;
  }

  /* The masthead sits over the document column rather than over the rail, so
     the title, the lede and the first clause share one left edge. */
  .legal-hero-inner {
    padding-left: calc(var(--legal-rail) + var(--legal-gutter));
  }
}

/* ==========================================================================
   Print
   ==========================================================================

   Somebody will print a terms page, and the rail is navigation rather than
   content once it is on paper.
   ========================================================================== */

@media print {
  .legal-toc {
    display: none;
  }

  .legal-doc,
  .legal-p,
  .legal-panel,
  .legal-card,
  .legal-well,
  .legal-rule {
    max-width: none;
  }

  .legal-link {
    color: inherit;
  }
}
