/* ==========================================================================
   CMS Page  (cms-*)
   Template: page-cms.php
   For: About Us, Privacy Policy, Terms & Conditions, Disclaimer, etc.
   Full-width outer → centered readable content column.
   Reuses: srch-section, srch-outer, arch-breadcrumb.
   BEM prefix: cms-*
   ========================================================================== */

/* ── CSS Variables ────────────────────────────────────────────────────────── */
:root {
  /* Layout */
  --cms-content-width:    740px;   /* overridden by Customizer width preset   */
  --cms-sec-pad:          48px;

  /* Page header */
  --cms-hdr-title:        #111827;
  --cms-hdr-subtitle:     #6b7280;
  --cms-hdr-border:       rgba(0,0,0,0.08);

  /* Meta bar */
  --cms-meta-col:         #6b7280;
  --cms-meta-link:        #374151;
  --cms-meta-border:      rgba(0,0,0,0.07);

  /* Content body */
  --cms-body-col:         #1f2937;
  --cms-body-size:        16px;    /* overridden by Customizer typo preset    */
  --cms-body-lh:          1.78;

  /* Headings */
  --cms-heading-col:      #111827;

  /* Links */
  --cms-link-col:         #2563eb;
  --cms-link-hover:       #1d4ed8;
  --cms-link-decoration:  underline;

  /* Borders / separators */
  --cms-border-col:       #e5e7eb;

  /* Blockquote */
  --cms-bq-border:        #e71d36;
  --cms-bq-bg:            rgba(231,29,54,0.04);
  --cms-bq-col:           #374151;

  /* Code – inline */
  --cms-code-bg:          #f3f4f6;
  --cms-code-col:         #111827;
  --cms-code-border:      rgba(0,0,0,0.08);

  /* Code – block / pre */
  --cms-pre-bg:           #0f172a;
  --cms-pre-col:          #e2e8f0;
  --cms-pre-radius:       8px;

  /* Table */
  --cms-table-border:     #e5e7eb;
  --cms-table-head-bg:    #f9fafb;
  --cms-table-head-col:   #111827;
  --cms-table-row-alt:    #fafafa;
  --cms-table-radius:     8px;

  /* TOC */
  --cms-toc-bg:           #f9fafb;
  --cms-toc-border:       rgba(0,0,0,0.07);
  --cms-toc-title:        #111827;
  --cms-toc-link:         #374151;
  --cms-toc-link-hover:   #e71d36;
  --cms-toc-accent:       #e71d36;
  --cms-toc-h3-col:       #6b7280;
}

body.dark-mode {
  /* Page header */
  --cms-hdr-title:        rgba(255,255,255,0.92);
  --cms-hdr-subtitle:     rgba(255,255,255,0.50);
  --cms-hdr-border:       rgba(255,255,255,0.08);

  /* Meta bar */
  --cms-meta-col:         rgba(255,255,255,0.45);
  --cms-meta-link:        rgba(255,255,255,0.68);
  --cms-meta-border:      rgba(255,255,255,0.08);

  /* Content body */
  --cms-body-col:         rgba(255,255,255,0.82);

  /* Headings */
  --cms-heading-col:      rgba(255,255,255,0.92);

  /* Links */
  --cms-link-col:         #60a5fa;
  --cms-link-hover:       #93c5fd;

  /* Borders */
  --cms-border-col:       rgba(255,255,255,0.10);

  /* Blockquote */
  --cms-bq-border:        #ff4d6d;
  --cms-bq-bg:            rgba(255,77,109,0.06);
  --cms-bq-col:           rgba(255,255,255,0.68);

  /* Code – inline */
  --cms-code-bg:          rgba(255,255,255,0.08);
  --cms-code-col:         rgba(255,255,255,0.88);
  --cms-code-border:      rgba(255,255,255,0.08);

  /* Code – block */
  --cms-pre-bg:           #0a0f1a;
  --cms-pre-col:          #cbd5e1;

  /* Table */
  --cms-table-border:     rgba(255,255,255,0.10);
  --cms-table-head-bg:    rgba(255,255,255,0.05);
  --cms-table-head-col:   rgba(255,255,255,0.90);
  --cms-table-row-alt:    rgba(255,255,255,0.025);

  /* TOC */
  --cms-toc-bg:           rgba(255,255,255,0.04);
  --cms-toc-border:       rgba(255,255,255,0.08);
  --cms-toc-title:        rgba(255,255,255,0.90);
  --cms-toc-link:         rgba(255,255,255,0.65);
  --cms-toc-link-hover:   #ff4d6d;
  --cms-toc-accent:       #ff4d6d;
  --cms-toc-h3-col:       rgba(255,255,255,0.45);
}

/* ── Section / container — reuses arch-bg variable from archive.css ──────── */
/* .srch-section and .srch-outer come from archive.css (already loaded)       */

/* ── Page header ──────────────────────────────────────────────────────────── */
.cms-hdr {
  padding: 20px 0 24px;
  border-bottom: 1px solid var(--cms-hdr-border);
  margin-bottom: 32px;
}

.cms-hdr__title {
  margin: 0 0 10px;
  font-size: clamp(26px, 3.5vw, 38px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--cms-hdr-title);
}

.cms-hdr__subtitle {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  color: var(--cms-hdr-subtitle);
  max-width: 600px;
}

/* ── Meta bar ─────────────────────────────────────────────────────────────── */
.cms-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--cms-meta-border);
  font-size: 13px;
  color: var(--cms-meta-col);
}

.cms-meta__av-wrap {
  flex-shrink: 0;
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  overflow: hidden;
  text-decoration: none;
}

.cms-meta__avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cms-meta__author {
  font-weight: 600;
  color: var(--cms-meta-link);
  text-decoration: none;
  transition: color 0.18s ease;
}

.cms-meta__author:hover {
  color: var(--cms-link-col);
}

.cms-meta__sep {
  flex-shrink: 0;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
}

.cms-meta__date {
  color: var(--cms-meta-col);
}

.cms-meta__readtime {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--cms-meta-col);
}

/* ── Content column — full width of srch-outer ───────────────────────────── */
.cms-wrap {
  width: 100%;
}

/* ── Mini TOC ─────────────────────────────────────────────────────────────── */
.cms-toc {
  background: var(--cms-toc-bg);
  border: 1px solid var(--cms-toc-border);
  border-left: 3px solid var(--cms-toc-accent);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 36px;
}

.cms-toc__title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--cms-toc-accent);
  margin: 0 0 12px;
}

.cms-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  counter-reset: toc-counter;
}

.cms-toc__item {
  counter-increment: toc-counter;
}

.cms-toc__link {
  display: block;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--cms-toc-link);
  text-decoration: none;
  padding: 3px 0;
  transition: color 0.18s ease;
}

.cms-toc__link::before {
  content: counter(toc-counter) ". ";
  color: var(--cms-toc-accent);
  font-weight: 700;
  font-size: 11px;
  margin-right: 2px;
}

.cms-toc__link:hover {
  color: var(--cms-toc-link-hover);
}

/* H3 items: indented, smaller, muted */
.cms-toc__item--h3 .cms-toc__link {
  padding-left: 16px;
  font-size: 12px;
  color: var(--cms-toc-h3-col);
}

.cms-toc__item--h3 .cms-toc__link::before {
  content: "↳ ";
  font-weight: 400;
}

/* H4 items: further indented */
.cms-toc__item--h4 .cms-toc__link {
  padding-left: 32px;
  font-size: 12px;
  color: var(--cms-toc-h3-col);
}

.cms-toc__item--h4 .cms-toc__link::before {
  content: "— ";
  font-weight: 400;
}

/* ==========================================================================
   CMS Content Typography  (.cms-content)
   Comprehensive editorial style for all WordPress content elements.
   All colors use --cms-* variables with dark mode overrides above.
   ========================================================================== */

.cms-content {
  font-size: var(--cms-body-size);
  line-height: var(--cms-body-lh);
  color: var(--cms-body-col);
  word-break: break-word;
  overflow-wrap: break-word;
}

/* ── Headings ─────────────────────────────────────────────────────────────── */
.cms-content h1,
.cms-content h2,
.cms-content h3,
.cms-content h4,
.cms-content h5,
.cms-content h6 {
  color: var(--cms-heading-col);
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 0;
}

/* Space before headings (separates sections) */
.cms-content h1 { font-size: 28px; margin-top: 40px; margin-bottom: 16px; }
.cms-content h2 { font-size: 24px; margin-top: 40px; margin-bottom: 14px; font-weight: 800; }
.cms-content h3 { font-size: 20px; margin-top: 32px; margin-bottom: 10px; }
.cms-content h4 { font-size: 17px; margin-top: 26px; margin-bottom: 8px;  font-weight: 600; }
.cms-content h5 { font-size: 15px; margin-top: 22px; margin-bottom: 6px;  font-weight: 600; }
.cms-content h6 {
  font-size: 12px;
  margin-top: 20px;
  margin-bottom: 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--cms-meta-col);
}

/* First heading in content — no extra top space */
.cms-content > :first-child { margin-top: 0; }

/* ── Paragraphs ───────────────────────────────────────────────────────────── */
.cms-content p {
  margin: 0 0 20px;
  color: var(--cms-body-col);
  line-height: var(--cms-body-lh);
}

.cms-content p:last-child { margin-bottom: 0; }

/* ── Links ────────────────────────────────────────────────────────────────── */
.cms-content a {
  color: var(--cms-link-col);
  text-decoration: var(--cms-link-decoration);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: color 0.18s ease;
}

.cms-content a:hover {
  color: var(--cms-link-hover);
}

/* ── Strong / emphasis ────────────────────────────────────────────────────── */
.cms-content strong,
.cms-content b {
  font-weight: 700;
  color: var(--cms-heading-col);
}

.cms-content em,
.cms-content i {
  font-style: italic;
}

/* ── Lists ────────────────────────────────────────────────────────────────── */
.cms-content ul,
.cms-content ol {
  margin: 0 0 20px;
  padding-left: 1.6em;
}

.cms-content ul { list-style: disc; }
.cms-content ol { list-style: decimal; }

.cms-content ul ul,
.cms-content ol ol,
.cms-content ul ol,
.cms-content ol ul {
  margin-bottom: 0;
  margin-top: 6px;
}

.cms-content li {
  margin-bottom: 6px;
  line-height: var(--cms-body-lh);
  color: var(--cms-body-col);
}

.cms-content li:last-child { margin-bottom: 0; }

/* Gutenberg list block */
.cms-content .wp-block-list {
  margin: 0 0 20px;
}

/* ── Blockquote ───────────────────────────────────────────────────────────── */
.cms-content blockquote,
.cms-content .wp-block-quote {
  border-left: 3px solid var(--cms-bq-border);
  background: var(--cms-bq-bg);
  padding: 16px 20px 16px 22px;
  margin: 28px 0;
  border-radius: 0 6px 6px 0;
  font-style: italic;
  color: var(--cms-bq-col);
}

.cms-content blockquote p,
.cms-content .wp-block-quote p {
  margin-bottom: 0;
  font-size: 1.05em;
  line-height: 1.65;
  color: inherit;
}

.cms-content blockquote cite,
.cms-content .wp-block-quote cite,
.cms-content .wp-block-quote .wp-block-quote__citation {
  display: block;
  font-size: 13px;
  font-style: normal;
  font-weight: 600;
  color: var(--cms-meta-col);
  margin-top: 10px;
}

.cms-content blockquote cite::before,
.cms-content .wp-block-quote cite::before {
  content: "— ";
}

/* Pull quote */
.cms-content .wp-block-pullquote {
  border-top: 3px solid var(--cms-bq-border);
  border-bottom: 3px solid var(--cms-bq-border);
  padding: 24px 0;
  margin: 32px 0;
  text-align: center;
  background: none;
}

.cms-content .wp-block-pullquote p {
  font-size: 1.2em;
  font-style: italic;
  font-weight: 600;
  color: var(--cms-heading-col);
  line-height: 1.4;
  margin-bottom: 0;
}

/* ── Horizontal rule ──────────────────────────────────────────────────────── */
.cms-content hr,
.cms-content .wp-block-separator {
  border: none;
  height: 1px;
  background: var(--cms-border-col);
  margin: 36px 0;
}

.cms-content .wp-block-separator.is-style-dots {
  background: none;
  height: auto;
  text-align: center;
  color: var(--cms-meta-col);
}

.cms-content .wp-block-separator.is-style-dots::before {
  content: "· · ·";
  font-size: 18px;
  letter-spacing: 0.5em;
}

/* ── Images ───────────────────────────────────────────────────────────────── */
.cms-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
}

/* WordPress alignment classes */
.cms-content .alignleft {
  float: left;
  margin: 4px 24px 16px 0;
  max-width: 46%;
}

.cms-content .alignright {
  float: right;
  margin: 4px 0 16px 24px;
  max-width: 46%;
}

.cms-content .aligncenter {
  float: none;
  margin: 20px auto;
}

.cms-content figure {
  margin: 24px 0;
}

.cms-content figure img {
  width: 100%;
}

.cms-content figcaption,
.cms-content .wp-block-image figcaption {
  font-size: 13px;
  color: var(--cms-meta-col);
  text-align: center;
  margin-top: 8px;
  line-height: 1.5;
  font-style: italic;
}

/* Gutenberg image block */
.cms-content .wp-block-image {
  margin: 24px 0;
}

.cms-content .wp-block-image img {
  border-radius: 8px;
  max-width: 100%;
  height: auto;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */

/* Wrapper div for overflow-x scrolling on mobile */
.cms-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
}

.cms-content .wp-block-table,
.cms-content figure.wp-block-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 24px 0;
  border-radius: var(--cms-table-radius);
  border: 1px solid var(--cms-table-border);
}

/* Gutenberg table: border is on the figure wrapper */
.cms-content .wp-block-table table {
  border: none;
  margin: 0;
}

.cms-content table th,
.cms-content table td {
  padding: 10px 14px;
  text-align: left;
  border: 1px solid var(--cms-table-border);
  vertical-align: top;
  color: var(--cms-body-col);
}

.cms-content table th {
  background: var(--cms-table-head-bg);
  font-weight: 600;
  font-size: 13px;
  color: var(--cms-table-head-col);
  white-space: nowrap;
}

.cms-content table tbody tr:nth-child(even) td {
  background: var(--cms-table-row-alt);
}

/* Classic editor standalone table needs overflow wrapper */
.cms-content > table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--cms-table-radius);
  border: 1px solid var(--cms-table-border);
}

/* ── Code – inline ────────────────────────────────────────────────────────── */
.cms-content code {
  font-family: 'Fira Code', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
  font-size: 0.875em;
  background: var(--cms-code-bg);
  color: var(--cms-code-col);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--cms-code-border);
  word-break: break-all;
}

/* ── Code – block (pre) ───────────────────────────────────────────────────── */
.cms-content pre {
  background: var(--cms-pre-bg);
  color: var(--cms-pre-col);
  padding: 18px 20px;
  border-radius: var(--cms-pre-radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  font-size: 14px;
  line-height: 1.65;
  margin: 24px 0;
  tab-size: 2;
}

/* pre > code: reset inline code styles */
.cms-content pre code {
  background: none;
  color: inherit;
  padding: 0;
  border: none;
  border-radius: 0;
  font-size: inherit;
  word-break: normal;
}

/* Gutenberg code block */
.cms-content .wp-block-code {
  background: var(--cms-pre-bg);
  color: var(--cms-pre-col);
  border-radius: var(--cms-pre-radius);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 24px 0;
  border: none;
}

.cms-content .wp-block-code code {
  background: none;
  color: inherit;
  padding: 0;
  border: none;
  font-size: 14px;
  line-height: 1.65;
  word-break: normal;
}

/* ── Embed / iFrame media ─────────────────────────────────────────────────── */
.cms-content .wp-block-embed,
.cms-content .wp-video,
.cms-content .wp-audio {
  margin: 24px 0;
}

.cms-content .wp-block-embed__wrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  border-radius: 8px;
}

.cms-content .wp-block-embed__wrapper iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ── Buttons (Gutenberg button block) ────────────────────────────────────── */
.cms-content .wp-block-buttons {
  margin: 24px 0;
}

.cms-content .wp-block-button__link {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  background: var(--cms-link-col);
  color: #ffffff;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.18s ease;
}

.cms-content .wp-block-button__link:hover {
  opacity: 0.85;
  color: #ffffff;
}

.cms-content .wp-block-button.is-style-outline .wp-block-button__link {
  background: transparent;
  color: var(--cms-link-col);
  border: 2px solid var(--cms-link-col);
}

/* ── WordPress notices / callouts ────────────────────────────────────────── */
.cms-content .wp-block-details {
  margin: 20px 0;
  padding: 14px 16px;
  border: 1px solid var(--cms-border-col);
  border-radius: 8px;
}

.cms-content .wp-block-details summary {
  font-weight: 600;
  cursor: pointer;
  color: var(--cms-heading-col);
  font-size: 15px;
}

/* ── Spacer ───────────────────────────────────────────────────────────────── */
.cms-content .wp-block-spacer {
  display: block;
}

/* ── Clearfix — for float-aligned images ────────────────────────────────── */
.cms-content::after {
  content: '';
  display: table;
  clear: both;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1024px) {
  :root {
    --cms-sec-pad: 40px;
  }
}

@media (max-width: 640px) {
  :root {
    --cms-sec-pad: 28px;
  }

  .cms-hdr__title { font-size: 24px; }
  .cms-hdr__subtitle { font-size: 14px; }

  /* Float images become block on mobile */
  .cms-content .alignleft,
  .cms-content .alignright {
    float: none;
    max-width: 100%;
    margin: 16px 0;
  }

  .cms-content h2 { font-size: 20px; }
  .cms-content h3 { font-size: 18px; }
  .cms-content h4 { font-size: 16px; }

  .cms-content pre,
  .cms-content .wp-block-code {
    font-size: 13px;
    padding: 14px 16px;
  }

  .cms-content table th,
  .cms-content table td {
    padding: 8px 10px;
  }

  .cms-toc { padding: 14px 16px; }
}

@media (max-width: 480px) {
  .cms-hdr__title { font-size: 22px; }
  .cms-content { --cms-body-size: 15px; }
}

/* ==========================================================================
   Dark mode — explicit overrides
   Belt-and-suspenders: ensures text is readable even if typography.css
   color: var(--color-text) cascades in before cms-content specificity wins.
   ========================================================================== */

body.dark-mode .cms-content p { color: rgba(255,255,255,0.82); }

body.dark-mode .cms-content h1,
body.dark-mode .cms-content h2,
body.dark-mode .cms-content h3,
body.dark-mode .cms-content h4,
body.dark-mode .cms-content h5,
body.dark-mode .cms-content h6 { color: rgba(255,255,255,0.92); }

body.dark-mode .cms-content strong,
body.dark-mode .cms-content b { color: rgba(255,255,255,0.92); }

body.dark-mode .cms-content a { color: #60a5fa; }
body.dark-mode .cms-content a:hover { color: #93c5fd; }

body.dark-mode .cms-content li { color: rgba(255,255,255,0.82); }

body.dark-mode .cms-content figcaption,
body.dark-mode .cms-content .wp-block-image figcaption { color: rgba(255,255,255,0.45); }

body.dark-mode .cms-content blockquote,
body.dark-mode .cms-content .wp-block-quote { color: rgba(255,255,255,0.68); }

body.dark-mode .cms-content blockquote cite,
body.dark-mode .cms-content .wp-block-quote cite { color: rgba(255,255,255,0.55); }

body.dark-mode .cms-content .wp-block-pullquote p { color: rgba(255,255,255,0.92); }

body.dark-mode .cms-content table td { color: rgba(255,255,255,0.82); }
body.dark-mode .cms-content table th { color: rgba(255,255,255,0.90); }

body.dark-mode .cms-hdr__title { color: rgba(255,255,255,0.92); }
body.dark-mode .cms-hdr__subtitle { color: rgba(255,255,255,0.50); }
