/* ==========================================================================
   Policy pages (Privacy Policy, Cookie Policy, Terms of Service)
   Shared presentation layer. Content lives in each page's .policy-content;
   this file handles layout, typography, the page header, the sticky table of
   contents, and the cookie / third-party tables. Theme-aware: light is the
   ACSS default, dark mirrors the conventions in theme.css.
   Root font-size is 10px (1rem = 10px) per ACSS — sizes here use px or tokens.
   ========================================================================== */

/* ---- Section shell ------------------------------------------------------- */
.policy-section.c-section {
  padding-top: var(--space-l);
  padding-bottom: var(--space-xxl);
  /* let the page/theme background show through instead of forcing white */
  background-color: transparent;
  border-top: 1px solid var(--base-light);
}

/* The legacy inline max-width:800px on .policy-content is overridden so the
   header + TOC + content grid can span a wider, more modern measure. */
.policy-section .policy-content {
  max-width: 1080px !important;
  margin: 0 auto !important;
  padding: 0 !important;
}

/* ---- Page header --------------------------------------------------------- */
.policy-header {
  margin-bottom: var(--space-l);
  padding-bottom: var(--space-m);
  border-bottom: 1px solid var(--base-light);
}

.policy-header__eyebrow {
  display: inline-block;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--base);
  margin-bottom: 1.2rem;
  padding: 0.5rem 1.2rem;
  border: 1px solid var(--base-light);
  border-radius: var(--radius-xl, 999px);
  background: var(--base-ultra-light);
}

.policy-header__title {
  font-size: clamp(3.2rem, 5vw, 5rem);
  line-height: 1.05;
  margin: 0 0 1.4rem;
  font-weight: 700;
}

.policy-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.6rem;
  font-size: 1.4rem;
}

.policy-meta__item {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--neutral-dark, #4f4f4f);
}

.policy-meta__item strong {
  font-weight: 600;
}

.policy-meta__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--action-medium, #d9a026);
  flex: none;
}

/* Hide the old plain-text date line — the header surfaces it now. */
.policy-content .policy-date {
  display: none;
}

/* ---- Layout: TOC sidebar + body ----------------------------------------- */
.policy-layout {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: var(--space-l);
  align-items: start;
}

/* Grid/flex items default to min-width:auto, which refuses to shrink below
   their content (e.g. the 480px-min tables) and blows out the layout on
   narrow screens. Force them to 0 so overflow-x on the table wrap can scroll. */
.policy-toc,
.policy-body {
  min-width: 0;
}

/* ---- Table of contents --------------------------------------------------- */
.policy-toc {
  position: sticky;
  top: 110px;
  align-self: start;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  padding: var(--space-s);
  border: 1px solid var(--base-light);
  border-radius: var(--radius-m, 12px);
  background: var(--base-ultra-light);
}

.policy-toc__title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--base);
  margin: 0 0 1.2rem;
}

.policy-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  counter-reset: toc;
}

.policy-toc__link {
  display: block;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-s, 8px);
  font-size: 1.4rem;
  line-height: 1.3;
  color: var(--base-dark) !important;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.policy-toc__link:hover {
  background: var(--white);
  color: var(--base) !important;
}

.policy-toc__link.is-active {
  background: var(--white);
  color: var(--base) !important;
  border-left-color: var(--action-medium, #d9a026);
  font-weight: 600;
}

/* ---- Body content typography -------------------------------------------- */
.policy-body {
  max-width: 72ch;
}

.policy-body > h2 {
  font-size: clamp(2.1rem, 2.6vw, 2.6rem);
  line-height: 1.2;
  margin: var(--space-l) 0 1.4rem;
  padding-top: 0.4rem;
  scroll-margin-top: 110px; /* offset for sticky header on anchor jump */
  font-weight: 700;
}

.policy-body > h2:first-of-type {
  margin-top: 0;
}

.policy-body p {
  font-size: 1.6rem;
  line-height: 1.75;
  margin: 0 0 1.6rem;
}

.policy-body ul {
  margin: 0 0 1.8rem;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.policy-body ul li {
  position: relative;
  padding-left: 2.4rem;
  font-size: 1.6rem;
  line-height: 1.7;
}

.policy-body ul li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1.05rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--action-medium, #d9a026);
}

.policy-body a {
  color: var(--base) !important;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.policy-body a:hover {
  color: var(--accent) !important;
}

/* Anchor affordance on headings */
.policy-body > h2 .policy-anchor {
  margin-left: 0.6rem;
  font-size: 0.7em;
  font-weight: 400;
  color: var(--base-light);
  opacity: 0;
  text-decoration: none;
  transition: opacity 0.15s ease;
}

.policy-body > h2:hover .policy-anchor {
  opacity: 1;
}

.policy-body > h2 .policy-anchor:hover {
  color: var(--action-medium, #d9a026) !important;
}

/* ---- Tables (cookies, third-party services) ----------------------------- */
.policy-table-wrap {
  margin: 0 0 1.8rem;
  overflow-x: auto;
  border: 1px solid var(--base-light);
  border-radius: var(--radius-m, 12px);
}

.policy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.5rem;
  min-width: 480px;
}

.policy-table th,
.policy-table td {
  text-align: left;
  padding: 1.2rem 1.6rem;
  vertical-align: top;
  line-height: 1.55;
  border-bottom: 1px solid var(--base-light);
}

.policy-table thead th {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--base);
  background: var(--base-ultra-light);
}

.policy-table tbody tr:last-child td {
  border-bottom: none;
}

.policy-table tbody tr:nth-child(even) td {
  background: var(--base-ultra-light);
}

.policy-table code,
.policy-body code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.92em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-xs, 4px);
  background: var(--base-ultra-light);
  color: var(--base-dark);
  border: 1px solid var(--base-light);
}

/* ---- Contact callout (last section) ------------------------------------- */
.policy-contact {
  margin-top: var(--space-m);
  padding: var(--space-m);
  border: 1px solid var(--base-light);
  border-radius: var(--radius-m, 12px);
  background: var(--base-ultra-light);
}

/* ==========================================================================
   Dark theme — mirrors theme.css conventions (rgba whites over the dark bg)
   ========================================================================== */
html[data-theme="dark"] .policy-section.c-section {
  border-top-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .policy-header,
html[data-theme="dark"] .policy-meta__item strong { }

html[data-theme="dark"] .policy-header {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .policy-header__eyebrow {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.8) !important;
}

html[data-theme="dark"] .policy-meta__item {
  color: rgba(255, 255, 255, 0.6);
}

html[data-theme="dark"] .policy-toc {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .policy-toc__title {
  color: rgba(255, 255, 255, 0.6);
}

html[data-theme="dark"] .policy-toc__link {
  color: rgba(255, 255, 255, 0.7) !important;
}

html[data-theme="dark"] .policy-toc__link:hover,
html[data-theme="dark"] .policy-toc__link.is-active {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.95) !important;
}

html[data-theme="dark"] .policy-toc__link.is-active {
  border-left-color: var(--action-medium, #d9a026);
}

html[data-theme="dark"] .policy-body a {
  color: rgba(255, 255, 255, 0.85) !important;
}

html[data-theme="dark"] .policy-body a:hover {
  color: rgb(20, 181, 235) !important;
}

html[data-theme="dark"] .policy-table-wrap {
  border-color: rgba(255, 255, 255, 0.1);
}

html[data-theme="dark"] .policy-table th,
html[data-theme="dark"] .policy-table td {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .policy-table thead th {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.85);
}

html[data-theme="dark"] .policy-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.03);
}

html[data-theme="dark"] .policy-body code,
html[data-theme="dark"] .policy-table code {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
}

html[data-theme="dark"] .policy-contact {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 991px) {
  .policy-layout {
    grid-template-columns: 1fr;
    gap: var(--space-m);
  }

  /* TOC becomes a collapsible block at the top, not sticky */
  .policy-toc {
    position: static;
    max-height: none;
    order: -1;
  }

  .policy-toc__list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .policy-toc__link {
    border-left: none;
    border: 1px solid var(--base-light);
    border-radius: var(--radius-xl, 999px);
    padding: 0.6rem 1.2rem;
    font-size: 1.3rem;
  }

  html[data-theme="dark"] .policy-toc__link {
    border-color: rgba(255, 255, 255, 0.12);
  }

  .policy-toc__link.is-active {
    border-left: 1px solid var(--action-medium, #d9a026);
    border-color: var(--action-medium, #d9a026);
  }

  .policy-body {
    max-width: none;
  }
}

@media (max-width: 767px) {
  .policy-section.c-section {
    padding-top: var(--space-m);
    padding-bottom: var(--space-xl);
  }

  .policy-body p,
  .policy-body ul li {
    font-size: 1.55rem;
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .policy-toc__link,
  .policy-body > h2 .policy-anchor {
    transition: none;
  }
}
