/* =============================================================================
 * single-policies.css  —  Harbor Policy Reader
 * Companion to: single-policies.php + single-policies.js
 * NOTE: PHP helpers belong in single-policies.php (or functions.php),
 *       NOT in this file.
 * =========================================================================== */

/* ── Tokens ──────────────────────────────────────────────────────────────── */
:root {
  --sp-navy:        #0d2f52;
  --sp-maroon:      #7a1f2b;
  --sp-border:      #e5e7eb;
  --sp-soft:        #f3f4f6;
  --sp-text:        #111827;
  --sp-muted:       #6b7280;
  --sp-green:       #22c55e;
  --sp-font:        'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --sp-radius:      10px;
  --sp-transition:  200ms ease;
}

*,
*::before,
*::after { box-sizing: border-box; }

/* ── Page wrapper ────────────────────────────────────────────────────────── */
.sp-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 20px 48px;
  font-family: var(--sp-font);
  font-size: 16px;
  color: var(--sp-text);
  line-height: 1.7;
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.sp-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.sp-back {
  color: var(--sp-navy);
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
}
.sp-back:hover { text-decoration: underline; }

.sp-pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--sp-maroon);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: var(--sp-radius);
  text-decoration: none;
  transition: filter var(--sp-transition);
}
.sp-pdf-btn:hover { filter: brightness(0.9); }

/* ── Header ──────────────────────────────────────────────────────────────── */
.sp-header { margin-bottom: 8px; }

.sp-label {
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--sp-muted);
  font-weight: 700;
  margin: 0 0 6px;
}

.sp-title {
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 900;
  color: var(--sp-text);
  margin: 0 0 14px;
  line-height: 1.2;
}

/* ── Meta pills ──────────────────────────────────────────────────────────── */
.sp-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.sp-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--sp-border);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  color: var(--sp-text);
}

.sp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sp-green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .18);
  flex-shrink: 0;
}

/* ── Info grid ───────────────────────────────────────────────────────────── */
.sp-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 0 0 18px;
  padding: 0;
}

.sp-info-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sp-info-item dt,
.sp-info-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sp-muted);
}

.sp-info-item dd,
.sp-info-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--sp-text);
  margin: 0;
}

/* ── Summary ─────────────────────────────────────────────────────────────── */
.sp-summary {
  background: #f7ecef;
  border: 1px solid #e0c8cc;
  border-radius: 6px;
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 16px;
  color: var(--sp-text);
}

/* ── Controls ────────────────────────────────────────────────────────────── */
.sp-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.sp-toggle-btn,
.sp-bulk-btn {
  border: 1px solid var(--sp-text);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  background: #fff;
  color: var(--sp-text);
  cursor: pointer;
  font-family: var(--sp-font);
  transition: background var(--sp-transition), color var(--sp-transition);
}
.sp-toggle-btn:hover,
.sp-bulk-btn:hover {
  background: var(--sp-maroon);
  border-color: var(--sp-maroon);
  color: #fff;
}
.sp-toggle-btn:focus-visible,
.sp-bulk-btn:focus-visible {
  outline: 3px solid rgba(122, 31, 43, .4);
  outline-offset: 2px;
}

.sp-timestamp {
  font-size: 12px;
  color: var(--sp-muted);
  font-weight: 600;
}

/* ── Divider ─────────────────────────────────────────────────────────────── */
.sp-divider {
  height: 5px;
  background: var(--sp-text);
  border: 0;
  margin: 14px 0 18px;
}

/* ── Accordion ───────────────────────────────────────────────────────────── */
.sp-accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sp-acc {
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  background: #fff;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
}

.sp-acc-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: none;
  cursor: pointer;
  font-family: var(--sp-font);
  font-size: 15px;
  font-weight: 800;
  color: var(--sp-text);
  text-align: left;
  transition: background var(--sp-transition);
}
.sp-acc-head:hover     { background: #f7f8fb; }
.sp-acc-head:focus       { outline: none; }
.sp-acc-head:focus-visible {
  outline: 3px solid rgba(122, 31, 43, .35);
  outline-offset: 2px;
}

.sp-acc-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--sp-navy);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  border-radius: 6px;
}

.sp-acc-title { flex: 1; }

.sp-acc-chevron {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--sp-muted);
  transition: transform var(--sp-transition);
}
.sp-acc.open .sp-acc-chevron { transform: rotate(180deg); }

/* Panel: JS controls max-height; transition handles the animation */
.sp-acc-panel {
  overflow: hidden;
  transition: max-height 220ms ease;
  will-change: max-height;
}

.sp-acc-inner {
  padding: 16px 18px 20px;
  font-size: 15px;
  line-height: 1.7;
}

/* ── Reference badge ─────────────────────────────────────────────────────── */
.ref-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px dashed rgba(122, 31, 43, .5);
  border-radius: 7px;
  padding: 3px 8px;
  margin: 0 3px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--sp-text);
  font-family: var(--sp-font);
  vertical-align: middle;
  line-height: 1;
  transition: all .15s ease;
  touch-action: manipulation;
}
.ref-badge:hover {
  background: #f7ecef;
  border-color: var(--sp-maroon);
}
.ref-badge:focus-visible {
  outline: 3px solid rgba(122, 31, 43, .4);
  outline-offset: 2px;
}

.ref-badge-icon {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--sp-maroon);
  color: #fff;
  flex-shrink: 0;
}

.ref-badge-text {
  font-weight: 700;
  letter-spacing: .2px;
  overflow-wrap: anywhere;
}

/* ── Regulation cards ────────────────────────────────────────────────────── */
.reg-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.reg-card {
  background: #fff;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 14px 16px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
  width: 100%;
  font-family: var(--sp-font);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  touch-action: manipulation;
}
.reg-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .12);
  border-color: var(--sp-maroon);
}
.reg-card:focus-visible {
  outline: 3px solid rgba(122, 31, 43, .4);
  outline-offset: 2px;
}

.reg-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.reg-card-badge {
  background: var(--sp-maroon);
  color: #fff;
  padding: 3px 7px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.reg-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--sp-text);
}

.reg-card-desc {
  font-size: 12px;
  color: #4b5563;
  line-height: 1.5;
}

/* ── Reference side panel ────────────────────────────────────────────────── */
.ref-panel {
  position: fixed;
  top: 0;
  right: 24px;
  bottom: 0;
  width: min(460px, calc(100vw - 32px));
  background: #fff;
  border-left: 1px solid var(--sp-border);
  box-shadow: -6px 0 32px rgba(15, 23, 42, .14);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transform: translateX(calc(100% + 32px));
  transition: transform 240ms ease;
  border-radius: 16px 0 0 16px;
}
.ref-panel.active {
  transform: translateX(0);
}

.ref-panel-hdr,
.ref-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--sp-border);
  background: var(--sp-soft);
  border-radius: 16px 0 0 0;
  cursor: default;
  user-select: none;
}

.ref-panel-code {
  font-weight: 900;
  font-size: 14px;
  color: var(--sp-text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ref-panel-btns,
.ref-panel-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.ref-panel-btn {
  border: 1px solid var(--sp-border);
  border-radius: 7px;
  background: #fff;
  color: var(--sp-text);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
  cursor: pointer;
  font-family: var(--sp-font);
  transition: background var(--sp-transition);
}
.ref-panel-btn:hover      { background: var(--sp-soft); }
.ref-panel-btn:focus-visible {
  outline: 3px solid rgba(122, 31, 43, .35);
  outline-offset: 2px;
}

.ref-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--sp-text);
}

/* Floating (draggable) state */
.ref-panel[style*="left"] {
  bottom: auto;
  height: min(80vh, 520px);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, .22);
}

/* Loading / error states */
.ref-loading { color: var(--sp-muted); font-style: italic; }
.ref-error   { color: #b91c1c; }
.ref-error a { color: var(--sp-maroon); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .sp-wrap { padding: 16px 14px 40px; }

  .ref-panel {
    right: 0;
    width: 100vw;
    border-radius: 0;
    transform: translateY(100%);
  }
  .ref-panel.active { transform: translateY(0); }
}
/* =============================================================================
 * Harbor Policy Reader — Title-first TOC + Reference Compatibility Updates
 * Safe to paste at the bottom of single-policies.css
 * ========================================================================== */

/* ── TOC / Volume policy list: title first, policy number underneath ───────── */

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-item {
  margin: 0;
  padding: 0;
}

.toc-link {
  display: block;
  padding: 12px 14px;
  border-bottom: 1px solid var(--sp-border);
  text-decoration: none !important;
  background: #fff;
  color: var(--sp-text);
  transition: background var(--sp-transition), border-color var(--sp-transition);
}

.toc-link:hover {
  background: #f9fafb;
  text-decoration: none !important;
}

.toc-link.current,
.toc-link[aria-current="page"] {
  background: #f7ecef;
  border-left: 4px solid var(--sp-maroon);
  padding-left: 10px;
}

.toc-policy-title {
  display: block;
  font-size: 14px;
  font-weight: 850;
  line-height: 1.35;
  color: var(--sp-text);
}

.toc-policy-number {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.2;
  color: #9ca3af;
  letter-spacing: .02em;
}

.toc-link.current .toc-policy-title,
.toc-link[aria-current="page"] .toc-policy-title {
  color: var(--sp-maroon);
  font-weight: 900;
}

.toc-link.current .toc-policy-number,
.toc-link[aria-current="page"] .toc-policy-number {
  color: var(--sp-muted);
}


/* ── Reference badge compatibility: supports PHP output using reference-marker ─ */

.reference-marker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  border: 1px dashed rgba(122, 31, 43, .5);
  border-radius: 7px;
  padding: 3px 8px;
  margin: 0 3px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  font-size: 12px;
  font-weight: 700;
  color: var(--sp-text);
  font-family: var(--sp-font);
  vertical-align: middle;
  line-height: 1.1;
  transition: all .15s ease;
  touch-action: manipulation;
  text-decoration: none !important;
  max-width: 100%;
  white-space: normal;
}

.reference-marker:hover {
  background: #f7ecef;
  border-color: var(--sp-maroon);
  color: var(--sp-text);
  text-decoration: none !important;
}

.reference-marker:focus-visible {
  outline: 3px solid rgba(122, 31, 43, .4);
  outline-offset: 2px;
}

.reference-marker .ref-icon,
.ref-badge .ref-icon {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--sp-maroon);
  color: #fff;
  flex-shrink: 0;
  font-size: 11px;
}

.reference-marker .ref-text,
.ref-badge .ref-text {
  font-weight: 750;
  letter-spacing: .2px;
  overflow-wrap: anywhere;
}

.policy-ref-badge {
  border-style: solid;
  border-color: rgba(13, 47, 82, .25);
}

.policy-ref-badge .ref-icon {
  background: var(--sp-navy);
}

.policy-ref-missing {
  opacity: .72;
  cursor: default;
  border-style: dashed;
}


/* ── Regulation card compatibility: supports both old and new class names ─── */

.regulation-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.regulation-card {
  background: #fff;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 14px 16px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
  width: 100%;
  font-family: var(--sp-font);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .05);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
  touch-action: manipulation;
}

.regulation-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .12);
  border-color: var(--sp-maroon);
}

.regulation-card:focus-visible {
  outline: 3px solid rgba(122, 31, 43, .4);
  outline-offset: 2px;
}

.regulation-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.regulation-badge {
  background: var(--sp-maroon);
  color: #fff;
  padding: 3px 7px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.regulation-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--sp-text);
}

.regulation-description {
  font-size: 12px;
  color: #4b5563;
  line-height: 1.5;
}


/* ── Related policy preview drawer styling ───────────────────────────────── */

.related-policy-preview {
  border-bottom: 1px solid var(--sp-border);
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.related-policy-eyebrow {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--sp-maroon);
}

.related-policy-num {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 800;
  color: var(--sp-muted);
}

.related-policy-preview h3 {
  margin: 0 0 12px;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 900;
  color: var(--sp-text);
}

.related-policy-reason,
.related-policy-section-list {
  background: #f9fafb;
  border: 1px solid var(--sp-border);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 10px 0;
}

.related-policy-reason p,
.related-policy-section-list p {
  margin: 0 0 6px;
}

.related-policy-reason p:last-child,
.related-policy-section-list p:last-child {
  margin-bottom: 0;
}

.related-policy-extracted-sections {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.related-policy-preview-section {
  background: #fff;
  border: 1px solid var(--sp-border);
  border-radius: 12px;
  padding: 14px 16px;
}

.related-policy-preview-section h4 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 900;
  color: var(--sp-navy);
}

.related-policy-cited-section {
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
  box-shadow: 0 8px 20px rgba(245, 158, 11, .10);
}

.related-policy-cited-section h4 {
  color: #92400e;
}

.related-policy-cited-section h4::after {
  content: "Cited section";
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
  vertical-align: middle;
}

.related-policy-preview-html {
  font-size: 14px;
  line-height: 1.7;
}

.related-policy-preview-html p:first-child,
.related-policy-preview-html ul:first-child,
.related-policy-preview-html ol:first-child {
  margin-top: 0;
}

.related-policy-preview-html p:last-child,
.related-policy-preview-html ul:last-child,
.related-policy-preview-html ol:last-child {
  margin-bottom: 0;
}

.related-policy-exact-ref-match {
  background: #fff7ed;
  border-radius: 6px;
  padding: 4px 6px;
}

.related-policy-open-full {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--sp-maroon);
  color: #fff !important;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none !important;
}

.related-policy-open-full:hover {
  filter: brightness(.94);
}


/* ── Highlighted regulation text inside side panel ───────────────────────── */

.reg-highlight {
  background: #fef9c3;
  border-left: 4px solid #f59e0b;
  padding-left: 8px;
  border-radius: 4px;
}


/* ── Mobile refinements ──────────────────────────────────────────────────── */

@media (max-width: 600px) {
  .toc-link {
    padding: 11px 12px;
  }

  .toc-policy-title {
    font-size: 13px;
  }

  .toc-policy-number {
    font-size: 10.5px;
  }

  .related-policy-preview h3 {
    font-size: 18px;
  }

  .related-policy-preview-section {
    padding: 12px;
  }
}