/* Mobile-First PWA Styles */

/* Reset & Base */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary: #0f766e;
  --primary-dark: #115e59;
  --primary-light: #ccfbf1;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #ffedd5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --bg: #f7f3ee;
  --card: #fffdf9;
  --border: #e7e1d8;
  --text: #1f2933;
  --text-muted: #6b7280;
  --shadow: 0 10px 30px rgba(31, 41, 51, 0.08);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  font-family: "Avenir Next", "Avenir", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.12), transparent 55%),
    radial-gradient(circle at 10% 20%, rgba(245, 158, 11, 0.12), transparent 45%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* App Container - Full Screen */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for mobile */
  width: 100vw;
  max-width: none;
  margin: 0;
  background: var(--card);
  box-shadow: var(--shadow);
  border-radius: 0;
  border: none;
}

@media (max-width: 900px) {
  .app-container {
    box-shadow: none;
  }
}

/* App Header */
.app-header {
  background: linear-gradient(135deg, #0f766e 0%, #0b4f4a 100%);
  color: white;
  padding: 1.25rem 1.5rem;
  padding-top: env(safe-area-inset-top, 1rem);
  flex-shrink: 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-icon {
  width: 40px;
  height: 40px;
  background: white;
  color: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.5rem;
}

.header-title h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
}

.header-subtitle {
  margin: 0;
  font-size: 0.75rem;
  opacity: 0.9;
}

.info-btn {
  margin-top: 0.5rem;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.info-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.header-score {
  text-align: center;
}

.score-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.18);
  border-radius: 50%;
  font-size: 1.25rem;
  font-weight: 700;
  border: 3px solid rgba(255,255,255,0.5);
}

/* Progress Container */
.progress-container {
  padding: 0.75rem 1.5rem;
  background: rgba(255, 253, 249, 0.95);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--success) 100%);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.5rem;
}

/* Main Content */
.main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem 0.5rem 1.5rem;
  width: 100%;
  max-width: none;
  margin: 0;
  display: block;
}

/* Screens */
.screen {
  min-height: 100%;
  padding: 1rem;
  width: 100%;
}

/* Loading Screen */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Question Screen */
.question-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.06);
  width: 100%;
}

.question-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.btn-compact {
  padding: 0.5rem 0.85rem;
  font-size: 0.8125rem;
}

/* Guide Panel */
.guide-panel {
  background: linear-gradient(135deg, #fff7ed 0%, #e0f2f1 100%);
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.guide-hero {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.guide-kicker {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin: 0 0 0.35rem;
}

.guide-hero h2 {
  font-size: 1.125rem;
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
}

.guide-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.guide-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.guide-preview {
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.guide-quick {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.guide-pill {
  background: white;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.guide-content h1,
.guide-content h2,
.guide-content h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
}

.guide-content h1 {
  font-size: 1.25rem;
}

.guide-content p {
  margin: 0 0 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
}

.guide-content ul,
.guide-content ol {
  padding-left: 1.25rem;
  margin: 0 0 0.75rem;
  color: var(--text);
  font-size: 0.875rem;
}

.guide-content li {
  margin-bottom: 0.35rem;
}

.guide-content strong {
  color: var(--text);
}

.guide-modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 2000;
}

.guide-modal.open {
  display: flex;
}

.guide-modal-content {
  width: min(100%, 980px);
  max-height: 85vh;
  background: var(--card);
  border-radius: 1rem;
  border: 1px solid var(--border);
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.guide-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, #fff7ed 0%, #e0f2f1 100%);
}

.guide-modal .guide-content {
  padding: 1.5rem;
  overflow-y: auto;
}

.question-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.question-badge {
  background: var(--primary);
  color: white;
  padding: 0.375rem 0.875rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 700;
}

.question-type-pill {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.question-text {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 0.75rem;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
  color: var(--text);
}

.question-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding: 0.5rem 0.75rem;
  background: rgba(15, 118, 110, 0.08);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  margin-bottom: 1.25rem;
}

/* Options */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-btn {
  width: 100%;
  text-align: left;
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: 0 8px 18px rgba(31, 41, 51, 0.06);
}

.option-btn:active {
  transform: scale(0.98);
}

.option-btn:focus-visible,
.nav-btn:focus-visible {
  outline: 2px solid rgba(15, 118, 110, 0.5);
  outline-offset: 2px;
}

.option-btn.selected {
  border-color: var(--primary);
  background: rgba(15, 118, 110, 0.12);
}

.option-btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
  background: #f3f4f6;
  border-color: #e5e7eb;
}

.option-flag {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #6b7280;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}

.option-btn.selected::after {
  content: "✓";
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.875rem;
}

.option-label {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: var(--text);
  padding-right: 2.5rem;
}

.option-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
  padding-right: 2.5rem;
}

.option-score {
  display: none;
  margin-top: 0.5rem;
  font-size: 0.6875rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--success-light);
  color: #065f46;
  font-weight: 600;
}

.option-btn.selected .option-score,
.option-btn:focus-visible .option-score {
  display: inline-block;
}

/* Results Screen */
.results-card {
  text-align: center;
}

.results-header {
  padding: 2rem 1rem;
  background: linear-gradient(135deg, #fff7ed 0%, #e2f8f6 100%);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}

.results-score-circle {
  width: 120px;
  height: 120px;
  margin: 0 auto 1rem;
  background: white;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(15, 118, 110, 0.2);
  border: 4px solid var(--primary);
}

.results-score-circle .score-number {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.results-score-circle .score-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.results-badge {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.9375rem;
  margin-bottom: 0.75rem;
}

.results-badge.excellent {
  background: var(--success-light);
  color: #065f46;
}

.results-badge.good {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.results-badge.needs_work {
  background: var(--warning-light);
  color: #92400e;
}

.results-badge.high_risk {
  background: var(--danger-light);
  color: #991b1b;
}

.results-message {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* Results Breakdown */
.results-breakdown {
  text-align: left;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: #f8fafc;
  margin-bottom: 0.5rem;
  border-left: 4px solid var(--primary);
}

.breakdown-item.good {
  border-left-color: var(--success);
}

.breakdown-item.ok {
  border-left-color: var(--warning);
}

.breakdown-item.poor {
  border-left-color: var(--danger);
}

.breakdown-question {
  font-size: 0.8125rem;
  color: var(--text);
  flex: 1;
  padding-right: 1rem;
}

.breakdown-score {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.results-disclaimer {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #fffbeb;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: #92400e;
  border: 1px solid #fcd34d;
}

/* Bottom Navigation */
.bottom-nav {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.app-footer {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.75rem 1.5rem 1.25rem;
  background: var(--card);
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: #111827;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.link-btn:hover {
  text-decoration: underline;
}

.nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav-btn-primary {
  background: #111827;
  border-color: #111827;
  color: #f9fafb;
}

.nav-btn-success {
  background: #1f2937;
  border-color: #1f2937;
  color: #f9fafb;
}

.nav-icon {
  font-size: 1rem;
}

/* Install Prompt */
.install-prompt {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  z-index: 1000;
}

.install-prompt p {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--text);
}

.install-buttons {
  display: flex;
  gap: 0.75rem;
}

/* Responsive - Desktop */
@media (min-width: 601px) {
  .app-container {
    margin: 0;
    height: 100vh;
    border-radius: 0;
    overflow: visible;
  }

  .question-text {
    font-size: 1.375rem;
  }

  .option-btn {
    padding: 1.25rem;
  }

  .option-btn:hover:not(.selected) {
    border-color: var(--primary);
    background: rgba(15, 118, 110, 0.06);
  }
}

@media (min-width: 900px) {
  .main-content {
    padding: 2rem 3rem 2.5rem;
  }

.question-screen {
  display: block;
  width: 100%;
}

  .question-card {
    max-width: none;
  }
}

@media (min-width: 1200px) {
  .app-container {
    height: 100vh;
  }
}

@media (min-width: 1440px) {
  .main-content {
    padding: 2.5rem 4rem 3rem;
  }

  .question-screen {
    max-width: none;
  }
}

/* Very small screens */
@media (max-width: 380px) {
  .header-title h1 {
    font-size: 1rem;
  }

  .header-icon {
    width: 36px;
    height: 36px;
    font-size: 1.25rem;
  }

  .question-text {
    font-size: 1.125rem;
  }

  .nav-label {
    display: none;
  }

  .nav-icon {
    font-size: 1.25rem;
  }
}

/* Animations */
.screen {
  animation: fadeIn 0.3s ease;
}

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

/* Touch Feedback */
@media (hover: none) {
  .option-btn:active {
    background: var(--primary-light);
  }

  .nav-btn:active:not(:disabled) {
    opacity: 0.8;
  }
}

/* Landscape Mode Warning */
@media (max-height: 500px) and (orientation: landscape) {
  .app-header {
    padding: 0.5rem 1rem;
  }

  .header-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .header-title h1 {
    font-size: 1rem;
  }

  .header-subtitle {
    display: none;
  }

  .progress-container {
    padding: 0.5rem 1rem;
  }

  .screen {
    padding: 0.75rem;
  }

  .question-text {
    font-size: 1rem;
    margin-bottom: 0.5rem;
  }

  .question-hint {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
  }

  .option-btn {
    padding: 0.75rem;
  }

  .bottom-nav {
    padding: 0.5rem 1rem;
  }

  .nav-btn {
    padding: 0.625rem 0.75rem;
  }
}
