* { box-sizing: border-box; }

body.legal-page {
  min-height: 100vh;
  margin: 0;
  background: var(--pet-background);
  color: var(--pet-charcoal);
}

.legal-header,
.legal-main,
.legal-footer {
  width: min(100% - 2rem, 1120px);
  margin-inline: auto;
}

.legal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0;
}

.legal-header nav,
.legal-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1rem;
  align-items: center;
}

.legal-header nav a,
.legal-footer a {
  color: var(--pet-green-dark);
  font-weight: 600;
  text-underline-offset: .2em;
}

.legal-main {
  padding: 2rem 0 5rem;
}

.legal-main > header {
  max-width: 780px;
  padding: 0 0 1.5rem;
}

.legal-eyebrow {
  margin: 0 0 .45rem;
  color: var(--pet-green-dark);
  font-size: .85rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.legal-main h1 {
  margin: 0 0 .7rem;
  font-size: clamp(2.25rem, 6vw, 4rem);
}

.legal-main h2 {
  margin: 2.4rem 0 .65rem;
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.legal-main h3 {
  margin: 1.45rem 0 .35rem;
  font-size: 1.15rem;
}

.legal-main p,
.legal-main li {
  max-width: 780px;
  overflow-wrap: anywhere;
}

.legal-main p { margin: .65rem 0; }
.legal-main ul,
.legal-main ol { max-width: 780px; padding-left: 1.35rem; }
.legal-main li + li { margin-top: .35rem; }

.legal-meta {
  color: var(--pet-muted);
  font-size: .9rem;
}

.legal-note,
.legal-toc,
.legal-card {
  max-width: 780px;
  padding: 1rem 1.15rem;
  border: 1px solid var(--pet-border);
  border-radius: var(--pet-radius-sm);
  background: var(--pet-surface);
}

.legal-note {
  border-left: 4px solid var(--pet-green);
  background: var(--pet-soft);
}

.legal-note p:first-child,
.legal-card p:first-child { margin-top: 0; }
.legal-note p:last-child,
.legal-card p:last-child { margin-bottom: 0; }

.analytics-opt-out-box { border-left-color: var(--accent); margin-block: 1.5rem; }
.analytics-opt-out-btn { margin-top: .5rem; }
.analytics-opt-out-hint { margin-top: .8rem; font-size: .85rem; color: var(--muted); }
.analytics-opt-out-status-active { color: var(--pet-green-dark); }
.analytics-opt-out-status-disabled { color: #a0341e; }

.legal-toc { margin: 0 0 2rem; }
.legal-toc strong { display: block; margin-bottom: .4rem; }
.legal-toc ol { margin: 0; }

.legal-main a { color: var(--pet-green-dark); }
.legal-main code { overflow-wrap: anywhere; }

.legal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 0 2rem;
  border-top: 1px solid var(--pet-border);
  color: var(--pet-muted);
  font-size: .9rem;
}

.legal-footer p { margin: 0; }

@media (max-width: 640px) {
  .legal-header,
  .legal-main,
  .legal-footer { width: min(100% - 1.5rem, 1120px); }
  .legal-header { align-items: flex-start; padding-top: 1rem; }
  .legal-header nav { justify-content: flex-end; font-size: .88rem; }
  .legal-main { padding-top: 1.25rem; }
  .legal-main h2 { margin-top: 2rem; }
  .legal-footer { align-items: flex-start; flex-direction: column; }
  .legal-footer nav { gap: .5rem .85rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* ==========================================================================
   PT-PR-101.2 Legal UX Reading Sheet Dialog
   Quiet, calm in-context legal reading surface for signup and booking flows.
   ========================================================================== */

.legal-sheet-dialog {
  width: min(760px, calc(100vw - 32px));
  max-width: none;
  height: min(820px, calc(100dvh - 48px));
  max-height: none;
  margin: auto;
  padding: 0;
  border: 1px solid var(--pet-border);
  border-radius: 20px;
  background: var(--pet-background);
  color: var(--pet-charcoal);
  box-shadow: 0 24px 80px rgba(41, 48, 56, 0.28);
  overflow: hidden;
}

.legal-sheet-dialog::backdrop {
  background: rgba(41, 48, 56, 0.42);
  backdrop-filter: blur(2px);
}

.legal-sheet-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
}

.legal-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--pet-border);
  background: var(--pet-surface);
  flex-shrink: 0;
}

.legal-sheet-header-text {
  min-width: 0;
}

.legal-sheet-eyebrow {
  margin: 0 0 3px;
  color: var(--pet-green-dark);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.legal-sheet-title {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--pet-charcoal);
  line-height: 1.25;
}

.legal-sheet-meta {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: var(--pet-muted);
}

.legal-sheet-close {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border: 1px solid var(--pet-border);
  border-radius: 50%;
  background: var(--pet-surface);
  color: var(--pet-charcoal);
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.legal-sheet-close:hover {
  background: var(--pet-soft);
  border-color: var(--pet-green);
}

.legal-sheet-close:focus-visible,
.legal-sheet-done:focus-visible,
.legal-sheet-canonical:focus-visible {
  outline: 3px solid rgba(50, 165, 121, 0.35);
  outline-offset: 2px;
}

.legal-sheet-content {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 28px;
  background: var(--pet-background);
  box-sizing: border-box;
}

.legal-sheet-content:focus {
  outline: none;
}

.legal-sheet-content:focus-visible {
  outline: 2px dashed rgba(50, 165, 121, 0.5);
  outline-offset: -2px;
}

/* Hide duplicate in-content header since the fixed dialog header already displays title & meta */
.legal-sheet-content > header,
.legal-sheet-content h1 {
  display: none;
}

.legal-sheet-content h2 {
  margin: 1.8rem 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--pet-charcoal);
}

.legal-sheet-content h2:first-of-type {
  margin-top: 0.8rem;
}

.legal-sheet-content h3 {
  margin: 1.25rem 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--pet-charcoal);
}

.legal-sheet-content p,
.legal-sheet-content li {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--pet-charcoal);
}

.legal-sheet-content .legal-note {
  margin: 0 0 1.25rem;
  font-size: 0.92rem;
}

.legal-sheet-content .legal-toc {
  margin: 0 0 1.5rem;
  font-size: 0.88rem;
}

.legal-sheet-content a {
  color: var(--pet-green-dark);
  text-underline-offset: 2px;
}

.legal-sheet-loading {
  padding: 40px 0;
  text-align: center;
  color: var(--pet-muted);
  font-size: 0.95rem;
}

.legal-sheet-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-top: 1px solid var(--pet-border);
  background: var(--pet-surface);
  flex-shrink: 0;
}

.legal-sheet-canonical {
  color: var(--pet-green-dark);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legal-sheet-canonical:hover {
  color: #105b43;
}

.legal-sheet-done {
  min-height: 38px;
  padding: 6px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

@media (max-width: 640px) {
  .legal-sheet-dialog {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .legal-sheet-container {
    height: 100dvh;
  }

  .legal-sheet-header {
    padding: 14px 16px 12px;
  }

  .legal-sheet-title {
    font-size: 1.25rem;
  }

  .legal-sheet-content {
    padding: 16px;
  }

  .legal-sheet-footer {
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 12px));
    flex-wrap: wrap;
  }

  .legal-sheet-canonical {
    font-size: 0.88rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .legal-sheet-dialog,
  .legal-sheet-content {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
