/* =========================================================================
   GrowCalc — mobile-first, lightweight, zero-CLS base stylesheet.
   Ad slots reserve their height up-front to guarantee zero layout shift.
   ========================================================================= */

:root {
  --c-bg: #ffffff;
  --c-fg: #16241b;
  --c-muted: #5b6b61;
  --c-brand: #1f7a3d;
  --c-brand-ink: #ffffff;
  --c-border: #e2e8e4;
  --c-card: #f6f9f7;
  --maxw: 880px;
  --gap: 1rem;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;

  /* Reserved ad heights — kept in :root so JS/markup can't drift from CSS. */
  --ad-leaderboard-h: 100px; /* mobile banner height */
  --ad-in-article-h: 280px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--c-fg);
  background: var(--c-bg);
  font-size: 1.0625rem; /* 17px base — body copy (p, li, a) a touch larger */
  line-height: 1.65;
  overflow-x: hidden; /* safety net against horizontal scroll on mobile */
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 0.5em;
  overflow-wrap: break-word; /* long titles never force horizontal overflow */
}

a {
  color: var(--c-brand);
}

img {
  max-width: 100%;
  height: auto;
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gap);
}

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

/* ---- Header / nav (mobile-first: collapses into a hamburger menu) ---- */
.site-header {
  border-bottom: 1px solid var(--c-border);
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-block: 0.6rem;
}
.brand {
  font-weight: 700;
  text-decoration: none;
  font-size: 1.15rem;
  margin-right: auto; /* pushes the toggle/menu to the right */
}

/* Hamburger toggle (mobile only) */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.nav-toggle__box {
  position: relative;
  width: 20px;
  height: 14px;
}
.nav-toggle__bar,
.nav-toggle__bar::before,
.nav-toggle__bar::after {
  position: absolute;
  left: 0;
  width: 20px;
  height: 2px;
  background: var(--c-fg);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle__bar {
  top: 6px;
}
.nav-toggle__bar::before {
  content: "";
  top: -6px;
}
.nav-toggle__bar::after {
  content: "";
  top: 6px;
}
.site-header.is-open .nav-toggle__bar {
  background: transparent;
}
.site-header.is-open .nav-toggle__bar::before {
  transform: translateY(6px) rotate(45deg);
}
.site-header.is-open .nav-toggle__bar::after {
  transform: translateY(-6px) rotate(-45deg);
}

/* Collapsible menu: hidden on mobile until toggled, full-width below header */
.site-menu {
  display: none;
  flex-basis: 100%;
  width: 100%;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.25rem 0 0.4rem;
}
.site-header.is-open .site-menu {
  display: flex;
}
.site-nav {
  display: flex;
  flex-direction: column;
}
.site-nav a {
  display: block;
  padding: 0.6rem 0.15rem;
  border-top: 1px solid var(--c-border);
  text-decoration: none;
  font-size: 1rem;
}
.lang-switch {
  margin-top: 0.5rem;
}
.lang-switch__select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: #fff;
  font: inherit;
}

/* Desktop: show the inline nav, hide the hamburger */
@media (min-width: 760px) {
  .nav-toggle {
    display: none;
  }
  .site-menu {
    display: flex;
    flex-basis: auto;
    width: auto;
    flex-direction: row;
    align-items: center;
    gap: 0.9rem;
    padding: 0;
    margin-left: auto;
  }
  .site-nav {
    flex-direction: row;
    gap: 0.9rem;
    font-size: 0.95rem;
  }
  .site-nav a {
    border-top: 0;
    padding: 0;
  }
  .lang-switch {
    margin-top: 0;
  }
  .lang-switch__select {
    width: auto;
    padding: 0.35rem 0.5rem;
  }
}

/* ---- Ad slots: height reserved to guarantee 0 CLS ---- */
.ad-slot {
  display: block;
  width: 100%;
  margin-block: 1.25rem;
  background: repeating-linear-gradient(
    45deg,
    #fafbfa,
    #fafbfa 10px,
    #f1f4f2 10px,
    #f1f4f2 20px
  );
  border: 1px dashed var(--c-border);
  border-radius: var(--radius);
}
.ad-slot--leaderboard {
  min-height: var(--ad-leaderboard-h);
}
.ad-slot--in-article {
  min-height: var(--ad-in-article-h);
}
.ad-rail {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gap);
}

/* ---- Cards / grids ---- */
.card-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}
.card {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-card);
}
.card__link {
  display: block;
  padding: 1rem;
  text-decoration: none;
  color: inherit;
}
.card__title {
  font-size: 1.05rem;
  color: var(--c-brand);
}
.card__desc {
  margin: 0;
  color: var(--c-muted);
  font-size: 0.95rem;
}

/* ---- Tool / calculator scaffolding ---- */
.tool,
.legal,
.hero,
.featured,
.browse {
  padding-block: 1.25rem;
}
.breadcrumbs {
  font-size: 0.85rem;
  color: var(--c-muted);
  display: flex;
  gap: 0.4rem;
}
.calculator {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--c-card);
  min-height: 200px; /* reserve while JS hydrates -> no shift */
}

/* ---- Buttons ---- */
.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--c-border);
  background: #fff;
}
.btn--primary {
  background: var(--c-brand);
  color: var(--c-brand-ink);
  border-color: var(--c-brand);
}
.btn--ghost {
  background: transparent;
}

/* ---- Footer ---- */
.site-footer {
  margin-top: 2rem;
  border-top: 1px solid var(--c-border);
  padding-block: 1.5rem;
  font-size: 0.9rem;
  color: var(--c-muted);
}
.site-footer__legal {
  display: flex;
  gap: 0.85rem;
  row-gap: 0.4rem;
  flex-wrap: wrap;
  margin-block: 0.5rem;
}
.site-footer__legal a {
  overflow-wrap: anywhere; /* long links/emails break instead of overflowing */
}

/* ---- Cookie banner (off-canvas until shown; never shifts content) ---- */
.cookie-banner {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 50;
  background: #fff;
  border-top: 1px solid var(--c-border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}
.cookie-banner[hidden] {
  display: none;
}
.cookie-banner__inner {
  display: flex;
  gap: var(--gap);
  align-items: center;
  flex-wrap: wrap;
  padding-block: 0.85rem;
}
.cookie-banner__text {
  margin: 0;
  flex: 1 1 240px;
  font-size: 0.9rem;
}
.cookie-banner__actions {
  display: flex;
  gap: 0.5rem;
  margin-inline-start: auto;
}

/* ---- Calculator form ---- */
.calc-form__fields {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: 1fr;
}
.field__label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.3rem;
}
.field__control {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.field__control:focus-within {
  border-color: var(--c-brand);
  box-shadow: 0 0 0 2px rgba(31, 122, 61, 0.15);
}
.field__control input,
.field__control select {
  font: inherit;
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  padding: 0.6rem 0.7rem;
  background: transparent;
  outline: none;
}
.field__addon,
.field__unit {
  display: inline-flex;
  align-items: center;
  padding: 0 0.65rem;
  background: var(--c-card);
  color: var(--c-muted);
  font-size: 0.9rem;
  white-space: nowrap;
}
.field__addon {
  border-right: 1px solid var(--c-border);
}
.field__unit {
  border-left: 1px solid var(--c-border);
}
.field__help {
  margin: 0.3rem 0 0;
  font-size: 0.82rem;
  color: var(--c-muted);
}
.calc-form__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* ---- Results ---- */
.results {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--c-border);
}
.results__title {
  font-size: 1rem;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.results__grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}
.result {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--c-border);
}
.result__label {
  color: var(--c-muted);
  font-size: 0.9rem;
}
.result__value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}
.result__unit {
  font-weight: 500;
  color: var(--c-muted);
  margin-left: 0.2rem;
  font-size: 0.85em;
}
.result--primary {
  background: #ecf6ef;
  border-color: #cfe8d7;
}
.result--primary .result__value {
  font-size: 1.35rem;
  color: var(--c-brand);
}

/* VPD safety heatmap colours (set via output[data-zone]) */
output[data-zone="low"],
output[data-zone="high"] {
  color: #b3261e;
}
output[data-zone="prop"] {
  color: #1565c0;
}
output[data-zone="veg"] {
  color: #1f7a3d;
}
output[data-zone="flower"] {
  color: #b26a00;
}

.formula code {
  display: block;
  padding: 0.7rem 0.85rem;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.5;
  overflow-x: auto;
}

/* ---- Long-form content blocks ---- */
.tool__content {
  max-width: 70ch;
}
.tool__content h2 {
  margin-top: 1.8rem;
  font-size: 1.25rem;
}
.results__note {
  margin: 0.85rem 0 0;
  font-size: 0.8rem;
  color: var(--c-muted);
  font-style: italic;
}
.tool__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--c-muted);
  margin: 0.5rem 0 0.5rem;
}
.steps {
  padding-left: 1.2rem;
}
.steps li {
  margin-bottom: 0.4rem;
}
.example {
  border-left: 3px solid var(--c-brand);
  background: var(--c-card);
  padding: 0.8rem 1rem;
  border-radius: 0 8px 8px 0;
}
.example__title {
  font-weight: 700;
  margin: 0 0 0.3rem;
}
.mistakes {
  padding-left: 1.2rem;
}
.mistakes li {
  margin-bottom: 0.4rem;
}

/* Reference / recommended-range tables */
.table-wrap {
  overflow-x: auto;
}
.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.ref-table caption {
  text-align: left;
  color: var(--c-muted);
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}
.ref-table th,
.ref-table td {
  border: 1px solid var(--c-border);
  padding: 0.5rem 0.7rem;
  text-align: left;
}
.ref-table thead th {
  background: var(--c-card);
}

/* FAQ (native disclosure — no JS, no CLS) */
.faq__item {
  border: 1px solid var(--c-border);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: #fff;
}
.faq__q {
  cursor: pointer;
  padding: 0.7rem 0.9rem;
  font-weight: 600;
  list-style: none;
}
.faq__q::-webkit-details-marker {
  display: none;
}
.faq__q::before {
  content: "+";
  display: inline-block;
  width: 1em;
  color: var(--c-brand);
  font-weight: 700;
}
.faq__item[open] .faq__q::before {
  content: "−";
}
.faq__a {
  padding: 0 0.9rem 0.8rem;
  color: var(--c-fg);
}
.faq__a p {
  margin: 0;
}

/* Related calculators */
.related {
  margin-top: 2rem;
}

/* Result actions (copy) + history */
.btn--sm {
  padding: 0.4rem 0.7rem;
  font-size: 0.9rem;
}
.results__actions {
  margin-top: 0.85rem;
}
.btn.is-copied {
  background: var(--c-brand);
  color: var(--c-brand-ink);
  border-color: var(--c-brand);
}
.history {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--c-border);
}
.history__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.history__list {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.history__restore {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.6rem;
  text-align: left;
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  font: inherit;
  cursor: pointer;
}
.history__restore:hover {
  border-color: var(--c-brand);
  background: var(--c-card);
}
.history__time {
  color: var(--c-muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.history__summary {
  font-weight: 600;
}

/* 404 page */
.not-found {
  padding-block: 2.5rem;
}
.not-found__langs {
  margin-top: 1.5rem;
  font-weight: 600;
}
.not-found__list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

/* Legal pages */
.legal {
  max-width: 72ch;
}
.legal h2 {
  margin-top: 1.6rem;
  font-size: 1.2rem;
}
.legal__updated {
  font-size: 0.82rem;
  color: var(--c-muted);
  margin-top: -0.25rem;
}
.legal__body ul {
  padding-left: 1.2rem;
}
.legal__body li {
  margin-bottom: 0.35rem;
}
.legal__contact {
  margin-top: 1.5rem;
  font-weight: 600;
}

/* ---- Ads temporarily disabled (re-enable by removing this rule) ---- */
.ad-slot {
  display: none !important;
}

/* ---- Tablet / desktop enhancements ---- */
@media (min-width: 700px) {
  :root {
    --ad-leaderboard-h: 90px; /* 728x90 leaderboard */
  }
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (min-width: 1000px) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
