/* Iridex wiki — a real documentation site layout (sidebar + content + "on
   this page" TOC + a search overlay), matching the aboutcapy-wiki pattern
   rather than reusing the marketing site's header/hero/footer chrome. */

body { overflow-x: hidden; }

/* ---------------------------------------------------------------- loader -- */
body.site-loading { overflow: hidden; }
.site-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.28s var(--ease-out);
}
.site-loader.is-hidden { opacity: 0; pointer-events: none; }
.site-loader-inner { display: grid; justify-items: center; gap: 0.8rem; }
.site-loader-ring {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-hi);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
.site-loader-text {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- layout -- */
.wiki-layout { display: flex; min-height: 100vh; flex: 1; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 272px;
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 2.2rem 1.3rem 1.5rem;
  border-right: 1px solid var(--border);
  background: var(--bg-subtle);
  overflow-y: auto;
}
.sidebar h3 {
  margin: 0 0 1.3rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.sidebar h3::before { content: "// "; color: var(--text-faint); }
.sidebar nav { display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar nav a {
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.16s var(--ease-out), background-color 0.16s var(--ease-out);
}
.sidebar nav a:hover { color: var(--text); background: var(--surface); }
.sidebar nav a.active { color: var(--text-bright); background: var(--surface-alt); font-weight: 600; }
.sidebar-footer { margin-top: auto; padding-top: 1.1rem; border-top: 1px solid var(--border); }
.sidebar-footer a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
}
.sidebar-footer a::before { content: "← "; }
.sidebar-footer a:hover { color: var(--text-bright); }

.content { flex: 1; min-width: 0; max-width: 860px; padding: 3.4rem 3rem 6rem; }

/* ------------------------------------------------------------------ toc -- */
.wiki-toc { margin: 1.5rem 0 0; padding-top: 1.1rem; border-top: 1px solid var(--border); }
.wiki-toc-label {
  display: block;
  margin-bottom: 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.wiki-toc ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.1rem; }
.wiki-toc a {
  display: block;
  padding: 0.3rem 0.65rem;
  border-left: 2px solid transparent;
  font-size: 0.82rem;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.16s var(--ease-out), border-color 0.16s var(--ease-out);
}
.wiki-toc a:hover { color: var(--text); }
.wiki-toc a.is-active { color: var(--text-bright); border-left-color: var(--accent); }

/* ----------------------------------------------------------------- type -- */
.content h1 {
  margin: 0 0 1.05rem;
  font-size: clamp(1.9rem, 4vw, 2.75rem);
  letter-spacing: -0.025em;
  line-height: 1.08;
}
.content h2 {
  margin: 2.8rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.4rem;
  scroll-margin-top: 1.4rem;
}
.content h3 { margin: 1.8rem 0 0.6rem; font-size: 1.08rem; }
.content p { color: var(--text-muted); margin: 0 0 1.1rem; }
.content ul, .content ol { color: var(--text-muted); padding-left: 1.25rem; margin: 0 0 1.4rem; }
.content li { margin-bottom: 0.45rem; }
.content li strong, .content p strong { color: var(--text); font-weight: 600; }
.content a:not(.btn) {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--border-hi);
  text-underline-offset: 3px;
  transition: text-decoration-color 0.16s var(--ease-out);
}
.content a:not(.btn):hover { text-decoration-color: var(--accent); }

/* ---------------------------------------------------------------- badge -- */
.command-card h3 { margin: 0; font-family: var(--font-mono); font-size: 1rem; font-weight: 500; color: var(--text-bright); }
.command-card > p { color: var(--text-muted); margin: 0.4rem 0 0; }
.command-card { padding: 1.3rem 1.4rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 1rem; scroll-margin-top: 1.4rem; }
.category-section { margin-bottom: 2.6rem; }
.category-section h2 { display: flex; align-items: center; gap: 0.8rem; }

/* --------------------------------------------------------------- tables -- */
table { width: 100%; border-collapse: collapse; margin: 1rem 0 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; font-size: 0.88rem; }
th, td { padding: 0.7rem 0.85rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-alt); font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-dim); font-weight: 600; }
td { color: var(--text-muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface); }
.hint { font-family: var(--font-mono); }

/* ----------------------------------------------------------------- hub -- */
.hub-wrapper { max-width: 1040px; margin: 0 auto; padding: clamp(3rem, 8vw, 5.5rem) 1.5rem 5rem; flex: 1; width: 100%; }
.hub-header { margin-bottom: 2.8rem; }
.hub-header h1 { margin: 0 0 0.75rem; font-size: clamp(2.1rem, 5.4vw, 3.3rem); letter-spacing: -0.03em; }
.hub-header p { color: var(--text-muted); margin: 0; max-width: 56ch; }
.hub-kicker {
  display: flex; align-items: center; gap: 0.7rem;
  margin: 0 0 1rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.hub-kicker::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--border), transparent); }
.hub-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.1rem; margin-bottom: 2.6rem; }
.portal-card {
  display: flex; flex-direction: column;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  transition: transform 0.22s var(--ease-out), border-color 0.22s var(--ease-out), background-color 0.22s var(--ease-out), box-shadow 0.22s var(--ease-out);
}
.portal-card:hover { transform: translateY(-3px); border-color: var(--border-hi); background: var(--surface-alt); box-shadow: var(--shadow-lg); }
.portal-card h2 { margin: 0 0 0.5rem; font-size: 1.28rem; }
.portal-card p { color: var(--text-muted); margin: 0 0 1.3rem; flex: 1; font-size: 0.93rem; }
.portal-card .card-link { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text); }
.portal-card .card-link::after { content: " →"; color: var(--text-dim); }

.hub-section { margin-bottom: 2.4rem; padding: 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.hub-section h2 { margin: 0 0 0.4rem; font-size: 1.2rem; }
.hub-section > p.text-muted { margin-top: -4px; }

.category-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.category-pill {
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  background: var(--surface-alt);
  border: 1px solid var(--border-hi);
  padding: 7px 16px;
  border-radius: var(--radius-full);
  transition: border-color 0.2s var(--ease-out), color 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.category-pill:hover { border-color: var(--accent); color: var(--text-bright); transform: translateY(-2px); }

/* ================= SITE FOOTER ================= */
/* Shared with homepage/dashboard — same markup, same classes, so the hub page
   reads as part of the same product instead of a standalone doc site. */
.site-footer {
  margin-top: auto;
  width: 100%;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.012);
}
:root[data-theme="light"] .site-footer { background: rgba(0, 0, 0, 0.012); }
.footer-grid {
  max-width: 1160px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.6fr repeat(3, minmax(0, 1fr));
  gap: 2rem;
  padding: 2.5rem 1.5rem 1.5rem;
}
.footer-brand-row { display: flex; align-items: center; gap: 9px; }
.footer-brand strong { font-family: var(--font-mono); font-size: 1.05rem; color: var(--text-bright); }
.footer-brand p { color: var(--text-muted); margin-top: 0.75rem; max-width: 34ch; font-size: 0.94rem; }
.footer-col { display: flex; flex-direction: column; align-items: flex-start; gap: 0.4rem; }
.footer-col h4 {
  font-family: var(--font-mono);
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-weight: 500;
}
.footer-col a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.94rem;
  padding: 3px 0;
  transition: color 0.16s var(--ease-out);
}
.footer-col a:hover { color: var(--text-bright); }
.footer-disclaimer {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 820px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

/* ------------------------------------------------------ header controls -- */
.wiki-search-launch, .wiki-theme-toggle {
  position: fixed;
  top: 1rem;
  z-index: 1001;
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.16s var(--ease-out), border-color 0.16s var(--ease-out), background-color 0.16s var(--ease-out);
}
.wiki-search-launch { right: 1rem; }
.wiki-theme-toggle { right: 3.4rem; }
.wiki-search-launch:hover, .wiki-theme-toggle:hover { color: var(--text-bright); border-color: var(--border-hi); background: var(--surface-alt); }
.wiki-search-icon, .wiki-theme-icon { width: 17px; height: 17px; }

/* --------------------------------------------------------------- search -- */
.wiki-search-backdrop {
  position: fixed; inset: 0; z-index: 1002;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
:root[data-theme="light"] .wiki-search-backdrop { background: rgba(10, 10, 12, 0.28); }
.wiki-search-panel {
  position: fixed; top: 4.1rem; right: 1rem; z-index: 1003;
  width: min(560px, calc(100vw - 2rem));
  padding: 0.9rem;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  box-shadow: var(--shadow-xl);
}
.wiki-search-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.7rem; }
.wiki-search-panel-head strong {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
}
.wiki-search-close {
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  cursor: pointer;
}
.wiki-search-close:hover { color: var(--text-bright); border-color: var(--border-hi); }
.wiki-search-input {
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.92rem;
}
.wiki-search-input::placeholder { color: var(--text-faint); }
.wiki-search-input:focus { outline: none; border-color: var(--accent); }
.search-hint { margin: 0.5rem 0 0; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-faint); }
.kbd-hint { padding: 0.1rem 0.35rem; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); font-family: var(--font-mono); font-size: 0.9em; }
.search-results { margin-top: 0.7rem; max-height: 340px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.search-results a { display: block; padding: 0.7rem 0.85rem; border-bottom: 1px solid var(--border); text-decoration: none; }
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover { background: var(--surface-alt); }
.search-title { display: block; font-size: 0.9rem; font-weight: 600; color: var(--text-bright); margin-bottom: 0.15rem; }
.search-meta { display: block; font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-dim); }
.search-empty { padding: 0.85rem; font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-dim); }

/* ------------------------------------------------------------------ 404 -- */
.error-page { display: grid; place-items: center; text-align: center; min-height: 100vh; padding: 2rem; flex: 1; width: 100%; }
.error-card { width: min(520px, 100%); padding: 2.5rem 2.1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); }
.error-code { margin: 0; font-family: var(--font-mono); font-size: clamp(3rem, 9vw, 4.6rem); font-weight: 700; letter-spacing: -0.03em; color: var(--text-dim); }
.error-title { margin: 0.4rem 0 0; font-size: clamp(1.4rem, 3vw, 1.9rem); }
.error-copy { margin: 0.7rem auto 0; max-width: 38ch; color: var(--text-muted); font-size: 0.96rem; }
.error-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.5rem; }
.error-actions a {
  padding: 0.55rem 1rem;
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.16s var(--ease-out), background-color 0.16s var(--ease-out), color 0.16s var(--ease-out);
}
.error-actions a:hover { border-color: var(--accent); background: var(--surface-alt); color: var(--text-bright); }

/* ----------------------------------------------------------- responsive -- */
@media (max-width: 980px) {
  .wiki-layout { flex-direction: column; }
  .sidebar { position: static; width: 100%; height: auto; padding: 1.1rem 1rem; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar h3 { text-align: center; margin-bottom: 0.8rem; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .sidebar-footer { margin-top: 0.9rem; text-align: center; }
  .wiki-toc { display: none; }
  .content { padding: 2.1rem 1.15rem 4rem; max-width: none; }
  .hub-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 620px) {
  .content h2 { margin-top: 2.1rem; font-size: 1.25rem; }
  th, td { padding: 0.6rem 0.7rem; font-size: 0.84rem; }
  .wiki-search-panel { top: 3.6rem; right: 0.6rem; width: calc(100vw - 1.2rem); }
  table { display: block; overflow-x: auto; }
}
