/* ICore Studyo — Constitutional Design System v0.1.0
   Brave-first, Mobile-first, Dark theme, Sovereign
   Zero external fonts. System fonts only. */

:root {
  /* Constitutional Color Palette */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a25;
  --bg-input: #0f0f18;
  --border: #2a2a3a;
  --border-active: #00e676;
  
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #555570;
  
  --accent: #00e676;
  --accent-dim: #00cc6a;
  --accent-glow: rgba(0, 230, 118, 0.15);
  
  --warning: #ffab00;
  --error: #ff5252;
  --info: #448aff;
  
  /* Trust levels */
  --trust-verified: #00e676;
  --trust-partial: #ffab00;
  --trust-unverified: #ff5252;
  --trust-unknown: #555570;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Typography */
  --font-system: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 
                 'Helvetica Neue', Arial, 'Noto Sans', sans-serif,
                 'Apple Color Emoji', 'Segoe UI Emoji';
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono',
               'Courier New', monospace;
  
  /* Touch targets (minimum 48px) */
  --touch-min: 48px;
  
  /* Radius */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-system);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* App Shell */
#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  position: sticky;
  top: 44px;
  z-index: 100;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md);
  backdrop-filter: blur(10px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 600px;
  margin: 0 auto;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header-logo {
  font-size: 1.5rem;
  line-height: 1;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.header-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Main Content */
.main {
  flex: 1;
  padding: var(--space-md);
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 80px; /* Space for bottom nav */
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: var(--space-sm) 0;
  padding-bottom: max(var(--space-sm), env(safe-area-inset-bottom));
  z-index: 100;
}

.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
  max-width: 600px;
  margin: 0 auto;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-xs) var(--space-sm);
  min-width: var(--touch-min);
  min-height: var(--touch-min);
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-system);
  font-size: 0.65rem;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
  color: var(--accent);
}

.nav-item-icon {
  font-size: 1.4rem;
  line-height: 1;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
}

.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
}

.card-description {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* Input */
.input-group {
  margin-bottom: var(--space-md);
}

.input-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-field {
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-md);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-system);
  font-size: 1rem;
  line-height: 1.5;
  resize: vertical;
  transition: border-color 0.2s;
}

.input-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-field::placeholder {
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: var(--touch-min);
  padding: var(--space-md) var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-system);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
}

.btn-primary:active {
  background: var(--accent-dim);
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:active {
  background: var(--border);
  transform: scale(0.98);
}

/* Trust Score */
.trust-score {
  text-align: center;
  padding: var(--space-xl) 0;
}

.trust-level {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-xs);
}

.trust-level.verified { color: var(--trust-verified); }
.trust-level.partial { color: var(--trust-partial); }
.trust-level.unverified { color: var(--trust-unverified); }
.trust-level.unknown { color: var(--trust-unknown); }

.trust-bar {
  height: 8px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: var(--space-md) 0;
}

.trust-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.8s ease-out;
}

/* Test Results */
.test-list {
  list-style: none;
}

.test-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.test-item:last-child {
  border-bottom: none;
}

.test-icon {
  font-size: 1rem;
  line-height: 1.5;
  flex-shrink: 0;
}

.test-pass { color: var(--trust-verified); }
.test-fail { color: var(--trust-unverified); }
.test-warn { color: var(--trust-partial); }

/* Layers */
.layer-grid {
  display: grid;
  gap: var(--space-sm);
}

.layer-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.2s;
  min-height: var(--touch-min);
}

.layer-item:active {
  border-color: var(--accent);
}

.layer-number {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-glow);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.layer-info {
  flex: 1;
  min-width: 0;
}

.layer-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.layer-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-status {
  font-size: 0.75rem;
  flex-shrink: 0;
}

.status-complete { color: var(--trust-verified); }
.status-partial { color: var(--trust-partial); }

/* History */
.history-item {
  padding: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-sm);
  cursor: pointer;
  min-height: var(--touch-min);
}

.history-item:active {
  border-color: var(--accent);
}

.history-claim {
  font-size: 0.875rem;
  margin-bottom: var(--space-xs);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* About */
.about-section {
  margin-bottom: var(--space-xl);
}

.about-section h3 {
  font-size: 1rem;
  margin-bottom: var(--space-sm);
  color: var(--accent);
}

.about-section p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* Install Banner */
.install-banner {
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  text-align: center;
}

.install-banner h3 {
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

.install-banner p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: var(--space-md);
}

/* Offline Indicator */
.offline-banner {
  background: var(--warning);
  color: var(--bg-primary);
  text-align: center;
  padding: var(--space-xs) var(--space-md);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-md);
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

/* Utility */
.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;
}

.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Safe area for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
  .header {
    padding-top: max(var(--space-md), env(safe-area-inset-top));
  }
}
