/*
 * AiGentsy Protocol — Shared Stylesheet
 * ======================================
 * Used by index.html, quickstart.html, console.html
 * Design tokens match existing hero page.
 */

/* ── Design Tokens ── */
:root {
  --bg: #05070e;
  --surface: #0a0d16;
  --s2: rgba(255,255,255,0.025);
  --bdr: rgba(255,255,255,0.06);
  --tx: rgba(255,255,255,0.88);
  --tx2: rgba(255,255,255,0.5);
  --tx3: rgba(255,255,255,0.22);
  --ac: #6366f1;
  --ac2: #06b6d4;
  --grn: #22c55e;
  --red: #ef4444;
  --warn: #f59e0b;
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'Outfit', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--tx); font-family: var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; }

/* ── Ambient effects ── */
.ambient { position: fixed; inset: 0; pointer-events: none; }
.ambient::before { content: ''; position: absolute; top: -300px; left: 50%; transform: translateX(-50%); width: 1100px; height: 600px; border-radius: 50%; background: radial-gradient(ellipse, rgba(99,102,241,0.05) 0%, transparent 70%); }
.ambient::after { content: ''; position: absolute; bottom: -200px; right: -100px; width: 600px; height: 400px; border-radius: 50%; background: radial-gradient(ellipse, rgba(6,182,212,0.03) 0%, transparent 70%); }
.grid-bg { position: fixed; inset: 0; pointer-events: none; opacity: 0.15; background-image: linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.012) 1px, transparent 1px); background-size: 72px 72px; }
.noise { position: fixed; inset: 0; pointer-events: none; opacity: 0.03; background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.top-line { height: 1px; background: linear-gradient(90deg, transparent 5%, var(--ac) 30%, var(--ac2) 70%, transparent 95%); opacity: 0.35; }

/* ── Nav ── */
nav { max-width: 1100px; margin: 0 auto; padding: 20px 32px; display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 10; }
.logo-row { display: flex; align-items: center; gap: 0; }
.logo-img { height: 160px; width: auto; filter: drop-shadow(0 0 16px rgba(0,191,255,0.4)) drop-shadow(0 0 32px rgba(0,191,255,0.15)); transition: filter .3s; }
.logo-img:hover { filter: drop-shadow(0 0 20px rgba(0,191,255,0.6)) drop-shadow(0 0 40px rgba(0,191,255,0.25)); }
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-link { font-size: 13px; color: var(--tx3); text-decoration: none; transition: color .2s; }
.nav-link:hover { color: var(--tx); }
.nav-login { font-size: 13px; color: var(--ac); text-decoration: none; font-weight: 500; }

/* ── Container ── */
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 32px; position: relative; z-index: 2; }

/* ── Hero ── */
.hero { text-align: center; padding: 80px 0 60px; max-width: 780px; margin: 0 auto; }
.hero-tag { display: inline-flex; align-items: center; gap: 8px; padding: 6px 16px; border-radius: 100px; background: rgba(99,102,241,0.06); border: 1px solid rgba(99,102,241,0.1); font-size: 12px; font-weight: 500; color: var(--ac); margin-bottom: 28px; opacity: 0; animation: up .6s ease-out .1s forwards; }
.hero-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--grn); animation: pulse 2s infinite; }
.hero h1 { font-family: var(--serif); font-size: clamp(40px,6vw,64px); font-weight: 400; line-height: 1.1; color: #fff; letter-spacing: -0.03em; margin-bottom: 24px; opacity: 0; animation: up .6s ease-out .2s forwards; }
.hero h1 em { font-style: italic; color: var(--ac); background: linear-gradient(135deg, #818cf8, #06b6d4); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero-sub { font-size: 18px; color: var(--tx2); line-height: 1.7; max-width: 560px; margin: 0 auto 40px; font-weight: 300; opacity: 0; animation: up .6s ease-out .3s forwards; }

/* ── How it works row ── */
.how-row { display: flex; justify-content: center; gap: 48px; margin-bottom: 60px; opacity: 0; animation: up .6s ease-out .4s forwards; }
.how-step { text-align: center; max-width: 180px; }
.how-num { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-size: 14px; font-weight: 600; margin: 0 auto 12px; background: rgba(99,102,241,0.08); color: var(--ac); }
.how-title { font-size: 14px; font-weight: 600; color: #fff; margin-bottom: 4px; }
.how-desc { font-size: 12px; color: var(--tx3); line-height: 1.5; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--bdr); border-radius: 14px; padding: 24px 20px; }
.card-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card-label { font-size: 12px; color: var(--tx3); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.card-value { font-size: 22px; font-weight: 600; color: #fff; font-family: var(--mono); }
.card-sub { font-size: 12px; color: var(--tx3); margin-top: 4px; }

/* ── Forms ── */
.form-block { max-width: 520px; margin: 0 auto; padding: 32px; background: var(--surface); border: 1px solid var(--bdr); border-radius: 18px; }
.form-title { font-size: 18px; font-weight: 600; color: #fff; text-align: center; margin-bottom: 20px; }
.form-row { margin-bottom: 12px; }
.form-label { font-size: 12px; color: var(--tx2); margin-bottom: 6px; display: block; }
.form-input { width: 100%; padding: 13px 18px; border-radius: 10px; border: 1px solid var(--bdr); background: rgba(255,255,255,0.025); color: #fff; font-family: var(--sans); font-size: 14px; outline: none; transition: border-color .2s; }
.form-input::placeholder { color: var(--tx3); }
.form-input:focus { border-color: rgba(99,102,241,0.25); }
select.form-input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; }
.form-check { display: flex; align-items: flex-start; gap: 10px; margin: 16px 0; }
.form-check input { width: 16px; height: 16px; accent-color: var(--ac); margin-top: 2px; flex-shrink: 0; }
.form-check label { font-size: 13px; color: var(--tx2); line-height: 1.4; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 24px; border: none; border-radius: 10px; font-family: var(--sans); font-size: 14px; font-weight: 600; color: #fff; cursor: pointer; transition: all .2s; text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, #6366f1, #4f46e5); box-shadow: 0 0 24px rgba(99,102,241,0.2), 0 4px 12px rgba(0,0,0,0.25); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 0 36px rgba(99,102,241,0.35), 0 6px 16px rgba(0,0,0,0.3); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-secondary { background: transparent; border: 1px solid var(--bdr); color: var(--tx2); }
.btn-secondary:hover { border-color: rgba(99,102,241,0.25); color: var(--tx); }
.btn-sm { padding: 8px 14px; font-size: 12px; border-radius: 8px; }
.btn-copy { background: rgba(99,102,241,0.08); color: var(--ac); border: 1px solid rgba(99,102,241,0.15); }
.btn-copy:hover { background: rgba(99,102,241,0.15); }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Trust signals ── */
.trust-bar { display: flex; justify-content: center; gap: 32px; flex-wrap: wrap; margin: 40px auto; max-width: 700px; }
.trust-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--tx3); }
.trust-link { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.trust-link:hover { color: var(--tx2); text-decoration: underline; }
.trust-subtle { text-align: center; font-size: 11px; color: var(--tx3); margin: -24px auto 32px; opacity: 0.7; }

/* ── API key display ── */
.key-display { background: rgba(0,0,0,0.4); border: 1px solid rgba(99,102,241,0.15); border-radius: 10px; padding: 16px; margin: 16px 0; font-family: var(--mono); font-size: 13px; word-break: break-all; }
.key-display .key-label { font-family: var(--sans); font-size: 11px; color: var(--tx3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.key-display .key-value { color: var(--ac); }
.key-display .key-agent-id { color: var(--ac2); margin-top: 8px; }
.key-display .key-last4 { color: var(--tx3); }
.key-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ── Expandable ── */
.expandable { border: 1px solid var(--bdr); border-radius: 12px; margin: 12px 0; overflow: hidden; }
.expandable-header { padding: 14px 18px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; background: var(--surface); font-size: 14px; font-weight: 500; color: var(--tx2); transition: color .2s; }
.expandable-header:hover { color: var(--tx); }
.expandable-header::after { content: '+'; font-size: 18px; color: var(--tx3); transition: transform .2s; }
.expandable.open .expandable-header::after { content: '-'; }
.expandable-body { display: none; padding: 16px 18px; border-top: 1px solid var(--bdr); }
.expandable.open .expandable-body { display: block; }

/* ── Code block ── */
pre.code-block { background: rgba(0,0,0,0.4); border: 1px solid var(--bdr); border-radius: 10px; padding: 16px; font-family: var(--mono); font-size: 12px; color: var(--tx2); overflow-x: auto; white-space: pre-wrap; word-break: break-all; line-height: 1.6; position: relative; }
pre.code-block .copy-btn { position: absolute; top: 8px; right: 8px; }

/* ── JSON viewer ── */
.json-view { background: rgba(0,0,0,0.4); border: 1px solid var(--bdr); border-radius: 10px; padding: 16px; font-family: var(--mono); font-size: 12px; color: var(--tx2); overflow-x: auto; white-space: pre-wrap; max-height: 400px; overflow-y: auto; }

/* ── Stepper (quickstart) ── */
.stepper { max-width: 700px; margin: 0 auto; }
.step { border: 1px solid var(--bdr); border-radius: 14px; margin-bottom: 16px; overflow: hidden; transition: border-color .2s; }
.step.active { border-color: rgba(99,102,241,0.25); }
.step.done { border-color: rgba(34,197,94,0.25); }
.step-header { padding: 18px 20px; display: flex; align-items: center; gap: 14px; background: var(--surface); cursor: pointer; }
.step-num { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; font-size: 14px; font-weight: 600; background: rgba(99,102,241,0.08); color: var(--ac); flex-shrink: 0; }
.step.done .step-num { background: rgba(34,197,94,0.1); color: var(--grn); }
.step-title { font-size: 15px; font-weight: 600; color: #fff; }
.step-status { margin-left: auto; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.step-status.pending { color: var(--tx3); }
.step-status.active { color: var(--ac); }
.step-status.done { color: var(--grn); }
.step-status.optional { color: var(--warn); }
.step-body { padding: 20px; border-top: 1px solid var(--bdr); display: none; }
.step.active .step-body, .step.done .step-body { display: block; }
.step-result { margin-top: 16px; }

/* ── Console layout ── */
.console-wrap { display: flex; min-height: 100vh; }
.console-sidebar { width: 280px; background: var(--surface); border-right: 1px solid var(--bdr); padding: 20px 0; overflow-y: auto; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.console-main { flex: 1; padding: 24px 32px; min-width: 0; }

/* ── Sidebar sections ── */
.sidebar-section { padding: 12px 20px; border-bottom: 1px solid var(--bdr); }
.sidebar-section:last-child { border-bottom: none; }
.sidebar-label { font-size: 10px; font-weight: 600; color: var(--tx3); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 8px; }
.sidebar-value { font-size: 14px; color: #fff; font-family: var(--mono); }
.sidebar-sub { font-size: 11px; color: var(--tx3); margin-top: 2px; }
.sidebar-agent-id { font-family: var(--mono); font-size: 12px; color: var(--ac2); word-break: break-all; }

/* ── OCS gauge ── */
.ocs-gauge { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin: 8px auto; position: relative; }
.ocs-gauge-value { font-size: 18px; font-weight: 700; color: #fff; font-family: var(--mono); }
.ocs-gauge-label { text-align: center; font-size: 11px; color: var(--tx3); margin-top: 4px; }

/* ── Tier badge ── */
.tier-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 100px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.tier-badge.elite { background: rgba(234,179,8,0.1); color: #eab308; }
.tier-badge.trusted { background: rgba(34,197,94,0.1); color: var(--grn); }
.tier-badge.standard { background: rgba(99,102,241,0.1); color: var(--ac); }
.tier-badge.probation { background: rgba(245,158,11,0.1); color: var(--warn); }
.tier-badge.restricted { background: rgba(239,68,68,0.1); color: var(--red); }

/* ── Badge list ── */
.badge-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 12px; }
.badge-icon { width: 20px; height: 20px; border-radius: 4px; display: grid; place-items: center; font-size: 10px; background: rgba(99,102,241,0.08); }
.badge-name { color: var(--tx2); }
.badge-boost { color: var(--grn); font-family: var(--mono); font-size: 11px; margin-left: auto; }

/* ── Tabs ── */
.tab-bar { display: flex; gap: 0; border-bottom: 1px solid var(--bdr); margin-bottom: 24px; overflow-x: auto; }
.tab { padding: 12px 20px; font-size: 13px; font-weight: 500; color: var(--tx3); cursor: pointer; border-bottom: 2px solid transparent; transition: all .2s; white-space: nowrap; }
.tab:hover { color: var(--tx2); }
.tab.active { color: var(--ac); border-bottom-color: var(--ac); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Search bar (console) ── */
.search-bar { display: flex; gap: 8px; margin-bottom: 20px; }
.search-bar .form-input { flex: 1; }

/* ── Status/latency ── */
.req-status { font-size: 11px; color: var(--tx3); font-family: var(--mono); margin-top: 8px; }
.req-status .latency { color: var(--ac2); }

/* ── Loading ── */
.loading { display: flex; align-items: center; gap: 8px; color: var(--tx3); font-size: 13px; padding: 20px 0; }
.loading::before { content: ''; width: 16px; height: 16px; border: 2px solid var(--bdr); border-top-color: var(--ac); border-radius: 50%; animation: spin .6s linear infinite; }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--surface); border: 1px solid var(--bdr); border-radius: 18px; padding: 32px; max-width: 440px; width: 90%; }
.modal-title { font-size: 18px; font-weight: 600; color: #fff; margin-bottom: 16px; text-align: center; }

/* ── API error banner ── */
.api-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 200; padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.api-banner--error { background: rgba(239,68,68,0.15); border-bottom: 1px solid rgba(239,68,68,0.25); color: var(--red); }
.api-banner--warn { background: rgba(245,158,11,0.15); border-bottom: 1px solid rgba(245,158,11,0.25); color: var(--warn); }
.api-banner button { background: none; border: 1px solid currentColor; color: inherit; padding: 4px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; }

/* ── Hero loop diagram ── */
.loop-diagram { display: flex; align-items: center; justify-content: center; gap: 0; margin: 40px auto; max-width: 700px; flex-wrap: wrap; opacity: 0; animation: up .6s ease-out .45s forwards; }
.loop-node { padding: 8px 16px; background: var(--surface); border: 1px solid var(--bdr); border-radius: 8px; font-size: 13px; font-weight: 500; color: #fff; white-space: nowrap; }
.loop-arrow { color: var(--tx3); font-size: 18px; padding: 0 8px; }
.loop-branch { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.loop-branch-label { font-size: 10px; color: var(--tx3); }

/* ── Footer ── */
.ftr { max-width: 1100px; margin: 0 auto; padding: 40px 32px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--bdr); position: relative; z-index: 2; }
.ftr-l { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--tx3); }
.ftr-r { font-size: 11px; color: var(--tx3); }

/* ── Links ── */
a { color: var(--ac); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Utilities ── */
.text-center { text-align: center; }
.text-mono { font-family: var(--mono); }
.text-muted { color: var(--tx3); }
.text-sm { font-size: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }

/* ── Animations ── */
@keyframes up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ── */
@media (max-width: 768px) {
  .hero { padding: 50px 0 40px; }
  .hero h1 { font-size: 32px; }
  .how-row { flex-direction: column; align-items: center; gap: 24px; }
  .loop-diagram { flex-direction: column; gap: 8px; }
  .loop-arrow { transform: rotate(90deg); }
  .trust-bar { flex-direction: column; align-items: center; gap: 12px; }
  nav { padding: 16px 20px; }
  .wrap { padding: 0 20px; }
  .console-wrap { flex-direction: column; }
  .console-sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--bdr); }
  .console-main { padding: 16px 20px; }
  .tab-bar { gap: 0; }
  .tab { padding: 10px 14px; font-size: 12px; }
  .card-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .form-block { padding: 20px; }
  .btn-group { flex-direction: column; }
  .search-bar { flex-direction: column; }
}
