/*
 * Shared stylesheet for the legal pages served from public/info/.
 *
 * Theme selection lives in info.js: it sets data-theme="light|dark" on <html>
 * from ?mode=, then next-themes' localStorage "theme", then the OS preference.
 * The @media fallback below covers the no-JS case only.
 *
 * Palette mirrors the tokens in app/globals.css (:root and .dark).
 */

:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --fg: #232a33;
  --heading: #141a21;
  --muted-fg: #626d7c;
  --card: #ffffff;
  --border: rgba(176, 187, 191, 0.55);
  --hairline: rgba(176, 187, 191, 0.35);
  --primary: #de046c;
  --link: #b8055a;
  --link-hover: #de046c;
  --accent: #f3e4ed;
  --accent-fg: #8a1e5c;
  --callout-bg: #fbf1f6;
  --callout-border: #e9bfd5;
  --code-bg: #e7ebed;
  --selection: rgba(222, 4, 108, 0.18);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14181d;
  --fg: #c9d2da;
  --heading: #edf1f3;
  --muted-fg: #9aa6b2;
  --card: #1a2027;
  --border: rgba(176, 187, 191, 0.22);
  --hairline: rgba(176, 187, 191, 0.14);
  --primary: #de046c;
  --link: #e56ea4;
  --link-hover: #f08dbb;
  --accent: #3a1f31;
  --accent-fg: #d98bb8;
  --callout-bg: #221a20;
  --callout-border: #4a2a3d;
  --code-bg: #232a33;
  --selection: rgba(222, 4, 108, 0.35);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    color-scheme: dark;
    --bg: #14181d;
    --fg: #c9d2da;
    --heading: #edf1f3;
    --muted-fg: #9aa6b2;
    --card: #1a2027;
    --border: rgba(176, 187, 191, 0.22);
    --hairline: rgba(176, 187, 191, 0.14);
    --link: #e56ea4;
    --link-hover: #f08dbb;
    --accent: #3a1f31;
    --accent-fg: #d98bb8;
    --callout-bg: #221a20;
    --callout-border: #4a2a3d;
    --code-bg: #232a33;
    --selection: rgba(222, 4, 108, 0.35);
  }
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 1.5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

::selection {
  background: var(--selection);
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--link) 45%, transparent);
  transition: color 120ms ease, text-decoration-color 120ms ease;
}

a {
  overflow-wrap: anywhere;
}

a:hover {
  color: var(--link-hover);
  text-decoration-color: currentColor;
}

a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ---------- Layout ---------- */

.page {
  max-width: 46rem;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3.5rem) clamp(1.25rem, 4vw, 2rem) 5rem;
}

.doc-header {
  padding-bottom: 1.5rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--hairline);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.9rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-fg);
}

.eyebrow::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--primary);
}

.doc-header h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.9rem, 4.5vw, 2.5rem);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--heading);
}

.doc-meta {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted-fg);
}

.doc-meta + .doc-meta {
  margin-top: 0.25rem;
}

/* ---------- Table of contents ---------- */

.toc {
  margin: 0 0 2.5rem;
  padding: 1.1rem 1.35rem 1.2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.toc summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--heading);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.toc summary::-webkit-details-marker {
  display: none;
}

.toc summary::after {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--muted-fg);
  border-bottom: 2px solid var(--muted-fg);
  transform: rotate(45deg);
  transition: transform 150ms ease;
  flex: none;
  margin-right: 0.25rem;
}

.toc[open] summary::after {
  transform: rotate(-135deg);
  margin-top: 0.3rem;
}

.toc ol {
  margin: 0.9rem 0 0;
  padding-left: 1.4rem;
  columns: 2;
  column-gap: 2rem;
}

.toc li {
  margin: 0.2rem 0;
  break-inside: avoid;
  font-size: 0.95rem;
}

.toc a {
  text-decoration: none;
  color: var(--fg);
}

.toc a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

@media (max-width: 560px) {
  .toc ol {
    columns: 1;
  }
}

/* ---------- Typography ---------- */

h2,
h3,
h4 {
  color: var(--heading);
  letter-spacing: -0.01em;
  line-height: 1.3;
  scroll-margin-top: 1.5rem;
}

h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 2.75rem 0 1rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--hairline);
}

h2 .num {
  display: inline-block;
  min-width: 1.6em;
  color: var(--accent-fg);
  font-variant-numeric: tabular-nums;
}

h3 {
  font-size: 1.08rem;
  font-weight: 650;
  margin: 1.9rem 0 0.6rem;
}

h3 .num {
  color: var(--muted-fg);
  font-weight: 500;
  margin-right: 0.35em;
}

h4 {
  font-size: 1rem;
  font-weight: 650;
  margin: 1.6rem 0 0.5rem;
}

p {
  margin: 0 0 1rem;
}

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

strong,
b {
  font-weight: 650;
  color: var(--heading);
}

em {
  font-style: italic;
}

.u {
  text-decoration: underline;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, currentColor 45%, transparent);
}

/* Capitalised legal notices read better a touch smaller and a touch looser. */
.legal-caps {
  font-size: 0.93rem;
  line-height: 1.7;
  letter-spacing: 0.005em;
}

/* Bordered notice used for the most important warnings. */
.callout {
  margin: 1.25rem 0 1.5rem;
  padding: 1rem 1.15rem;
  background: var(--callout-bg);
  border: 1px solid var(--callout-border);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
}

.callout p {
  margin: 0;
}

.callout p + p {
  margin-top: 0.75rem;
}

/* ---------- Lists ---------- */

ul,
ol {
  margin: 0 0 1.1rem;
  padding-left: 1.6rem;
}

li {
  margin: 0.35rem 0;
  padding-left: 0.2rem;
}

li::marker {
  color: var(--accent-fg);
}

ul.tight li {
  margin: 0.15rem 0;
}

ol.alpha {
  list-style: none;
  counter-reset: alpha;
  padding-left: 0;
}

ol.alpha > li {
  counter-increment: alpha;
  position: relative;
  padding-left: 2.4rem;
}

ol.alpha > li::before {
  content: "(" counter(alpha, lower-alpha) ")";
  position: absolute;
  left: 0;
  top: 0;
  width: 2rem;
  color: var(--accent-fg);
  font-variant-numeric: tabular-nums;
}

ol.alpha.from-e {
  counter-reset: alpha 4;
}

/* Lettered sub-items written inline in the source, e.g. "(a) Create cases…" */
dl.inline-defs {
  margin: 0 0 1.1rem;
}

dl.inline-defs > div {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  margin: 0.4rem 0;
}

dl.inline-defs dt {
  color: var(--accent-fg);
  font-variant-numeric: tabular-nums;
}

dl.inline-defs dd {
  margin: 0;
}

/* Term definitions inside bulleted lists: bold lead-in then explanation. */
li .lead {
  color: var(--heading);
  font-weight: 650;
}

/* ---------- Do / Don't sections (community guidelines) ---------- */

.rule-group {
  margin: 2.25rem 0;
}

.rule-group h2 {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-top: 0;
  padding-top: 0;
  margin: 0 0 1rem;
}

.rule-group h2::before {
  content: "";
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  flex: none;
  background-color: var(--accent);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 1rem;
}

.rule-group.do h2::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23de046c' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

.rule-group.dont h2::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23de046c' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
}

.rule {
  padding: 1.1rem 1.25rem;
  margin: 0 0 0.85rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.rule h3 {
  margin: 0 0 0.5rem;
  font-size: 1.02rem;
}

.rule p:last-child,
.rule ul:last-child {
  margin-bottom: 0;
}

/* ---------- Address block & signature form ---------- */

address {
  font-style: normal;
  margin: 0 0 1rem;
  padding: 0.85rem 1.1rem;
  display: inline-block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  line-height: 1.5;
}

.form {
  margin: 1.5rem 0 0;
  padding: 1.35rem 1.4rem 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.form h3 {
  margin-top: 0;
}

.form .field {
  margin: 0.9rem 0;
}

.form .field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted-fg);
  margin-bottom: 0.3rem;
}

.form .blank {
  display: block;
  height: 1.9rem;
  border-bottom: 1px solid var(--border);
}

.form .blank + .blank {
  margin-top: 0.4rem;
}

.form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.form .checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin: 0.4rem 0 0;
}

.form .checks span::before {
  content: "";
  display: inline-block;
  width: 0.95rem;
  height: 0.95rem;
  margin-right: 0.45rem;
  vertical-align: -0.15rem;
  border: 1.5px solid var(--muted-fg);
  border-radius: 3px;
}

@media (max-width: 560px) {
  .form .row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

/* ---------- Footer ---------- */

.doc-footer {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--hairline);
  font-size: 0.9rem;
  color: var(--muted-fg);
}

.doc-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.25rem;
  margin-top: 0.4rem;
}

.doc-footer nav a {
  text-decoration: none;
}

.doc-footer nav a:hover {
  text-decoration: underline;
}

.signoff {
  margin-top: 1.75rem;
  color: var(--heading);
  font-weight: 600;
}

@media print {
  body {
    background: #fff;
    color: #000;
  }
  .toc,
  .doc-footer nav {
    display: none;
  }
  .rule,
  .form,
  .callout,
  address {
    border-color: #999;
    background: #fff;
  }
}
