/* ═══════════════════════════════════════════════════════════════
   HV Legal Docs — checkout modal
   Colours follow the hv-direct-checkout steps template.

   Two requirements from the legal brief:
     - indented clauses stay indented ([data-custom-style="Clause …"])
     - tables scroll sideways on a phone
   Style only. Never change the document text to fix a layout.
═══════════════════════════════════════════════════════════════ */

.hvld-modal,
.hvld-preview {
  --hvld-ink:    #111318;
  --hvld-text:   #3B3F48;
  --hvld-muted:  #6A6F7B;
  --hvld-line:   #E6E7EB;
  --hvld-panel:  #F7F7F5;
  --hvld-orange: #EE6A1F;
  --hvld-link:   #B5470A;  /* 5.3:1 on white */
  --hvld-font:   "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-family: var(--hvld-font);
  color: var(--hvld-text);
}

html.hvld-open { overflow: hidden; } /* no page scroll behind the modal */


/* ─── Dialog shell ─── */
.hvld-modal {
  width: min(860px, calc(100% - 32px));
  max-width: none;
  height: min(88vh, 960px);
  max-height: none;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 64px -16px rgba(17, 19, 24, .35);
  overflow: hidden;
}

.hvld-modal[open] {
  display: flex;
  flex-direction: column;
}

.hvld-modal::backdrop {
  background: rgba(17, 19, 24, .55);
}

.hvld-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px 28px;
  border-bottom: 1px solid var(--hvld-line);
  flex: none;
}

.hvld-modal__title {
  margin: 0 0 2px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--hvld-ink);
}

.hvld-modal__meta {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--hvld-muted);
}

.hvld-modal__close {
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: 26px;
  line-height: 1;
  color: var(--hvld-muted);
  cursor: pointer;
}

.hvld-modal__close:hover,
.hvld-modal__close:focus-visible {
  background: var(--hvld-panel);
  color: var(--hvld-ink);
}


/* ─── Tabs (SLA core + annexes) ─── */
.hvld-modal__tabs {
  display: flex;
  gap: 4px;
  padding: 8px 20px 0;
  border-bottom: 1px solid var(--hvld-line);
  overflow-x: auto;
  scrollbar-width: thin;
  flex: none;
}

.hvld-modal__tabs[hidden] { display: none; }

.hvld-tab {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  max-width: 240px;
  padding: 8px 14px 10px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  font: inherit;
  text-align: left;
  color: var(--hvld-muted);
  cursor: pointer;
}

.hvld-tab__name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.hvld-tab__sub {
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.hvld-tab:hover { color: var(--hvld-ink); }

.hvld-tab[aria-selected="true"] {
  color: var(--hvld-ink);
  border-bottom-color: var(--hvld-orange);
}

.hvld-tab:focus-visible {
  outline: 2px solid var(--hvld-orange);
  outline-offset: -2px;
  border-radius: 6px 6px 0 0;
}


/* ─── Scrolling document area ─── */
.hvld-modal__body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 28px 40px;
}

.hvld-modal__body:focus-visible { outline: 2px solid var(--hvld-orange); outline-offset: -2px; }

.hvld-modal__status {
  margin: 40px 0;
  text-align: center;
  color: var(--hvld-muted);
}


/* ─── The document (Gil's fragment) ─── */
.hvld-modal .hv-legal-doc,
.hvld-preview .hv-legal-doc {
  font-size: 15px;
  line-height: 1.7;
  overflow-wrap: break-word;
}

/* Permanent-address bar: those pages are not published; the modal header shows version and date instead */
.hvld-modal .hv-legal-meta,
.hvld-preview .hv-legal-meta {
  display: none;
}

.hv-legal-doc p { margin: 0 0 1em; }

.hv-legal-doc a {
  color: var(--hvld-link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hv-legal-doc strong { font-weight: 600; color: var(--hvld-ink); }

.hv-legal-doc h1,
.hv-legal-doc h2,
.hv-legal-doc h3 {
  font-family: var(--hvld-font);
  color: var(--hvld-ink);
  letter-spacing: -0.01em;
}

.hv-legal-doc h1 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 .8em;
}

/* Annex B uses further <h1>s as PART dividers */
.hv-legal-doc h1 ~ h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .02em;
  margin: 2.2em 0 .7em;
  padding-top: 1.1em;
  border-top: 2px solid var(--hvld-line);
}

.hv-legal-doc h2 {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  margin: 1.8em 0 .5em;
}

.hv-legal-doc h3 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  margin: 1.4em 0 .4em;
}

/* Clauses — indent levels must survive restyling */
.hv-legal-doc [data-custom-style] p { margin: .35em 0; }

.hv-legal-doc [data-custom-style="Clause 1"],
.hv-legal-doc [data-custom-style="Clause Text 1"] { margin-left: 1.5em; }

.hv-legal-doc [data-custom-style="Clause 2"],
.hv-legal-doc [data-custom-style="Clause Text 2"] { margin-left: 3em; }

.hv-legal-doc [data-custom-style="Clause 3"],
.hv-legal-doc [data-custom-style="Clause Text 3"] { margin-left: 4.5em; }

.hv-legal-doc ol,
.hv-legal-doc ul { margin: 0 0 1em; padding-left: 1.75em; }

.hv-legal-doc li { margin: 0 0 .4em; }

/* AUP uses <blockquote> for indented paragraphs, not quotations */
.hv-legal-doc blockquote {
  margin: 0 0 1em 1.5em;
  padding: 0;
  border: 0;
  font-size: inherit;
  font-style: normal;
  color: inherit;
}

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

/* Tables — scroll sideways on a phone */
.hv-legal-doc table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 1.2em 0 1.5em;
  font-size: 14px;
  line-height: 1.55;
}

.hv-legal-doc th,
.hv-legal-doc td {
  border: 1px solid var(--hvld-line);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  min-width: 7em;
}

.hv-legal-doc th {
  background: var(--hvld-panel);
  color: var(--hvld-ink);
  font-weight: 600;
}


/* ─── Phone: full screen ─── */
@media (max-width: 600px) {
  .hvld-modal {
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .hvld-modal__head { padding: 12px 8px 10px 16px; }
  .hvld-modal__title { font-size: 16px; }
  .hvld-modal__meta { font-size: 12px; }
  .hvld-modal__tabs { padding: 6px 8px 0; }
  .hvld-modal__body { padding: 18px 16px 32px; }

  .hv-legal-doc [data-custom-style="Clause 1"],
  .hv-legal-doc [data-custom-style="Clause Text 1"] { margin-left: 1em; }
  .hv-legal-doc [data-custom-style="Clause 2"],
  .hv-legal-doc [data-custom-style="Clause Text 2"] { margin-left: 2em; }
  .hv-legal-doc [data-custom-style="Clause 3"],
  .hv-legal-doc [data-custom-style="Clause Text 3"] { margin-left: 3em; }
}

@media (prefers-reduced-motion: no-preference) {
  .hvld-modal[open] { animation: hvld-in .18s ease-out; }
  @keyframes hvld-in { from { opacity: 0; transform: translateY(8px); } }
}
