/* ===========================================================
   Receptfüzet – stíluslap
   Világos / sötét téma, meleg "konyhás" színpaletta
   =========================================================== */

:root {
  --bg: #f7f3ec;
  --bg-soft: #efe8dd;
  --card: #ffffff;
  --text: #2a2320;
  --text-soft: #756a62;
  --line: #e3d9cb;
  --brand: #9c3d2e;
  --brand-dark: #7d2f23;
  --accent: #d9932b;
  --accent-soft: #fdf3e0;
  --green: #4d7c4a;
  --green-soft: #eaf3e7;
  --shadow: 0 1px 2px rgba(42, 35, 32, .05), 0 6px 18px rgba(42, 35, 32, .06);
  --shadow-lg: 0 12px 40px rgba(42, 35, 32, .22);
  --radius: 14px;
  --radius-sm: 9px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --font-title: ui-serif, Georgia, "Times New Roman", serif;
  color-scheme: light;
}

body.dark {
  --bg: #1b1815;
  --bg-soft: #241f1b;
  --card: #262120;
  --text: #f0e9e1;
  --text-soft: #a99e94;
  --line: #3a3230;
  --brand: #e07a63;
  --brand-dark: #c56450;
  --accent: #e8b35a;
  --accent-soft: #3a2f1d;
  --green: #86bd80;
  --green-soft: #22301f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  transition: background .2s ease, color .2s ease;
}

h1, h2, h3 { font-family: var(--font-title); letter-spacing: -.01em; }

/* ---------- Fejléc ---------- */
.topbar {
  background: linear-gradient(140deg, var(--brand-dark), var(--brand) 70%);
  color: #fff;
  padding: 20px clamp(14px, 4vw, 34px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: clamp(22px, 3.4vw, 30px); }
.subtitle { opacity: .82; font-size: 14px; margin-top: 2px; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Gombok ---------- */
button, .file-btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform .12s ease, box-shadow .12s ease,
              background .15s ease, filter .15s ease;
}
button:hover, .file-btn:hover { filter: brightness(.97); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:focus-visible, .file-btn:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.primary { background: var(--accent); color: #2a2320; border-color: #00000018; }
.ghost { background: #ffffff1f; color: #fff; border-color: #ffffff4d; }
.ghost:hover { background: #ffffff33; }
.danger { color: var(--brand); }
.file-btn input { display: none; }
.icon-btn { padding: 9px 11px; }

/* ---------- Elrendezés ---------- */
.container { max-width: 1240px; margin: auto; padding: clamp(14px, 3vw, 26px); }

.tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}
.tool-card, .filters, .recipe-card, .empty {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tool-card { padding: 15px 16px; }
.tool-card h2 {
  font-size: 13px;
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-soft);
  margin: 0 0 9px;
}
.tool-card input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--bg-soft);
  color: var(--text);
}
.tool-card small { display: block; margin-top: 7px; color: var(--text-soft); font-size: 12.5px; }
.home-card { border-top: 4px solid var(--accent); }

/* ---------- Szűrők ---------- */
.filters {
  margin-top: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px 20px;
  flex-wrap: wrap;
}
.filters label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.filters select {
  margin-left: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--bg-soft);
  color: var(--text);
}
.letters { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-left: 6px; }
.letters button {
  padding: 5px 9px;
  min-width: 32px;
  justify-content: center;
  background: var(--bg-soft);
  border-color: var(--line);
  font-size: 13.5px;
}
.letters button.active { background: var(--brand); color: #fff; border-color: transparent; }
.letters button:disabled { opacity: .3; cursor: default; transform: none; }
.spacer { margin-left: auto; }

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 4px 10px;
  color: var(--text-soft);
  font-size: 14px;
}

/* ---------- Receptkártyák ---------- */
.recipe-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.recipe-card {
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  position: relative;
}
.recipe-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.recipe-card:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.thumb {
  aspect-ratio: 16 / 9;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  color: var(--text-soft);
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe-card:not(:has(.thumb)) { border-top: 4px solid var(--brand); }
.card-body { padding: 14px 15px 15px; display: flex; flex-direction: column; flex: 1; }
.recipe-card h3 { margin: 0 0 4px; font-size: 19px; color: var(--text); padding-right: 30px; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-soft); }
.chip {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 100px;
}
.snippet {
  margin-top: 10px;
  white-space: pre-line;
  color: var(--text-soft);
  font-size: 14px;
  flex: 1;
}
.match {
  display: inline-block;
  margin-top: 10px;
  background: var(--green-soft);
  color: var(--green);
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  align-self: flex-start;
}
.card-buttons {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.card-buttons button { padding: 7px 10px; font-size: 13.5px; background: var(--bg-soft); }
.fav-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: #ffffffdd;
  border-radius: 50%;
  padding: 6px 8px;
  font-size: 16px;
  line-height: 1;
  box-shadow: var(--shadow);
  z-index: 2;
}
body.dark .fav-btn { background: #000000a6; }

.empty {
  padding: 46px 24px;
  text-align: center;
  border-style: dashed;
  color: var(--text-soft);
  grid-column: 1 / -1;
}
.empty strong { display: block; font-size: 17px; color: var(--text); margin-bottom: 6px; }

/* ---------- Modális ablakok ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 15, 12, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 3vw, 24px);
  z-index: 50;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0 } }
.hidden { display: none !important; }
.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  max-width: 780px;
  width: 100%;
  max-height: 92vh;
  overflow: auto;
  padding: clamp(18px, 3vw, 28px);
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0 } }
.close {
  position: absolute;
  right: 10px; top: 10px;
  background: var(--bg-soft);
  border-radius: 50%;
  width: 36px; height: 36px;
  padding: 0;
  justify-content: center;
  font-size: 20px;
  z-index: 3;
}
.modal-box > h2 { margin: 0 0 4px; padding-right: 44px; }

/* ---------- Űrlap ---------- */
form label { display: block; margin: 14px 0 0; font-weight: 600; font-size: 14px; }
form input:not([type=file]), form textarea, form select {
  display: block;
  width: 100%;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  background: var(--bg-soft);
  color: var(--text);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 14px; }
.hint { font-weight: 400; color: var(--text-soft); font-size: 12.5px; display: block; margin-top: 4px; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
  flex-wrap: wrap;
  position: sticky;
  bottom: -28px;
  background: linear-gradient(to top, var(--card) 60%, transparent);
  padding: 14px 0 0;
}
.image-preview img { max-width: 100%; max-height: 260px; border-radius: var(--radius-sm); margin-top: 10px; }
.image-preview { display: flex; align-items: flex-end; gap: 10px; }

/* ---------- Recept megtekintése ---------- */
.recipe-view h1 { margin: 0 0 6px; font-size: clamp(24px, 4vw, 33px); }
.recipe-view .hero { width: 100%; max-height: 340px; object-fit: cover; border-radius: var(--radius-sm); margin: 14px 0; }
.recipe-view .section { margin-top: 24px; }
.recipe-view .section h2 {
  font-size: 13px;
  font-family: var(--font);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-soft);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin: 0 0 12px;
}
.recipe-view pre { white-space: pre-wrap; font: inherit; margin: 0; line-height: 1.65; }

.ing-list { list-style: none; margin: 0; padding: 0; }
.ing-list li { border-bottom: 1px dashed var(--line); }
.ing-list label {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 9px 2px;
  cursor: pointer;
  font-weight: 400;
  margin: 0;
  font-size: 16px;
}
.ing-list input { width: 19px; height: 19px; margin-top: 2px; accent-color: var(--green); flex: none; }
.ing-list input:checked + span { text-decoration: line-through; color: var(--text-soft); }

.scaler { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; font-size: 14px; }
.scaler button { padding: 5px 11px; background: var(--bg-soft); }
.scaler .val { font-weight: 700; min-width: 76px; text-align: center; }

body.cooking .modal-box.recipe-view { max-width: 980px; font-size: 19px; }
body.cooking .recipe-view pre,
body.cooking .ing-list label { font-size: 20px; line-height: 1.75; }
body.cooking .recipe-view .hero { display: none; }

/* ---------- Toast ---------- */
.toasts {
  position: fixed;
  bottom: 18px; left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  width: min(440px, calc(100% - 24px));
}
.toast {
  background: #2a2320;
  color: #fff;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14.5px;
  animation: pop .18s ease;
}
.toast button { background: #ffffff26; color: #fff; padding: 6px 10px; font-size: 13px; margin-left: auto; }
body.dark .toast { background: #423938; color: #f6f0ea; }

/* ---------- Mobil ---------- */
@media (max-width: 720px) {
  .topbar { align-items: flex-start; }
  .top-actions { width: 100%; }
  .top-actions button, .top-actions .file-btn { flex: 1; justify-content: center; }
  .filters { gap: 10px; }
  .spacer { margin-left: 0; }
  .toasts { left: 12px; right: 12px; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Nyomtatás ---------- */
@media print {
  body { background: #fff; color: #000; }
  .topbar, .container, .toasts, #modal, .close,
  .form-actions, .scaler, .fav-btn { display: none !important; }
  #viewModal { position: static; display: block !important; background: none; padding: 0; backdrop-filter: none; }
  .modal-box {
    box-shadow: none;
    max-height: none;
    max-width: none;
    padding: 0;
    overflow: visible;
    animation: none;
  }
  .recipe-view .hero { max-height: 70mm; }
  .recipe-view .section { page-break-inside: avoid; }
  .ing-list input { display: none; }
  .ing-list li { display: list-item; list-style: disc; margin-left: 20px; border: 0; }
  .ing-list label { display: inline; padding: 0; }
  .recipe-view pre, .ing-list label { font-size: 12pt; }
  .recipe-view h1 { font-size: 22pt; }
}

/* ---------- Lábjegyzet ---------- */
.foot {
  max-width: 1240px;
  margin: 0 auto;
  padding: 6px clamp(14px, 3vw, 26px) 30px;
  color: var(--text-soft);
  font-size: 12.5px;
}
.foot code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 12px;
  word-break: break-all;
}
@media print { .foot { display: none !important; } }

/* ---------- Bejelentkezés ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(140deg, var(--brand-dark), var(--brand) 70%);
}
.auth-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px;
  max-width: 400px;
  width: 100%;
}
.auth-box h1 { margin: 0 0 6px; font-size: 26px; }
.auth-sub { color: var(--text-soft); margin: 0 0 18px; font-size: 14px; }
.auth-box input {
  display: block; width: 100%; margin: 8px 0; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; background: var(--bg-soft); color: var(--text);
}
.auth-buttons { display: flex; gap: 8px; margin-top: 14px; }
.auth-buttons button { flex: 1; justify-content: center; padding: 12px; }
.auth-msg { margin-top: 12px; font-size: 14px; min-height: 20px; }
.auth-msg.error { color: var(--brand); }
.auth-msg.ok { color: var(--green); }