/* Fulltrúinn — stylesheet. Hand-written; the from-scratch CSS engine (crates/css)
   will generate utility output alongside this via /utilities.css. */

:root {
  --bg: #0a0c11;
  --bg-2: #0f131b;
  --panel: #141925;
  --panel-2: #1a2030;
  --border: #232b3b;
  --fg: #e7ebf3;
  --muted: #8a93a8;
  --accent: #5b8cff;
  --accent-2: #8a6bff;
  --gold: #F0A500;
  --ok: #3ddc84;
  --warn: #f5b945;
  --info: #58b2ff;
  --danger: #ff6b6b;
  --radius: 14px;
  --shadow: 0 24px 60px -28px #000;
  /* extra tokens used by the vendored framework AI layer (chat + tool-ui) */
  --border-2: #2c3650;
  --dim: #5c647a;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(900px 480px at 80% -8%, #1b2236, transparent),
    radial-gradient(800px 420px at 0% 0%, #181433, transparent),
    var(--bg);
  color: var(--fg);
  font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

/* Nav */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-2) 80%, transparent);
  position: sticky; top: 0; backdrop-filter: blur(8px); z-index: 10;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 700; color: var(--fg); text-decoration: none;
  letter-spacing: -0.01em;
}
.brand-logo { width: 24px; height: 24px; flex-shrink: 0; }
.nav-links { display: flex; gap: 22px; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav-links a:hover { color: var(--fg); }

.container { max-width: 1040px; margin: 0 auto; padding: 0 24px 64px; }

/* Hero */
.hero { padding: 64px 0 36px; }
.hero-logo { margin-bottom: 8px; color: var(--fg); }
.hero h1 { margin: 0 0 10px; font-size: clamp(30px, 5vw, 52px); line-height: 1.1; letter-spacing: -0.03em; }
.lede { margin: 0 0 18px; color: var(--muted); font-size: 20px; max-width: 60ch; }

/* Status pill */
.status {
  display: inline-flex; align-items: center; gap: 9px; margin-top: 22px;
  padding: 8px 14px; border-radius: 999px; font-size: 14px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
}
.status.ok { color: var(--ok); border-color: #1d3a2a; }
.status.error { color: var(--danger); border-color: #4a2323; }
.status::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 22%, transparent);
}

/* 3-column grid (feature cards) */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* Cards */
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.card-icon { margin-bottom: 14px; }
.card h2 { margin: 0 0 2px; font-size: 20px; letter-spacing: -0.01em; }
.card h3 { margin: 0 0 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.card-sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

/* Alerts */
.alerts { display: grid; gap: 10px; margin: 8px 0 40px; }
.alert {
  padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel); font-size: 14px;
}
.alert strong { margin-right: 4px; }
.alert-success { border-color: #1d3a2a; background: color-mix(in srgb, var(--ok) 10%, var(--panel)); }
.alert-warning { border-color: #4a3a1a; background: color-mix(in srgb, var(--warn) 10%, var(--panel)); }
.alert-info { border-color: #1d3450; background: color-mix(in srgb, var(--info) 10%, var(--panel)); }
.alert-danger { border-color: #4a2323; background: color-mix(in srgb, var(--danger) 10%, var(--panel)); }

/* Table */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.table tbody tr:hover { background: var(--panel-2); }
.table td:first-child { font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--accent); }

/* Utility */
.muted { color: var(--muted); }
h2 { font-size: clamp(20px, 3vw, 28px); letter-spacing: -0.02em; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border); padding: 28px 24px;
  text-align: center; color: var(--muted); font-size: 13px;
}
.site-footer .muted { margin: 4px 0 0; opacity: .7; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 9px; padding: 12px 24px; border-radius: 10px; border: none;
  font: inherit; font-weight: 600; font-size: 16px; cursor: pointer;
  text-decoration: none; transition: opacity .15s, transform .1s, box-shadow .15s;
  -webkit-font-smoothing: antialiased;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .42; cursor: not-allowed; transform: none !important; }
.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 18px -4px color-mix(in srgb, var(--accent) 50%, transparent);
}
.btn-primary:hover {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent),
              0 6px 22px -4px color-mix(in srgb, var(--accent) 60%, transparent);
}
.btn-lg { padding: 15px 32px; font-size: 17px; border-radius: 12px; }

/* ── Phone frame ─────────────────────────────────────────── */
.phone-frame-wrap {
  display: flex; flex-direction: column; align-items: center;
  margin: 0 auto 32px; max-width: 300px;
}
.phone-frame {
  position: relative; width: 100%;
  aspect-ratio: 412 / 915;
  background: var(--panel); border: 2px solid var(--border);
  border-radius: 24px; overflow: hidden;
  /* Layered box-shadows to simulate phone bezel */
  box-shadow: 0 0 0 6px var(--bg-2), 0 0 0 8px var(--border), var(--shadow);
}
.phone-screenshot { display: none; width: 100%; height: 100%; object-fit: cover; }
.phone-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px;
}
.phone-step { margin-top: 10px; font-size: 12px; letter-spacing: .03em; }

/* Spinner animation inside the phone overlay */
.phone-spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Session section ─────────────────────────────────────── */
.session-section { margin-bottom: 40px; }

/* ── Approval card ───────────────────────────────────────── */
@keyframes pulse-border {
  0%, 100% { border-color: color-mix(in srgb, var(--gold) 35%, var(--border)); }
  50%       { border-color: var(--gold); }
}
.approval-card {
  background: color-mix(in srgb, var(--gold) 7%, var(--panel));
  border: 2px solid color-mix(in srgb, var(--gold) 35%, var(--border));
  border-radius: var(--radius);
  padding: 26px 24px;
  display: flex; align-items: flex-start; gap: 20px;
  margin-bottom: 32px;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--gold) 12%, transparent), var(--shadow);
  animation: pulse-border 2.2s ease-in-out infinite;
}
.approval-icon { padding-top: 2px; }
.approval-body { flex: 1; min-width: 0; }
.approval-headline {
  margin: 0 0 14px; font-size: 18px; font-weight: 600; line-height: 1.45;
  color: var(--fg);
}
.approval-code {
  display: inline-block; padding: 12px 22px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 10px;
  font-family: ui-monospace, "SF Mono", Menlo, "Cascadia Code", monospace;
  font-size: 30px; font-weight: 700; letter-spacing: .18em;
  color: var(--gold); margin-top: 4px;
  user-select: all; /* easy copy */
}

/* ── Message cards ───────────────────────────────────────── */
.messages-list { display: grid; gap: 16px; }
.message-card { padding: 20px 24px; }
.message-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 4px;
}
.message-subject { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.3; }
.message-date { font-size: 13px; white-space: nowrap; flex-shrink: 0; padding-top: 2px; }
.message-sender { margin: 0 0 14px; font-size: 13px; }
.message-body {
  font-size: 15px; line-height: 1.7;
  white-space: pre-wrap; word-break: break-word;
  color: var(--fg);
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 760px) {
  .grid-3 { grid-template-columns: 1fr; }
  .nav-links { display: none; }
  .hero { padding: 48px 0 24px; }
  .approval-card { flex-direction: column; gap: 14px; padding: 20px; }
  .approval-headline { font-size: 16px; }
  .approval-code { font-size: 26px; }
}

/* ============================================================================
   AI layer — vendored from AkurAI-Framework v0.7.0 (site/frontend/ai/* + the
   chat/tool-ui design-system selectors those modules rely on). Namespaced
   chat-* / toolui-* / tc-* so they never collide with the rest of the system.
   ========================================================================== */

.small { font-size: 13px; }

/* Supporting button + badge + code-block selectors the chat primitives use */
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-secondary { background: var(--panel-2); color: var(--fg); border: 1px solid var(--border-2); }
.btn-secondary:hover { background: #212a3d; opacity: 1; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--fg); font-size: 18px; line-height: 1;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-icon:hover { background: var(--panel-2); border-color: var(--border-2); opacity: 1; }
.btn-icon:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.btn-icon.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-icon.btn-ghost:hover { background: var(--panel-2); }
.btn-icon.btn-icon-sm { width: 32px; height: 32px; font-size: 15px; border-radius: 8px; }
.btn-icon > svg { width: 1em; height: 1em; display: block; }

.badge { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border); }
.badge-ok { color: var(--ok); border-color: #1d3a2a; background: color-mix(in srgb, var(--ok) 12%, transparent); }
.badge-muted { color: var(--muted); background: var(--panel-2); }

.code-block { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--bg-2); }
.code-block-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--border); }
.code-block-name { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.code-block code { font-family: var(--mono); font-size: 0.82rem; line-height: 1.6; color: var(--fg); }

/* Chat primitives ----------------------------------------------------------- */
.chat-root { display: flex; flex-direction: column; gap: 14px; }
.chat-thread {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), var(--bg-2)); overflow: hidden;
}
.chat-thread-viewport { height: clamp(320px, 56vh, 620px); overflow-y: auto; scroll-behavior: smooth; padding: 22px; }
.chat-thread-viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chat-thread-list { display: flex; flex-direction: column; gap: 18px; }
.chat-thread-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 240px; color: var(--muted); text-align: center; }
.chat-thread-empty.is-hidden { display: none; }
.chat-thread-empty-mark { font-size: 30px; color: var(--accent); opacity: 0.7; }
.chat-thread-tobottom { position: absolute; right: 16px; bottom: 16px; z-index: 2; background: var(--panel-2); border-color: var(--border-2); box-shadow: var(--shadow); }
.chat-thread-tobottom.is-hidden { display: none; }

.chat-message { display: flex; gap: 12px; align-items: flex-start; }
.chat-message-user { flex-direction: row-reverse; }
.chat-message-avatar { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--panel-2); border: 1px solid var(--border-2); color: var(--muted); }
.chat-message-assistant .chat-message-avatar { background: linear-gradient(180deg, var(--accent), #4577ec); color: #fff; border-color: transparent; }
.chat-message-body { min-width: 0; max-width: 80%; }
.chat-message-user .chat-message-body { text-align: right; }
.chat-message-role { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); margin-bottom: 5px; }
.chat-message-content { display: inline-block; text-align: left; padding: 11px 14px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border); color: var(--fg); line-height: 1.55; overflow-wrap: anywhere; }
.chat-message-user .chat-message-content { background: color-mix(in srgb, var(--accent) 16%, var(--panel)); border-color: var(--border-2); }
.chat-message-system .chat-message-content { font-style: italic; color: var(--muted); }
.chat-message-content > :first-child { margin-top: 0; }
.chat-message-content > :last-child { margin-bottom: 0; }
.chat-message-content p { margin: 0 0 8px; }
.chat-message-error .chat-message-content { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: color-mix(in srgb, var(--danger) 10%, var(--panel)); color: var(--fg); }
.chat-message-error-icon { color: var(--danger); font-weight: 700; }

.chat-md-h { margin: 12px 0 6px; font-size: 1.02em; line-height: 1.3; }
.chat-md-list { margin: 6px 0 8px; padding-left: 1.4em; }
.chat-md-list li { margin: 2px 0; }
.chat-md-quote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid var(--border-2); color: var(--muted); }
.chat-code-inline { font-family: var(--mono); font-size: 0.88em; padding: 1px 5px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); }
.chat-code-block { margin: 8px 0; padding: 12px 14px; border-radius: 10px; overflow-x: auto; background: var(--bg); border: 1px solid var(--border); font-family: var(--mono); font-size: 0.85em; line-height: 1.5; }
.chat-code-block code { font-family: inherit; }

.chat-cursor { display: inline-block; width: 7px; height: 1.05em; margin-left: 2px; vertical-align: text-bottom; background: var(--accent); border-radius: 2px; animation: chat-blink 1s steps(2, start) infinite; }
@keyframes chat-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .chat-cursor { animation: none; } }

.chat-toolcall { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; padding: 8px 12px; border-radius: 10px; font-size: 13px; color: var(--muted); background: color-mix(in srgb, var(--accent-2) 10%, var(--panel)); border: 1px dashed var(--border-2); }
.chat-toolcall-icon { color: var(--accent-2); }
.chat-toolcall code { font-family: var(--mono); color: var(--fg); }

.chat-actionbar { display: flex; gap: 4px; margin-top: 6px; opacity: 0; transition: opacity 0.12s; }
.chat-message-user .chat-actionbar { justify-content: flex-end; }
.chat-message:hover .chat-actionbar, .chat-actionbar:focus-within { opacity: 1; }
.chat-actionbar.is-hidden { display: none; }

.chat-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.chat-composer.is-disabled { opacity: 0.7; }
.chat-composer-input { flex: 1 1 auto; resize: none; min-height: 24px; max-height: 200px; padding: 8px 10px; border: none; outline: none; background: transparent; color: var(--fg); font: inherit; line-height: 1.5; }
.chat-composer-input::placeholder { color: var(--dim); }
.chat-composer-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.chat-composer-voice.is-listening { color: var(--danger); animation: chat-blink 1s infinite; }
.chat-composer-send { flex: none; }

/* Suggestions chips */
.toolui-suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.toolui-suggestion-chip { white-space: nowrap; }

/* toolui JSON fail-safe card */
.toolui-fallback h3 { margin: 0 0 6px; font-size: 15px; }

/* Page chrome + the inline island_session frame --------------------------- */
.chat-page { padding-top: 28px; }
.chat-intro { display: flex; align-items: center; gap: 18px; margin: 8px 0 22px; }
.chat-intro-logo { color: var(--fg); flex: none; }
.chat-intro-copy h1 { margin: 0 0 4px; font-size: clamp(24px, 4vw, 34px); line-height: 1.1; letter-spacing: -0.02em; }
.chat-intro-copy .muted { margin: 0; font-size: 15px; max-width: 60ch; }
.chat-intro-copy .status { margin-top: 12px; }
.chat-suggestions { margin-top: 2px; }
.chat-privacy { font-size: 12.5px; margin: 18px auto 0; max-width: 70ch; text-align: center; opacity: .85; }

.island-session { padding: 18px; margin-top: 12px; display: grid; gap: 14px; }
.island-session-head { display: flex; align-items: center; gap: 10px; }
.island-session-mark { color: var(--accent); display: inline-flex; }
.island-session-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.island-session-head .status { margin-top: 0; margin-left: auto; }
.island-session .phone-frame-wrap { margin: 0 auto 4px; }
.island-session .approval-card { margin-bottom: 0; }
.island-messages { margin: 0; }

@media (max-width: 760px) {
  .chat-intro { flex-direction: column; align-items: flex-start; gap: 12px; }
}
