/* ── crumb — Blue Hearts visual signature ─────────────────────────────── */

:root {
  --bg-deep: #0a0e1a;
  --bg-card: #111827;
  --bg-card-hover: #162033;
  --border: #1e3a5f;
  --border-soft: #1a2942;
  --blue: #3b82f6;
  --blue-light: #60a5fa;
  --blue-bright: #93c5fd;
  --blue-glow: rgba(59, 130, 246, 0.3);
  --gold: #fbbf24;
  --gold-glow: rgba(251, 191, 36, 0.25);
  --green: #34d399;
  --orange: #fb923c;
  --red: #f87171;
  --text: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.06), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(59, 130, 246, 0.04), transparent 50%);
}

a { color: var(--blue-light); text-decoration: none; }
a:hover { color: var(--blue-bright); }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* ── Topbar ──────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--text);
}
.brand:hover { color: var(--text); }
.brand-icon { font-size: 1.5rem; }
.brand-name {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 0.25rem;
}

.topnav { display: flex; gap: 1rem; align-items: center; }
.nav-link {
  padding: 0.5rem 0.85rem;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.nav-link:hover {
  color: var(--text);
  background: var(--bg-card);
}
.nav-cta {
  border: 1px solid var(--border);
  color: var(--blue-light);
}
.nav-cta:hover {
  border-color: var(--blue);
  background: rgba(59, 130, 246, 0.08);
  box-shadow: 0 0 0 3px var(--blue-glow);
  color: var(--blue-bright);
}

/* ── Main ────────────────────────────────────────────────────────────── */

.main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}

.loading, .error {
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.error { color: var(--red); }

/* ── Footer ──────────────────────────────────────────────────────────── */

.footer {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-soft);
  font-family: var(--font-mono);
}
.footer a { font-size: 1rem; }

/* ── Page headers ────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}
.page-header h1 {
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.4rem;
}
.crumbs {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.crumbs a { color: var(--text-secondary); }

/* ── Tree view ───────────────────────────────────────────────────────── */

.tree {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.tree-empty {
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-secondary);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.tree-node {
  position: relative;
}
.tree-children {
  margin-left: 2rem;
  padding-left: 1.25rem;
  border-left: 2px solid var(--border-soft);
  margin-top: 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ── Recipe card ─────────────────────────────────────────────────────── */

.recipe-card {
  display: block;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  transition: all 0.15s;
  position: relative;
}
.recipe-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--blue);
  transform: translateX(2px);
  color: var(--text);
  box-shadow: 0 0 0 3px var(--blue-glow);
}

.recipe-card.crowned {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.06), var(--bg-card));
}
.recipe-card.crowned:hover {
  box-shadow: 0 0 0 3px var(--gold-glow);
}
.recipe-card.abandoned {
  opacity: 0.5;
  border-style: dashed;
}

.recipe-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.recipe-name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.recipe-name .crown { color: var(--gold); margin-right: 0.3rem; }

.recipe-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.78rem;
}
.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  background: var(--border-soft);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.tag.gen { background: rgba(59, 130, 246, 0.1); color: var(--blue-light); border-color: var(--blue); }
.tag.crowned { background: rgba(251, 191, 36, 0.12); color: var(--gold); border-color: var(--gold); }
.tag.abandoned { color: var(--text-muted); }
.tag.success { background: rgba(52, 211, 153, 0.12); color: var(--green); border-color: var(--green); }
.tag.partial { background: rgba(251, 146, 60, 0.12); color: var(--orange); border-color: var(--orange); }
.tag.failure { background: rgba(248, 113, 113, 0.12); color: var(--red); border-color: var(--red); }

.recipe-summary {
  margin-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── Detail page ─────────────────────────────────────────────────────── */

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
@media (min-width: 800px) {
  .detail-grid { grid-template-columns: 1fr 1fr; }
}

.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}
.section h2 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.section h2 small {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  font-size: 0.88rem;
}
.kv dt {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  white-space: nowrap;
}
.kv dd { color: var(--text); }
.kv dd.muted { color: var(--text-muted); }

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover {
  border-color: var(--blue);
  color: var(--blue-light);
  box-shadow: 0 0 0 3px var(--blue-glow);
}
.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: white;
}
.btn-primary:hover {
  background: var(--blue-light);
  border-color: var(--blue-light);
  color: white;
}
.btn-gold {
  border-color: var(--gold);
  color: var(--gold);
}
.btn-gold:hover {
  background: rgba(251, 191, 36, 0.1);
  box-shadow: 0 0 0 3px var(--gold-glow);
  color: var(--gold);
}
.btn-danger:hover {
  border-color: var(--red);
  color: var(--red);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
}

/* ── Bakes list ──────────────────────────────────────────────────────── */

.bake-list { display: flex; flex-direction: column; gap: 0.75rem; }
.bake-item {
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  background: rgba(17, 24, 39, 0.5);
}
.bake-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}
.bake-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}
.bake-ratings {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}
.bake-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.bake-photo {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-soft);
}

.bake-notes {
  margin-top: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: pre-wrap;
}

/* ── Forms ───────────────────────────────────────────────────────────── */

.form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 760px;
}
.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}
.form-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
  color: var(--blue-light);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem 1rem;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.form-field label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.form-field input,
.form-field select,
.form-field textarea {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.5rem 0.7rem;
  color: var(--text);
  font-size: 0.9rem;
  transition: all 0.15s;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-glow);
}
.form-field textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}
.form-field .hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.form-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  align-items: center;
}
.form-msg {
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
.form-msg.error { color: var(--red); }
.form-msg.success { color: var(--green); }

details.advanced {
  margin-top: 0.75rem;
}
details.advanced summary {
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.4rem 0;
}
details.advanced summary:hover { color: var(--blue-light); }

/* ── Photo upload ────────────────────────────────────────────────────── */

.photo-uploads {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.photo-upload-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.photo-upload-row select { flex: 0 0 140px; }
.photo-upload-row input[type=file] { flex: 1; }
.photo-upload-row button { flex: 0 0 auto; }
