:root {
  /* Palette: warm paper + moss green (primary) + clay terracotta (rare accent,
     tied to plant pots — used only for Premium/CTA and harvested-state badges,
     never as the dominant surface color). */
  --green: #3b6b4a;
  --green-dark: #294b34;
  --green-light: #e6eee1;
  --clay: #c1683a;
  --clay-dark: #9c4f27;
  --clay-mist: #f5e1d2;
  --amber: #c98a2e;
  --red: #c1442e;
  --text: #221c13;
  --muted: #7c7362;
  --border: #e7decb;
  --bg: #faf6ec;
  --bg-grad-top: #f2ebd9;
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --warn-bg: #fbf0d9;
  --warn-border: #e9ce8e;
  --harvested-bg: var(--clay-mist);
  --harvested-text: var(--clay-dark);
  --shadow: rgba(70, 50, 20, 0.1);
  --card-radius: 22px;
  --radius-sm: 14px;
  --font-body: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --content-width: 720px;
  --nav-width: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --green: #82c48d;
    --green-dark: #aee0b6;
    --green-light: rgba(130, 196, 141, 0.16);
    --clay: #e3986a;
    --clay-dark: #f0ae7e;
    --clay-mist: rgba(227, 152, 106, 0.16);
    --amber: #e0a94f;
    --red: #e07a63;
    --text: #f1ebdc;
    --muted: #a69c87;
    --border: #332c1f;
    --bg: #14120d;
    --bg-grad-top: #1b1811;
    --card-bg: #1e1b13;
    --input-bg: #262115;
    --warn-bg: #2e2712;
    --warn-border: #4d3f16;
    --shadow: rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  --green: #82c48d;
  --green-dark: #aee0b6;
  --green-light: rgba(130, 196, 141, 0.16);
  --clay: #e3986a;
  --clay-dark: #f0ae7e;
  --clay-mist: rgba(227, 152, 106, 0.16);
  --amber: #e0a94f;
  --red: #e07a63;
  --text: #f1ebdc;
  --muted: #a69c87;
  --border: #332c1f;
  --bg: #14120d;
  --bg-grad-top: #1b1811;
  --card-bg: #1e1b13;
  --input-bg: #262115;
  --warn-bg: #2e2712;
  --warn-border: #4d3f16;
  --shadow: rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

html { -webkit-tap-highlight-color: transparent; }

body {
  font-family: var(--font-body);
  background: linear-gradient(180deg, var(--bg-grad-top) 0%, var(--bg) 340px);
  color: var(--text);
  margin: 0;
  padding: 0 1.5rem 3rem;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: inherit; }

:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Scroll-scrubbed hero (index.html only) ──
   .hero is a pure scroll-distance spacer: its fixed-position child covers the
   viewport for the whole track, first scrubbing the video (see
   shared/hero-scroll.js), then crossfading into #app-section, whose negative
   margin-top (set from JS, matched to the fade portion of the scroll track)
   pulls it up to physically share screen space with the fading hero instead
   of just appearing once scrolled past — that overlap is what makes it read
   as one thing dissolving into the other rather than a hard scroll cut. */
.hero {
  position: relative;
  height: 210vh;
  margin: 0 -1.5rem 0;
}

.hero-sticky {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(160deg, var(--green-dark), var(--bg) 85%);
  z-index: 25;
  pointer-events: none;
}

.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(200deg, rgba(20, 15, 8, 0.15), rgba(15, 12, 7, 0.65));
}

.hero-text {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: var(--nav-width);
  margin: 0 auto;
  padding: 0 2rem 4rem;
  color: #fdfaf3;
}

.reveal-section {
  position: relative;
  z-index: 20;
  opacity: 0;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 0.6rem;
}

.hero-title {
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 0.9rem;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.4);
}

.hero-tagline {
  font-size: 1.1rem;
  line-height: 1.6;
  color: rgba(253, 250, 243, 0.92);
  max-width: 460px;
  margin: 0;
}

header {
  position: relative;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0.75rem 0 1.5rem;
  text-align: center;
  animation: fadeInUp 0.4s ease both;
}

header h1 {
  margin: 0.75rem 0 0.5rem;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.01em;
}

header p {
  color: var(--muted);
  margin: 0;
  font-size: 0.95rem;
}

main {
  max-width: var(--content-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

/* ── Classic top navbar (shared/nav.js → #nav-root) ── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  margin: 0 -1.5rem 1.5rem;
}

.site-nav-inner {
  max-width: var(--nav-width);
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.5rem;
}

.nav-brand {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex: 1;
}

.nav-link {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.3rem 0;
  border-bottom: 2px solid transparent;
}

.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--green); border-bottom-color: var(--green); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

/* Keep the navbar on one row even on real phone widths, instead of
   wrapping to a lopsided second line. */
@media (max-width: 480px) {
  .nav-brand-text { display: none; }
  .site-nav-inner { gap: 0.4rem 0.5rem; padding: 0.75rem 1rem; }
  .nav-links { gap: 0.85rem; }
  .nav-link { font-size: 0.85rem; }
  .nav-actions { gap: 0.5rem; }
  .icon-toggle { width: 34px; height: 34px; font-size: 0.95rem; }
  .nav-account { font-size: 0.8rem; padding: 0.4rem 0.7rem; max-width: 34vw; }
}

.icon-toggle {
  width: 38px;
  height: 38px;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-toggle:active { transform: scale(0.92); }

.nav-account {
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--green-dark);
  background: var(--green-light);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 40vw;
}

.nav-login {
  color: var(--card-bg);
  background: var(--green);
}

/* ── Cards ── */
.upload-card, .result-card, .chat-card, .history-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1.4rem;
  box-shadow: 0 2px 10px var(--shadow);
  transition: background 0.2s ease, border-color 0.2s ease;
  animation: fadeInUp 0.4s ease both;
}

.upload-card { position: relative; }

.vine {
  position: absolute;
  top: -6px;
  width: 62px;
  height: 62px;
  pointer-events: none;
  z-index: 1;
}

.vine-stem {
  fill: none;
  stroke: var(--green);
  stroke-width: 2.5;
  stroke-linecap: round;
  opacity: 0.85;
}

.vine-leaf { fill: var(--green); opacity: 0.85; }
.vine-leaf:nth-child(3) { fill: var(--clay); opacity: 0.7; }

.vine-left {
  left: -6px;
  transform-origin: 4px 4px;
  animation: vineSwayLeft 5s ease-in-out infinite;
}

.vine-right {
  right: -6px;
  transform-origin: 86px 4px;
  animation: vineSwayRight 5s ease-in-out infinite;
}

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

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

.drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  border: 2px dashed var(--clay);
  border: 2px dashed color-mix(in srgb, var(--clay) 55%, var(--border));
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--muted);
  text-align: center;
  padding: 1rem;
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--green);
  background: var(--green-light);
}

.drop-zone img {
  max-width: 100%;
  max-height: 320px;
  border-radius: 10px;
  object-fit: contain;
}

button {
  background: var(--green);
  color: var(--card-bg);
  border: none;
  border-radius: 16px;
  padding: 0.85rem 1.25rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  margin-top: 1rem;
  transition: opacity 0.15s, transform 0.12s, box-shadow 0.15s;
  box-shadow: 0 3px 10px var(--shadow);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--green) 35%, transparent);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

button:hover:not(:disabled) { opacity: 0.92; }
button:active:not(:disabled) { transform: scale(0.97); box-shadow: none; }

.premium-btn {
  background: linear-gradient(135deg, var(--clay), var(--clay-dark));
  box-shadow: 0 3px 10px var(--shadow);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--clay) 40%, transparent);
}

/* ── Loader: a two-leaf sprout unfurling, instead of a generic spinner ── */
.loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2.2rem 0;
  color: var(--muted);
}

.spinner {
  width: 40px;
  height: 34px;
  position: relative;
}

.spinner::before, .spinner::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 16px;
  height: 26px;
  background: var(--green);
}

.spinner::before {
  left: 3px;
  border-radius: 0 100% 0 100%;
  transform-origin: bottom right;
  animation: leafGrow 1.2s ease-in-out infinite;
}

.spinner::after {
  right: 3px;
  border-radius: 100% 0 100% 0;
  transform-origin: bottom left;
  animation: leafGrow 1.2s ease-in-out 0.2s infinite;
}

@keyframes leafGrow {
  0%, 100% { transform: scale(0.35) rotate(0deg); opacity: 0.55; }
  50% { transform: scale(1) rotate(-4deg); opacity: 1; }
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.species-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 700;
}

.result-header h2 {
  margin: 0.15rem 0 0;
  font-size: 1.35rem;
  font-weight: 800;
}

.state-badge {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--green-light);
  color: var(--green-dark);
}

.state-badge.harvested {
  background: var(--harvested-bg);
  color: var(--harvested-text);
}

.health-gauge {
  position: relative;
  width: 84px;
  height: 84px;
  flex-shrink: 0;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-track {
  fill: none;
  stroke: var(--border);
  stroke-width: 10;
}

.gauge-fill {
  fill: none;
  stroke: var(--green);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.9s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.3s ease;
}

.gauge-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 1.05rem;
}

.gauge-percent-sign {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  margin-left: 1px;
  font-weight: 500;
  color: var(--muted);
}

.health-note {
  color: var(--muted);
  margin: 0.9rem 0 1.1rem;
  line-height: 1.5;
}

.care-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.7rem;
}

.care-tile {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
}

.care-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.care-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.2rem;
}

.care-value {
  font-size: 0.92rem;
  line-height: 1.4;
}

.raw-details {
  margin-top: 1.1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.raw-details summary { cursor: pointer; }

.raw-details pre {
  white-space: pre-wrap;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

/* ── Chat / comments ── */
.chat-card h2 {
  margin-top: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

#chat-log, #comments-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 1rem;
  max-height: 320px;
  overflow-y: auto;
}

.chat-msg {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  max-width: 88%;
  font-size: 0.95rem;
  animation: fadeInUp 0.25s ease both;
}

.chat-msg.user {
  background: var(--green-light);
  align-self: flex-end;
}

.chat-msg.assistant {
  background: var(--bg);
  align-self: flex-start;
}

.chat-msg.loading {
  color: var(--muted);
  font-style: italic;
}

#chat-form, #comment-form {
  display: flex;
  gap: 0.5rem;
}

#chat-input, #comment-input {
  flex: 1;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  min-width: 0;
  background: var(--input-bg);
  color: var(--text);
}

#chat-form button, #comment-form button {
  width: auto;
  margin-top: 0;
  padding: 0.7rem 1.1rem;
  flex-shrink: 0;
}

.not-plant-notice {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
}

.not-plant-icon { font-size: 1.4rem; line-height: 1; }
.not-plant-title { font-weight: 800; margin-bottom: 0.3rem; }
.not-plant-text { margin: 0; color: var(--muted); line-height: 1.5; }

.quota-note {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.6rem;
}

.empty-note {
  font-size: 0.9rem;
  color: var(--muted);
  text-align: center;
  margin-top: 1rem;
}

.secondary-btn {
  background: transparent;
  color: var(--green-dark);
  border: 1px solid var(--border);
  box-shadow: none;
}

.secondary-btn:hover:not(:disabled) {
  background: var(--green-light);
  opacity: 1;
}

.result-actions { margin-top: 1.1rem; }
.result-actions button { margin-top: 0; }

.share-toast {
  font-size: 0.8rem;
  color: var(--green-dark);
  text-align: center;
  margin-top: 0.5rem;
  min-height: 1em;
}

/* ── History ── */
.history-card summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

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

#history-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin: 1rem 0;
  max-height: 360px;
  overflow-y: auto;
}

.history-item-wrapper {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.history-delete-btn {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 72px;
  margin: 0;
  border: none;
  border-radius: 0;
  background: var(--red);
  color: #fff;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none;
}

@keyframes swipeHint {
  0%, 100% { transform: translateX(0); }
  28% { transform: translateX(-30px); }
  50% { transform: translateX(-6px); }
  70% { transform: translateX(-22px); }
}

.history-item.swipe-hint {
  animation: swipeHint 1.3s ease-in-out 0.4s 1;
}

.history-item {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  margin-top: 0;
  touch-action: pan-y;
  user-select: none;
  box-shadow: none;
}

.history-item:hover { border-color: var(--green); opacity: 1; }

.history-thumb {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--card-bg);
}

.history-info { flex: 1; min-width: 0; }

.history-species {
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.history-empty { color: var(--muted); font-size: 0.85rem; padding: 0.5rem 0; }

#history-clear-btn { font-size: 0.85rem; padding: 0.55rem 1rem; }

/* ── Auth (giris.html) ── */
.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.1rem;
}

.auth-tab {
  flex: 1;
  width: auto;
  margin-top: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: none;
}

.auth-tab.active {
  background: var(--green-light);
  color: var(--green-dark);
  border-color: var(--green-light);
}

#auth-form input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  background: var(--input-bg);
  color: var(--text);
  margin-top: 0.6rem;
}

.auth-note {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.8rem;
}

/* ── Blog feed & post composer ── */
#feed {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-card {
  display: block;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  box-shadow: 0 2px 10px var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  animation: fadeInUp 0.4s ease both;
  transition: transform 0.15s ease;
}

@media (hover: hover) {
  .post-card:hover { transform: translateY(-2px); }
}

.post-card img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  display: block;
}

.post-card-body { padding: 0.9rem 1.1rem; }

.post-card-author {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.post-card-caption { margin-bottom: 0.5rem; }

.post-card-stats {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
}

.post-detail-image {
  width: 100%;
  max-height: 480px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

#new-caption {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  resize: vertical;
  margin-top: 0.9rem;
}

/* ── Profile grid ── */
#profile-feed {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

#profile-feed .post-card { border-radius: 10px; aspect-ratio: 1 / 1; }
#profile-feed .post-card img { height: 100%; max-height: none; }

/* Mobile fine-tuning for very small phones */
@media (max-width: 380px) {
  .upload-card, .result-card, .chat-card, .history-card { padding: 1.1rem; }
  .drop-zone { min-height: 160px; }
  .result-header { flex-direction: column; align-items: flex-start; }
  .health-gauge { align-self: center; }
  .care-grid { grid-template-columns: 1fr; }
  .chat-msg { max-width: 96%; }
}

/* Desktop: give the nav and hero more breathing room */
@media (min-width: 900px) {
  .site-nav-inner { padding: 1.1rem 2.5rem; }
  .nav-links { gap: 1.75rem; }
}
