/*
 * VálaszAI's legal pages (templates/legal.html): /aszf, /adatvedelem,
 * /adatfeldolgozas, /impresszum.
 *
 * Loaded after foundation.css and auth.css, whose header, light palette and
 * faint violet page wash these pages share. What is added here is a page made
 * for reading: one text column at about 68 characters a line, the "Röviden"
 * summary first in a soft violet box, and on a wide screen a quiet column on
 * the left with the four documents and the sections of this one, which stays
 * in view while the text scrolls. On a phone the documents become a row of
 * tabs and the sections fold into a toggle above the text.
 *
 * Corner radii follow foundation.css: links and small boxes 8px, containers
 * (the summary, the question box, tables) 12px. The accent is the product's
 * violet and nothing else; the one other colour is the warning tint that
 * marks an unfinished draft and its placeholders.
 */

:root {
  --legal-wrap: 1120px;
  --legal-side: 228px;
  --legal-text: 1.0625rem;
}

@media (prefers-reduced-motion: no-preference) {
  html:has(.legal-page) {
    scroll-behavior: smooth;
  }
}

/* --- Frame ------------------------------------------------------------------ */

.legal-shell {
  display: grid;
  grid-template-columns: var(--legal-side) minmax(0, 1fr);
  gap: 64px;
  width: 100%;
  max-width: var(--legal-wrap);
  margin: 0 auto;
  padding: 24px 32px 112px;
}

.legal-side {
  position: sticky;
  top: 24px;
  align-self: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
  min-width: 0;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding-bottom: 8px;
}

.legal-side-label {
  margin: 0 0 8px;
  padding: 0 10px;
  font-size: 0.8125rem;
  font-weight: 650;
  color: var(--ink-soft);
}

.legal-docs ul,
.legal-toc-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legal-docs a {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 0.9375rem;
  font-weight: 550;
  text-decoration: none;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}

.legal-docs a:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.legal-docs a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* The sections of this document: a thin rule on the left that the link
   being hovered lights up, so the list reads as one column of the page. */
.legal-toc-list {
  gap: 0;
  border-left: 1px solid var(--border);
  margin-left: 10px;
}

.legal-toc .legal-toc-list a {
  display: block;
  margin-left: -1px;
  padding: 5px 0 5px 14px;
  border-left: 2px solid transparent;
  color: var(--ink-faint);
  font-size: 0.8125rem;
  line-height: 1.4;
  text-decoration: none;
  overflow-wrap: normal;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.legal-toc .legal-toc-list a:hover {
  border-left-color: var(--accent);
  color: var(--ink);
}

.legal-page a:focus-visible,
.legal-page summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Reading column --------------------------------------------------------- */

.legal-main {
  min-width: 0;
  max-width: 720px;
}

.legal-lang-note {
  margin: 0 0 24px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  color: var(--ink);
  font-size: 0.875rem;
}

.legal-doc {
  color: var(--ink);
  font-size: var(--legal-text);
  line-height: 1.7;
}

.legal-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.2vw, 2.75rem);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.1;
  text-wrap: balance;
}

.legal-details {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin: 14px 0 0;
  color: var(--ink-faint);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.legal-draft {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 0;
  padding: 6px 12px 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 550;
  line-height: 1.4;
}

.legal-draft svg {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--warn);
}

/* The summary: what a reader who stops here should still know. */
.legal-summary {
  margin: 32px 0 0;
  padding: 24px 28px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent-soft) 70%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 14%, transparent);
}

.legal-summary h2 {
  margin: 0 0 10px;
  font-size: 1.125rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--accent-ink);
}

.legal-summary ul {
  margin: 0 0 14px;
  padding-left: 20px;
}

.legal-summary li + li {
  margin-top: 8px;
}

.legal-summary li::marker {
  color: var(--accent);
}

.legal-summary p {
  margin: 0 0 12px;
}

.legal-summary > :last-child {
  margin-bottom: 0;
}

/* The sections toggle above the text, for screens without the side column. */
.legal-toc-narrow {
  display: none;
  margin: 24px 0 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.legal-toc-narrow summary {
  padding: 12px 16px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
}

.legal-toc-narrow .legal-toc-list {
  margin: 0 16px 14px 26px;
}

.legal-toc-narrow .legal-toc-list a {
  font-size: 0.875rem;
  color: var(--ink-soft);
}

/* --- The text ---------------------------------------------------------------- */

.legal-body h2 {
  margin: 56px 0 14px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.3;
  text-wrap: balance;
  scroll-margin-top: 16px;
}

.legal-body h3 {
  margin: 32px 0 6px;
  font-size: 1.0625rem;
  font-weight: 650;
  line-height: 1.4;
}

.legal-body p,
.legal-body ul,
.legal-body ol {
  max-width: 68ch;
  margin: 0 0 16px;
}

.legal-body ul,
.legal-body ol {
  padding-left: 24px;
}

.legal-body li + li {
  margin-top: 8px;
}

.legal-body ol > li::marker {
  color: var(--accent-ink);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.legal-body ul > li::marker {
  color: var(--ink-faint);
}

.legal-doc a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
  transition: text-decoration-color 0.15s var(--ease);
}

.legal-doc a:hover {
  text-decoration-color: currentColor;
}

.legal-doc code {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: var(--mono);
  font-size: 0.85em;
}

.legal-body blockquote {
  max-width: 68ch;
  margin: 0 0 16px;
  padding: 18px 22px;
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}

.legal-body blockquote p {
  margin: 0;
}

.legal-body hr {
  margin: 64px 0 0;
  border: 0;
}

.legal-table {
  margin: 0 0 20px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.legal-table table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.9375rem;
  line-height: 1.5;
}

.legal-table th,
.legal-table td {
  padding: 11px 14px;
  text-align: left;
  vertical-align: top;
}

/* Sentence case: app.css sets table headers as small capitals labels, which
   in running text reads like a form rather than a sentence. */
.legal-table th {
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 650;
  letter-spacing: normal;
  text-transform: none;
}

.legal-table tbody tr + tr td {
  border-top: 1px solid var(--border);
}

/* A detail still to be filled in, such as [SZÉKHELY]. */
.legal-todo {
  padding: 0 4px;
  border-radius: 4px;
  background: var(--warn-soft);
  color: inherit;
}

/* --- The question box under the text ------------------------------------------ */

.legal-ask {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  margin: 72px 0 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.legal-ask-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 22px;
}

.legal-ask h2 {
  margin: 0 0 4px;
  font-size: 1.125rem;
  font-weight: 650;
}

.legal-ask p {
  margin: 0 0 10px;
  color: var(--ink-soft);
  font-size: 0.9375rem;
}

.legal-ask-link {
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.15s var(--ease);
}

.legal-ask-link:hover {
  text-decoration-color: currentColor;
}

/* --- Narrow screens --------------------------------------------------------- */

@media (max-width: 1023px) {
  .legal-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding: 8px 24px 80px;
  }

  .legal-side {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0;
  }

  /* The four documents as a row of tabs that scrolls on its own. */
  .legal-docs .legal-side-label,
  .legal-toc-wide {
    display: none;
  }

  .legal-docs ul {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin: 0 -24px;
    padding: 2px 24px;
    scrollbar-width: none;
  }

  .legal-docs a {
    padding: 7px 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.875rem;
    white-space: nowrap;
  }

  .legal-docs a[aria-current="page"] {
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  }

  .legal-toc-narrow {
    display: block;
  }

  .legal-main {
    max-width: none;
  }
}

@media (max-width: 560px) {
  :root {
    --legal-text: 1rem;
  }

  .legal-shell {
    padding: 4px 16px 64px;
  }

  .legal-docs ul {
    margin: 0 -16px;
    padding: 2px 16px;
  }

  .legal-summary {
    padding: 20px;
  }

  .legal-ask {
    grid-template-columns: minmax(0, 1fr);
  }
}
