/* App shell — source of truth: UI.md §6, §7, §12
   Mobile: 60px header + fixed bottom navigation.
   Desktop (1024px+): compact left sidebar, no bottom navigation. */

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Sidebar (desktop only) ---------- */
.sidebar {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--forest-900);
}

/* App crest mark (shield + livestock + crop + red alert triangle),
   cropped from the supplied logo. border-radius clips it to a tile. */
.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 10px;
  display: block;
  object-fit: cover;
}

.brand-name {
  font: 700 17px/22px var(--font-ui);
  letter-spacing: -0.01em;
}

.brand-tag {
  font: var(--text-caption);
  color: var(--ink-tertiary);
}

/* ---------- Mobile header ---------- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--gutter);
  padding-top: max(var(--space-2), env(safe-area-inset-top));
  background: rgba(245, 247, 244, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: var(--hairline);
}

.app-bar .brand-name {
  font-size: 16px;
}

.app-bar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Desktop shows the screen title; mobile shows the compact brand. */
#app-bar-title {
  display: none;
  font: var(--text-card);
  color: var(--forest-900);
}

@media (min-width: 1024px) {
  .app-bar .brand {
    display: none;
  }
  #app-bar-title {
    display: block;
  }
}

/* ---------- Page ---------- */
.page {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-5) var(--gutter);
  padding-bottom: calc(var(--bottomnav-h) + var(--space-12) + env(safe-area-inset-bottom));
}

.page-narrow {
  max-width: calc(var(--form-max) + var(--gutter) * 2);
}

.page-head {
  margin-bottom: var(--space-5);
}

.page-head p {
  margin-top: var(--space-1);
  font: var(--text-supporting);
  color: var(--ink-secondary);
}

/* ---------- Bottom navigation (mobile) ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  align-items: stretch;
  gap: 2px;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  border-top: var(--hairline);
  box-shadow: var(--shadow-floating);
}

.nav-item {
  min-height: var(--bottomnav-h);
  min-width: var(--tap-min);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-2) 4px;
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink-secondary);
  font: var(--text-caption);
  font-weight: 600;
}

.nav-item .nav-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 28px;
  border-radius: var(--radius-chip);
}

.nav-item[aria-current="page"] {
  color: var(--leaf-700);
}

.nav-item[aria-current="page"] .nav-icon {
  background: var(--leaf-100);
}

/* ---------- Wide screens ---------- */
@media (min-width: 1024px) {
  .app {
    flex-direction: row;
  }

  .sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    width: 248px;
    flex: 0 0 248px;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: var(--space-5) var(--space-4);
    background: var(--surface);
    border-right: var(--hairline);
  }

  .sidebar-nav {
    margin-top: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
  }

  .sidebar .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--space-3);
    min-height: 46px;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-control);
    font: var(--text-body);
    font-size: 15px;
    font-weight: 600;
  }

  .sidebar .nav-item .nav-icon {
    width: 26px;
    height: 26px;
  }

  .sidebar .nav-item:hover {
    background: var(--surface-muted);
  }

  .sidebar-cta {
    margin-top: var(--space-4);
  }

  .sidebar-foot {
    margin-top: auto;
    padding-top: var(--space-4);
    border-top: var(--hairline);
  }

  .app-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
  }

  .app-bar {
    background: rgba(245, 247, 244, 0.9);
  }

  .bottom-nav {
    display: none;
  }

  .page {
    padding-bottom: var(--space-16);
  }

  .two-col {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: var(--space-8);
    align-items: start;
  }
}

/* ---------- Landing (public) ---------- */
.landing-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--gutter);
  background: rgba(245, 247, 244, 0.86);
  backdrop-filter: blur(12px);
  border-bottom: var(--hairline);
}

.landing-header .app-bar-actions {
  gap: var(--space-3);
}

.hero {
  /* The image is referenced directly (not through a --hero-image custom
     property) so the URL always resolves against this file:
     src/styles → ../../assets/images. Declaring the token in index.html
     made Chromium request /src/styles/assets/… and 404. */
  background-image: linear-gradient(
      rgba(9, 32, 24, 0.62),
      rgba(9, 32, 24, 0.72)
    ),
    url("../../assets/images/agric2.jpg");
  background-size: cover;
  background-position: center;
  color: #fff;
  padding: var(--space-16) var(--gutter);
}

.hero-inner {
  max-width: var(--content-max);
  margin: 0 auto;
}

.hero h1 {
  color: #fff;
  font: var(--text-display);
  margin-top: var(--space-3);
  max-width: 15ch;
}

.hero p {
  margin-top: var(--space-4);
  font-size: 17px;
  line-height: 26px;
  max-width: 48ch;
  color: rgba(255, 255, 255, 0.92);
}

.hero .eyebrow {
  color: #b8e6c9;
}

.hero-actions {
  margin-top: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 420px;
}

.hero-note {
  margin-top: var(--space-6);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font: var(--text-supporting);
  color: rgba(255, 255, 255, 0.9);
  max-width: 52ch;
}

.landing-body {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-12) var(--gutter);
}

@media (min-width: 640px) {
  .hero-actions {
    flex-direction: row;
    max-width: none;
  }
}

@media (min-width: 1024px) {
  .hero {
    padding: var(--space-16) var(--gutter) 96px;
  }

  .hero h1 {
    font-size: 44px;
    line-height: 52px;
  }
}
