/* DICE LINKED website: legal styles. Loaded after site.css. See DESIGN.md.
   Privacy, Terms and Credits are a house-rules sheet laid on the felt: a lamp-lit
   paper sheet (--paper) in dark ink, a brass date plate on the felt above it, and
   a contents rail beside it that marks the section you are reading.
   Replaces the boxed .legal-body sections from site.css (that markup is gone). */

.legal-page {
  /* Ink on paper. Contrast against --paper (#f3ead2) and the sheet's darkest tone (#efe5ca). */
  --sheet-ink: #1b1306;      /* headings, run-in terms: 15.3:1 */
  --sheet-text: #2b2112;     /* body: 13.2:1 */
  --sheet-soft: #4f412a;     /* credits notes, colophon: 8.3:1 */
  --sheet-brass: #6e4c12;    /* worn brass for links, numerals, ornaments: 6.5:1 */
  --sheet-rule: rgba(27, 19, 6, 0.15);
  --sheet-rule-strong: rgba(27, 19, 6, 0.5);
  --sheet-pad: clamp(1.25rem, 5vw, 2.25rem);
  --measure: 36rem;          /* about 72 characters of 17px Outfit */
  --sheet-max: calc(var(--measure) + 2 * var(--sheet-pad));
  --legal-top: 7rem;         /* clears the fixed nav */
  --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.42 0 0 0 0 0.3 0 0 0 0 0.12 0.2 0 0 0 -0.06'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23g)'/%3E%3C/svg%3E");
  position: relative;
  padding-bottom: clamp(4.5rem, 9vw, 7.5rem);
}
@media (min-width: 768px) {
  .legal-page { --sheet-pad: clamp(3.25rem, 4.6vw, 4.75rem); }
}

/* Sticky works because site.css makes the viewport the only scroller (body overflow: clip visible). */

/* ---------- Title on the felt, dated by a brass plate ---------- */

/* Title and layout share one centered frame so the title sits over the contents rail. */
.legal-head.wrap,
.legal-layout.wrap { max-width: 68rem; }
.legal-head { padding-top: clamp(7.5rem, 12vw, 10rem); padding-bottom: clamp(2rem, 4vw, 3rem); }
.legal-head h1 { max-width: 16ch; }
.legal-date { margin-top: 2.1rem; transform: rotate(-1.5deg); transform-origin: 0 50%; }
.legal-date span { font-size: 0.76rem; letter-spacing: 0.12em; }
.legal-date time { font: inherit; }

/* ---------- Layout: contents rail + sheet ---------- */

.legal-layout { position: relative; isolation: isolate; display: grid; gap: 1.5rem; }
/* The lamp falls on the top of the sheet. */
.legal-layout::before {
  content: '';
  position: absolute;
  z-index: -1;
  top: -5rem;
  left: 50%;
  width: min(72rem, 100%);
  height: 36rem;
  translate: -50% 0;
  background: radial-gradient(closest-side, rgba(255, 228, 165, 0.085), transparent);
  pointer-events: none;
}
@media (max-width: 639px) {
  .legal-layout.wrap { padding-inline: 0.75rem; }
}
@media (min-width: 1024px) {
  .legal-layout {
    grid-template-columns: 12.5rem minmax(0, var(--sheet-max));
    column-gap: clamp(2.5rem, 4vw, 4.5rem);
    align-items: start;
  }
}

/* ---------- Contents ---------- */

.legal-toc { --toc-pad: 0.5rem; }
.legal-toc__label { display: none; }
.legal-toc__toggle {
  display: flex;
  width: 100%;
  min-height: 3.25rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem var(--toc-pad);
  border-block: 1px solid var(--hair);
  color: var(--ivory);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-align: left;
  transition: color 200ms;
}
.legal-toc__toggle:hover { color: var(--brass-hi); }
.legal-toc__toggle i { color: var(--brass-hi); font-size: 1rem; transition: transform 300ms var(--ease-out); }
.legal-toc.is-open .legal-toc__toggle i { transform: rotate(180deg); }
.legal-toc__list { display: none; margin: 0; padding: 0.35rem 0 0.6rem; list-style: none; border-bottom: 1px solid var(--hair); }
.legal-toc.is-open .legal-toc__list { display: block; }

.legal-page .legal-toc a {
  position: relative;
  display: grid;
  grid-template-columns: 1.6rem minmax(0, 1fr);
  align-items: baseline;
  min-height: 2.75rem;
  padding: 0.6rem var(--toc-pad);
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.35;
  text-decoration: none;
  transition: color 200ms;
}
.legal-toc .n { color: var(--brass); font-variant-numeric: tabular-nums; }
.legal-toc .t { grid-column: 2; text-wrap: pretty; }
.legal-page .legal-toc a:hover { color: var(--ivory); }
.legal-page .legal-toc a[aria-current] { color: var(--brass-hi); }
.legal-page .legal-toc a[aria-current] .n { color: var(--brass-hi); }

@media (min-width: 1024px) {
  .legal-toc { position: sticky; top: var(--legal-top); --toc-pad: 0; padding-top: 0.4rem; }
  .legal-toc__toggle { display: none; }
  .legal-toc__label {
    display: block;
    color: var(--ivory);
    font-family: var(--font-display);
    font-size: 1.02rem;
    font-weight: 650;
    letter-spacing: -0.01em;
  }
  /* A brass track; a diamond rides it to the section in view. */
  .legal-toc__list { display: block; margin-top: 1rem; padding: 0.15rem 0; border: 0; border-left: 1px solid var(--hair); }
  .legal-page .legal-toc a {
    min-height: 0;
    grid-template-columns: 1.4rem minmax(0, 1fr);
    padding: 0.42rem 0 0.42rem 1.1rem;
    font-size: 0.92rem;
  }
  .legal-page .legal-toc a::before {
    content: '';
    position: absolute;
    left: -4px;
    top: calc(0.42rem + 0.675em - 3.5px);
    width: 7px;
    height: 7px;
    background: linear-gradient(135deg, var(--brass-hi), var(--brass) 55%, var(--brass-lo));
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.6);
    transform: rotate(45deg) scale(0);
    transition: transform 320ms var(--ease-out);
  }
  .legal-page .legal-toc a[aria-current]::before { transform: rotate(45deg) scale(1); }
}

/* ---------- The sheet ---------- */

.legal-sheet {
  position: relative;
  max-width: var(--sheet-max);
  padding: clamp(3.1rem, 6vw, 4.6rem) var(--sheet-pad) clamp(2.25rem, 5vw, 3.5rem);
  border-radius: 0.3rem;
  background:
    radial-gradient(64rem 30rem at 50% -8rem, rgba(255, 252, 240, 0.8), transparent 72%),
    var(--paper-grain),
    linear-gradient(180deg, var(--paper), #efe5ca);
  color: var(--sheet-text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    inset 0 0 0 1px rgba(110, 72, 16, 0.2),
    0 50px 70px -42px rgba(0, 0, 0, 0.95),
    0 26px 34px -20px rgba(0, 0, 0, 0.75);
  font-size: 1.0625rem;
  line-height: 1.7;
  overflow-wrap: break-word;
}
/* Printed head rule: a heavy line over a light one, like a printed rules card. */
.legal-sheet::before {
  content: '';
  position: absolute;
  top: clamp(1.35rem, 2.6vw, 1.9rem);
  left: var(--sheet-pad);
  right: var(--sheet-pad);
  height: 5px;
  border-top: 2px solid var(--sheet-rule-strong);
  border-bottom: 1px solid var(--sheet-rule-strong);
}
.legal-sheet > * { max-width: var(--measure); }
.legal-sheet ::selection { background: rgba(220, 176, 94, 0.55); color: var(--sheet-ink); }
.legal-sheet :focus-visible { outline-color: var(--sheet-brass); }

.legal-sec + .legal-sec { margin-top: 2.6rem; padding-top: 2.6rem; border-top: 1px solid var(--sheet-rule); }
.legal-sec__head { display: flex; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.95rem; }

/* site.css forces ivory on .legal-page headings; on paper they are ink. */
.legal-page .legal-sheet h2 {
  position: relative;
  color: var(--sheet-ink) !important;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.1vw, 1.65rem);
  font-weight: 700;
  font-stretch: 96%;
  line-height: 1.18;
  letter-spacing: -0.022em;
  text-wrap: balance;
  scroll-margin-top: var(--legal-top);
}
.legal-sheet h2:focus { outline: none; }
.legal-sheet h2:focus-visible { outline: 2px solid var(--sheet-brass); outline-offset: 6px; }
.legal-num { color: var(--sheet-brass); font-variant-numeric: tabular-nums; }
/* Section numbers hang in the margin so the headings share one left edge. */
@media (min-width: 768px) {
  .legal-num { position: absolute; right: 100%; top: 0; padding-right: 0.5em; }
}

.legal-page .legal-sheet .legal-anchor {
  display: grid;
  flex: none;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-top: -0.05rem;
  border-radius: 50%;
  color: var(--sheet-brass);
  font-size: 1.05rem;
  text-decoration: none;
  opacity: 0;
  transition: opacity 200ms, background-color 200ms;
}
.legal-sec__head:hover .legal-anchor,
.legal-page .legal-sheet .legal-anchor:focus-visible { opacity: 1; }
.legal-page .legal-sheet .legal-anchor:hover { background-color: rgba(110, 76, 18, 0.1); }
@media (hover: none) {
  .legal-page .legal-sheet .legal-anchor { display: none; }
}

.legal-sheet p { text-wrap: pretty; }
.legal-sec p + p,
.legal-sec p + ul,
.legal-sec ul + p,
.legal-sec [data-seo-passage] + p { margin-top: 1.05em; }
.legal-sheet strong { color: var(--sheet-ink); font-weight: 620; }

.legal-page .legal-sheet a {
  color: var(--sheet-brass);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(110, 76, 18, 0.45);
  text-underline-offset: 0.2em;
  transition: color 200ms, text-decoration-color 200ms;
}
.legal-page .legal-sheet a:hover { color: var(--sheet-ink); text-decoration-color: currentColor; }

/* Lists: worn-brass diamonds, the site's inlay mark, instead of bullets. */
.legal-list { display: grid; gap: 0.8rem; margin: 1.15rem 0 0; padding: 0; list-style: none; }
.legal-list li { position: relative; padding-left: 1.4rem; text-wrap: pretty; }
.legal-list li::before {
  content: '';
  position: absolute;
  left: 0.2rem;
  top: calc(0.85em - 3px);
  width: 6px;
  height: 6px;
  background: var(--sheet-brass);
  transform: rotate(45deg);
}

/* The privacy promise, set as the line a player would remember. */
.legal-sec .legal-pledge {
  margin-top: 1.6rem;
  color: var(--sheet-ink);
  font-family: var(--font-display);
  font-size: clamp(1.28rem, 1.9vw, 1.5rem);
  font-weight: 640;
  font-stretch: 96%;
  line-height: 1.3;
  letter-spacing: -0.015em;
  text-wrap: balance;
}
.legal-keep { white-space: nowrap; }
.legal-pledge::before {
  content: '';
  display: block;
  width: 2.75rem;
  height: 5px;
  margin-bottom: 0.95rem;
  border-top: 2px solid var(--sheet-brass);
  border-bottom: 1px solid var(--sheet-brass);
}

/* "AS IS": a printed notice between double rules, no side bar. */
.legal-notice {
  padding-block: 0.95rem;
  border-block: 3px double var(--sheet-rule-strong);
  color: var(--sheet-ink);
  font-size: 0.98rem;
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: 0.02em;
}

/* Credits: a ruled register, name on the left, use and license on the right. */
.legal-ledger { margin: 1.5rem 0 0; padding: 0; list-style: none; border-bottom: 1px solid var(--sheet-rule); }
.legal-ledger li { display: grid; gap: 0.15rem; padding-block: 0.85rem; border-top: 1px solid var(--sheet-rule); }
.legal-ledger strong { font-family: var(--font-display); font-size: 1.02rem; font-weight: 650; line-height: 1.35; letter-spacing: -0.01em; }
.legal-ledger span { color: var(--sheet-soft); font-size: 0.98rem; line-height: 1.55; }
@media (min-width: 640px) {
  .legal-ledger li { grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); column-gap: 1.75rem; }
}

/* Colophon: who to ask, under a closing double rule. */
.legal-colophon {
  margin-top: 3rem;
  padding-top: 1.35rem;
  border-top: 3px double var(--sheet-rule-strong);
  color: var(--sheet-soft);
  font-size: 0.97rem;
  line-height: 1.65;
}

/* ---------- Motion: the sheet is laid down once, the plate settles ---------- */

@media (prefers-reduced-motion: no-preference) {
  .legal-sheet { animation: legal-lay 760ms var(--ease-out) backwards; }
  .legal-date { animation: legal-plate 900ms var(--ease-land) 140ms backwards; }
}
@keyframes legal-lay { from { transform: translateY(18px); } }
@keyframes legal-plate { from { transform: translateY(-10px) rotate(-5deg); } }

/* ---------- Print: just the sheet, in black ---------- */

@media print {
  @page { margin: 16mm 18mm; }
  html:has(.legal-page)::before,
  html:has(.legal-page)::after { display: none; }
  html:has(.legal-page),
  body:has(.legal-page) { background: #fff !important; }
  body:has(.legal-page) .site-header,
  body:has(.legal-page) #mobile-menu,
  body:has(.legal-page) .site-footer,
  .legal-toc,
  .legal-page .legal-sheet .legal-anchor { display: none !important; }
  body:has(.legal-page) #content { min-height: 0; }

  .legal-page { padding: 0; color: #000; }
  .legal-head.wrap,
  .legal-layout.wrap { max-width: none; padding: 0; }
  .legal-head { padding-bottom: 10pt; }
  .legal-head h1 { max-width: none; color: #000; font-size: 24pt; }
  .legal-date { margin-top: 6pt; padding: 0; background: none; box-shadow: none; transform: none; animation: none; }
  .legal-date::before,
  .legal-date::after { display: none; }
  .legal-date span { color: #333; font-family: var(--font-body); font-size: 10pt; letter-spacing: 0; text-transform: none; text-shadow: none; }
  .legal-layout { display: block; }
  .legal-layout::before { display: none; }

  .legal-sheet { max-width: none; padding: 0; background: none; box-shadow: none; border-radius: 0; animation: none; color: #000; font-size: 10.5pt; line-height: 1.5; }
  .legal-sheet::before { display: none; }
  .legal-sheet > * { max-width: none; }
  .legal-sec + .legal-sec { margin-top: 14pt; padding-top: 10pt; }
  .legal-page .legal-sheet h2 { color: #000 !important; font-size: 13pt; break-after: avoid; }
  .legal-num { position: static; padding: 0; color: #000; }
  .legal-sheet p,
  .legal-sheet li { orphans: 3; widows: 3; }
  .legal-sheet strong,
  .legal-ledger span,
  .legal-colophon,
  .legal-notice,
  .legal-pledge { color: #000; }
  .legal-list li::before,
  .legal-pledge::before { background: #000; border-color: #000; }
  .legal-ledger li { break-inside: avoid; }
  .legal-page .legal-sheet a { color: #000; }
  .legal-page .legal-sheet a[href^="http"]:not([href="https://onitsoga.com/contact"])::after { content: " (" attr(href) ")"; font-size: 0.85em; word-break: break-all; }
}
