/* ==========================================================================
   AWS Cloud Quest — Design System Tokens & Base Primitives (CLF-C02)
   ========================================================================== */

:root {
  /* Surfaces & Canvas */
  --bg-canvas: #090d16;
  --bg-surface: #111726;
  --bg-surface-elevated: #171f33;
  --bg-surface-hover: #192237;
  --surface-overlay: rgba(255, 255, 255, 0.05);
  --surface-code: rgba(255, 255, 255, 0.08);
  --backdrop-scrim: rgba(3, 6, 12, 0.78);

  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-default: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.24);

  /* Typography Colors */
  --text-strong: #ffffff;
  --text-primary: #f8fafc;
  --text-body: #cbd5e1;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --text-on-brand: #090d16;
  --text-on-success: #051b11;

  /* Brand / AWS Accent */
  --brand-primary: #ff9900;
  --brand-hover: #ffa726;
  --brand-subtle: rgba(255, 153, 0, 0.11);
  --brand-tint: rgba(255, 153, 0, 0.04);
  --brand-tint-hover: rgba(255, 153, 0, 0.07);
  --brand-border: rgba(255, 153, 0, 0.28);
  --brand-text: #ffb84d;

  /* Functional Status Colors */
  --success-primary: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.32);
  --success-text: #34d399;

  --danger-primary: #f43f5e;
  --danger-hover: #e11d48;
  --danger-subtle: rgba(244, 63, 94, 0.12);
  --danger-border: rgba(244, 63, 94, 0.32);
  --danger-text: #fb7185;

  --accent-info-subtle: rgba(56, 189, 248, 0.10);
  --accent-info-border: rgba(56, 189, 248, 0.28);
  --accent-info-text: #38bdf8;

  --muted-glyph: rgba(255, 255, 255, 0.18);

  /* Geometry & Metrics */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 9999px;

  --tap-target: 48px;
  --shell-width: 620px;

  /* Shadows */
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.32);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);

  /* Typography (System-native stack: instant load, offline-ready, zero external tracking) */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Code", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Viewport safe areas */
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* Base reset & layout */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background-color: var(--bg-canvas);
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

button, a, input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}

h1, h2, h3, h4, p {
  margin: 0;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

::selection {
  background: var(--brand-border);
  color: var(--text-strong);
}

/* ==========================================================================
   Shell Container
   ========================================================================== */

#app {
  position: relative;
  width: 100%;
  max-width: var(--shell-width);
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-top) + 16px) 20px calc(24px + var(--safe-bottom));
  animation: screenFadeIn 0.16s ease-out;
}

.screen.no-anim {
  animation: none;
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Typography Hierarchy
   ========================================================================== */

.title-section {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--text-primary);
}

.text-caption {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ==========================================================================
   Buttons & Interactive Elements
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap-target);
  padding: 0 18px;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
  user-select: none;
  touch-action: manipulation;
  border: 1px solid transparent;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--primary {
  background-color: var(--brand-primary);
  color: var(--text-on-brand);
  border-color: var(--brand-primary);
}

.btn--primary:hover {
  background-color: var(--brand-hover);
  border-color: var(--brand-hover);
}

.btn--secondary {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn--secondary:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn--ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: var(--border-subtle);
}

.btn--ghost:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn--danger {
  background-color: var(--danger-primary);
  color: var(--text-strong);
  border-color: var(--danger-primary);
}

.btn--danger:hover {
  background-color: var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn--sm {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: var(--r-sm);
}

.btn--lg {
  min-height: 52px;
  padding: 0 22px;
  font-size: 15px;
}

.btn--block {
  width: 100%;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.08s ease;
}

.icon-btn:hover {
  background-color: var(--bg-surface-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.icon-btn:active {
  transform: scale(0.96);
}

/* ==========================================================================
   Status Badges & Tags
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

.badge--neutral {
  background-color: var(--surface-overlay);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.badge--brand {
  background-color: var(--brand-subtle);
  color: var(--brand-text);
  border: 1px solid var(--brand-border);
}

.badge--success {
  background-color: var(--success-subtle);
  color: var(--success-text);
  border: 1px solid var(--success-border);
}

.badge--danger {
  background-color: var(--danger-subtle);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.badge--info {
  background-color: var(--accent-info-subtle);
  color: var(--accent-info-text);
  border: 1px solid var(--accent-info-border);
}

/* ==========================================================================
   Progress Bar
   ========================================================================== */

.progress-track {
  position: relative;
  width: 100%;
  height: 5px;
  border-radius: var(--r-full);
  background-color: var(--border-subtle);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: var(--r-full);
  background-color: var(--brand-primary);
  transition: width 0.25s ease;
}

/* ==========================================================================
   SVG Stars
   ========================================================================== */

.stars-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.star-icon {
  width: 14px;
  height: 14px;
  display: block;
}

.star-icon.is-filled {
  color: var(--brand-primary);
}

.star-icon.is-empty {
  color: var(--muted-glyph);
}

/* ==========================================================================
   Modal Dialog & Toast
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background-color: var(--backdrop-scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: 400px;
  padding: 24px;
  border-radius: var(--r-lg);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  text-align: left;
  animation: modalScale 0.16s ease-out;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.97) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.modal__body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal__body b {
  color: var(--text-primary);
  font-weight: 600;
}

.modal__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  position: fixed;
  top: calc(var(--safe-top) + 12px);
  left: 50%;
  transform: translate(-50%, -12px);
  z-index: 100;
  max-width: min(90vw, 360px);
  padding: 10px 16px;
  border-radius: var(--r-full);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
