/* =========================================================================
   Grown Clean — Organic City Opportunity Score
   Design tokens live at the top of this file. Change branding here.
   ========================================================================= */

:root {
  /* ---- COLOR: change branding here ---- */
  --bg: #F2F5EC;            /* misty sage page background */
  --surface: #FFFFFF;       /* card surfaces */
  --surface-alt: #EAF0E2;   /* soft recessed panels */
  --ink: #1E2A1B;           /* primary text, deep forest */
  --muted: #5B6B54;         /* secondary text */
  --line: #D8E1CC;          /* hairline borders */
  --primary: #386641;       /* leaf green — buttons, links */
  --primary-dark: #223A26;  /* deep forest — headings, hero */
  --primary-tint: #DCEBD9;  /* light green chip backgrounds */
  --accent: #C99A3E;        /* harvest gold — score emphasis */
  --accent-soft: #F1E3C3;
  --danger: #A6462F;        /* used sparingly for low scores/errors */

  /* ---- SCORE BANDS: change score-color coding here ----
     0–24   score-low       (red)
     25–49  score-mid-low   (orange)
     50–75  score-mid-high  (gold)
     76–100 score-high      (green)
  */
  --score-low: #A6462F;
  --score-low-ink: #FFFFFF;
  --score-mid-low: #C1662B;
  --score-mid-low-ink: #2E1A0A;
  --score-mid-high: #C99A3E;
  --score-mid-high-ink: #3B2C05;
  --score-high: #80CF8F;
  --score-high-ink: #EFF6EA;

  /* ---- TYPE: change fonts here ---- */
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Menlo, monospace;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow-card: 0 8px 24px rgba(30, 42, 27, 0.08);
  --shadow-pop: 0 16px 40px rgba(30, 42, 27, 0.16);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }

a { color: var(--primary-dark); }

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

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ---------- Layout shell ---------- */

.app-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.site-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.brand-mark {
  width: 38px; height: 38px;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  color: var(--primary-dark);
  letter-spacing: 0.01em;
}

.beta-chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--accent-soft);
  color: #6B4E17;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #E3CE95;
}

.tool-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.9rem;
  line-height: 1.15;
  color: var(--primary-dark);
  margin: 18px 0 8px;
}

.tool-subtitle {
  color: var(--muted);
  font-size: 1rem;
  max-width: 56ch;
  margin: 0 0 28px;
}

/* ---------- Search card ---------- */

.search-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.field-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary-dark);
}

.field input {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
}

.field input:focus {
  border-color: var(--primary);
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
  list-style: none;
  padding: 6px;
  display: none;
}

.autocomplete-list.open { display: block; }

.autocomplete-list li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  cursor: pointer;
}

.autocomplete-list li:hover,
.autocomplete-list li[aria-selected="true"] {
  background: var(--primary-tint);
}

.calc-button {
  width: 100%;
  margin-top: 6px;
  padding: 14px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition: transform 0.12s ease, background 0.15s ease;
}

.calc-button:hover { background: var(--primary-dark); }
.calc-button:active { transform: scale(0.98); }
.calc-button:disabled { opacity: 0.6; cursor: default; }

.form-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 10px;
}

/* ---------- Browse rated cities (collapsible) ---------- */

.browse-section {
  margin-top: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 4px 20px;
}

.browse-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0;
}

.browse-summary::-webkit-details-marker { display: none; }

.browse-summary .chevron {
  margin-left: auto;
  flex-shrink: 0;
}

.browse-section[open] .browse-summary .chevron { transform: rotate(180deg); }

.browse-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--primary-dark);
}

.browse-count {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
}

.browse-content {
  padding: 0 0 20px;
}

.browse-search-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 11px 14px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  margin-bottom: 16px;
}

.browse-search-input:focus {
  border-color: var(--primary);
}

.city-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.city-card {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background-color: var(--surface-alt);
  background-size: cover;
  background-position: center;
  overflow: hidden;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.city-card:hover,
.city-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-pop);
}

.city-card-score {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #3B2C05;
}

.city-card-score.score-low { background: var(--score-low); color: var(--score-low-ink); }
.city-card-score.score-mid-low { background: var(--score-mid-low); color: var(--score-mid-low-ink); }
.city-card-score.score-mid-high { background: var(--score-mid-high); color: var(--score-mid-high-ink); }
.city-card-score.score-high { background: var(--score-high); color: var(--score-high-ink); }

.city-card-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.city-card-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.55);
}

.city-card-region {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: #E7EFE2;
  text-shadow: 0 1px 3px rgba(0,0,0,0.55);
}

.browse-empty {
  display: none;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 20px 0 4px;
}

/* ---------- Loading state ---------- */

.loading-panel {
  display: none;
  text-align: center;
  padding: 48px 20px;
}

.loading-panel.active { display: block; }

.sprout-loader {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  animation: sway 1.6s ease-in-out infinite;
}

@keyframes sway {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

.loading-panel p {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

@media (prefers-reduced-motion: reduce) {
  .sprout-loader { animation: none; }
}

/* ---------- Results ---------- */

.results-panel { display: none; }
.results-panel.active { display: block; margin-top: 28px; }

.result-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.result-header {
  background: var(--primary-dark);
  color: #EFF6EA;
  padding: 26px 24px 22px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.result-header .place {
  flex: 1 1 200px;
  min-width: 160px;
}

.result-header .place-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
}

.result-header .place-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #C7D9BE;
  margin-top: 4px;
}

/* Growth-ring score dial: signature element */
.score-dial-wrap {
  position: relative;
  width: 118px; height: 118px;
  flex-shrink: 0;
}

.score-dial-wrap svg { width: 100%; height: 100%; }

.dial-track { stroke: rgba(255,255,255,0.16); fill: none; }
.dial-progress {
  stroke: var(--accent);
  fill: none;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Score-band coloring for the dial ring — overrides the default accent
   fill above. Applied via a class chosen in app.js from the city's
   overallScore, so the ring color reflects the score at a glance. */
.dial-progress.score-low { stroke: var(--score-low); }
.dial-progress.score-mid-low { stroke: var(--score-mid-low); }
.dial-progress.score-mid-high { stroke: var(--score-mid-high); }
.dial-progress.score-high { stroke: var(--score-high); }

.dial-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.dial-score {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.dial-outof {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: #C7D9BE;
}

.grade-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: #3B2C05;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Score-band coloring for the grade badge pill — same four bands as
   the dial ring, kept in sync via the same class from app.js. */
.grade-badge.score-low { background: var(--score-low); color: var(--score-low-ink); }
.grade-badge.score-mid-low { background: var(--score-mid-low); color: var(--score-mid-low-ink); }
.grade-badge.score-mid-high { background: var(--score-mid-high); color: var(--score-mid-high-ink); }
.grade-badge.score-high { background: var(--score-high); color: var(--score-high-ink); }

.result-body { padding: 22px 24px 26px; }

.result-summary {
  font-size: 1rem;
  color: var(--ink);
  margin: 0 0 20px;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 26px 0 10px;
}

/* Category breakdown */
.category-list {
  border-top: 1px solid var(--line);
}

.category-row {
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.category-row summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}

.category-row summary::-webkit-details-marker { display: none; }

.cat-icon {
  width: 26px; height: 26px;
  flex-shrink: 0;
  color: var(--primary);
}

.cat-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.96rem;
}

.cat-score {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--primary-dark);
  white-space: nowrap;
}

.cat-bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-alt);
  margin: 10px 0 0 38px;
  overflow: hidden;
}

.cat-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}

.cat-explanation {
  margin: 10px 0 0 38px;
  font-size: 0.9rem;
  color: var(--muted);
}

.chevron {
  width: 16px; height: 16px;
  transition: transform 0.15s ease;
  color: var(--muted);
}

.category-row[open] .chevron { transform: rotate(180deg); }

/* Highlights / improvements */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}

.pill-list {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pill-list li {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.88rem;
}

.pill-list.improve li { background: #F5EFE2; }

/* Sources */
.source-list {
  margin: 0; padding-left: 18px;
  font-size: 0.88rem;
  color: var(--muted);
}

.source-list li { margin-bottom: 4px; }

/* Not-yet-evaluated state */
.not-found-panel {
  display: none;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  margin-top: 28px;
  text-align: center;
}

.not-found-panel.active { display: block; }

.not-found-panel h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--primary-dark);
  margin: 6px 0 8px;
}

/* Request form */
.request-form {
  margin-top: 18px;
  text-align: left;
  display: grid;
  gap: 10px;
}

.request-form input, .request-form textarea {
  font-family: var(--font-body);
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.request-form textarea { min-height: 70px; resize: vertical; }

.secondary-button {
  background: var(--primary-tint);
  color: var(--primary-dark);
  border: 1px solid #BFD8B6;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 700;
  font-size: 0.9rem;
}

/* Methodology + disclaimer */
.disclaimer-box {
  margin-top: 26px;
  padding: 16px 18px;
  background: var(--surface-alt);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  color: var(--muted);
}

.link-row {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 0.85rem;
}

.link-row button {
  background: none;
  border: none;
  color: var(--primary-dark);
  text-decoration: underline;
  font-size: 0.85rem;
  padding: 4px;
}

/* Modal (methodology) */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 18, 0.5);
  z-index: 100;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}

.modal-overlay.active { display: flex; }

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 620px;
  width: 100%;
  padding: 28px 26px 30px;
  box-shadow: var(--shadow-pop);
}

.modal-card h2 {
  font-family: var(--font-display);
  color: var(--primary-dark);
  margin-top: 0;
}

.modal-card h3 {
  font-size: 0.95rem;
  color: var(--primary-dark);
  margin: 20px 0 6px;
}

.modal-card p, .modal-card li { font-size: 0.92rem; color: var(--ink); }

.modal-close {
  float: right;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
}

.site-footer {
  text-align: center;
  margin-top: 44px;
  font-size: 0.78rem;
  color: var(--muted);
}

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

@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .result-header { flex-direction: column; align-items: flex-start; }
  .score-dial-wrap { align-self: center; }
  .city-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
