/* ─────────────────────────────────────────────────────────────
   Bladwijzer — botanical editorial
   palette: deep moss, paper cream, terracotta accent, ink
   ────────────────────────────────────────────────────────── */
:root {
  --paper:        #f4efe4;
  --paper-deep:   #ebe4d2;
  --ink:          #1f2a1a;
  --ink-soft:     #3a4732;
  --moss:         #5a6a3c;
  --moss-deep:    #2e3a22;
  --terra:        #b8593a;
  --terra-soft:   #d68c6e;
  --sky:          #7a8a91;
  --line:         #cabb9c;

  --font-display: 'Fraunces', 'Times New Roman', serif;
  --font-body:    'Outfit', system-ui, sans-serif;
  --font-mono:    'DM Mono', ui-monospace, monospace;

  --r-sm: 4px;
  --r-md: 10px;
  --r-lg: 22px;
  --shadow-soft: 0 1px 0 rgba(31,42,26,.06), 0 18px 40px -28px rgba(31,42,26,.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  /* paper grain */
  background-image:
    radial-gradient(circle at 1px 1px, rgba(31,42,26,.04) 1px, transparent 0);
  background-size: 4px 4px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--moss-deep); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .2s; }
a:hover { border-bottom-color: var(--terra); }

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

/* ─── Header ─────────────────────────────────────────── */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 38px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display);
  font-weight: 500; font-size: 24px;
  letter-spacing: -.01em;
  color: var(--ink);
  border-bottom: none;
}
.brand:hover { border-bottom: none; }
.brand-mark { width: 32px; height: 32px; color: var(--moss); }

.nav { display: flex; align-items: center; gap: 22px; font-size: 15px; }
.nav a { color: var(--ink-soft); }
.nav a.active { color: var(--terra); }
.btn-pill {
  padding: 8px 16px;
  background: var(--ink);
  color: var(--paper) !important;
  border-radius: 999px;
  border-bottom: none !important;
}
.btn-pill:hover { background: var(--moss-deep); }
.link { background: none; border: none; color: var(--ink-soft); font-size: 15px; padding: 0; }
.link:hover { color: var(--terra); }

/* ─── Footer ─────────────────────────────────────────── */
.foot {
  margin-top: auto;
  padding: 32px 38px;
  border-top: 1px solid var(--line);
  display: flex; gap: 12px; align-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-soft);
}
.foot .leaf { color: var(--terra); font-size: 16px; }

/* ─── Layout ─────────────────────────────────────────── */
main {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 38px 80px;
}

@media (max-width: 720px) {
  .top { padding: 16px 18px; }
  main { padding: 28px 18px 60px; }
  .nav { gap: 14px; font-size: 14px; }
  .foot { padding: 24px 18px; }
}

/* ─── Hero / Landing ─────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 60px;
  align-items: center;
  min-height: 70vh;
}
@media (max-width: 880px) { .hero { grid-template-columns: 1fr; gap: 32px; } }

.hero h1 {
  font-family: var(--font-display);
  font-weight: 350;
  font-variation-settings: "opsz" 144, "SOFT" 30, "WONK" 1;
  font-size: clamp(48px, 7vw, 96px);
  line-height: .95;
  letter-spacing: -.02em;
  margin: 0 0 24px;
  color: var(--ink);
}
.hero h1 em {
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
  color: var(--terra);
}
.hero p {
  font-size: 19px;
  color: var(--ink-soft);
  max-width: 48ch;
  margin: 0 0 36px;
}
.hero .cta { display: flex; gap: 14px; flex-wrap: wrap; }
.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 14px 26px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 500;
}
.btn-primary:hover { background: var(--moss-deep); }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 13px 26px;
  border-radius: 999px;
  font-size: 16px;
}
.btn-ghost:hover { background: var(--ink); color: var(--paper); }

/* Hero illustration */
.hero-art {
  position: relative;
  aspect-ratio: 1 / 1.1;
  background: var(--paper-deep);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.hero-art svg { width: 100%; height: 100%; display: block; }

/* ─── Forms ──────────────────────────────────────────── */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 36px;
  box-shadow: var(--shadow-soft);
}
.card-narrow { max-width: 460px; margin: 40px auto; }

.card h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 36px;
  margin: 0 0 8px;
  letter-spacing: -.01em;
}
.card .lead {
  color: var(--ink-soft);
  margin: 0 0 28px;
  font-size: 15px;
}

label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
input, textarea, select {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--ink);
  margin-bottom: 18px;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--moss);
  box-shadow: 0 0 0 3px rgba(90,106,60,.15);
}
textarea { min-height: 90px; resize: vertical; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 540px) { .form-row { grid-template-columns: 1fr; } }

.checkbox-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 18px;
}
.checkbox-row input { width: auto; margin: 0; }
.checkbox-row label { margin: 0; text-transform: none; letter-spacing: 0; font-family: var(--font-body); font-size: 15px; color: var(--ink); }

.form-error {
  background: rgba(184,89,58,.1);
  color: var(--terra);
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 14px;
  margin-bottom: 16px;
}

.subnote {
  font-size: 14px;
  color: var(--ink-soft);
  margin-top: 18px;
  text-align: center;
}

/* ─── Plant grid / cards ─────────────────────────────── */
.section-title {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 32px;
}
.section-title h1 {
  font-family: var(--font-display);
  font-weight: 350;
  font-size: clamp(36px, 5vw, 56px);
  margin: 0;
  letter-spacing: -.015em;
}
.section-title h1 em {
  font-style: italic;
  font-variation-settings: "SOFT" 100, "WONK" 1;
  color: var(--terra);
}
.section-meta { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .12em; }

.plant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 28px;
}

.plant-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .25s, box-shadow .25s;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.plant-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 40px -22px rgba(31,42,26,.45);
  border-bottom: 1px solid var(--line);
}
.plant-card .thumb {
  aspect-ratio: 1 / 1;
  background: var(--paper-deep);
  position: relative;
  overflow: hidden;
}
.plant-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.plant-card .thumb .empty {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 64px; color: var(--moss); opacity: .5;
  font-family: var(--font-display);
}
.plant-card .body { padding: 18px 20px 22px; }
.plant-card .name {
  font-family: var(--font-display);
  font-weight: 450;
  font-size: 22px;
  margin: 0 0 4px;
  letter-spacing: -.005em;
}
.plant-card .species {
  font-family: var(--font-mono);
  font-size: 12px;
  font-style: italic;
  color: var(--ink-soft);
  text-transform: lowercase;
  margin: 0 0 10px;
}
.plant-card .meta {
  font-size: 13px;
  color: var(--ink-soft);
  display: flex; gap: 12px; flex-wrap: wrap;
}
.plant-card .meta .dot { color: var(--terra); }
.plant-card .owner {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-bottom: 4px;
}

.thirsty-banner {
  background: linear-gradient(100deg, rgba(122,138,145,.18), rgba(122,138,145,.06));
  border: 1px solid var(--sky);
  border-radius: var(--r-lg);
  padding: 24px 28px;
  margin-bottom: 36px;
  display: flex; align-items: center; gap: 20px;
}
.thirsty-banner .icon { font-size: 32px; }
.thirsty-banner strong { font-family: var(--font-display); font-weight: 500; font-size: 20px; }
.thirsty-banner ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: var(--ink-soft); }

/* ─── Plant detail ───────────────────────────────────── */
.plant-detail { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; }
@media (max-width: 880px) { .plant-detail { grid-template-columns: 1fr; gap: 32px; } }

.gallery-main {
  aspect-ratio: 4 / 5;
  background: var(--paper-deep);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 14px;
  position: relative;
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-main .empty {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 22px; color: var(--ink-soft);
}
.gallery-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.gallery-thumbs img {
  width: 60px; height: 60px; object-fit: cover;
  border-radius: var(--r-sm); cursor: pointer;
  opacity: .7; transition: opacity .2s;
}
.gallery-thumbs img:hover, .gallery-thumbs img.active { opacity: 1; }
.upload-btn {
  width: 60px; height: 60px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r-sm);
  background: transparent;
  font-size: 22px;
  color: var(--ink-soft);
  display: flex; align-items: center; justify-content: center;
}
.upload-btn:hover { border-color: var(--moss); color: var(--moss); }

.plant-head h1 {
  font-family: var(--font-display);
  font-weight: 350;
  font-size: clamp(40px, 5vw, 64px);
  margin: 0 0 4px;
  letter-spacing: -.02em;
}
.plant-head .species {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
  color: var(--moss);
  margin: 0 0 24px;
}
.plant-head .by {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .15em;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.factbox {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin: 24px 0;
}
.factbox dt { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft); padding: 14px 0 4px; }
.factbox dd { margin: 0 0 14px; font-family: var(--font-display); font-size: 20px; font-weight: 400; }
.factbox > div { padding: 0 20px 0 0; }

.timeline { margin-top: 16px; }
.timeline h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  margin: 28px 0 14px;
  display: flex; align-items: baseline; gap: 12px;
}
.timeline h3::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}

.entry {
  padding: 14px 0;
  border-bottom: 1px solid var(--paper-deep);
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 16px;
}
.entry:last-child { border-bottom: none; }
.entry .date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .08em;
}
.entry .content { font-size: 15px; }
.entry .tag {
  display: inline-block;
  padding: 2px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  border-radius: 999px;
  margin-right: 8px;
}
.entry .tag.water { background: rgba(122,138,145,.2); color: var(--sky); }
.entry .tag.fert  { background: rgba(184,89,58,.15); color: var(--terra); }
.entry .tag.note  { background: rgba(90,106,60,.15); color: var(--moss); }

.action-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 28px; }
.action-row button {
  background: var(--paper-deep);
  border: 1px solid var(--line);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px;
}
.action-row button:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.action-row button.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.action-row button.primary:hover { background: var(--moss-deep); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-soft);
}
.empty-state .glyph { font-family: var(--font-display); font-size: 64px; color: var(--moss); opacity: .4; line-height: 1; }
.empty-state h3 { font-family: var(--font-display); font-weight: 400; font-size: 28px; margin: 14px 0 8px; color: var(--ink); }
.empty-state p { max-width: 40ch; margin: 0 auto 20px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(31,42,26,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: 32px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 30px 80px -20px rgba(31,42,26,.5);
}
.modal h3 { font-family: var(--font-display); font-weight: 400; font-size: 28px; margin: 0 0 6px; }
.modal .close-btn { float: right; background: none; border: none; font-size: 22px; color: var(--ink-soft); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--paper);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.4);
  animation: toast .25s ease-out;
}
.toast.err { background: var(--terra); }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* Hide based on auth state — JS toggles classes on body */
body:not(.is-auth) [data-auth] { display: none !important; }
body.is-auth [data-anon] { display: none !important; }

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--paper-deep) 25%, #e8dfca 50%, var(--paper-deep) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-md);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
