/* hypi.shop legal pages. Colors and type roles follow /var/www/hypi-app/DESIGN.md:
   purple carries the brand, yellow marks the active choice, reading stays calm. */

:root {
  color-scheme: light dark;
  --bg: #F8F7FB;
  --surface: #FFFDFF;
  --surface-alt: #F1EDF6;
  --text: #210829;
  --muted: #665B6D;
  --border: #DED7E3;
  --brand: #8F35D0;
  --masthead: #290C4E;
  --on-masthead: #FFF9FF;
  --yellow: #FEE707;
  --highlight: #FFF44D;
  --on-yellow: #210829;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --gutter: clamp(1rem, 0.4rem + 2.6vw, 2rem);
  --wide: 72rem;
  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #160A20;
    --surface: #210D30;
    --surface-alt: #2E163E;
    --text: #FFF9FF;
    --muted: #CBBED2;
    --border: #4A2D59;
    --brand: #CD67F6;
  }
}

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

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

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 400 1.0625rem/1.65 var(--font);
}

a {
  color: var(--brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

.skip-link {
  position: absolute;
  top: -10rem;
  left: var(--gutter);
  z-index: 10;
  padding: 0.625rem 1rem;
  border-radius: 12px;
  background: var(--yellow);
  color: var(--on-yellow);
  font-weight: 700;
}

.skip-link:focus {
  top: 0.75rem;
}

/* Masthead */

.masthead {
  background: var(--masthead);
  color: var(--on-masthead);
}

.masthead-inner {
  max-width: var(--wide);
  margin-inline: auto;
  padding: 0.625rem var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}

.brand {
  display: block;
  border-radius: 12px;
}

.brand img {
  display: block;
  height: clamp(3rem, 2.6rem + 1.2vw, 3.5rem);
  width: auto;
}

.docnav {
  display: flex;
  gap: 0.25rem;
}

.docnav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 0.875rem;
  border-radius: 999px;
  color: var(--on-masthead);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 150ms ease-out;
}

.docnav a:hover {
  background: rgb(255 249 255 / 0.16);
}

.docnav a[aria-current="page"] {
  background: var(--yellow);
  color: var(--on-yellow);
}

.docnav a:focus-visible {
  outline-color: var(--yellow);
}

/* On phones the three documents sit in one row of equal chips. */
@media (max-width: 40rem) {
  .docnav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.375rem;
    padding-bottom: 0.375rem;
  }

  .docnav a {
    padding: 0 0.25rem;
    background: rgb(255 249 255 / 0.1);
    font-size: clamp(0.75rem, 3.3vw, 0.875rem);
  }
}

.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--wide);
  margin-inline: auto;
}

/* Index of documents */

.hub,
.notfound {
  padding: clamp(2.5rem, 7vw, 5.5rem) var(--gutter) clamp(3.5rem, 8vw, 6rem);
}

.hub h1,
.notfound h1 {
  margin: 0 0 clamp(1.75rem, 4vw, 3rem);
  font-size: clamp(2.25rem, 1.5rem + 3.4vw, 3.75rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
  font-weight: 800;
  text-wrap: balance;
}

.doc-index {
  max-width: 52rem;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.doc-index li {
  position: relative;
  display: grid;
  gap: 0.375rem;
  padding: clamp(1.25rem, 3vw, 1.75rem) 0;
  border-bottom: 1px solid var(--border);
}

.doc-index h2 {
  margin: 0;
  font-size: clamp(1.25rem, 1.05rem + 1vw, 1.75rem);
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.doc-index h2 a {
  color: var(--text);
  text-decoration: none;
}

/* The whole row opens the document. */
.doc-index h2 a::before {
  content: "";
  position: absolute;
  inset: 0;
}

.doc-index h2 a::after {
  content: " →";
  color: var(--brand);
}

.doc-index li:hover h2 a {
  color: var(--brand);
}

.doc-index p {
  max-width: 60ch;
  margin: 0;
  color: var(--muted);
}

.doc-index .doc-index-meta {
  margin-top: 0.25rem;
  font-size: 0.875rem;
}

.contact {
  max-width: 52rem;
  margin-top: clamp(2.5rem, 6vw, 4rem);
  padding: clamp(1.25rem, 3vw, 2rem);
  border-radius: 16px;
  background: var(--yellow);
  color: var(--on-yellow);
}

.contact h2 {
  margin: 0 0 0.375rem;
  font-size: clamp(1.125rem, 1rem + 0.6vw, 1.375rem);
  line-height: 1.3;
  font-weight: 750;
}

.contact p {
  margin: 0;
}

.contact a {
  color: var(--on-yellow);
  font-weight: 700;
}

.contact a:focus-visible {
  outline-color: var(--on-yellow);
}

.notfound p {
  margin: 0 0 1rem;
  color: var(--muted);
}

/* Static pages written by hand, e.g. /delete-account */
.info {
  padding: clamp(1.75rem, 5vw, 3.5rem) var(--gutter) clamp(3rem, 7vw, 5rem);
}

.prose ol > li::marker {
  color: var(--brand);
  font-weight: 700;
}

/* Document pages */

.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
  padding: clamp(1.75rem, 5vw, 3.5rem) var(--gutter) clamp(3rem, 7vw, 5rem);
}

.toc-aside {
  display: none;
}

@media (min-width: 64rem) {
  .doc-layout {
    grid-template-columns: 16.5rem minmax(0, 1fr);
    gap: clamp(2.5rem, 5vw, 5rem);
  }

  .toc-aside {
    display: block;
    position: sticky;
    top: 1.5rem;
    align-self: start;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    padding-right: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.4;
  }

  .toc-inline {
    display: none;
  }
}

.toc-title {
  margin: 0 0 0.625rem 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.toc-aside ul,
.toc-inline ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc-aside a,
.toc-inline a {
  display: block;
  padding: 0.4375rem 0.5rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.toc-aside a:hover,
.toc-inline a:hover {
  background: var(--surface-alt);
  color: var(--brand);
}

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

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

.eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
}

.eyebrow a {
  color: var(--muted);
  text-decoration: none;
}

.eyebrow a:hover {
  color: var(--brand);
  text-decoration: underline;
}

.doc h1 {
  margin: 0;
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  font-weight: 800;
  text-wrap: balance;
  overflow-wrap: break-word;
}

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

.toc-inline {
  margin: 0 0 2.25rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.toc-inline summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 3rem;
  padding: 0.5rem 1rem;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

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

.toc-inline summary::after {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.25rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-0.125rem) rotate(45deg);
  transition: transform 180ms cubic-bezier(0.25, 1, 0.5, 1);
}

.toc-inline[open] summary::after {
  transform: translateY(0.125rem) rotate(-135deg);
}

.toc-inline nav {
  padding: 0 0.5rem 0.75rem;
  font-size: 0.9375rem;
  line-height: 1.4;
}

/* The documents themselves */

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

.prose p {
  margin: 0 0 1em;
  text-wrap: pretty;
}

.prose h2,
.prose h3,
.prose h4 {
  scroll-margin-top: 1.25rem;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.prose h2 {
  margin: 2.75rem 0 1rem;
  font-size: clamp(1.25rem, 1.15rem + 0.45vw, 1.4375rem);
  line-height: 1.3;
  font-weight: 750;
}

.prose h2.part {
  margin-top: 4.5rem;
  padding-top: 2rem;
  border-top: 2px solid var(--text);
  font-size: clamp(1.4375rem, 1.2rem + 1vw, 1.75rem);
  line-height: 1.25;
}

.prose h3 {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.1875rem;
  line-height: 1.35;
  font-weight: 700;
}

.prose h4 {
  margin: 1.75rem 0 0.5rem;
  font-size: 1.0625rem;
  line-height: 1.45;
  font-weight: 700;
}

.prose :is(h2, h3, h4):target {
  text-decoration: underline 0.2em var(--yellow);
  text-underline-offset: 0.25em;
}

.prose strong {
  font-weight: 700;
}

.clause {
  scroll-margin-top: 1.25rem;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.clause:target {
  border-radius: 4px;
  background: var(--highlight);
  box-shadow: 0 0 0 0.2em var(--highlight);
  color: var(--on-yellow);
}

.prose ul,
.prose ol {
  margin: 0 0 1em;
  padding-left: 1.375rem;
}

.prose li {
  margin: 0.375em 0;
  padding-left: 0.25rem;
}

.prose li > p {
  margin: 0;
}

.prose li > ul,
.prose li > ol {
  margin: 0.375em 0 0;
}

.prose ul > li::marker {
  color: var(--brand);
}

.prose .indent {
  margin: 0 0 1em 1.25rem;
}

.prose .indent p {
  margin-bottom: 0.5em;
}

.prose a {
  overflow-wrap: anywhere;
}

.to-top {
  margin: 3rem 0 0;
  font-size: 0.9375rem;
}

/* Footer */

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.55;
}

.footer-inner {
  max-width: var(--wide);
  margin-inline: auto;
  padding: 1.75rem var(--gutter) 2.25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
}

.footer-inner p {
  margin: 0;
}

@media print {
  .skip-link,
  .docnav,
  .toc-aside,
  .toc-inline,
  .to-top {
    display: none !important;
  }

  body {
    background: none;
    color: #1a1a1a;
    font-size: 11pt;
  }

  .masthead {
    background: none;
  }

  .brand img {
    height: 2.5rem;
  }

  .doc-layout {
    display: block;
    padding: 0;
  }

  .doc {
    max-width: none;
  }

  a,
  .clause {
    color: inherit;
  }
}
