/* Reusable component classes. All values read from tokens. */

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-sans);
  font-size: var(--type-label-md-size);
  font-weight: var(--type-label-md-weight);
  letter-spacing: 0.02em;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-default);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
  user-select: none;
}
.btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--action-primary);
  color: var(--action-primary-on);
  border-color: var(--action-primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--action-primary-hover);
  border-color: var(--action-primary-hover);
}
.btn-primary:active:not(:disabled) { transform: scale(0.98); }

.btn-secondary {
  background: transparent;
  color: var(--action-primary);
  border-color: var(--action-border);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--action-primary);
  background: var(--action-ghost);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.btn-danger {
  background: var(--state-flagged-bg);
  color: var(--state-flagged-text);
  border-color: var(--state-flagged-border);
}
.btn-danger:hover:not(:disabled) {
  background: var(--state-flagged-bg);
  border-color: var(--state-flagged-text);
}

.btn-block { width: 100%; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: var(--type-label-sm-size); }

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* ── INPUTS ── */
.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
textarea,
select {
  font-family: var(--font-sans);
  font-size: var(--type-body-md-size);
  font-weight: 400;
  line-height: var(--type-body-md-line);
  color: var(--text-primary);
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-default);
  padding: 0.625rem 0.875rem;
  outline: none;
  width: 100%;
  transition: var(--transition);
}
.input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
  border-color: var(--border-focus);
  background: var(--surface-card);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--action-primary) 12%, transparent);
}
input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}
textarea {
  resize: vertical;
  min-height: 88px;
}

.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field-help { font-size: var(--type-label-sm-size); color: var(--text-muted); }
.field-error { font-size: var(--type-label-sm-size); color: var(--state-flagged-text); }

/* ── CARDS ── */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}
.card-elevated {
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.card-title {
  font-family: var(--font-serif);
  font-size: var(--type-headline-md-size);
  margin-bottom: var(--space-1);
}
.card-subtitle {
  font-size: var(--type-label-sm-size);
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── CHIPS ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-sans);
  font-size: var(--type-label-sm-size);
  font-weight: var(--type-label-md-weight);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid currentColor;
  white-space: nowrap;
}
.chip-gold    { color: var(--gold-text);            border-color: var(--gold-border);            background: var(--gold-bg); }
.chip-active  { color: var(--state-cleared-text);   border-color: var(--state-cleared-border);   background: var(--state-cleared-bg); }
.chip-pending { color: var(--text-muted); border-color: var(--border-subtle); background: transparent; }
.chip-error   { color: var(--state-flagged-text); border-color: var(--state-flagged-border); background: var(--state-flagged-bg); }

/* ── BANNERS ── */
.banner {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
  background: var(--surface-card);
  color: var(--text-primary);
}
.banner-error {
  border-color: var(--state-flagged-border);
  background: var(--state-flagged-bg);
  color: var(--state-flagged-text);
}
.banner-info {
  border-color: var(--gold-border);
  background: var(--gold-bg);
  color: var(--gold-text);
}

/* ── EMPTY STATE ── */
.empty {
  text-align: center;
  padding: var(--space-6) var(--space-3);
  color: var(--text-muted);
}
.empty h3 {
  font-family: var(--font-serif);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}
.empty p { color: var(--text-muted); margin-bottom: var(--space-3); }

/* ── PRIVILEGE STAMP (brand mark) ── */
.privilege-stamp {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-sans);
  font-size: var(--type-label-sm-size);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-text);
  border: 1px solid var(--gold-border);
  padding: 4px 10px;
  border-radius: var(--radius-default);
  background: var(--gold-bg);
}

/* ── TOP NAV / HEADER ── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-rail);
  border-bottom: 1px solid var(--border-subtle);
}
.topnav-links {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.topnav-links a:not(.btn) {
  color: var(--text-muted);
  font-size: var(--type-label-md-size);
  font-weight: 500;
}
.topnav-links a:not(.btn):hover { color: var(--text-primary); }

/* ── SIDEBAR ── */
.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
.sidebar {
  background: var(--surface-rail);
  border-right: 1px solid var(--border-subtle);
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 0 var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-section h4 { margin-bottom: var(--space-1); }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-default);
  color: var(--text-muted);
  font-size: var(--type-body-md-size);
  transition: var(--transition);
}
.sidebar-link:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}
.sidebar-link.active {
  background: var(--gold-bg);
  color: var(--gold-text);
}

.main-content { padding: var(--space-3) var(--space-4); }
@media (max-width: 900px) {
  .main-content { padding: var(--space-2); }
}

/* ── CHAT BUBBLES ── */
.chat-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--surface-page);
}
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: var(--surface-rail);
  border-bottom: 1px solid var(--border-subtle);
}
.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 880px;
  width: 100%;
  margin: 0 auto;
}
.msg-row { display: flex; }
.msg-row.user      { justify-content: flex-end; }
.msg-row.assistant { justify-content: flex-start; }

.msg-bubble {
  max-width: 78%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  font-size: var(--type-body-md-size);
  line-height: var(--type-body-md-line);
  word-wrap: break-word;
}
.msg-bubble.user {
  background: var(--surface-active);
  color: var(--text-primary);
  border-bottom-right-radius: var(--radius-sm);
}
.msg-bubble.assistant {
  background: var(--surface-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-bottom-left-radius: var(--radius-sm);
}
.msg-bubble p + p { margin-top: 0.5rem; }
.msg-bubble ul, .msg-bubble ol { padding-left: 1.25rem; margin: 0.4rem 0; }
.msg-bubble strong { font-weight: 600; }

.msg-meta {
  font-size: var(--type-label-sm-size);
  color: var(--text-muted);
  margin-top: 0.25rem;
  padding: 0 0.25rem;
}

.chat-composer {
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-rail);
  padding: var(--space-2) var(--space-3);
}
.chat-composer form {
  display: flex;
  gap: var(--space-1);
  align-items: flex-end;
  max-width: 880px;
  margin: 0 auto;
}
.chat-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 200px;
  resize: none;
  line-height: 1.5;
}

/* Typing dots */
.typing {
  display: inline-flex;
  gap: 4px;
  padding: 0.85rem 1rem;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}
.typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1;   }
}

/* ── AUTH SHELL ── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-3);
  background: var(--surface-page);
}
.auth-card {
  width: 100%;
  max-width: 368px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
}
/* Subtle light-mode shadow on the login card only — Linen elevation
   exception. Removed in dark via the [data-theme="dark"] override below. */
.auth-card { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06); }
[data-theme="dark"] .auth-card { box-shadow: none; }

.auth-card .logo-mark { margin-bottom: var(--space-2); display: inline-flex; }
.auth-card h1 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-bottom: 4px;
}
.auth-card .lead {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: var(--space-3);
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: var(--space-3) 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--border-subtle);
}

/* ── MARKETING SECTIONS ── */
.hero {
  padding: var(--space-12) 0 var(--space-10);
  text-align: center;
}
.hero h1 {
  font-size: clamp(40px, 6vw, 64px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}
.hero .lead {
  font-size: var(--type-body-lg-size);
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 auto var(--space-3);
}
.hero-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}
.section {
  padding: var(--space-8) 0;
}
.section h2 {
  text-align: center;
  margin-bottom: var(--space-4);
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-3);
}
.feature {
  padding: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
}
.feature h3 {
  font-size: var(--type-headline-md-size);
  margin-bottom: var(--space-1);
}
.feature p { color: var(--text-muted); }

.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-4) 0;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--type-label-sm-size);
  letter-spacing: 0.05em;
}
