/* ============================================================
   app.css – Global styles for "Unser Kochbuch"
   Complements Tailwind CDN classes.
   ============================================================ */

/* ── Fonts ───────────────────────────────────────────────── */
:root {
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
}

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

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

body {
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* ── Focus Styles ────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid #ed6f14;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Custom Scrollbar ────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.dark ::-webkit-scrollbar-thumb { background: #334155; }

/* ── Form Elements ───────────────────────────────────────── */
.form-input {
  display: block;
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.9375rem;
  font-family: var(--font-body);
  border: 1.5px solid #e5e7eb;
  border-radius: 0.75rem;
  background-color: #fff;
  color: #111827;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.dark .form-input {
  border-color: #334155;
  background-color: #1e293b;
  color: #f1f5f9;
}

.form-input:focus {
  border-color: #ed6f14;
  box-shadow: 0 0 0 3px rgba(237, 111, 20, 0.15);
}

.form-input::placeholder { color: #9ca3af; }
.dark .form-input::placeholder { color: #64748b; }

textarea.form-input { resize: vertical; min-height: 6rem; }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.375rem;
}

.dark .form-label { color: #94a3b8; }

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: var(--font-body);
  border-radius: 0.75rem;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.25;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background-color: #ed6f14;
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background-color: #de540a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(237, 111, 20, 0.3);
}

.btn-secondary {
  background-color: #f3f4f6;
  color: #374151;
}
.dark .btn-secondary {
  background-color: #1e293b;
  color: #cbd5e1;
}
.btn-secondary:hover:not(:disabled) {
  background-color: #e5e7eb;
}
.dark .btn-secondary:hover:not(:disabled) {
  background-color: #293548;
}

.btn-ghost {
  background-color: transparent;
  color: #6b7280;
}
.btn-ghost:hover { background-color: #f9fafb; }
.dark .btn-ghost:hover { background-color: #1e293b; }

.btn-danger {
  background-color: #fee2e2;
  color: #991b1b;
}
.btn-danger:hover:not(:disabled) { background-color: #fecaca; }

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  border-radius: 0.5rem;
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
  border-radius: 1rem;
}

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background-color: #fff;
  border-radius: 1rem;
  border: 1px solid #f3f4f6;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.dark .card {
  background-color: #1e293b;
  border-color: #334155;
}

.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

/* ── Recipe Card ─────────────────────────────────────────── */
.recipe-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.recipe-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.recipe-card-image {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background-color: #f9fafb;
}

.dark .recipe-card-image { background-color: #0f172a; }

/* ── Tags ────────────────────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  background-color: #fef7ee;
  color: #9a3412;
  border: 1px solid #fed7aa;
}

.dark .tag {
  background-color: #431407;
  color: #fdba74;
  border-color: #7c2d12;
}

/* ── Drag & Drop ─────────────────────────────────────────── */
.sortable-ghost {
  opacity: 0.3;
  background-color: #fef7ee !important;
}

.dark .sortable-ghost { background-color: #431407 !important; }

.sortable-drag {
  box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important;
  rotate: 1deg;
}

.drag-handle {
  cursor: grab;
  color: #d1d5db;
  transition: color 0.15s;
}

.drag-handle:hover { color: #9ca3af; }
.drag-handle:active { cursor: grabbing; }

/* ── Step Editor ─────────────────────────────────────────── */
.step-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background-color: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dark .step-item {
  background-color: #1e293b;
  border-color: #334155;
}

.step-item:focus-within {
  border-color: #ed6f14;
  box-shadow: 0 0 0 3px rgba(237,111,20,0.1);
}

.step-number {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background-color: #ed6f14;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Image Upload Preview ────────────────────────────────── */
.image-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 0.5rem;
}

.image-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 0.5rem;
  overflow: hidden;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-item .remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: rgba(0,0,0,0.6);
  color: #fff;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  padding: 0;
  line-height: 1;
}

/* ── Safe area (iOS) ─────────────────────────────────────── */
.h-safe-bottom { height: env(safe-area-inset-bottom, 0px); }

/* ── Transitions ─────────────────────────────────────────── */
[x-cloak] { display: none !important; }

.fade-in {
  animation: fadeIn 0.25s ease-out;
}

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

/* ── Flash messages ──────────────────────────────────────── */
.flash-message {
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Search highlight ────────────────────────────────────── */
mark {
  background-color: #fed7aa;
  color: #9a3412;
  border-radius: 2px;
  padding: 0 2px;
}
.dark mark {
  background-color: #7c2d12;
  color: #fdba74;
}

/* ============================================================
   PRINT STYLESHEET
   Always prints in light mode, clean layout for DIN A4.
   ============================================================ */
@media print {
  /* Force light mode regardless of dark mode setting */
  :root { color-scheme: light !important; }
  html { background: #fff !important; color: #000 !important; }
  .dark body { background: #fff !important; color: #000 !important; }
  * { background: transparent !important; box-shadow: none !important; }

  /* Hide navigation and UI chrome */
  aside, header, nav, footer,
  .btn, .no-print,
  #mobile-nav,
  .flash-message { display: none !important; }

  /* Layout reset for print */
  body { font-family: Georgia, serif !important; font-size: 11pt !important; line-height: 1.5; }
  main { display: block !important; width: 100% !important; }

  /* Page setup */
  @page { size: A4; margin: 2cm; }

  /* Recipe title */
  .print-recipe-title {
    font-size: 22pt;
    font-weight: bold;
    margin-bottom: 0.5cm;
    border-bottom: 2px solid #000;
    padding-bottom: 0.3cm;
  }

  /* Metadata row */
  .print-meta { font-size: 9pt; color: #333; margin-bottom: 0.5cm; }

  /* Ingredients list */
  .print-ingredients { margin-bottom: 0.7cm; }
  .print-ingredients h2 { font-size: 13pt; font-weight: bold; margin-bottom: 0.3cm; }
  .print-ingredients li {
    display: flex;
    justify-content: space-between;
    padding: 2pt 0;
    border-bottom: 0.5pt solid #eee;
  }

  /* Steps */
  .print-steps h2 { font-size: 13pt; font-weight: bold; margin-bottom: 0.3cm; }
  .print-steps .step {
    display: flex;
    gap: 0.4cm;
    margin-bottom: 0.4cm;
    break-inside: avoid;
  }
  .print-steps .step-num {
    width: 1.2em;
    height: 1.2em;
    border-radius: 50%;
    background: #000 !important;
    color: #fff !important;
    font-size: 10pt;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Step images: small, black & white */
  .print-steps img { max-height: 3cm; filter: grayscale(100%); break-inside: avoid; }

  /* Tags */
  .tag { border: 0.5pt solid #999 !important; color: #333 !important; font-size: 8pt; }

  a { color: #000 !important; text-decoration: none !important; }

  /* No widows or orphans */
  p { widows: 3; orphans: 3; }
  h2, h3 { page-break-after: avoid; }
}
