/* ============================================================
   Family Recipe Share — warm, inviting cook-app aesthetic
   ============================================================ */

:root {
  --cream: #FBF6EF;
  --cream-dark: #F3E8D8;
  --paper: #FFFCF7;
  --ink: #2C2118;
  --ink-soft: #5C4A3A;
  --muted: #8A7360;
  --border: #E8D5C0;
  --border-strong: #D4B896;
  --terracotta: #C45C26;
  --terracotta-dark: #A3481A;
  --terracotta-soft: #F5E0D4;
  --sage: #5A7A5A;
  --sage-soft: #E4EDE4;
  --gold: #C9A227;
  --gold-soft: #F5EDD0;
  --danger: #B33A3A;
  --danger-soft: #F8E0E0;
  --shadow: 0 2px 12px rgba(44, 33, 24, 0.08);
  --shadow-lg: 0 8px 32px rgba(44, 33, 24, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Source Sans 3", system-ui, sans-serif;
  --max: 720px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 0%, #F8EDE0 0%, transparent 50%),
    radial-gradient(ellipse at 90% 10%, #F0E8D8 0%, transparent 40%),
    var(--cream);
  line-height: 1.55;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---- Typography ---- */
h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
  margin: 0;
}

h1 { font-size: clamp(1.75rem, 5vw, 2.25rem); }
h2 { font-size: clamp(1.35rem, 4vw, 1.65rem); }
h3 { font-size: 1.15rem; }

p { margin: 0 0 0.75rem; color: var(--ink-soft); }

a { color: var(--terracotta); }

/* ---- Layout ---- */
.shell {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 1.1rem calc(2rem + var(--safe-bottom));
  flex: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(251, 246, 239, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.1rem;
}

.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  flex: 1;
  min-width: 0;
}

.brand-mark {
  font-size: 1.5rem;
  line-height: 1;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  border: 1.5px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--terracotta);
  color: #fff;
  box-shadow: 0 2px 8px rgba(196, 92, 38, 0.3);
}
.btn-primary:hover { background: var(--terracotta-dark); }

.btn-secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--cream-dark); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  padding: 0.55rem 0.75rem;
}
.btn-ghost:hover { background: var(--cream-dark); color: var(--ink); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { background: #f0c8c8; }

.btn-icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border-radius: 50%;
  font-size: 1.15rem;
}

.btn-sm {
  font-size: 0.85rem;
  padding: 0.5rem 0.85rem;
}

.btn-block { width: 100%; }

/* ---- Cards ---- */
.card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
}

.card-clickable {
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s, border-color 0.15s;
  text-decoration: none;
  color: inherit;
  display: block;
}
.card-clickable:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.recipe-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.recipe-card-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
}

.recipe-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.recipe-card-desc {
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #7A6410;
}

/* ---- Forms ---- */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field { display: flex; flex-direction: column; gap: 0.35rem; }

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.field .hint {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 400;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
textarea,
select {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px var(--terracotta-soft);
}

textarea {
  min-height: 6rem;
  resize: vertical;
  line-height: 1.5;
}

textarea.tall { min-height: 9rem; }

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 480px) {
  .row-2 { grid-template-columns: 1fr; }
}

/* ---- Search ---- */
.search-wrap {
  position: relative;
  margin: 1.25rem 0 1rem;
}

.search-wrap input {
  padding-left: 2.6rem;
  border-radius: 999px;
  background: var(--paper);
}

.search-icon {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.05rem;
  pointer-events: none;
  opacity: 0.6;
}

/* ---- Hero / empty ---- */
.hero {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}

.hero-emoji { font-size: 3rem; margin-bottom: 0.5rem; }

.hero p {
  max-width: 28rem;
  margin: 0.5rem auto 1.25rem;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}

.empty-state .emoji { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* ---- Recipe list ---- */
.recipe-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0.5rem 0 1rem;
}

.section-header h1 { flex: 1; }

/* ---- Detail / cook mode ---- */
.recipe-hero {
  padding: 1.5rem 0 0.5rem;
}

.recipe-hero .eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--terracotta);
  margin-bottom: 0.4rem;
}

.recipe-hero h1 {
  font-size: clamp(1.85rem, 6vw, 2.5rem);
  margin-bottom: 0.6rem;
}

.meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--cream-dark);
  color: var(--ink-soft);
}

.pill-sage { background: var(--sage-soft); color: var(--sage); }

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem;
}

.cook-section {
  margin: 1.75rem 0;
}

.cook-section h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--border);
}

.cook-section h2 .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: var(--terracotta);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
}

.ingredient-list,
.step-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ingredient-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  font-size: 1.05rem;
  line-height: 1.45;
}

.ingredient-item:hover { background: var(--cream-dark); }

.ingredient-item.checked {
  opacity: 0.55;
  text-decoration: line-through;
  text-decoration-color: var(--muted);
}

.ingredient-item input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.15rem;
  accent-color: var(--sage);
  flex-shrink: 0;
  cursor: pointer;
}

.step-item {
  display: flex;
  gap: 0.9rem;
  padding: 1rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 1.1rem;
  line-height: 1.55;
}

.step-item:last-child { border-bottom: none; }

.step-num {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--terracotta-soft);
  color: var(--terracotta-dark);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}

.notes-box {
  background: var(--gold-soft);
  border-left: 4px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 1rem 1.15rem;
  font-size: 1.05rem;
  color: var(--ink-soft);
  white-space: pre-wrap;
}

.family-banner {
  background: var(--sage-soft);
  color: var(--sage);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #c8d8c8;
}

/* ---- Modal / PIN ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(44, 33, 24, 0.45);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.18s ease;
}

@media (min-width: 540px) {
  .overlay { align-items: center; }
}

.modal {
  background: var(--paper);
  border-radius: var(--radius) var(--radius) calc(var(--radius) + 4px) calc(var(--radius) + 4px);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  padding: 1.5rem 1.35rem calc(1.5rem + var(--safe-bottom));
  animation: slideUp 0.22s ease;
}

.modal h2 { margin-bottom: 0.4rem; }
.modal .lead { margin-bottom: 1.25rem; font-size: 0.95rem; }

.pin-input {
  font-size: 1.5rem !important;
  letter-spacing: 0.4em;
  text-align: center;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: calc(1.5rem + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-width: calc(100% - 2rem);
  transition: transform 0.25s ease;
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ---- Preview badge ---- */
.preview-banner {
  background: var(--terracotta);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.preview-banner .btn {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border-color: rgba(255,255,255,0.4);
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}
.preview-banner .btn:hover { background: rgba(255,255,255,0.3); }

/* ---- Status chip ---- */
.owner-chip {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: var(--terracotta-soft);
  color: var(--terracotta-dark);
}

/* ---- Print ---- */
@media print {
  body {
    background: #fff;
    color: #000;
    font-size: 12pt;
  }
  .topbar, .action-bar, .family-banner, .preview-banner,
  .btn, .toast, .overlay, .search-wrap, .no-print {
    display: none !important;
  }
  .shell { max-width: none; padding: 0; }
  .ingredient-item { cursor: default; }
  .ingredient-item input { display: none; }
  .step-item { page-break-inside: avoid; }
  .cook-section h2 { border-bottom-color: #ccc; }
  a { color: inherit; text-decoration: none; }
}

/* ---- Utilities ---- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  border: 0;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.flex-1 { flex: 1; }

/* ---- Cover / hero images ---- */
.shell-bleed {
  padding-left: 0;
  padding-right: 0;
}
.shell-bleed > .recipe-hero,
.shell-bleed > .cook-section,
.shell-bleed > .action-bar,
.shell-bleed > .text-center {
  padding-left: 1.1rem;
  padding-right: 1.1rem;
}

.hero-cover {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--cream-dark);
  border-radius: 0 0 var(--radius) var(--radius);
}
.hero-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-cover-empty {
  aspect-ratio: 16 / 5;
  max-height: 140px;
}
.hero-cover-gradient {
  width: 100%;
  height: 100%;
  background:
    linear-gradient(135deg, #E8C4A0 0%, #C45C26 45%, #8B4513 100%);
  opacity: 0.55;
}

.recipe-hero { padding-top: 1.25rem; }

.step-body { flex: 1; min-width: 0; }
.step-text { margin-bottom: 0; }
.step-photo {
  margin: 0.75rem 0 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--cream-dark);
  max-width: 100%;
}
.step-photo img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: cover;
}

/* ---- Home list thumbnails ---- */
.recipe-card {
  flex-direction: row;
  align-items: stretch;
  gap: 0;
  padding: 0;
  overflow: hidden;
}
.recipe-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1rem 1.1rem;
  flex: 1;
  min-width: 0;
}
.card-cover {
  width: 108px;
  flex-shrink: 0;
  align-self: stretch;
  min-height: 108px;
  overflow: hidden;
  background: var(--cream-dark);
}
.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    145deg,
    hsl(calc(20 + var(--ph, 30) * 1deg), 45%, 82%),
    hsl(calc(15 + var(--ph, 30) * 1deg), 55%, 55%)
  );
  font-size: 1.75rem;
}
@media (max-width: 420px) {
  .card-cover { width: 88px; min-height: 88px; }
}

/* ---- Photo editor ---- */
.cover-editor {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.cover-editor-preview {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px dashed var(--border-strong);
  background: var(--cream-dark);
}
.cover-editor-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover-editor-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}
.cover-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.file-btn { cursor: pointer; margin: 0; }

.steps-editor {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.step-editor {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.step-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.step-editor-num {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--terracotta-soft);
  color: var(--terracotta-dark);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.step-text-input {
  min-height: 4rem !important;
}
.step-photo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}
.step-photo-preview {
  width: 96px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.step-photo-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.step-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.size-hint, .size-warn {
  font-size: 0.85rem;
  margin: 0;
}
.size-warn {
  color: var(--terracotta-dark);
  background: var(--terracotta-soft);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
}

@media print {
  .hero-cover {
    border-radius: 0;
    max-height: 220px;
    break-inside: avoid;
  }
  .step-photo { max-width: 60%; }
  .card-cover, .cover-editor { display: none !important; }
}
