/* SafeNest — calm, rounded, high-contrast design. Deliberately distinct
   from GradeScript's warm editorial-serif look: here it's Quicksand's soft
   geometric rounding + a cool teal/coral palette, built to feel calm and
   trustworthy for an audience that may include elderly or less
   tech-familiar users. Big touch targets, no typing, generous whitespace. */

:root {
  --bg: #f2f7f7;
  --bg-soft: #e9f2f1;
  --surface: #ffffff;
  --surface-alt: #fbfefe;
  --text: #1c2b2c;
  --text-soft: #536567;
  --border: #dbe8e7;

  --primary: #146c74;
  --primary-dark: #0c4d54;
  --primary-light: #dcefee;

  --hazard: #db6b42;
  --hazard-light: #fcebe1;

  --na: #7d8b8a;
  --na-light: #eef3f2;

  --amber: #b9862a;
  --amber-light: #faf1dc;

  --accent: #d97757;

  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --shadow-sm: 0 2px 10px rgba(12, 45, 48, 0.06);
  --shadow-md: 0 12px 34px rgba(12, 45, 48, 0.10);
  --shadow-lift: 0 18px 40px rgba(20, 108, 116, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .logo, #landing-title {
  font-family: "Quicksand", -apple-system, sans-serif;
  font-weight: 700;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------------- Landing screen ---------------- */

#landing-screen {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2.5vh, 40px) 20px;
  transition: opacity 0.4s ease;
  background:
    radial-gradient(620px 440px at 12% -8%, rgba(20, 108, 116, 0.10), transparent 60%),
    radial-gradient(560px 420px at 104% 104%, rgba(217, 119, 87, 0.12), transparent 55%),
    var(--bg);
}

#landing-screen.fading-out { opacity: 0; }
#landing-screen.hidden { display: none; }

#landing-card {
  max-width: 580px;
  width: 100%;
  max-height: 100%;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: clamp(18px, 5vh, 52px) clamp(22px, 5vw, 46px) clamp(16px, 4vh, 44px);
  text-align: center;
  border: 1px solid var(--border);
}

#landing-mark {
  width: clamp(40px, 8vh, 72px);
  height: clamp(40px, 8vh, 72px);
  margin: 0 auto clamp(6px, 2vh, 20px);
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

#landing-mark svg { width: 50%; height: 50%; }

.landing-eyebrow {
  margin: 0 0 clamp(3px, 1vh, 8px);
  font-size: clamp(10.5px, 1.6vh, 12.5px);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

#landing-title {
  font-size: clamp(26px, 5.5vh, 46px);
  color: var(--primary-dark);
  margin: 0 0 clamp(3px, 1.2vh, 10px);
  letter-spacing: -0.01em;
  line-height: 1.05;
}

.landing-tagline {
  font-size: clamp(14px, 2.4vh, 20px);
  font-weight: 500;
  color: var(--text-soft);
  margin: 0 0 clamp(10px, 2.8vh, 28px);
  line-height: 1.35;
}

.landing-stat {
  background: var(--primary-light);
  border-radius: var(--radius-md);
  padding: clamp(10px, 2.2vh, 18px) 22px;
  font-size: clamp(12.5px, 2vh, 16.5px);
  line-height: 1.35;
  color: var(--primary-dark);
  margin-bottom: clamp(10px, 2.4vh, 24px);
  text-align: left;
  position: relative;
  padding-left: 24px;
}

.landing-stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 4px;
  background: var(--accent);
}

.landing-stat strong {
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: clamp(14.5px, 2.3vh, 20px);
}

.landing-stat-source {
  display: block;
  margin-top: 4px;
  font-size: clamp(10.5px, 1.6vh, 12.5px);
  color: var(--text-soft);
  font-weight: 500;
}

.landing-explain {
  font-size: clamp(12.5px, 2vh, 16.5px);
  line-height: 1.4;
  color: var(--text-soft);
  margin: 0 0 clamp(12px, 3vh, 32px);
}

#landing-start {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(15px, 2.4vh, 20px);
  font-weight: 700;
  font-family: "Quicksand", sans-serif;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: none;
  border-radius: 999px;
  padding: clamp(12px, 2.4vh, 18px) 40px;
  box-shadow: var(--shadow-lift);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#landing-start .arrow {
  transition: transform 0.15s ease;
  display: inline-block;
}

#landing-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 46px rgba(20, 108, 116, 0.28);
}

#landing-start:hover .arrow { transform: translateX(4px); }

#landing-start:active { transform: translateY(0); }

.landing-disclaimer {
  font-size: clamp(10.5px, 1.6vh, 13px);
  color: var(--na);
  margin: clamp(10px, 2.4vh, 26px) 0 0;
  line-height: 1.5;
}

/* ---------------- App shell ---------------- */

#app.app-hidden { display: none; }
#app.app-visible { display: block; animation: fade-in 0.4s ease; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(251, 254, 254, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.logo {
  font-size: 22px;
  color: var(--primary-dark);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#risk-profile-trigger, #resources-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 9px 18px 9px 14px;
  font-size: 14px;
  font-weight: 600;
  transition: border-color 0.12s ease, background 0.12s ease, color 0.12s ease;
}

#risk-profile-trigger:hover, #resources-trigger:hover { border-color: var(--primary); }

#resources-trigger:hover { background: var(--primary-light); color: var(--primary-dark); }

#risk-profile-trigger.has-selections {
  border-color: var(--accent);
  background: var(--hazard-light);
  color: var(--hazard);
}

.risk-profile-icon { font-size: 16px; }

#score-badge {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--na-light);
  transition: background 0.25s ease, color 0.25s ease;
}

#score-number { font-family: "Quicksand", sans-serif; font-size: 25px; font-weight: 700; }
#score-label { font-size: 14px; color: var(--text-soft); }

#score-badge.tier-none { background: var(--na-light); }
#score-badge.tier-great, #score-badge.tier-good { background: var(--primary-light); color: var(--primary-dark); }
#score-badge.tier-great #score-number, #score-badge.tier-good #score-number { color: var(--primary-dark); }
#score-badge.tier-caution { background: var(--amber-light); color: var(--amber); }
#score-badge.tier-caution #score-number { color: var(--amber); }
#score-badge.tier-risk { background: var(--hazard-light); color: var(--hazard); }
#score-badge.tier-risk #score-number { color: var(--hazard); }

/* ---------------- Room nav ---------------- */

#room-nav {
  display: flex;
  gap: 12px;
  padding: 20px 28px;
  overflow-x: auto;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
}

.room-btn {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 108px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-soft);
  font-weight: 600;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.room-btn:hover { transform: translateY(-1px); }

.room-icon { font-size: 25px; }
.room-name { font-size: 13.5px; text-align: center; font-weight: 600; }
.room-progress { font-size: 11.5px; color: var(--na); }

.room-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.room-btn.room-done:not(.active) {
  border-color: var(--primary);
}

.room-add-btn {
  border-style: dashed;
  border-color: var(--accent);
  color: var(--accent);
  background: transparent;
}

.room-add-btn:hover {
  background: var(--hazard-light);
}

/* ---------------- Add-a-room modal ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(28, 43, 44, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.hidden { display: none; }

#add-room-modal, #risk-profile-modal, #resources-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-width: 640px;
  width: 100%;
  max-height: min(680px, 90vh);
  overflow-y: auto;
  padding: 28px 30px 32px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.modal-header h2 {
  font-size: 24px;
  color: var(--primary-dark);
  margin: 0;
}

#add-room-close, #risk-profile-close, #resources-close {
  border: none;
  background: var(--na-light);
  color: var(--text-soft);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

#add-room-close:hover, #risk-profile-close:hover, #resources-close:hover { background: var(--hazard-light); color: var(--hazard); }

.modal-subtitle {
  color: var(--text-soft);
  font-size: 15px;
  margin: 0 0 22px;
}

#add-room-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.room-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 12px;
  text-align: center;
  transition: transform 0.1s ease, border-color 0.1s ease, background 0.1s ease;
}

.room-option:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  background: var(--primary-light);
}

.room-option-icon { font-size: 30px; }
.room-option-name { font-weight: 700; font-size: 15px; color: var(--text); }
.room-option-count { font-size: 12px; color: var(--text-soft); }

.modal-empty {
  text-align: center;
  color: var(--text-soft);
  font-size: 15px;
  padding: 24px 0;
}

.modal-empty.hidden { display: none; }

#risk-profile-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.risk-chip {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  background: var(--surface-alt);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: left;
  transition: border-color 0.1s ease, background 0.1s ease;
}

.risk-chip:hover { border-color: var(--accent); }

.risk-chip.selected {
  background: var(--hazard-light);
  border-color: var(--hazard);
}

.risk-chip-check {
  flex: 0 0 auto;
  font-size: 16px;
  line-height: 1.4;
}

.risk-chip-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.risk-chip-label {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
}

.risk-chip-desc {
  font-size: 12.5px;
  color: var(--text-soft);
}

/* ---------------- Main layout ---------------- */

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 26px;
  padding: 28px 28px 44px;
  max-width: 1200px;
  margin: 0 auto;
}

#questions-panel { min-width: 0; }

#room-title {
  font-size: 26px;
  color: var(--primary-dark);
  margin: 0 0 20px;
}

#questions-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.question-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 22px 24px;
  transition: box-shadow 0.15s ease;
}

.question-card:hover { box-shadow: var(--shadow-md); }

.question-text {
  font-size: 18.5px;
  font-weight: 500;
  margin-bottom: 15px;
}

.question-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ans-btn {
  flex: 1 1 150px;
  border: 2px solid var(--border);
  background: var(--surface-alt);
  border-radius: 999px;
  padding: 14px 12px;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text-soft);
  text-align: center;
  transition: transform 0.1s ease, border-color 0.1s ease, background 0.1s ease;
}

.ans-btn:hover { transform: translateY(-1px); border-color: var(--na); }

.ans-safe.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.ans-hazard.selected {
  background: var(--hazard);
  border-color: var(--hazard);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.ans-na.selected {
  background: var(--na);
  border-color: var(--na);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

#room-nav-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 26px;
}

#prev-room, #next-room {
  font-size: 16.5px;
  font-weight: 700;
  font-family: "Quicksand", sans-serif;
  background: var(--surface);
  border: 2px solid var(--primary);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 14px 26px;
  transition: background 0.12s ease, transform 0.12s ease;
}

#prev-room:disabled, #next-room:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#next-room:not(:disabled):hover, #prev-room:not(:disabled):hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

/* ---------------- Priority sidebar ---------------- */

#priority-panel {
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 22px;
  align-self: start;
  position: sticky;
  top: 96px;
}

#priority-panel h2 {
  font-size: 19px;
  margin: 0 0 14px;
  color: var(--primary-dark);
}

.priority-empty {
  font-size: 14.5px;
  color: var(--text-soft);
  margin: 0;
}

.fix-budget {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0 0 14px;
}

.fix-budget.hidden { display: none; }

.priority-boosted {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}

#priority-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.priority-card {
  display: flex;
  gap: 12px;
  background: var(--hazard-light);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  animation: fade-in 0.3s ease;
}

.priority-rank {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--hazard);
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
  font-family: "Quicksand", sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
}

.priority-body { min-width: 0; }

.priority-question {
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 2px;
}

.priority-meta {
  font-size: 12px;
  color: var(--text-soft);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.priority-tip {
  font-size: 13px;
  color: var(--text);
  line-height: 1.4;
}

.priority-help-link {
  display: inline-block;
  margin-top: 8px;
  border: none;
  background: none;
  padding: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary-dark);
  text-decoration: underline;
}

.priority-help-link:hover { color: var(--primary); }

.resources-inline-link {
  display: block;
  width: 100%;
  margin-top: 14px;
  border: 2px dashed var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.resources-inline-link:hover { background: var(--surface); }
.resources-inline-link.hidden { display: none; }

/* ---------------- Get-help-paying modal ---------------- */

#location-finder {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin: 4px 0 18px;
}

.location-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 10px;
}

.location-input-row {
  display: flex;
  gap: 10px;
}

#location-input {
  flex: 1 1 auto;
  min-width: 0;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}

#location-input:focus {
  outline: none;
  border-color: var(--primary);
}

#location-find-btn {
  flex: 0 0 auto;
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 11px 22px;
}

#location-find-btn:hover { background: var(--primary-dark); }

.location-results {
  margin-top: 14px;
}

.location-results.hidden { display: none; }

.location-state-guess {
  font-size: 13.5px;
  color: var(--primary-dark);
  margin: 0 0 10px;
}

.location-search-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.location-search-link {
  display: block;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
  text-decoration: none;
}

.location-search-link:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.resources-subhead {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  margin: 22px 0 10px;
}

.resources-subhead:first-of-type { margin-top: 4px; }

#resources-localizers, #resources-programs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.resource-card {
  display: flex;
  gap: 14px;
  background: var(--surface-alt);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.resource-card-localizer {
  background: var(--primary-light);
  border-color: var(--primary);
}

.resource-icon {
  flex: 0 0 auto;
  font-size: 26px;
}

.resource-body { min-width: 0; }

.resource-name {
  font-weight: 700;
  font-size: 15.5px;
  color: var(--text);
}

.resource-for {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  margin-top: 2px;
}

.resource-desc {
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.45;
  margin: 6px 0 10px;
}

.resource-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.resource-phone, .resource-visit {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-dark);
  text-decoration: none;
}

.resource-phone:hover, .resource-visit:hover { text-decoration: underline; }

.resources-disclaimer {
  font-size: 12px;
  color: var(--na);
  line-height: 1.5;
  margin: 20px 0 0;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 860px) {
  main {
    grid-template-columns: 1fr;
  }
  #priority-panel {
    position: static;
  }
}

@media (max-width: 520px) {
  html, body { font-size: 16px; }
  #landing-card { padding: 38px 24px 32px; }
  #landing-title { font-size: 34px; }
  header { padding: 12px 18px; }
  #room-nav { padding: 16px 18px; }
  main { padding: 20px 18px 32px; }
  .question-buttons { flex-direction: column; }
  .ans-btn { flex: 1 1 auto; }
}
