/* CSS Design System for Survive Hub */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Noto+Sans+TC:wght@400;500;700;900&display=swap');

:root {
  --bg-main: #040711;
  --bg-card: #0d1322;
  --bg-card-hover: #151d30;
  --bg-glass: rgba(13, 19, 34, 0.85);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-accent: rgba(245, 158, 11, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.25);
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.25);
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  
  --font-family: 'Inter', 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --shadow-main: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light high-contrast mode override when toggled */
body.contrast-mode {
  --bg-main: #000000;
  --bg-card: #111111;
  --bg-card-hover: #1c1c1c;
  --border-color: #333333;
  --text-primary: #ffffff;
  --text-secondary: #dddddd;
  --accent-amber: #ffbe0b;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: radial-gradient(circle at 30% 30%, #f59e0b, #b45309);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--accent-amber-glow);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  fill: #000;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-text span {
  font-size: 0.75rem;
  color: var(--accent-amber);
  font-weight: 600;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Base Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  transition: var(--transition);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-sos {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #fff;
  border: none;
  box-shadow: 0 0 15px var(--accent-red-glow);
  animation: pulse-sos 2s infinite;
}

.btn-sos:hover {
  background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
}

.btn-sos.active {
  background: #ffffff;
  color: #dc2626;
  animation: pulse-sos-active 0.4s infinite alternate;
}

@keyframes pulse-sos {
  0%, 100% { box-shadow: 0 0 10px var(--accent-red-glow); }
  50% { box-shadow: 0 0 22px rgba(239, 68, 68, 0.6); }
}

@keyframes pulse-sos-active {
  from { transform: scale(1); }
  to { transform: scale(1.04); }
}

.btn-amber {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #000;
  border: none;
}

.btn-amber:hover {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
}

/* Main Container */
.main-content {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
  flex: 1;
}

/* Hero / Search Section */
.search-section {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.search-section::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, var(--accent-amber-glow) 0%, transparent 70%);
  pointer-events: none;
}

.search-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

.search-desc {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.search-bar {
  position: relative;
  max-width: 600px;
}

.search-input {
  width: 100%;
  padding: 0.875rem 1rem 0.875rem 2.75rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: var(--transition);
}

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

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  stroke: var(--text-muted);
  pointer-events: none;
}

/* Quick Tool Cards */
.quick-tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: var(--transition);
}

.tool-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.tool-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-amber);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tool-info h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.tool-info p {
  font-size: 0.825rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

/* Category Filter Tabs */
.categories-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
  scrollbar-width: none;
}

.categories-tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  white-space: nowrap;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.tab-btn.active {
  background: var(--accent-amber);
  color: #000;
  border-color: var(--accent-amber);
  box-shadow: 0 0 15px var(--accent-amber-glow);
}

/* Survival Guide Cards Grid */
.guides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.guide-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  position: relative;
}

.guide-card:hover {
  border-color: rgba(245, 158, 11, 0.3);
  box-shadow: var(--shadow-main);
}

.guide-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.guide-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
}

.badge-severity {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.badge-critical {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-info {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.guide-summary {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.steps-list {
  list-style: none;
  counter-reset: step-counter;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex: 1;
}

.steps-list li {
  counter-increment: step-counter;
  position: relative;
  padding-left: 2.2rem;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.steps-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0.15rem;
  width: 1.5rem;
  height: 1.5rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-amber);
}

.guide-tips {
  background: rgba(0, 0, 0, 0.3);
  border-left: 3px solid var(--accent-amber);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: auto;
}

.guide-tips strong {
  color: var(--accent-amber);
  display: block;
  margin-bottom: 0.2rem;
}

/* Calculator Section & Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.75rem;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1rem;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-amber);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 50%;
  transition: var(--transition);
}

.modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  font-size: 0.95rem;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-amber);
}

.calc-results {
  background: rgba(0, 0, 0, 0.4);
  border: 1px dashed var(--border-accent);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1.5rem;
}

.calc-results h4 {
  color: var(--accent-amber);
  font-size: 1rem;
  margin-bottom: 1rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.9rem;
}

.calc-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
}

.calc-item label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: block;
}

.calc-item value {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  display: block;
}

/* SOS Strobe Overlay for Screen */
.sos-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #ffffff;
  z-index: 999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.05s ease-in-out;
}

.sos-overlay.blink-active {
  display: flex;
  opacity: 1;
}

.sos-overlay-text {
  font-size: 4rem;
  font-weight: 900;
  color: #000000;
  letter-spacing: 0.2em;
}

/* Highlight search terms */
mark.highlight {
  background: rgba(245, 158, 11, 0.35);
  color: #ffffff;
  padding: 0 0.2rem;
  border-radius: 2px;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border-color);
  padding: 1.5rem 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-main);
}

/* Interactive Checklist & Progress Bar Styles */
.checklist-progress-box {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.checklist-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
}

.checklist-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-main);
  border-radius: 4px;
  overflow: hidden;
}

.checklist-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #10b981);
  transition: width 0.3s ease-in-out;
}

.checklist-item-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
}

.checklist-item-row:hover {
  background: rgba(245, 158, 11, 0.08);
}

.checklist-item-row.checked {
  opacity: 0.65;
  text-decoration: line-through;
}

.checklist-item-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent-amber);
  cursor: pointer;
}

.checklist-item-text {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-primary);
}

/* Responsive tweaks */
@media (max-width: 640px) {
  .header-actions {
    gap: 0.25rem;
  }
  .btn span {
    display: none;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .guides-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   PRINT STYLESHEET (@media print) - For Physical A4 Survival Manual
   ========================================================================== */
@media print {
  @page {
    size: A4;
    margin: 1.5cm;
  }

  body {
    background-color: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt;
    line-height: 1.4;
  }

  .app-header,
  .search-section,
  .quick-tools,
  .categories-tabs,
  .header-actions,
  .btn,
  .modal-overlay,
  .sos-overlay,
  .app-footer {
    display: none !important;
  }

  .main-content {
    max-width: 100% !important;
    padding: 0 !important;
  }

  .print-header {
    display: block !important;
    text-align: center;
    border-bottom: 2pt solid #000;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
  }

  .print-header h1 {
    font-size: 18pt;
    font-weight: bold;
  }

  .guides-grid {
    display: block !important;
  }

  .guide-card {
    background: #ffffff !important;
    border: 1pt solid #ccc !important;
    page-break-inside: avoid;
    margin-bottom: 1rem;
    padding: 10pt !important;
    color: #000000 !important;
  }

  .guide-title {
    color: #000000 !important;
    font-size: 12pt !important;
    font-weight: bold !important;
  }

  .badge-severity {
    border: 1pt solid #000 !important;
    color: #000 !important;
    background: none !important;
  }

  .guide-summary {
    color: #333333 !important;
    font-size: 9.5pt !important;
  }

  .steps-list li {
    color: #000000 !important;
    font-size: 9.5pt !important;
  }

  .steps-list li::before {
    background: #eee !important;
    color: #000 !important;
    border: 1pt solid #000 !important;
  }

  .guide-tips {
    background: #f5f5f5 !important;
    border-left: 3pt solid #000 !important;
    color: #000000 !important;
  }
}
