/* ─────────────────────────────────────────────────────────────────────────────
   Houseplant Hub — Global Styles
   Philosophy: Clean, minimal, elegant. Plants and data are the focus.
───────────────────────────────────────────────────────────────────────────── */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-dark:   #2d6a4f;
  --green-mid:    #40916c;
  --green-light:  #74c69d;
  --green-pale:   #d8f3dc;
  --cream:        #fafaf8;
  --white:        #ffffff;
  --grey-100:     #f4f4f2;
  --grey-200:     #e8e8e4;
  --grey-400:     #b0b0aa;
  --grey-600:     #7a7a72;
  --grey-800:     #3a3a36;
  --text:         #1e2a22;
  --text-light:   #5a6b60;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
  --shadow-md:    0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:    0 8px 24px rgba(0,0,0,.12);
  --radius:       10px;
  --radius-sm:    6px;
  --transition:   0.2s ease;
  --font-sans:    'Inter', system-ui, -apple-system, sans-serif;
  --max-width:    1200px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--cream);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--green-mid); text-decoration: none; }
a:hover { color: var(--green-dark); text-decoration: underline; }

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

/* ── Layout ── */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Header / Nav ── */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--grey-200);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--green-dark);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.logo:hover { color: var(--green-mid); text-decoration: none; }

.logo-icon { font-size: 1.4rem; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-light);
  transition: color var(--transition);
}

.nav-links a:hover { color: var(--green-dark); text-decoration: none; }

/* Compare badge in nav */
.compare-badge {
  background: var(--green-mid);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 99px;
  padding: 0.15rem 0.5rem;
  margin-left: 0.25rem;
  display: none;
}
.compare-badge.has-items { display: inline; }

/* ── Hero / Page Header ── */
.page-hero {
  padding: 3rem 0 2rem;
  text-align: center;
}

.page-hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  color: var(--green-dark);
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.6rem;
}

.page-hero p {
  font-size: 1.05rem;
  color: var(--text-light);
  max-width: 540px;
  margin: 0 auto;
}

/* ── Search Bar ── */
.search-bar-wrap {
  display: flex;
  gap: 0.5rem;
  max-width: 520px;
  margin: 1.5rem auto 0;
}

.search-bar-wrap input {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--white);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.search-bar-wrap input:focus {
  border-color: var(--green-light);
  box-shadow: 0 0 0 3px rgba(116,198,157,.2);
}

/* ── Filter Chips ── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 1.25rem 0 2rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.9rem;
  border: 1.5px solid var(--grey-200);
  border-radius: 99px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-light);
  background: var(--white);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.filter-chip:hover {
  border-color: var(--green-light);
  color: var(--green-dark);
  background: var(--green-pale);
}

.filter-chip.active {
  border-color: var(--green-mid);
  background: var(--green-mid);
  color: var(--white);
}

/* ── Plant Grid ── */
.plants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  padding-bottom: 3rem;
}

/* ── Plant Card ── */
.plant-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), box-shadow var(--transition);
  border: 1px solid var(--grey-200);
}

.plant-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.plant-card__image-wrap {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--grey-100);
}

.plant-card__image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.plant-card:hover .plant-card__image-wrap img {
  transform: scale(1.04);
}

.plant-card__no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--grey-400);
}

.plant-card__body {
  padding: 0.9rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.plant-card__name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.plant-card__sci {
  font-size: 0.78rem;
  color: var(--text-light);
  font-style: italic;
}

.plant-card__traits {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.trait-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  white-space: nowrap;
}

.trait-pill--green  { background: #dcf5e8; color: #1d6b40; }
.trait-pill--red    { background: #fde8e8; color: #9b2020; }
.trait-pill--grey   { background: var(--grey-100); color: var(--grey-600); }

.plant-card__actions {
  display: flex;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
  margin-top: auto;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: var(--green-mid);
  color: white;
  flex: 1;
}
.btn-primary:hover { background: var(--green-dark); color: white; text-decoration: none; }

.btn-outline {
  background: transparent;
  color: var(--text-light);
  border: 1.5px solid var(--grey-200);
  flex: 1;
}
.btn-outline:hover {
  border-color: var(--green-light);
  color: var(--green-dark);
  text-decoration: none;
}

.btn-outline.in-compare {
  border-color: var(--green-mid);
  color: var(--green-mid);
  background: var(--green-pale);
}

.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
  border: none;
}
.btn-danger:hover { background: #fecaca; }

/* ── Results count ── */
.results-meta {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1rem;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-light);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state p { font-size: 0.95rem; }

/* ── Loading Spinner ── */
.spinner-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4rem 1rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--grey-200);
  border-top-color: var(--green-mid);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ── Compare Bar (floating) ── */
.compare-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--green-dark);
  color: white;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 -4px 20px rgba(0,0,0,.2);
}

.compare-bar.visible { transform: translateY(0); }

.compare-bar .container {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
  flex-wrap: wrap;
}

.compare-bar__plants {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  flex-wrap: wrap;
}

.compare-bar__plant-tag {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,.15);
  border-radius: 99px;
  padding: 0.25rem 0.65rem;
  font-size: 0.82rem;
  font-weight: 500;
}

.compare-bar__plant-tag button {
  background: none;
  border: none;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
}
.compare-bar__plant-tag button:hover { color: white; }

.compare-bar__label {
  font-size: 0.85rem;
  opacity: 0.8;
  white-space: nowrap;
}

.compare-bar__actions {
  display: flex;
  gap: 0.5rem;
}

.compare-bar__actions .btn {
  font-size: 0.85rem;
  padding: 0.5rem 1.1rem;
}

.btn-white {
  background: white;
  color: var(--green-dark);
}
.btn-white:hover { background: var(--green-pale); color: var(--green-dark); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: rgba(255,255,255,.8);
  border: 1.5px solid rgba(255,255,255,.3);
}
.btn-ghost:hover { background: rgba(255,255,255,.1); color: white; text-decoration: none; }

/* ── Plant Detail Page ── */
.plant-detail {
  padding: 2.5rem 0 4rem;
}

.plant-detail__grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 2.5rem;
  align-items: start;
}

.plant-detail__image-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: var(--grey-100);
  aspect-ratio: 3/4;
  max-height: 500px;
}

.plant-detail__image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.plant-detail__no-image {
  width: 100%;
  height: 100%;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 5rem;
  color: var(--grey-400);
}

.image-attribution {
  margin-top: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-light);
  line-height: 1.4;
}
.image-attribution a { color: var(--grey-600); }

.plant-detail__info h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 800;
  color: var(--green-dark);
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.3rem;
}

.plant-detail__sci {
  font-style: italic;
  color: var(--text-light);
  font-size: 1rem;
  margin-bottom: 1.2rem;
}

.plant-detail__description {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 1.75rem;
}

/* Traits grid on detail page */
.traits-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.trait-card {
  background: var(--grey-100);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.trait-card__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--grey-600);
}

.trait-card__value {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}

.trait-card__value--yes   { color: #1d6b40; }
.trait-card__value--no    { color: #9b2020; }
.trait-card__value--unknown { color: var(--grey-600); }

.plant-detail__actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.plant-detail__actions .btn {
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
}

/* Alternative names */
.plant-detail__alt-names {
  font-size: 0.83rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.alt-name-pill {
  display: inline-block;
  background: var(--green-pale);
  color: var(--green-dark);
  border-radius: 99px;
  padding: 0.18rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 500;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 1.5rem;
  transition: color var(--transition);
}
.back-link:hover { color: var(--green-dark); text-decoration: none; }

/* ── Compare Page ── */
.compare-page {
  padding: 2rem 0 4rem;
  overflow-x: auto;
}

.compare-intro {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-light);
}
.compare-intro .icon { font-size: 3rem; margin-bottom: 1rem; }

.compare-table-wrap {
  overflow-x: auto;
  margin-top: 1.5rem;
}

.compare-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 500px;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--grey-200);
}

.compare-table th,
.compare-table td {
  padding: 0.85rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid var(--grey-200);
  vertical-align: top;
}

.compare-table th {
  background: var(--grey-100);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--grey-600);
  white-space: nowrap;
  width: 160px;
  min-width: 130px;
}

.compare-table td {
  font-size: 0.9rem;
  min-width: 180px;
}

.compare-table tr:last-child th,
.compare-table tr:last-child td {
  border-bottom: none;
}

.compare-table .plant-header td {
  background: var(--white);
  border-bottom: 2px solid var(--grey-200);
  padding-bottom: 1rem;
}

.compare-plant-header {
  text-align: center;
}

.compare-plant-img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin: 0 auto 0.5rem;
  border: 1px solid var(--grey-200);
  display: block;
  background: var(--grey-100);
}

.compare-plant-no-img {
  width: 100px;
  height: 100px;
  background: var(--grey-100);
  border-radius: var(--radius-sm);
  margin: 0 auto 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--grey-400);
  border: 1px solid var(--grey-200);
}

.compare-plant-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.compare-plant-sci {
  font-size: 0.75rem;
  font-style: italic;
  color: var(--text-light);
  margin-top: 0.15rem;
}

.compare-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--grey-400);
  font-size: 1rem;
  margin-top: 0.4rem;
  transition: color var(--transition);
}
.compare-remove-btn:hover { color: #b91c1c; }

.compare-val--yes     { color: #1d6b40; font-weight: 700; }
.compare-val--no      { color: #9b2020; font-weight: 700; }
.compare-val--unknown { color: var(--grey-400); }

.compare-controls {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* ── Footer ── */
.site-footer {
  background: var(--grey-100);
  border-top: 1px solid var(--grey-200);
  padding: 1.5rem 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--grey-600);
}

.site-footer a { color: var(--grey-600); }

/* ── Error message ── */
.error-msg {
  text-align: center;
  padding: 3rem 1rem;
  color: #9b2020;
}

/* ── Responsive ── */
@media (max-width: 720px) {
  .plant-detail__grid {
    grid-template-columns: 1fr;
  }

  .plant-detail__image-wrap {
    aspect-ratio: 4/3;
    max-height: 280px;
  }

  .traits-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .plants-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .compare-bar .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .nav-links { gap: 1rem; }
}

@media (max-width: 480px) {
  .plants-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .traits-grid {
    grid-template-columns: 1fr 1fr;
  }
}
