/*
 * ui/common/css/site.css
 * ----------------------
 * Site chrome rendered by ../js/nav.js: header links, the Docs and Results menus, the paper footer,
 * the BibTeX block, the "Read the paper" / "View the code" buttons, and the brand header
 * shared by the results and docs pages. Colours are the tokens of theme.css.
 *
 * Load it after theme.css / base.css and before the page's own stylesheet, so a page can
 * restyle its header links (.site-link, .site-menu__button) to match its header. The Docs and
 * Results menus share the .site-menu classes (each also carries .docs-menu / .results-menu).
 */

/* Screen-reader-only text */
.site-sr {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ─── Header links (default look: quiet pills; pages override) ─────────────── */
.site-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.site-link,
.site-menu__button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--nav-border);
  border-radius: 6px;
  background: var(--nav-bg);
  color: var(--nav-fg);
  font: 500 0.875rem/1.3 var(--font-sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.site-link:hover,
.site-menu__button:hover,
.site-menu__button[aria-expanded="true"],
.site-link.active,
.site-menu__button.is-current {
  background: var(--nav-active-bg);
  border-color: var(--nav-active-border);
  color: var(--nav-active-fg);
  text-decoration: none;
}
.site-link:focus-visible,
.site-menu__button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
.site-links .site-link--strong { font-weight: 700; }
.site-link__icon { width: 12px; height: 12px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.8; }

/* ─── Docs / Results menus ──────────────────────────────────────────────────────────── */
.site-menu {
  position: relative;
  display: inline-flex;
}
.site-menu__caret {
  width: 13px; height: 13px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.15s;
}
.site-menu__button[aria-expanded="true"] .site-menu__caret { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .site-menu__caret { transition: none; } }

.site-menu__panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1000;
  width: max-content;
  min-width: 180px;
  max-width: calc(100vw - 16px);
  padding: 6px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  color: var(--text-primary);
  font-family: var(--font-sans);
  text-align: left;
}
.site-menu__panel[hidden] { display: none; }
.site-menu__list { list-style: none; margin: 0; padding: 0; }
/* High specificity on purpose: page rules like `.header-links a` must not restyle the items. */
.site-menu .site-menu__panel .site-menu__item {
  display: flex;
  align-items: baseline;
  margin: 0;
  padding: 9px 11px;
  border: 0;
  border-radius: calc(var(--radius-md) - 1px);
  background: transparent;
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.35;
  text-decoration: none;
  white-space: normal;
}
.site-menu .site-menu__panel .site-menu__item:hover,
.site-menu .site-menu__panel .site-menu__item:focus-visible {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  text-decoration: none;
}
.site-menu .site-menu__panel .site-menu__item:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.site-menu .site-menu__panel .site-menu__item[aria-current="page"] { background: var(--accent-soft); }
.site-menu__label { font-weight: 600; color: var(--text-primary); }
/* Playground ▾: chat needs the live backend; in demo / public mode its hint says so (nav.js) */
.site-menu__tag { margin-left: 8px; font-size: 0.72rem; font-weight: 600; color: var(--orange); text-transform: uppercase; letter-spacing: 0.4px; }

/* ─── Brand header (results/, docs/) ─────────────────────────────────────────── */
.site-header {
  background: var(--header-bg-brand);
  border-bottom: 1px solid var(--header-border);
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}
.site-header .brand {
  color: var(--header-fg);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.2px;
  text-decoration: none;
}
.site-header .brand:hover { color: var(--header-fg); text-decoration: none; }
.site-header .header-end { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.site-header .site-links { gap: 8px; }
.site-header .site-link,
.site-header .site-menu__button {
  padding: 6px 14px;
  border-color: transparent;
  background: var(--header-link-bg);
  color: var(--header-link-fg);
}
.site-header .site-link:hover,
.site-header .site-menu__button:hover,
.site-header .site-menu__button[aria-expanded="true"] {
  border-color: transparent;
  background: var(--header-link-bg-hover);
  color: var(--header-link-fg-active);
}
.site-header .site-link.active,
.site-header .site-menu__button.is-current {
  border-color: transparent;
  background: var(--header-link-bg-active);
  color: var(--header-link-fg-active);
}
@media (max-width: 720px) {
  /* brand + theme toggle on the first row, the links below */
  .site-header { padding: 12px 16px; }
  .site-header .header-end { display: contents; }
  .site-header .theme-toggle { order: 2; }
  .site-header .site-links { order: 3; flex-basis: 100%; gap: 6px; }
  .site-header .site-link,
  .site-header .site-menu__button { padding: 5px 10px; }
}

/* ─── "Read the paper" / "View the code" ─────────────────────────────────────── */
.cta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
}
.cta {
  /* Soft surface with a faint accent wash; on hover the gradient slides across (background-position). */
  --cta-from: var(--bg-secondary);
  --cta-to: color-mix(in srgb, var(--accent) 16%, var(--bg-secondary));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: 10px;
  background-color: var(--cta-from);
  background-image: linear-gradient(115deg, var(--cta-from) 0%, var(--cta-from) 45%, var(--cta-to) 100%);
  background-size: 230% 100%;
  background-position: 0% 50%;
  color: var(--accent-text);
  font: 600 0.92rem/1.3 var(--font-sans);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  transition: background-position 0.5s ease, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.cta:hover {
  background-position: 100% 50%;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.09);
  color: var(--accent-text);
  text-decoration: none;
  transform: translateY(-1px);
}
.cta--primary {
  --cta-from: color-mix(in srgb, var(--accent) 11%, var(--bg-secondary));
  --cta-to: color-mix(in srgb, var(--accent) 28%, var(--bg-secondary));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}
.cta--primary:hover { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); color: var(--accent-text); }
@media (prefers-reduced-motion: reduce) {
  .cta { transition: border-color 0.2s, box-shadow 0.2s; }
  .cta:hover { transform: none; }
}
.cta:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.cta svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cta-note { color: var(--text-secondary); font-size: 0.85rem; }

/* ─── Paper footer ───────────────────────────────────────────────────────────── */
.site-footer-host { display: block; }
.paper-footer {
  max-width: var(--footer-width, 1280px);  /* pages set --footer-width to their content width */
  margin: 32px auto 0;
  padding: 18px 24px 28px;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.55;
}
.paper-footer p { margin: 0; }
.paper-footer__title strong { color: var(--text-primary); font-weight: 600; }
.paper-footer__links { margin-top: 4px !important; }
.paper-footer__links a { color: var(--accent-text); text-decoration: none; overflow-wrap: anywhere; }
.paper-footer__links a:hover { text-decoration: underline; }
.paper-footer__sep { margin: 0 7px; color: var(--text-muted); }
.paper-footer__more { margin-top: 2px !important; color: var(--text-muted); font-size: 0.78rem; }
.paper-footer__more a { color: var(--accent-text); text-decoration: none; }
.paper-footer__more a:hover { text-decoration: underline; }
@media (max-width: 720px) { .paper-footer { padding: 16px 16px 24px; } }

/* ─── BibTeX block ───────────────────────────────────────────────────────────── */
.cite-block {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-inset);
  overflow: hidden;
}
.cite-block__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.cite-block__label { font: 600 0.78rem/1 var(--font-sans); letter-spacing: 0.4px; text-transform: uppercase; color: var(--text-secondary); }
.cite-block__status { flex: 1; min-width: 0; color: var(--text-secondary); font-size: 0.8rem; text-align: right; }
.cite-block__copy {
  padding: 5px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: 500 0.82rem/1.3 var(--font-sans);
  cursor: pointer;
}
.cite-block__copy:hover { background: var(--bg-tertiary); }
.cite-block__copy[data-state="copied"] { border-color: var(--green); color: var(--green); }
.cite-block__copy:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.cite-block__code {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  font: 0.8rem/1.55 var(--font-mono);
  color: var(--text-primary);
  background: transparent;
  white-space: pre-wrap;      /* wrap long fields on narrow screens; the copy is the exact entry */
  overflow-wrap: anywhere;
}
.cite-block__code code { font: inherit; background: none; padding: 0; }
.cite-block__code:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }

/* Results ▾: the secondary Beta entry (exploratory page, not a core tab) */
.site-menu__item--secondary { opacity: 0.8; font-style: italic; }
.site-menu__item--secondary .site-menu__tag { font-style: normal; color: var(--ink-3, currentColor); }

/* ─── Data mode: notices and the Real / Synthetic switch (js/mode.js) ─────── */
.mode-notice {
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-left: 4px solid var(--orange);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font: 0.875rem/1.5 var(--font-sans);
}
.mode-notice .portal-link { color: var(--accent-text); font-weight: 600; }
[data-mode-notice][hidden] { display: none; }
.mode-switch { display: inline-flex; align-items: center; gap: 4px; font: 600 0.8rem/1.3 var(--font-sans); }
.mode-switch__label { margin-right: 4px; color: var(--header-link-fg, var(--text-secondary)); }
.mode-switch button {
  margin: 0; padding: 3px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: inherit;
  cursor: pointer;
}
.mode-switch button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--border-active); }
.mode-switch button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
@media (max-width: 720px) { .site-header [data-mode-switch] { order: 2; } }

/* ─── Portal ▾ (nav.js) ──────────────────────────────────────────────────── */
.portal-menu__panel { width: 360px; max-width: calc(100vw - 24px); padding: 16px; }
.portal-menu__group { margin: 0; padding: 0; border: 0; min-width: 0; }
.portal-menu__group + .portal-menu__group { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.portal-menu__group > legend, .portal-menu__heading { padding: 0; margin: 0 0 6px; font: 700 0.9rem/1.3 var(--font-sans); color: var(--text-primary); }
.portal-menu__text { margin: 4px 0; font: 0.82rem/1.45 var(--font-sans); color: var(--text-secondary); white-space: normal; }
.portal-menu__text code { font-family: var(--font-mono); font-size: 0.78rem; overflow-wrap: anywhere; }
.portal-menu__field { display: flex; gap: 6px; margin: 6px 0; }
.portal-menu__field input { flex: 1; min-width: 0; margin: 0; padding: 5px 8px; font: 0.85rem var(--font-mono); color: var(--text-primary); background: var(--bg-input); border: 1px solid var(--border-strong); border-radius: var(--radius-md); }
.portal-menu__field button, .portal-menu__clear { margin: 0; padding: 5px 10px; font: 600 0.82rem var(--font-sans); color: var(--text-primary); background: var(--bg-tertiary); border: 1px solid var(--border-strong); border-radius: var(--radius-md); cursor: pointer; }
.portal-menu__status { min-height: 1.2em; margin: 2px 0; font: 0.8rem/1.4 var(--font-sans); color: var(--text-secondary); }
.portal-menu .portal-menu__panel a.portal-menu__link { display: block; margin: 4px 0; padding: 6px 8px; border-radius: var(--radius-md); background: transparent; color: var(--accent-text); font: 600 0.88rem var(--font-sans); text-decoration: none; }
.portal-menu .portal-menu__panel a.portal-menu__link:hover, .portal-menu .portal-menu__panel a.portal-menu__link:focus-visible { background: var(--bg-tertiary); text-decoration: underline; }
.portal-menu__panel details summary { cursor: pointer; font: 600 0.82rem var(--font-sans); color: var(--accent-text); }
.portal-menu__panel input:focus-visible, .portal-menu__panel button:focus-visible, .portal-menu__panel summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.portal-menu__signed { font-weight: 700; color: var(--text-primary); }

/* Portal ▾: the sign-in card at the top, the backend connection below */
.portal-menu__card { padding: 14px 16px 12px; border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--border)); border-radius: var(--radius-md); background: color-mix(in srgb, var(--accent) 7%, var(--bg-secondary)); }
.portal-menu__card + .portal-menu__group { border-top: 0; padding-top: 0; }
.portal-menu__card-title { margin: 0 0 6px; font: 700 0.98rem/1.3 var(--font-sans); color: var(--text-primary); }
.portal-menu__benefits { margin: 6px 0 12px; padding-left: 18px; font: 0.82rem/1.5 var(--font-sans); color: var(--text-secondary); }
.portal-menu__benefits li + li { margin-top: 2px; }
.portal-menu .portal-menu__panel a.portal-menu__signin { display: flex; justify-content: center; align-items: center; min-height: 38px; padding: 8px 16px; border-radius: var(--radius-md); background: var(--accent); color: var(--on-accent, #fff); font: 600 0.92rem var(--font-sans); text-decoration: none; }
.portal-menu .portal-menu__panel a.portal-menu__signin:hover, .portal-menu .portal-menu__panel a.portal-menu__signin:focus-visible { background: var(--accent-hover, var(--accent)); text-decoration: none; }
.portal-menu__fine { margin: 8px 0 0; font: 0.75rem/1.4 var(--font-sans); color: var(--text-muted, var(--text-secondary)); text-align: center; }
.portal-menu__label { display: block; margin: 10px 0 0; font: 600 0.78rem/1.3 var(--font-sans); color: var(--text-primary); }
.portal-menu__group[data-portal-group="connect"] .portal-menu__field { margin: 4px 0 6px; }
.portal-menu .portal-menu__panel a.portal-menu__readme { display: inline-block; margin: 2px 0 0; padding: 4px 0; font-size: 0.84rem; }
.portal-menu .portal-menu__panel .portal-menu__signout { display: flex; justify-content: center; align-items: center; width: 100%; min-height: 36px; margin: 12px 0 0; padding: 7px 16px; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--bg-secondary); color: var(--text-primary); font: 600 0.88rem var(--font-sans); cursor: pointer; }
.portal-menu .portal-menu__panel .portal-menu__signout:hover { background: var(--bg-tertiary); }
.portal-menu .portal-menu__panel .portal-menu__signout:disabled { opacity: 0.6; cursor: progress; }
@media (pointer: coarse) { .portal-menu .portal-menu__panel a.portal-menu__signin, .portal-menu .portal-menu__panel .portal-menu__signout { min-height: 44px; } }
