/* Ayra ix community — article layout + reading-companion chat panel */

/* Community pages set their own --accent/--accent2 pair; keep the primary CTA in that pair
   instead of shared.css's hardcoded teal second stop, which clashes on non-teal pages. */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}

.article-wrap {
  --prose-w: 780px;
  --chat-w: 340px;
  --article-gap: clamp(28px, 3vw, 52px);
  display: grid;
  grid-template-columns: 1fr min(var(--prose-w), calc(100% - var(--chat-w) - var(--article-gap))) var(--chat-w) 1fr;
  column-gap: var(--article-gap);
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: calc(var(--nav-h) + 48px) 0 80px;
  position: relative;
  z-index: 1;
  align-items: start;
}

article.post {
  grid-column: 2;
  min-width: 0;
  max-width: none;
}

.chat-rail {
  grid-column: 3;
  width: var(--chat-w);
  min-width: 0;
  position: relative;
}
.post-hero {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1200 / 630;
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-bottom: var(--space-6);
  object-fit: cover;
}
.post .eyebrow-line {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-mono);
  font-size: 11px; color: var(--accent);
  letter-spacing: 0.14em; text-transform: uppercase; font-weight: 500;
  margin-bottom: var(--space-5);
}
.post .eyebrow-line::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 8px var(--accent);
  flex-shrink: 0;
}
.post h1 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 4.4vw, 3.1rem);
  font-weight: 700; line-height: 1.08;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-5);
  background: linear-gradient(180deg, var(--text) 0%, color-mix(in srgb, var(--text) 82%, var(--accent)) 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.post .post-meta {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px; color: var(--muted); letter-spacing: 0.01em;
  margin-bottom: var(--space-10);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--border);
}
.post h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl); font-weight: 600;
  letter-spacing: -0.01em;
  margin: var(--space-12) 0 var(--space-5);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border);
  position: relative;
}
.post h2::before {
  content: ''; position: absolute; top: -1px; left: 0;
  width: 48px; height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.post > h2:first-of-type { border-top: none; padding-top: 0; margin-top: var(--space-8); }
.post p {
  font-size: 17px; color: var(--text2);
  line-height: 1.75;
  margin-bottom: var(--space-5);
}
.post ul, .post ol { margin: 0 0 var(--space-5) 1.2em; }
.post li { color: var(--text2); line-height: 1.75; padding: 4px 0; }
.post blockquote {
  position: relative;
  padding: var(--space-6) var(--space-8) var(--space-6) var(--space-8);
  margin: var(--space-8) 0;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 8%, transparent), color-mix(in srgb, var(--accent2) 4%, transparent));
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: -0.005em;
}
.post blockquote::before {
  content: '"';
  position: absolute; top: 2px; left: var(--space-6);
  font-family: var(--font-display); font-size: 3.2rem; font-weight: 700;
  line-height: 1; color: var(--accent); opacity: 0.35;
}

/* ── Article data viz: stat cards, bar charts, sparklines, comparison tables ── */
@keyframes barGrow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@media (prefers-reduced-motion: reduce) {
  .bar-fill { animation: none !important; }
}

.viz-block {
  position: relative;
  margin: var(--space-10) 0;
  padding: var(--space-6);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 20px 40px -24px rgba(0,0,0,0.5);
  overflow: hidden;
}
.viz-block::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2), transparent);
}
.viz-label {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: var(--space-2);
}
.viz-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: var(--text-base); color: var(--text); margin-bottom: var(--space-5);
  letter-spacing: -0.005em;
}
.viz-source {
  margin-top: var(--space-5);
  font-size: 12.5px; color: var(--muted); line-height: 1.6;
  border-top: 1px solid var(--border); padding-top: var(--space-4);
}
.viz-illustrative {
  display: inline-block; font-size: 9.5px; font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--border);
  border-radius: var(--radius-full); padding: 3px 9px; margin-left: 8px;
  vertical-align: middle;
}

.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4); margin: var(--space-8) 0;
}
.stat-card {
  position: relative;
  padding: var(--space-6) var(--space-5) var(--space-5);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 8%, transparent), rgba(255,255,255,0.015));
  transition: transform .25s cubic-bezier(.16,1,.3,1), border-color .25s, box-shadow .25s;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: var(--space-5); right: var(--space-5); height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  border-radius: var(--radius-full);
}
.stat-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  box-shadow: 0 16px 32px -16px color-mix(in srgb, var(--accent) 25%, transparent);
}
.stat-card .stat-num {
  font-family: var(--font-mono); font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 1.9rem; color: var(--accent); line-height: 1;
  margin-bottom: var(--space-3);
  letter-spacing: -0.01em;
}
.stat-card .stat-label {
  font-size: 13.5px; color: var(--text2); line-height: 1.55;
}
.stat-card .stat-src { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); margin-top: var(--space-3); }

.bar-list { display: flex; flex-direction: column; gap: var(--space-4); }
.bar-row { display: grid; grid-template-columns: 140px 1fr 56px; align-items: center; gap: var(--space-3); }
.bar-row .bar-name { font-size: 13.5px; color: var(--text2); }
.bar-track {
  height: 8px; border-radius: var(--radius-full);
  background: rgba(255,255,255,0.05); overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%; border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transform-origin: left;
  animation: barGrow .9s cubic-bezier(.16,1,.3,1) both;
}

/* Vertical trend — year-over-year scores */
.trend-chart {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(20px, 4vw, 40px);
  height: 180px;
  padding: 0 var(--space-2) var(--space-2);
  border-bottom: 1px solid var(--border);
}
.trend-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
  max-width: 120px;
  height: 100%;
  justify-content: flex-end;
}
.trend-bar {
  position: relative;
  width: 100%;
  max-width: 72px;
  height: calc(var(--h, 50%) * 1.55);
  max-height: 140px;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--accent2)));
  box-shadow: 0 8px 24px -8px color-mix(in srgb, var(--accent) 40%, transparent);
}
.trend-col--peak .trend-bar {
  background: linear-gradient(180deg, var(--accent2), var(--accent));
}
.trend-val {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  white-space: nowrap;
}
.trend-yr {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.trend-baseline {
  margin-top: var(--space-3);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* Side-by-side reader journey */
.flow-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}
.flow-path {
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.02);
}
.flow-path--old { border-color: color-mix(in srgb, #f38ba0 25%, var(--border)); }
.flow-path--new {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 6%, transparent), rgba(255,255,255,0.01));
}
.flow-path-head {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-4);
}
.flow-path--new .flow-path-head { color: var(--accent); }
.flow-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  counter-reset: flow;
}
.flow-steps li {
  position: relative;
  padding: 10px 0 10px 28px;
  font-size: 13.5px;
  color: var(--text2);
  line-height: 1.45;
  border-left: 1px dashed var(--border);
  margin-left: 8px;
}
.flow-steps li:first-child { padding-top: 0; }
.flow-steps li:last-child { border-left-color: transparent; padding-bottom: 0; }
.flow-steps li::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 14px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--bg, #0a0708);
}
.flow-path--new .flow-steps li::before { background: var(--accent); }
.flow-steps li.flow-dead {
  color: #f38ba0;
  font-weight: 500;
}
.flow-steps li.flow-dead::before { background: #f38ba0; }

/* Funnel — attrition through stages */
.funnel-viz {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.funnel-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: var(--w, 100%);
  max-width: 100%;
  min-width: 140px;
  padding: 12px 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 10%, transparent), rgba(255,255,255,0.02));
  font-size: 13.5px;
  color: var(--text2);
  transition: width .6s cubic-bezier(.16,1,.3,1);
}
.funnel-step span { color: var(--text); font-weight: 500; }
.funnel-step strong {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--accent);
}
.funnel-step:first-child { border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }

/* Stacked composition bar (parts of a whole) */
.stack-bar {
  display: flex;
  height: 14px;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: var(--space-5);
  border: 1px solid var(--border);
}
.stack-seg {
  height: 100%;
  background: var(--seg-color, var(--accent));
  opacity: var(--seg-opacity, 1);
}
.stack-legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-3);
}
.stack-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text2);
}
.stack-legend-item::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--seg-color, var(--accent));
  flex-shrink: 0;
}

/* Token routing split */
.split-bar {
  display: flex;
  height: 36px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin: var(--space-4) 0;
}
.split-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--bg, #0a0708);
}
.split-seg--local {
  flex: 8;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
}
.split-seg--frontier {
  flex: 2;
  background: rgba(255,255,255,0.12);
  color: var(--text2);
  border-left: 1px solid var(--border);
}
.split-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
}
.bar-row .bar-val {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 13px; font-weight: 600; color: var(--text); text-align: right;
}

.spark-wrap { display: flex; align-items: flex-end; gap: var(--space-2); }
.spark-wrap svg { flex: 1; overflow: visible; }
.spark-endlabels { display: flex; justify-content: space-between; margin-top: var(--space-3); }
.spark-endlabels span { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.spark-endlabels strong { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }

.cmp-table { width: 100%; border-collapse: collapse; font-size: 13.5px; border-radius: 12px; overflow: hidden; }
.cmp-table th, .cmp-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.cmp-table th { color: var(--muted); font-weight: 600; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; background: rgba(255,255,255,0.02); }
.cmp-table tbody tr { transition: background .15s; }
.cmp-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.cmp-table tbody tr:nth-child(even) { background: rgba(255,255,255,0.012); }
.cmp-table td { color: var(--text2); }
.cmp-table td:first-child { color: var(--text); font-weight: 500; }
.cmp-table tr:last-child td { border-bottom: none; }
.cmp-table .cell-bad { color: #f38ba0; }
.cmp-table .cell-good { color: var(--accent); font-weight: 500; }

/* ── Chat panel ── */
.chat-panel {
  position: sticky; top: calc(var(--nav-h) + 24px);
  display: flex; flex-direction: column;
  height: calc(100vh - var(--nav-h) - 48px);
  max-height: 720px;
  border: 1px solid rgba(251,146,60,0.18);
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(251,146,60,0.05), rgba(244,114,182,0.03)), var(--bg-elevated, rgba(255,255,255,0.02));
  backdrop-filter: blur(12px);
  overflow: hidden;
}
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.chat-head .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 10px var(--accent);
  flex-shrink: 0;
}
.chat-head .chat-title { font-weight: 600; font-size: var(--text-sm); }
.chat-head .chat-sub { font-size: var(--text-xs); color: var(--muted); }
.chat-user {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
}
.chat-user img { width: 26px; height: 26px; border-radius: 50%; }
.chat-user button {
  background: none; border: none; color: var(--muted);
  font-size: var(--text-xs); cursor: pointer; padding: 4px;
}
.chat-user button:hover { color: var(--text); }

.chat-log {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.chat-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(251,146,60,0.25), rgba(244,114,182,0.2));
  border: 1px solid rgba(251,146,60,0.3);
  color: var(--text);
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant {
  align-self: flex-start;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  color: var(--text2);
  border-bottom-left-radius: 4px;
}
.chat-msg.thinking { color: var(--muted); font-style: italic; }
.chat-note {
  text-align: center; font-size: var(--text-xs); color: var(--muted);
  padding: 4px 12px;
}

.chat-gate {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center;
}
.chat-gate p { font-size: var(--text-sm); color: var(--muted); max-width: 260px; line-height: var(--leading-relaxed); }
.google-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 11px 22px;
  border-radius: var(--radius-full);
  background: #fff; color: #1f1f1f;
  font-weight: 600; font-size: var(--text-sm);
  text-decoration: none;
  transition: transform .2s, box-shadow .2s;
}
.google-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(251,146,60,0.25); }
.google-btn svg { width: 18px; height: 18px; }

.chat-input-row {
  display: flex; gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.chat-input-row textarea {
  flex: 1; resize: none;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  padding: 10px 12px;
  min-height: 42px; max-height: 120px;
  outline: none;
}
.chat-input-row textarea:focus { border-color: rgba(251,146,60,0.4); }
.chat-send {
  align-self: flex-end;
  border: none; cursor: pointer;
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #fb923c, #f472b6);
  color: #0a0708; font-size: 16px; font-weight: 700;
  transition: opacity .2s, transform .2s;
}
.chat-send:hover { transform: translateY(-1px); }
.chat-send:disabled { opacity: .4; cursor: default; transform: none; }

/* ── Nav auth widget ── */
#authWidget { display: flex; align-items: center; gap: 8px; }
#authWidget img { width: 26px; height: 26px; border-radius: 50%; }
#authWidget span { font-size: var(--text-sm); color: var(--text2); }
#authWidget > button {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--muted); font-size: var(--text-xs);
  padding: 5px 12px; cursor: pointer;
}
#authWidget > button:hover { color: var(--text); border-color: var(--border-strong); }
.google-btn.google-btn-sm { padding: 7px 16px; font-size: var(--text-xs); }
.google-btn.google-btn-sm svg { width: 14px; height: 14px; }

/* Mobile: chat becomes a bottom sheet behind a floating button */
.chat-fab { display: none; }
@media (max-width: 980px) {
  .article-wrap {
    grid-template-columns: 1fr;
    padding: calc(var(--nav-h) + 48px) 20px 80px;
  }
  article.post { grid-column: 1; }
  .chat-rail { grid-column: 1; width: auto; }
  .flow-compare { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 1fr; gap: var(--space-2); }
  .bar-row .bar-val { text-align: left; }
  .chat-panel {
    position: fixed; inset: auto 0 0 0;
    height: 72vh; max-height: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(105%);
    transition: transform .35s cubic-bezier(.3,1,.4,1);
    z-index: 60;
    background: var(--bg-deep, #0a0708);
  }
  .chat-panel.open { transform: translateY(0); }
  .chat-fab {
    display: flex; align-items: center; gap: 8px;
    position: fixed; right: 18px; bottom: 18px; z-index: 59;
    padding: 13px 20px;
    border: none; border-radius: var(--radius-full);
    background: linear-gradient(135deg, #fb923c, #f472b6);
    color: #0a0708; font-weight: 700; font-size: var(--text-sm);
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(251,146,60,0.35);
  }
  .chat-close { display: block !important; }
}
.chat-close {
  display: none;
  background: none; border: none; color: var(--muted);
  font-size: 20px; cursor: pointer; padding: 0 4px;
}
