/* ======== Shared Design Tokens & Base Styles ======== */
:root {
  --bg-primary: #06090f;
  --bg-card: #0d1117;
  --bg-card-alt: #0f1520;
  --bg-card-hover: #141d2d;
  --bg-highlight: #111827;
  --border: #1b2436;
  --border-soft: #151e30;
  --text-primary: #e8ecf4;
  --text-secondary: #9ba8c0;
  --text-muted: #5e6e87;
  --accent-blue: #5b9cf6;
  --accent-red: #f06565;
  --accent-orange: #f5993d;
  --accent-yellow: #ecc94b;
  --accent-green: #48d89b;
  --accent-purple: #b380f6;
  --accent-cyan: #46c8e3;
  --radius: 16px;
  --radius-sm: 10px;
}

:root[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-alt: #f3f6fb;
  --bg-card-hover: #edf2f7;
  --bg-highlight: #f1f5f9;
  --border: #dbe3ef;
  --border-soft: #e7edf6;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --accent-blue: #2563eb;
  --accent-red: #dc2626;
  --accent-orange: #ea580c;
  --accent-yellow: #ca8a04;
  --accent-green: #16a34a;
  --accent-purple: #9333ea;
  --accent-cyan: #0891b2;
}

/* ---- Reset ---- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary); color: var(--text-primary);
  line-height: 1.7; font-size: 15px; -webkit-font-smoothing: antialiased;
}

html { scroll-behavior: smooth; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #283654; border-radius: 3px; }

/* ---- Accessibility ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.sr-only:focus-visible { position: fixed; top: 8px; left: 8px; width: auto; height: auto; clip: auto; z-index: 9999; padding: 12px 20px; background: var(--accent-blue); color: #fff; border-radius: 8px; font-weight: 600; font-size: 0.9em; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; }
button:focus-visible, a:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent-blue); outline-offset: 2px; border-radius: 4px; }

/* ---- Shared Components ---- */
.tz-select, .lang-select {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-secondary); font-size: 0.8em; cursor: pointer;
}

.theme-toggle {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-secondary); cursor: pointer; padding: 6px 14px; font-size: 0.78em; font-weight: 500;
}
.theme-toggle:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

.sse-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent-green);
  display: inline-block; margin-right: 4px; animation: pulse 2s infinite;
}
.sse-dot.disconnected { background: var(--accent-red); animation: none; }

@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.5;transform:scale(0.8)} }

/* ---- Shared Toolbar (used by landing, report, glossary) ---- */
.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.toolbar-left  { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar-toggle {
  display: none; align-items: center; gap: 4px;
  background: none; border: 1px solid var(--border); border-radius: 8px;
  color: var(--text-muted); font-size: 0.78em; padding: 5px 10px; cursor: pointer;
}
.toolbar-toggle:hover { color: var(--text-secondary); border-color: var(--accent-blue); }
.sticky-toolbar {
  position: sticky; top: 0; z-index: 80;
  background: color-mix(in srgb, var(--bg-base) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 0; margin-bottom: 18px;
}
.motion-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-secondary); font-size: 0.76em;
  cursor: pointer; transition: all 0.2s;
}
.motion-toggle:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.motion-toggle[aria-pressed="true"] {
  background: var(--accent-blue); color: #fff; border-color: var(--accent-blue);
}
.glossary-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-secondary); font-size: 0.76em;
  text-decoration: none; cursor: pointer; transition: all 0.2s; line-height: 1;
}
.glossary-link:hover, .glossary-link:focus-visible {
  border-color: var(--accent-blue); color: var(--accent-blue);
}
.glossary-link .glossary-link__icon { font-size: 1em; }

@media (max-width: 700px) {
  .toolbar { gap: 8px; margin-bottom: 16px; }
  .toolbar-toggle { display: flex; }
  .toolbar-right {
    max-height: 0; overflow: hidden; width: 100%;
    transition: max-height 0.3s ease;
  }
  .toolbar-right.show,
  .toolbar-right.expanded { max-height: 240px; }
}

/* ---- Shared Footer (used by landing, report, glossary) ---- */
.site-footer {
  text-align: center; padding: 28px; color: var(--text-muted);
  font-size: 0.76em; border-top: 1px solid var(--border-soft);
  margin-top: 20px; line-height: 1.8;
}
.site-footer a {
  color: var(--text-muted); text-decoration: none;
  border-bottom: 1px dotted var(--text-muted);
}
.site-footer a:hover { color: var(--text-secondary); }
@media (max-width: 700px) {
  .site-footer { padding: 18px 12px; font-size: 0.7em; }
}

/* ---- Risk Badges ---- */
.risk-badge {
  display: inline-block; padding: 4px 12px; border-radius: 14px;
  font-weight: 700; font-size: 0.7em; text-transform: uppercase;
  letter-spacing: 0.6px;
}
.risk-low { background: #073b2b; color: #6ee7b7; }
.risk-moderate { background: #142d52; color: #7bb8f5; }
.risk-elevated { background: #4a2c0a; color: #fcd480; }
.risk-high { background: #511717; color: #fca5a5; }
.risk-critical { background: #5a1111; color: #fff; border: 1px solid #ef4444; }

:root[data-theme="light"] .risk-low { background: #dcfce7; color: #166534; }
:root[data-theme="light"] .risk-moderate { background: #dbeafe; color: #1d4ed8; }
:root[data-theme="light"] .risk-elevated { background: #fef3c7; color: #92400e; }
:root[data-theme="light"] .risk-high { background: #ffedd5; color: #9a3412; }
:root[data-theme="light"] .risk-critical { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ---- Translation Status ---- */
.translate-status {
  font-size: 0.72em;
  color: var(--text-muted);
  min-width: 130px;
  text-align: right;
}
.translate-status.loading::before {
  content: '';
  display: inline-block;
  width: 9px;
  height: 9px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  margin-right: 6px;
  animation: translate-spin 0.9s linear infinite;
  vertical-align: -1px;
}
@keyframes translate-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ---- Command Palette ---- */
.cmd-palette-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 3000;
  display: none; align-items: flex-start; justify-content: center; padding-top: 15vh;
  backdrop-filter: blur(4px);
}
.cmd-palette-overlay.open { display: flex; }
.cmd-palette {
  width: 480px; max-width: 90vw; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(0,0,0,0.4); overflow: hidden;
  animation: fade-up 0.15s ease-out;
}
.cmd-input {
  width: 100%; padding: 16px 20px; border: none; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text-primary); font-size: 1em;
  outline: none; font-family: inherit;
}
.cmd-input::placeholder { color: var(--text-muted); }
.cmd-list { max-height: 320px; overflow-y: auto; padding: 8px; }
.cmd-item {
  padding: 10px 14px; border-radius: var(--radius-sm); cursor: pointer;
  display: flex; align-items: center; gap: 12px; font-size: 0.88em;
  color: var(--text-secondary); transition: background 0.1s;
}
.cmd-item:hover, .cmd-item.selected { background: var(--bg-highlight); color: var(--text-primary); }
.cmd-item-icon { font-size: 1.1em; width: 24px; text-align: center; flex-shrink: 0; }
.cmd-item-label { flex: 1; }
.cmd-item-shortcut { font-size: 0.72em; color: var(--text-muted); font-family: monospace; }
.cmd-hint { padding: 8px 16px; font-size: 0.68em; color: var(--text-muted); text-align: center; border-top: 1px solid var(--border); }

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 2000;
  display: flex; flex-direction: column-reverse; gap: 8px; pointer-events: none;
}
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm); font-size: 0.84em;
  font-weight: 500; pointer-events: auto; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25); border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-primary);
  animation: toast-in 0.3s ease-out; max-width: 400px; cursor: pointer;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.toast-info { border-left: 4px solid var(--accent-blue); }
.toast.toast-success { border-left: 4px solid var(--accent-green); }
.toast.toast-warning { border-left: 4px solid var(--accent-orange); }
.toast.toast-error { border-left: 4px solid var(--accent-red); }
.toast.removing { opacity: 0; transform: translateX(80px); }
.toast-icon { font-size: 1.1em; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-action {
  font-size: 0.78em; font-weight: 700; color: var(--accent-blue);
  text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; cursor: pointer;
  background: none; border: none; padding: 4px 8px;
}
.toast-action:hover { text-decoration: underline; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---- Mobile Shared ---- */
@media (max-width: 600px) {
  body { font-size: 14px; }
  .toast-container { bottom: 12px; right: 12px; left: 12px; align-items: stretch; }
  .toast { max-width: 100%; font-size: 0.8em; padding: 10px 14px; }
  .cmd-palette { max-width: 95vw; }
  .cmd-input { padding: 14px 16px; font-size: 0.95em; }
  .cmd-item { padding: 10px 12px; font-size: 0.84em; }
  .cmd-list { max-height: 260px; }
  .tz-select, .lang-select { font-size: 0.76em; padding: 5px 8px; }
  .theme-toggle { padding: 5px 10px; font-size: 0.74em; }
  .risk-badge { font-size: 0.65em; padding: 3px 10px; }
}
@media (max-width: 380px) {
  .toast { padding: 8px 10px; font-size: 0.76em; gap: 6px; }
  .cmd-palette { max-width: 98vw; border-radius: 12px; }
}
