/* policy-render.css
 *
 * Document styling for rendered policies. Screen, mobile and print.
 * Pairs with policy-render.js — the class names come from that renderer.
 *
 * Scoped under .policy-doc so nothing here affects the rest of the site.
 */

.policy-doc {
  max-width: 48rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
  color: #1a1a1a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

/* Inline variant: the policy sits inside an existing card or panel that
 * already supplies its own width and padding (the candidate portal's
 * .panel-card, the admin policy detail view). Drops the page-level framing
 * and keeps only the typography and table rules.
 */

.policy-doc.policy-doc-inline {
  max-width: none;
  margin: 0.75rem 0 0;
  padding: 0;
  font-size: 0.95rem;
}

.policy-doc.policy-doc-inline h1 {
  font-size: 1.35rem;
  margin-bottom: 1.125rem;
}

.policy-doc.policy-doc-inline h2 { font-size: 1.15rem; margin-top: 1.75rem; }
.policy-doc.policy-doc-inline h3 { font-size: 1.02rem; margin-top: 1.5rem; }

/* ---------- headings ---------- */

.policy-doc h1 {
  font-size: 1.75rem;
  line-height: 1.25;
  font-weight: 700;
  margin: 0 0 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid #e2e2e2;
}

.policy-doc h2 {
  font-size: 1.3rem;
  line-height: 1.3;
  font-weight: 700;
  margin: 2.5rem 0 0.875rem;
}

.policy-doc h3 {
  font-size: 1.1rem;
  line-height: 1.35;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
}

.policy-doc h4,
.policy-doc h5,
.policy-doc h6 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.5rem 0 0.5rem;
}

.policy-doc h1:first-child,
.policy-doc h2:first-child {
  margin-top: 0;
}

/* ---------- body text ---------- */

.policy-doc p {
  margin: 0 0 1.125rem;
}

.policy-doc strong { font-weight: 700; }
.policy-doc em     { font-style: italic; }

.policy-doc code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: #f4f4f5;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.policy-doc hr {
  border: 0;
  border-top: 1px solid #e2e2e2;
  margin: 2.25rem 0;
}

/* ---------- lists ---------- */

.policy-doc ul,
.policy-doc ol {
  margin: 0 0 1.125rem;
  padding-left: 1.5rem;
}

.policy-doc li {
  margin-bottom: 0.5rem;
}

.policy-doc li:last-child {
  margin-bottom: 0;
}

/* ---------- tables ---------- */

.policy-table-wrap {
  margin: 0 0 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.policy-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.policy-table th,
.policy-table td {
  text-align: left;
  vertical-align: top;
  padding: 0.7rem 0.85rem;
  border: 1px solid #ddd;
}

.policy-table th {
  background: #f4f4f5;
  font-weight: 700;
  line-height: 1.4;
}

.policy-table tbody tr:nth-child(even) td {
  background: #fafafa;
}

/* ---------- mobile: stack table rows instead of scrolling ----------
 * Each cell shows its column heading, taken from the data-label the
 * renderer writes. Keeps long two-column tables like Roles and
 * Responsibilities readable on a phone.
 */

@media (max-width: 40rem) {
  .policy-doc {
    padding: 1rem 1rem 3rem;
    font-size: 0.975rem;
  }

  .policy-doc h1 { font-size: 1.45rem; }
  .policy-doc h2 { font-size: 1.2rem; margin-top: 2rem; }

  .policy-table,
  .policy-table thead,
  .policy-table tbody,
  .policy-table tr,
  .policy-table td {
    display: block;
    width: 100%;
  }

  .policy-table thead {
    position: absolute;
    left: -9999px;
  }

  .policy-table tr {
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
  }

  .policy-table td {
    border: 0;
    border-bottom: 1px solid #eee;
    padding: 0.65rem 0.85rem;
  }

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

  .policy-table tbody tr:nth-child(even) td {
    background: transparent;
  }

  .policy-table td[data-label]:before {
    content: attr(data-label);
    display: block;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #666;
    margin-bottom: 0.2rem;
  }

  /* A cell whose label is empty gets no heading line. */
  .policy-table td[data-label=""]:before {
    content: none;
  }
}

/* ---------- print / PDF ---------- */

@media print {
  .policy-doc {
    max-width: none;
    padding: 0;
    font-size: 11pt;
    line-height: 1.5;
    color: #000;
  }

  .policy-doc h1 { font-size: 18pt; }
  .policy-doc h2 { font-size: 14pt; page-break-after: avoid; }
  .policy-doc h3 { font-size: 12pt; page-break-after: avoid; }

  .policy-doc p,
  .policy-doc li {
    orphans: 3;
    widows: 3;
  }

  /* Tables stay tables on paper — never stacked, never scrolling. */
  .policy-table-wrap {
    overflow: visible;
  }

  .policy-table {
    font-size: 10pt;
    page-break-inside: auto;
  }

  .policy-table thead {
    display: table-header-group;   /* repeat headers across pages */
    position: static;
  }

  .policy-table tr {
    page-break-inside: avoid;
  }

  .policy-table th,
  .policy-table td {
    display: table-cell;
    border: 1px solid #999;
  }

  .policy-table td:before {
    content: none !important;
  }

  .policy-doc a[href]:after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555;
  }
}
