/* ============================================================
   c-ai.chat — Global redesign layer
   Header height, theme-adaptive wordmark, dark-mode contrast,
   focus visibility, Cite buttons, table a11y, ad slots,
   mobile hub-content fix. Uses !important only to override
   Blocksy parent-theme rules.
   ============================================================ */

/* ---------- HEADER HEIGHT (was 140px / 90px) ---------- */
header.ct-header [data-row="middle"]{
  --minHeight:74px !important;
  min-height:74px !important;
  padding-top:8px !important; padding-bottom:8px !important;
}
header.ct-header [data-row="middle"] .ct-container{ min-height:0 !important; }
header.ct-header{ border-bottom:1px solid var(--cai-border); }
@media (max-width:1180px){
  header.ct-header [data-row="middle"]{
    --minHeight:62px !important; min-height:62px !important;
    padding-top:6px !important; padding-bottom:6px !important;
  }
}
/* reserve space for the theme toggle so it never shifts the header */
.ct-header [data-id="cai-theme-toggle"], .cai-theme-toggle{ min-width:44px; min-height:44px; }

/* ---------- THEME-ADAPTIVE HTML WORDMARK ---------- */
.cai-wordmark{
  display:inline-flex; align-items:center; gap:9px; text-decoration:none; line-height:1;
  font-family:var(--cai-font-sans); font-weight:800; font-size:22px; letter-spacing:-.02em;
  color:var(--cai-ink);
}
.cai-wordmark:hover,.cai-wordmark:focus{ color:var(--cai-ink); }
.cai-wordmark__dot{ width:9px; height:9px; border-radius:50%; background:var(--cai-cyan); flex:0 0 auto; }
.cai-wordmark__text{ color:currentColor; }
@media (max-width:1180px){ .cai-wordmark{ font-size:20px; } }

/* ---------- FOCUS VISIBILITY (both themes) ---------- */
a:focus-visible,button:focus-visible,[tabindex]:focus-visible,summary:focus-visible,
input:focus-visible,select:focus-visible,.cai-copy-cite:focus-visible{
  outline:2.5px solid var(--cai-focus) !important; outline-offset:2px; border-radius:4px;
}

/* ---------- DARK-MODE CONTRAST REPAIRS ---------- */
html[data-theme="dark"] .entry-content,
html[data-theme="dark"] p{ color:var(--cai-text); }
html[data-theme="dark"] figcaption,
html[data-theme="dark"] .wp-element-caption,
html[data-theme="dark"] small,
html[data-theme="dark"] .cai-muted,
html[data-theme="dark"] time{ color:var(--cai-muted); }
/* footer links legible in dark */
html[data-theme="dark"] .ct-footer a,
html[data-theme="dark"] footer a{ color:var(--cai-text); }
html[data-theme="dark"] .ct-footer a:hover,
html[data-theme="dark"] footer a:hover{ color:var(--cai-accent-hover); }

/* ---------- CITE BUTTONS (.cai-copy-cite) ---------- */
.cai-copy-cite{
  display:inline-flex; align-items:center; gap:6px;
  min-height:36px; padding:7px 14px;
  font-family:var(--cai-font-sans); font-size:14px; font-weight:600; line-height:1;
  color:var(--cai-accent); background:var(--cai-accent-soft);
  border:1px solid color-mix(in srgb,var(--cai-accent) 30%,transparent);
  border-radius:var(--cai-radius-sm); cursor:pointer;
  transition:background .15s ease,border-color .15s ease,color .15s ease;
}
.cai-copy-cite:hover{ background:color-mix(in srgb,var(--cai-accent) 14%,var(--cai-surface)); border-color:var(--cai-accent); }
.cai-copy-cite[aria-pressed="true"],.cai-copy-cite.is-copied{ color:var(--cai-success); border-color:var(--cai-success); }
.cai-copy-cite:disabled{ opacity:.55; cursor:default; }
@media (max-width:600px){ .cai-copy-cite{ min-height:44px; padding:11px 16px; } }

/* ---------- TABLE ACCESSIBILITY ---------- */
.cai-table-scroll{ overflow-x:auto; -webkit-overflow-scrolling:touch; max-width:100%; }
.cai-table-scroll:focus-visible{ outline:2.5px solid var(--cai-focus); outline-offset:2px; }
.cai-table-hint{
  display:block; font-family:var(--cai-font-sans); font-size:13px; color:var(--cai-muted);
  margin:0 0 6px; font-style:normal;
}
.cai-table-hint::before{ content:"↔ "; color:var(--cai-accent); }
/* sticky first column surface follows theme */
.wp-block-table td:first-child[style*="position: sticky"],
.cai-table-scroll th[scope="row"]{ background:var(--cai-surface); }

/* ---------- AD SLOTS: label + reserved height, breathing room ---------- */
/* scoped to content containers so a structural element (body/main wrapper)
   can never be styled even if mistakenly tagged — defense in depth for the
   enhanceAds() body-tagging bug fixed in redesign-enhance.js */
.entry-content .cai-ad-slot, .page-description .cai-ad-slot, main .cai-ad-slot{ margin:48px auto; text-align:center; min-height:120px; }
.cai-ad-slot > .cai-ad-label{
  display:block; font-family:var(--cai-font-sans); font-size:11px; letter-spacing:.08em;
  text-transform:uppercase; color:var(--cai-muted); margin-bottom:6px;
}
ins.adsbygoogle{ display:block; }
/* keep ads from causing horizontal overflow */
.adsbygoogle,ins.adsbygoogle{ max-width:100%; overflow:hidden; }

/* ---------- CRITICAL: hub editorial intro hidden on mobile ---------- */
/* Blocksy sets description_visibility.mobile => false, adding .ct-hidden-sm to
   the archive .page-description. The content is in the DOM (indexable) but
   display:none for phone users. Restore visibility at the child level. */
@media (max-width:689.98px){
  .entry-header .page-description.ct-hidden-sm,
  .hero-section .page-description.ct-hidden-sm{ display:block !important; }
}

/* ---------- ARCHIVE: avoid double padding/border ---------- */
/* Spec: .archive .hero-section and nested .entry-header both received padding+border.
   Apply spacing once, on the outer hero-section only. */
.archive .entry-header{ padding-top:0 !important; padding-bottom:0 !important; border:0 !important; }

/* ---------- NAV: external "Open official Claude" action ---------- */
.cai-nav-openclaude > a{
  display:inline-flex !important; align-items:center; gap:6px;
  background:var(--cai-accent); color:#fff !important; border-radius:var(--cai-radius-sm);
  padding:8px 15px !important; font-weight:600;
}
.cai-nav-openclaude > a:hover{ background:var(--cai-accent-hover); color:#fff !important; }
.cai-nav-openclaude > a::after{ content:"\2197"; font-size:.9em; }
html[data-theme="dark"] .cai-nav-openclaude > a{ color:#04212a !important; background:var(--cai-accent); }
/* dropdown surface follows theme */
html[data-theme="dark"] .ct-header .sub-menu,
html[data-theme="dark"] .ct-header ul.sub-menu{ background:var(--cai-surface) !important; border-color:var(--cai-border) !important; }
