/* ------------------------------------------------------------------ *
 * Privacy page - stylesheet
 * ------------------------------------------------------------------ */

:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-inset: #f1f4f8;
  --bg-card: #ffffff;
  --text: #151a21;
  --text-soft: #59616e;
  --text-faint: #646d79;
  --border: #e5e8ec;
  --border-strong: #d3d8e0;
  --accent: #1f6feb;
  --accent-soft: rgba(31, 111, 235, 0.1);
  --accent-text: #1757c4;
  --danger: #c0392f;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 6px -2px rgba(16, 24, 40, 0.04),
    0 12px 20px -6px rgba(16, 24, 40, 0.09);
  --radius: 10px;
  --radius-sm: 6px;
  --measure: 46rem;
  --shell: 74rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1319;
    --bg-soft: #141a22;
    --bg-inset: #1a212b;
    --bg-card: #161c25;
    --text: #e4e9f0;
    --text-soft: #a2acba;
    --text-faint: #78828f;
    --border: #262d38;
    --border-strong: #34404e;
    --accent: #6ea8fe;
    --accent-soft: rgba(110, 168, 254, 0.14);
    --accent-text: #8cb8ff;
    --danger: #ef7a70;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px -2px rgba(0, 0, 0, 0.35),
      0 14px 24px -8px rgba(0, 0, 0, 0.5);
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent-text);
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 2px;
}

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

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 0 0 var(--radius-sm) 0;
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
}

.skip-link:focus {
  left: 0;
}

/* ----------------------------- masthead ---------------------------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.masthead-inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.masthead-link {
  font-size: 0.85rem;
  color: var(--text-soft);
  text-decoration: none;
}

.masthead-link:hover {
  color: var(--accent-text);
  text-decoration: underline;
}

/* ------------------------------- shell ----------------------------- */

.shell {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.shell-plain {
  max-width: var(--measure);
}

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

.doc-title {
  margin: 0;
  font-size: clamp(1.75rem, 1.25rem + 2vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.025em;
  font-weight: 700;
}

.doc-meta {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.chip-link {
  text-decoration: none;
}

.chip-link:hover {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent-text);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2.5rem;
}

@media (min-width: 1080px) {
  .layout {
    grid-template-columns: 15rem minmax(0, 1fr);
    gap: 3.5rem;
    align-items: start;
  }
}

/* --------------------------- table of contents --------------------- */

.toc {
  font-size: 0.875rem;
}

@media (min-width: 1080px) {
  .toc {
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
    padding-right: 0.5rem;
  }
}

.toc-details {
  margin: 0;
}

.toc-title {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  list-style: none;
}

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

.toc-title::marker {
  content: "";
}

/* On wide screens the list is always open and the label is not a toggle. */
@media (min-width: 1080px) {
  .toc-title {
    pointer-events: none;
    cursor: default;
  }
}

/* On small screens the list becomes a collapsible panel. */
@media (max-width: 1079px) {
  .toc-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0;
    padding: 0.65rem 0.9rem;
    background: var(--bg-inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
  }

  .toc-title::after {
    content: "";
    flex: none;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 1.5px solid var(--text-faint);
    border-bottom: 1.5px solid var(--text-faint);
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform 0.15s ease;
  }

  .toc-details[open] .toc-title::after {
    transform: rotate(-135deg) translate(-2px, -2px);
  }

  .toc-list {
    margin-top: 0.75rem;
    padding-bottom: 0.25rem;
  }
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

.toc-item a {
  display: block;
  padding: 0.3rem 0 0.3rem 0.85rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-soft);
  text-decoration: none;
  line-height: 1.4;
}

.toc-item a:hover {
  color: var(--text);
  border-left-color: var(--border-strong);
}

.toc-depth-3 a {
  padding-left: 1.6rem;
  font-size: 0.82rem;
  color: var(--text-faint);
}

/* ------------------------------ document --------------------------- */

.doc {
  max-width: var(--measure);
  font-family: var(--font-serif);
  font-size: 1.075rem;
  line-height: 1.78;
}

.doc > *:first-child {
  margin-top: 0;
}

.doc h2,
.doc h3,
.doc h4 {
  font-family: var(--font-sans);
  letter-spacing: -0.017em;
  line-height: 1.3;
  scroll-margin-top: 5.5rem;
}

.doc h2 {
  margin: 2.75rem 0 0.9rem;
  padding-top: 0.4rem;
  font-size: 1.5rem;
  font-weight: 650;
}

.doc h3 {
  margin: 2rem 0 0.6rem;
  font-size: 1.18rem;
  font-weight: 650;
}

.doc h4 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.02rem;
  font-weight: 650;
}

.doc p {
  margin: 0 0 1.1rem;
}

.doc ul,
.doc ol {
  margin: 0 0 1.2rem;
  padding-left: 1.4rem;
}

.doc li {
  margin-bottom: 0.45rem;
}

.doc li > ul,
.doc li > ol {
  margin-top: 0.45rem;
  margin-bottom: 0.2rem;
}

.doc strong {
  font-weight: 650;
}

.doc hr {
  height: 1px;
  margin: 2.5rem 0;
  border: 0;
  background: var(--border);
}

.doc blockquote {
  margin: 0 0 1.2rem;
  padding: 0.1rem 0 0.1rem 1rem;
  border-left: 3px solid var(--border-strong);
  color: var(--text-soft);
}

.doc code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 0.12em 0.36em;
  border-radius: 4px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  word-break: break-word;
}

.doc pre {
  margin: 0 0 1.3rem;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.86rem;
  line-height: 1.6;
}

.doc pre code {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
}

/* permalink anchor that appears on hover */
.anchor {
  margin-left: 0.4rem;
  color: var(--text-faint);
  font-family: var(--font-sans);
  font-size: 0.8em;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.doc h2:hover .anchor,
.doc h3:hover .anchor,
.doc h4:hover .anchor,
.anchor:focus-visible {
  opacity: 1;
}

/* ------------------------------- tables ---------------------------- */

.table-wrap {
  margin: 0 0 1.6rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.6;
}

.table-wrap th,
.table-wrap td {
  padding: 0.7rem 0.9rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.table-wrap th {
  background: var(--bg-soft);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.table-wrap tbody tr:last-child td {
  border-bottom: 0;
}

.table-wrap tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--bg-soft) 55%, transparent);
}

.table-wrap td:first-child {
  white-space: nowrap;
}

.table-wrap td:first-child code {
  white-space: nowrap;
}

.ta-left {
  text-align: left;
}
.ta-center {
  text-align: center;
}
.ta-right {
  text-align: right;
}

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

.footer {
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}

.footer-inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.footer-inner p {
  margin: 0;
}

.footer-note {
  color: var(--text-faint);
}

/* ------------------------------- admin ----------------------------- */

.admin-body {
  background: var(--bg-soft);
}

.admin {
  max-width: 56rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.admin-head h1 {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

.admin-intro {
  margin: 0 0 1.75rem;
  color: var(--text-soft);
  max-width: 42rem;
}

.admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.input,
.editor {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.editor {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 22rem;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}

.btn:hover {
  border-color: var(--text-faint);
}

.btn:disabled {
  opacity: 0.55;
  cursor: progress;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-danger {
  color: var(--danger);
}

.admin-status {
  margin: 0;
  min-height: 1.2rem;
  font-size: 0.88rem;
  color: var(--text-soft);
}

.admin-status.is-error {
  color: var(--danger);
}

.admin-status.is-ok {
  color: var(--accent-text);
}

.admin-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* ------------------------------- print ----------------------------- */

@media print {
  :root {
    --bg: #ffffff;
    --text: #000000;
    --text-soft: #333333;
    --border: #cccccc;
  }

  .masthead,
  .toc,
  .doc-meta,
  .footer,
  .skip-link,
  .anchor {
    display: none !important;
  }

  .shell {
    padding: 0;
    max-width: none;
  }

  .doc {
    max-width: none;
    font-size: 11.5pt;
  }

  .table-wrap {
    border: 1px solid #cccccc;
    box-shadow: none;
    overflow: visible;
  }

  .doc a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-break: break-all;
  }
}