/* Original to MIRA: the legal pages (privacy, terms, cookies). One template:
   a switcher between the three documents, a header with the dates, a short
   summary, a sticky table of contents beside the text on desktop (folded
   into a disclosure on smaller screens) and numbered sections.
   Same tokens as the rest of the site: no new colours, type sizes or
   breakpoints. */

.mira-legal {
  margin: 0;
  background: var(--ui-bg);
  color: var(--ui-text);
}

.mira-legal__container {
  width: min(calc(100% - 80px), 1120px);
  margin-inline: auto;
}

.mira-legal a { color: inherit; }
.mira-legal svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mira-legal a:focus-visible,
.mira-legal summary:focus-visible {
  outline: 2px solid var(--ui-primary);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ---------- Top bar: back link + document switcher ---------- */

.mira-legal__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 0;
  border-bottom: 1px solid var(--ui-soft);
}

.mira-legal__back {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ui-muted);
  font-size: var(--fs-small);
  font-weight: 500;
  text-decoration: none;
  transition: color 220ms ease;
}

.mira-legal__back:hover { color: var(--ui-text); }
.mira-legal__back svg { width: 18px; height: 18px; transition: transform 220ms ease; }
.mira-legal__back:hover svg { transform: translateX(-4px); }

.mira-legal__docs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--ui-soft);
  border-radius: 999px;
}

.mira-legal__docs a {
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--ui-muted);
  font-size: var(--fs-small);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color 220ms ease, background-color 220ms ease;
}

.mira-legal__docs a:hover { color: var(--ui-text); }

.mira-legal__docs a[aria-current='page'] {
  background: var(--ui-text);
  color: var(--ui-bg);
}

/* ---------- Header ---------- */

.mira-legal__header { padding: 88px 0 48px; }

.mira-legal__eyebrow {
  margin: 0 0 20px;
  color: var(--ui-muted);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mira-legal__header h1 {
  max-width: 14ch;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(44px, 6vw, 88px);
  font-weight: 800;
  letter-spacing: -0.065em;
  line-height: 0.98;
}

.mira-legal__lead {
  max-width: 640px;
  margin: 28px 0 0;
  color: var(--ui-muted);
  font-size: var(--fs-lead);
  line-height: 1.6;
}

.mira-legal__dates {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 32px;
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
  color: var(--ui-muted);
  font-size: var(--fs-small);
}

.mira-legal__dates strong { color: var(--ui-text); font-weight: 600; }

/* ---------- Layout: contents + document ---------- */

.mira-legal__layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 80px;
  align-items: start;
  padding: 56px 0 120px;
  border-top: 1px solid var(--ui-soft);
}

.mira-legal__toc {
  position: sticky;
  top: 32px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}

.mira-legal__toc summary {
  list-style: none;
  color: var(--ui-text);
  font-size: var(--fs-label);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: default;
  pointer-events: none;   /* on desktop the contents are always open */
}

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

.mira-legal__toc ol {
  display: grid;
  gap: 2px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
}

.mira-legal__toc li { counter-increment: toc; }

.mira-legal__toc a {
  display: grid;
  grid-template-columns: 28px 1fr;
  padding: 7px 0 7px 14px;
  border-left: 1px solid var(--ui-soft);
  color: var(--ui-muted);
  font-size: var(--fs-small);
  line-height: 1.4;
  text-decoration: none;
  transition: color 220ms ease, border-color 220ms ease;
}

.mira-legal__toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-variant-numeric: tabular-nums;
}

.mira-legal__toc a:hover { color: var(--ui-text); }

.mira-legal__toc a.is-current {
  border-left-color: var(--ui-text);
  color: var(--ui-text);
  font-weight: 600;
}

/* ---------- Document ---------- */

.mira-legal__doc { max-width: 720px; }

.mira-legal__summary {
  margin: 0 0 56px;
  padding: 28px 32px;
  border: 1px solid var(--ui-soft);
  border-radius: 16px;
  background: var(--ui-surface);
}

.mira-legal__summary h2 {
  margin: 0 0 16px;
  font-family: var(--font-body);
  font-size: var(--fs-ui);
  font-weight: 700;
  letter-spacing: 0;
}

.mira-legal__summary ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
}

.mira-legal__summary li {
  color: var(--ui-muted);
  font-size: var(--fs-small);
  line-height: 1.6;
}

.mira-legal__section {
  padding-top: 8px;
  scroll-margin-top: 32px;
}

.mira-legal__section + .mira-legal__section {
  margin-top: 48px;
  padding-top: 48px;
  border-top: 1px solid var(--ui-soft);
}

.mira-legal__section h2 {
  display: flex;
  gap: 16px;
  margin: 0 0 20px;
  font-family: var(--font-display);
  font-size: clamp(24px, 2.4vw, 30px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.15;
}

.mira-legal__num {
  color: var(--ui-muted);
  font-variant-numeric: tabular-nums;
}

.mira-legal__section h3 {
  margin: 32px 0 12px;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.mira-legal__section p,
.mira-legal__section li {
  margin: 0 0 14px;
  color: var(--ui-muted);
  font-size: var(--fs-body);
  line-height: 1.7;
}

.mira-legal__section ul,
.mira-legal__section ol {
  margin: 0 0 14px;
  padding-left: 22px;
}

.mira-legal__section li { margin-bottom: 8px; }
.mira-legal__section li::marker { color: var(--ui-muted); }

.mira-legal__section strong { color: var(--ui-text); font-weight: 700; }

.mira-legal__section a {
  color: var(--ui-text);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--ui-soft);
  text-underline-offset: 4px;
  transition: text-decoration-color 220ms ease;
}

.mira-legal__section a:hover { text-decoration-color: currentColor; }

/* Company details still to be confirmed before launch (see DESIGN-SYSTEM §6
   quinquies). Deliberately visible so none ships by accident. */
.mira-legal__todo {
  padding: 1px 6px;
  border: 1px dashed var(--ui-muted);
  border-radius: 6px;
  background: transparent;
  color: var(--ui-text);
}

/* ---------- Tables ---------- */

.mira-legal__table-wrap {
  margin: 8px 0 24px;
  overflow-x: auto;
  border: 1px solid var(--ui-soft);
  border-radius: 12px;
}

.mira-legal__table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
}

.mira-legal__table th,
.mira-legal__table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ui-soft);
  text-align: left;
  vertical-align: top;
}

.mira-legal__table tr:last-child td { border-bottom: 0; }

.mira-legal__table th {
  background: var(--ui-surface);
  color: var(--ui-text);
  font-weight: 700;
  white-space: nowrap;
}

.mira-legal__table td { color: var(--ui-muted); line-height: 1.6; }
.mira-legal__table td:first-child { color: var(--ui-text); font-weight: 600; }

/* ---------- Contact card ---------- */

.mira-legal__contact {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  padding: 24px 28px;
  border: 1px solid var(--ui-soft);
  border-radius: 16px;
  font-style: normal;
}

.mira-legal__contact span {
  color: var(--ui-muted);
  font-size: var(--fs-small);
  line-height: 1.6;
}

.mira-legal__contact strong { color: var(--ui-text); font-size: var(--fs-body); }

/* ---------- Foot ---------- */

.mira-legal__foot {
  background: var(--ui-footer-deep);
  color: var(--ui-footer-text);
}

.mira-legal__foot-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 96px;
  padding: 24px 0;
  font-size: var(--fs-small);
}

.mira-legal__foot .mira-mark { width: 96px; }

.mira-legal__foot nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
}

.mira-legal__foot a {
  color: var(--ui-footer-text);
  text-decoration: none;
  transition: opacity 250ms ease;
}

.mira-legal__foot a:hover { opacity: 0.7; }

/* ---------- Tablet and below: contents fold above the text ---------- */

@media (max-width: 1023.98px) {
  .mira-legal__layout {
    grid-template-columns: minmax(0, 1fr);   /* the cookie table scrolls inside its frame instead of widening the page */
    gap: 40px;
    padding-top: 40px;
  }

  .mira-legal__toc {
    position: static;
    max-height: none;
    overflow: visible;
    border: 1px solid var(--ui-soft);
    border-radius: 16px;
  }

  .mira-legal__toc summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    cursor: pointer;
    pointer-events: auto;
  }

  .mira-legal__toc summary::after {
    content: '+';
    font-size: 20px;
    font-weight: 400;
    letter-spacing: 0;
    transition: transform 300ms cubic-bezier(.22, 1, .36, 1);
  }

  .mira-legal__toc[open] summary::after { transform: rotate(45deg); }
  .mira-legal__toc ol { margin: 0; padding: 0 22px 18px; }
}

@media (max-width: 767.98px) {
  .mira-legal__container { width: calc(100% - 36px); }
  .mira-legal__bar { flex-direction: column; align-items: flex-start; gap: 18px; padding: 24px 0; }
  .mira-legal__docs { max-width: 100%; overflow-x: auto; }
  .mira-legal__header { padding: 56px 0 36px; }
  .mira-legal__layout { padding-bottom: 80px; }
  .mira-legal__summary { padding: 22px 20px; }
  .mira-legal__section + .mira-legal__section { margin-top: 36px; padding-top: 36px; }
  .mira-legal__section h2 { gap: 12px; }
  .mira-legal__foot-inner { flex-direction: column; align-items: flex-start; }

  /* The cookie table becomes one card per row: four columns do not fit. */
  .mira-legal__table thead { display: none; }
  .mira-legal__table tr { display: grid; gap: 6px; padding: 18px 20px; border-bottom: 1px solid var(--ui-soft); }
  .mira-legal__table tr:last-child { border-bottom: 0; }
  .mira-legal__table td { display: grid; grid-template-columns: 88px 1fr; gap: 12px; padding: 0; border: 0; }
  .mira-legal__table td::before { content: attr(data-label); color: var(--ui-text); font-weight: 600; }
  .mira-legal__table td:first-child { grid-template-columns: 1fr; }
  .mira-legal__table td:first-child::before { content: none; }
}

@media (prefers-reduced-motion: reduce) {
  .mira-legal * { transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}
