/* The legal and help pages.
 *
 * Deliberately NOT built on tokens.css or styles.css. Those carry the six
 * household themes and the whole app's component surface, and a household
 * that has picked Notebook should not read its own privacy policy through
 * a theme it can change - these pages have to look the same for everyone,
 * including a person who is signed out, locked out, or reading the link
 * from an email before they have an account at all.
 *
 * Both appearances are here rather than only light: a photophobic person
 * does not stop needing dark mode when they open the terms. Same
 * three-state pattern the rest of the product uses - bare :root for
 * light, prefers-color-scheme for the OS, and nothing stamped on the
 * element because these pages carry no theme toggle.
 */

:root {
  --paper: #fbf7f3;
  --card: #ffffff;
  --ink: #2f2a2c;
  --ink-soft: #5d5457;
  --muted: #756a6d;
  --line: #e6ddd6;
  --line-soft: #f0e9e3;
  --link: #0f6b7d;
  --quote-bg: #f6f1ec;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #17161a;
    --card: #1e1d22;
    --ink: #ece7e9;
    --ink-soft: #bdb5b8;
    --muted: #918a8d;
    --line: #322f36;
    --line-soft: #26242a;
    --link: #6cc3d4;
    --quote-bg: #232128;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

/* Visible on focus only. A keyboard reader should not have to tab through
   the header of a 300-line document to reach it. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
}

.skip-link:focus {
  left: 12px;
  top: 12px;
  z-index: 10;
  background: var(--card);
  color: var(--link);
  padding: 10px 14px;
  border-radius: 8px;
  border: 2px solid var(--link);
}

.legal-page {
  max-width: 44rem;
  margin: 0 auto;
  padding-inline: 20px;
  padding-block: 28px 64px;
}

.legal-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
  margin-bottom: 28px;
}

.legal-back {
  display: inline-block;
  font-size: 0.9rem;
  color: var(--link);
  text-decoration: none;
  margin-bottom: 14px;
}

.legal-back:hover,
.legal-back:focus-visible {
  text-decoration: underline;
}

.legal-head h1 {
  font-size: clamp(1.6rem, 5vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

/* ---- the document itself ---- */

.legal-doc h2 {
  font-size: 1.2rem;
  line-height: 1.3;
  margin: 40px 0 10px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
  text-wrap: balance;
}

.legal-doc h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.legal-doc h3 {
  font-size: 1.02rem;
  margin: 26px 0 8px;
  text-wrap: balance;
}

.legal-doc p {
  margin: 0 0 14px;
  color: var(--ink-soft);
}

.legal-doc strong {
  color: var(--ink);
}

.legal-doc ul,
.legal-doc ol {
  margin: 0 0 16px;
  padding-left: 22px;
  color: var(--ink-soft);
}

.legal-doc li {
  margin-bottom: 9px;
}

.legal-doc li > ul,
.legal-doc li > ol {
  margin-top: 9px;
}

.legal-doc a {
  color: var(--link);
}

.legal-doc hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 32px 0;
}

.legal-doc blockquote {
  margin: 18px 0;
  padding: 14px 18px;
  background: var(--quote-bg);
  border-left: 3px solid var(--link);
  border-radius: 0 8px 8px 0;
}

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

.legal-doc code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
  background: var(--quote-bg);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  padding: 1px 5px;
  overflow-wrap: anywhere;
}

/* Every table in these documents is a real table - retention periods,
   what each supplier can see - so it gets its own scroll container rather
   than being allowed to widen the page on a phone. */
.legal-doc table {
  display: block;
  overflow-x: auto;
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 18px;
  font-size: 0.94rem;
}

.legal-doc th,
.legal-doc td {
  text-align: left;
  vertical-align: top;
  padding: 9px 14px 9px 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-soft);
}

.legal-doc th {
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

/* ---- footer ---- */

.legal-foot {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--muted);
}

.legal-foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-bottom: 14px;
}

.legal-foot a {
  color: var(--link);
}

.legal-foot nav [aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
}

.legal-foot p {
  margin: 0;
}

.legal-foot code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
}

/* ---- the help form ---- */

.help-intro {
  color: var(--ink-soft);
  margin: 0 0 24px;
}

.help-form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
}

.help-field {
  margin-bottom: 18px;
}

.help-field:last-of-type {
  margin-bottom: 20px;
}

.help-field label {
  display: block;
  font-weight: 600;
  font-size: 0.94rem;
  margin-bottom: 4px;
}

.help-hint {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 7px;
  font-weight: 400;
}

.help-field input,
.help-field select,
.help-field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
}

.help-field textarea {
  min-height: 9rem;
  resize: vertical;
}

.help-field input:focus-visible,
.help-field select:focus-visible,
.help-field textarea:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 1px;
}

.help-submit {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--link);
  border: 0;
  border-radius: 9px;
  padding: 12px 22px;
  cursor: pointer;
}

.help-submit:disabled {
  opacity: 0.6;
  cursor: default;
}

.help-submit:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* One place for the answer, whichever way it went. A form that clears
   itself and says nothing is the same as a form that lost your message. */
.help-result {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 9px;
  font-size: 0.94rem;
  line-height: 1.5;
}

.help-result.ok {
  background: #e9f4ee;
  border: 1px solid #b9dcc7;
  color: #14512f;
}

.help-result.bad {
  background: #fbeceb;
  border: 1px solid #f0c6c1;
  color: #8d2016;
}

@media (prefers-color-scheme: dark) {
  /* The dark --link is a LIGHT teal, so the button's own label has to
     flip with it. White on it measures 2.02:1 - the send button on a
     help form, unreadable to the person already having a bad enough day
     to be filling it in. Caught by scanning dark mode explicitly; the
     repo's accessibility suite scans the default appearance only. */
  .help-submit {
    color: #0b2429;
  }

  .help-submit:focus-visible {
    outline-color: var(--ink);
  }

  .help-result.ok {
    background: #11251a;
    border-color: #26472f;
    color: #86d3a3;
  }

  .help-result.bad {
    background: #2a1513;
    border-color: #4c231f;
    color: #f2a49a;
  }
}

.help-fallback {
  margin-top: 22px;
  font-size: 0.9rem;
  color: var(--muted);
}

.help-fallback a {
  color: var(--link);
}
