/* ==========================================================================
   legal.css: the legal pages (privacy, terms, SMS terms, accessibility) and the 404 page
   Layer: sections

   Table of contents
     1. Page base ................................... body.page-legal
     2. Legal header band (dark, under the fixed header) ... header.legal__head
        Breadcrumb (ol > li, separators drawn here), eyebrow, h1, "last updated"
     3. Reading column ............................... div.prose (max 72ch)
        h2 with a small sunset ridge accent, h3, p, lists, links, strong, tables, hr, address
     4. Call-to-action card .......................... aside.legal__cta
     5. 404 page ..................................... main.error-page

   Notes
   - The header is always in its condensed, solid state on these pages (is-scrolled is-static),
     so the dark band starts below a condensed header height.
   - Links in running text are underlined in --color-accent; the hover thickens the line
     instead of changing the color, so contrast on paper stays at 5.6:1 (AA).
   ========================================================================== */

@layer sections {
  /* ---- 1. Page base ---- */
  body.page-legal {
    background: var(--paper);
    background-image: var(--grain-light);
    background-size: var(--grain-size);
    background-repeat: repeat;
  }

  .legal {
    display: block;
    min-block-size: 60vh;
    min-block-size: 60svh;
    background: var(--paper);
    background-image: var(--grain-light);
    background-size: var(--grain-size);
    background-repeat: repeat;
    color: var(--color-text);
  }

  /* ---- 2. Legal header band ---- */
  .legal__head {
    --color-bg: var(--ink-900);
    position: relative;
    isolation: isolate;
    padding-block: calc(var(--header-h-condensed) + 3rem) clamp(3rem, 6vw, 4.5rem);
    background-color: var(--ink-900);
    background-image: var(--grain-dark), radial-gradient(90% 120% at 100% 0%, rgb(232 102 44 / 0.22), transparent 60%);
    background-size: var(--grain-size), auto;
    background-repeat: repeat, repeat;
    color: var(--dark-text);
  }

  /* Ridge at the bottom edge: a paper peak rising into the dark band. */
  .legal__head::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    inset-block-end: 0;
    z-index: 1;
    translate: 0 100%;
    block-size: clamp(1.125rem, 3vw, 2.75rem);
    background: var(--paper);
    background-image: var(--grain-light);
    background-size: var(--grain-size);
    background-repeat: repeat;
    clip-path: polygon(0 100%, 50% 0, 100% 100%);
    pointer-events: none;
  }

  .legal__head .breadcrumb {
    margin-block-end: 1.5rem;
  }

  .breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: var(--fs-sm);
    line-height: 1.3;
  }

  .breadcrumb li {
    display: inline-flex;
    align-items: center;
    color: var(--dark-text-muted);
  }

  .breadcrumb li + li::before {
    content: "/";
    margin-inline: 0.55rem;
    color: rgb(255 255 255 / 0.35);
  }

  .breadcrumb a {
    display: inline-flex;
    align-items: center;
    min-block-size: 2.75rem;
    color: var(--dark-text-muted);
    text-decoration: none;
    border-radius: var(--r-xs);
  }

  @media (hover: hover) {
    .breadcrumb a:hover {
      color: var(--white);
      text-decoration: underline;
      text-decoration-thickness: 1px;
      text-underline-offset: 0.25em;
    }
  }

  .breadcrumb [aria-current="page"] {
    color: var(--dark-text);
    font-weight: 600;
  }

  .legal__head .eyebrow {
    margin-block-end: 1rem;
  }

  .legal__title {
    max-inline-size: 18ch;
    margin: 0;
    color: var(--white);
    font-size: clamp(2.4rem, 1.7rem + 3.4vw, 4.25rem);
    font-weight: var(--fw-black);
    font-stretch: var(--stretch-display);
    letter-spacing: var(--tracking-display);
    line-height: 1.02;
    text-wrap: balance;
  }

  .legal__updated {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    margin: 1.4rem 0 0;
    padding-block: 0.35rem;
    padding-inline: 0.85rem;
    border: 1px solid var(--dark-border);
    border-radius: var(--r-pill);
    background: var(--dark-surface);
    color: var(--dark-text-muted);
    font-size: var(--fs-xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
  }

  /* ---- 3. Reading column ---- */
  .legal > .container {
    padding-block: clamp(3rem, 6vw, 5rem) clamp(4rem, 8vw, 6rem);
  }

  .prose {
    max-inline-size: 72ch;
    color: var(--color-text);
    font-size: var(--fs-body);
    line-height: 1.7;
    text-wrap: pretty;
  }

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

  .prose p,
  .prose ul,
  .prose ol,
  .prose table,
  .prose address {
    margin: 0 0 1.15em;
  }

  .prose h2 {
    margin: 2.6em 0 0.7em;
    color: var(--color-heading);
    font-size: clamp(1.5rem, 1.3rem + 0.8vw, 1.95rem);
    font-weight: 740;
    font-stretch: 92%;
    letter-spacing: -0.015em;
    line-height: 1.15;
    text-wrap: balance;
  }

  /* Small sunset ridge above each h2. */
  .prose h2::before {
    content: "";
    display: block;
    inline-size: 1.875rem;
    block-size: 0.625rem;
    margin-block-end: 0.85rem;
    background: var(--gradient-sunset);
    clip-path: polygon(0 100%, 50% 0, 100% 100%);
  }

  .prose h3 {
    margin: 2em 0 0.5em;
    color: var(--color-heading);
    font-size: var(--fs-h3);
    font-weight: 700;
    font-stretch: 94%;
    letter-spacing: -0.012em;
    line-height: 1.25;
    text-wrap: balance;
  }

  .prose ul,
  .prose ol {
    padding-inline-start: 1.4rem;
  }

  .prose li {
    padding-inline-start: 0.2rem;
    margin-block: 0.4em;
  }

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

  .prose ol li::marker {
    font-variant-numeric: tabular-nums;
  }

  .prose a {
    color: var(--color-accent);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    overflow-wrap: anywhere;
  }

  @media (hover: hover) {
    .prose a:hover {
      text-decoration-thickness: 2px;
    }
  }

  .prose a:focus-visible {
    border-radius: 2px;
  }

  .prose strong {
    color: var(--color-heading);
    font-weight: 700;
  }

  .prose table {
    inline-size: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
    line-height: 1.5;
  }

  .prose th,
  .prose td {
    padding: 0.75rem 0.9rem;
    border-block-end: 1px solid var(--sand-300);
    text-align: start;
    vertical-align: top;
    overflow-wrap: anywhere;
  }

  .prose th {
    background: var(--sand-100);
    color: var(--color-heading);
    font-weight: 700;
  }

  .prose hr {
    inline-size: 100%;
    margin: 2.75rem 0;
    border: 0;
    border-block-start: 1px solid var(--sand-300);
  }

  .prose address {
    font-style: normal;
  }

  /* ---- 4. Call-to-action card ---- */
  .legal__cta {
    --color-text: var(--dark-text);
    --color-text-muted: var(--dark-text-muted);
    --color-heading: var(--white);
    --color-accent: var(--amber-300);
    --color-border: var(--white-a14);
    display: grid;
    justify-items: start;
    gap: 0.75rem;
    max-inline-size: 72ch;
    margin-block-start: clamp(3rem, 6vw, 4rem);
    padding: clamp(1.5rem, 3.4vw, 2.25rem);
    border: 0;
    border-radius: var(--r-xl);
    background: radial-gradient(90% 120% at 100% 0%, rgb(232 102 44 / 0.3), transparent 60%), var(--ink-900);
    color: var(--dark-text);
    box-shadow: var(--shadow-xl);
  }

  .legal__cta h2 {
    margin: 0;
    color: var(--white);
    font-size: var(--fs-h3);
    font-weight: 700;
    font-stretch: 94%;
    line-height: 1.2;
  }

  .legal__cta p {
    margin: 0;
    color: var(--dark-text-muted);
  }

  .legal__cta .btn {
    margin-block: 0.4rem 0.2rem;
    inline-size: auto;
  }

  .legal__cta > .link {
    display: inline-flex;
    align-items: center;
    min-block-size: 2.75rem;
  }

  @media (max-width: 39.9375rem) {
    .legal__cta .btn {
      inline-size: 100%;
      justify-content: center;
    }
  }

  /* ---- 5. 404 page ---- */
  .error-page {
    position: relative;
    display: grid;
    align-items: center;
    min-block-size: 100vh;
    min-block-size: 100svh;
    padding-block: calc(var(--header-h-condensed) + 2.5rem) clamp(4rem, 9vw, 7rem);
    overflow: hidden;
    background-color: var(--paper);
    background-image: radial-gradient(60% 50% at 50% 42%, rgb(232 102 44 / 0.14), transparent 70%), var(--grain-light);
    background-size: auto, var(--grain-size);
    background-repeat: repeat, repeat;
    color: var(--color-text);
    text-align: center;
  }

  .error-page .container {
    display: grid;
    justify-items: center;
    gap: 0.9rem;
  }

  /* The huge numerals are outlined, not filled, so the page stays calm. */
  .error-page__code {
    margin: 0;
    color: transparent;
    font-size: clamp(7rem, 4rem + 26vw, 16rem);
    font-weight: var(--fw-black);
    font-stretch: 75%;
    letter-spacing: -0.04em;
    line-height: 0.82;
    font-variant-numeric: tabular-nums;
    -webkit-text-stroke: 2px var(--ink-900);
    text-stroke: 2px var(--ink-900);
    user-select: none;
  }

  .error-page h1 {
    margin: 0.4rem 0 0;
    color: var(--color-heading);
    font-size: clamp(2.1rem, 1.5rem + 2.6vw, 3.25rem);
    font-weight: var(--fw-black);
    font-stretch: var(--stretch-display);
    letter-spacing: var(--tracking-heading);
    line-height: 1.08;
    text-wrap: balance;
  }

  .error-page p:not(.error-page__code) {
    max-inline-size: 40ch;
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--fs-lead);
    line-height: 1.55;
  }

  .error-page__actions {
    display: grid;
    inline-size: 100%;
    max-inline-size: 26rem;
    gap: 0.75rem;
    margin-block-start: 1.25rem;
  }

  .error-page__actions .btn {
    justify-content: center;
  }

  @media (min-width: 40rem) {
    .error-page__actions {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      inline-size: auto;
      max-inline-size: none;
    }

    .error-page__actions .btn {
      inline-size: auto;
    }
  }
}
