/* Mama Rezzas. No frameworks, no web fonts: system fonts only. */

:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --ink: #2b2622;
  --muted: #71675e;
  --line: #e6ddd0;
  --accent: #a83c24;
  --accent-hover: #8c2f1a;
  --accent-ink: #ffffff;
  --accent-soft: #f7e6df;
  --star: #c97a10;
  --danger: #a02121;
  --radius: 10px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1917;
    --surface: #26221f;
    --ink: #f0e9df;
    --muted: #a99e92;
    --line: #3b3530;
    --accent: #e8826a;
    --accent-hover: #f09a85;
    --accent-ink: #1c1917;
    --accent-soft: #3a2620;
    --star: #e6a23c;
    --danger: #f08a8a;
  }
}

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

[hidden] { display: none !important; }

html { font-size: 17px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
}

h1, h2, h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.5em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 1em; }

a { color: var(--accent); text-underline-offset: 0.15em; }
a:hover { color: var(--accent-hover); }

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

.container { max-width: 68rem; margin: 0 auto; padding: 0 1.1rem; }
main.container { padding-top: 2.25rem; padding-bottom: 4rem; }

@media (max-width: 30rem) {
  h1, .hero h1, .recipe h1 { font-size: 1.75rem; }
  .recipe-body { padding: 1.1rem 1rem; }
}

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.lead { font-size: 1.15rem; color: var(--muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- Header ---- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }

.site-header .container {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem 1.25rem;
  padding-top: 0.7rem; padding-bottom: 0.7rem;
}

.brand {
  font-family: var(--serif); font-size: 1.35rem; font-weight: 700;
  color: var(--ink); text-decoration: none; white-space: nowrap;
}
.brand:hover { color: var(--accent); }
.brand { display: inline-flex; align-items: center; }
.brand img { display: block; height: 3.6rem; width: auto; }

@media (max-width: 30rem) {
  .brand img { height: 3rem; }
}

/* The logo is dark red on transparent; give it a light plate on the dark header. */
@media (prefers-color-scheme: dark) {
  .brand { background: #faf6ef; border-radius: var(--radius); padding: 0.2rem 0.6rem; }
}

.search { flex: 1 1 14rem; display: flex; }

.site-nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.site-nav a { color: var(--ink); text-decoration: none; }
.site-nav a:hover { color: var(--accent); text-decoration: underline; }
.site-nav form { margin: 0; }

/* ---- Forms and buttons ---- */

.input {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
}
.input:focus { outline: 3px solid var(--accent-soft); border-color: var(--accent); }
textarea.input { min-height: 6rem; resize: vertical; }

.field { margin-bottom: 1rem; }
.label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.error { color: var(--danger); font-size: 0.9rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.5rem 0.95rem;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:disabled { opacity: 0.6; cursor: default; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }

.btn-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn-danger:hover { border-color: var(--danger); color: var(--danger); }
.btn-small { padding: 0.25rem 0.6rem; font-size: 0.875rem; font-weight: 500; }
.btn-large { padding: 0.75rem 1.1rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-link {
  background: none; border: none; padding: 0; font: inherit; cursor: pointer;
  color: var(--accent); text-decoration: underline; text-underline-offset: 0.15em;
}

.alert { border-radius: var(--radius); padding: 0.75rem 1rem; margin-bottom: 1rem; border: 1px solid var(--line); background: var(--surface); }
.alert-error { border-color: var(--danger); color: var(--danger); }

/* ---- Sign-in pages ---- */

.signin {
  max-width: 28rem; margin: 2rem auto; padding: 2rem 2rem 1.75rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 1px 2px rgba(43, 38, 34, 0.06), 0 12px 32px rgba(43, 38, 34, 0.12);
}
/* Signed-out pages have no header bar: the logo floats above the card. */
.auth-page main.container { padding-top: 3rem; }
.auth-logo { display: flex; justify-content: center; margin: 0 auto 1.5rem; }
.auth-logo img { display: block; width: min(20rem, 80%); height: auto; }
.auth-page .signin { margin-top: 0; }

@media (prefers-color-scheme: dark) {
  .auth-logo img { background: #faf6ef; border-radius: 14px; padding: 0.5rem 1rem; }
}

.signin > :last-child { margin-bottom: 0; }
.signin .btn + .btn, .signin form + form { margin-top: 0.75rem; }
.signin form + p { margin-top: 1.5rem; }
.signin .btn + p { margin-top: 0.75rem; }
.signin .input { background: var(--bg); }

@media (prefers-color-scheme: dark) {
  .signin { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.45); }
}

@media (max-width: 30rem) {
  .signin { margin: 1rem auto; padding: 1.5rem 1.25rem 1.25rem; }
}

.code-input { font-size: 1.75rem; letter-spacing: 0.4em; text-align: center; }

.divider { display: flex; align-items: center; gap: 0.75rem; margin: 1.25rem 0; color: var(--muted); }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

.rows { list-style: none; margin: 0 0 1rem; padding: 0; }
.rows li {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.7rem 0; border-bottom: 1px solid var(--line);
}

/* ---- Home and browse ---- */

.hero { margin-bottom: 2rem; }
.hero h1 { font-size: 2.3rem; margin-bottom: 0.2em; }

.section { margin-bottom: 2.5rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; }
.section-head h2 { margin: 0; }

/* Recipe lists: one row per recipe, like the old site's table. */
.recipe-list {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.recipe-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 8rem 9rem 3.5rem;
  align-items: baseline; gap: 0.2rem 1rem;
  padding: 0.6rem 1rem; border-top: 1px solid var(--line);
}
.recipe-row:first-child { border-top: none; }
.recipe-row:hover { background: var(--accent-soft); }
.recipe-row-head, .recipe-row-head:hover {
  background: none; color: var(--muted); font-size: 0.8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; padding-top: 0.5rem; padding-bottom: 0.4rem;
}
.recipe-row-title { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; text-decoration: none; }
.recipe-row-title:hover { text-decoration: underline; }
.recipe-row-main .tag { margin-left: 0.4rem; }
.recipe-row-main p {
  margin: 0.1rem 0 0; color: var(--muted); font-size: 0.9rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recipe-row-cuisine, .recipe-row-by { color: var(--muted); font-size: 0.9rem; }
.recipe-row-rating { text-align: right; font-size: 0.9rem; }
.by-label { display: none; }

/* Phones: name on the first line, the details in a line underneath, no column headings. */
@media (max-width: 40rem) {
  .recipe-row { display: flex; flex-wrap: wrap; gap: 0.1rem 1rem; }
  .recipe-row-head { display: none; }
  .recipe-row:nth-child(2) { border-top: none; }
  .recipe-row-main { flex: 0 0 100%; min-width: 0; }
  .recipe-row-rating { margin-left: auto; }
  .by-label { display: inline; }
}

.stars { color: var(--star); white-space: nowrap; }

.tag {
  display: inline-block; font-size: 0.75rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; padding: 0.05rem 0.55rem;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; list-style: none; margin: 0; padding: 0; }
.chip {
  display: inline-flex; align-items: baseline; gap: 0.4rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  padding: 0.3rem 0.8rem; color: var(--ink); text-decoration: none; font-size: 0.95rem;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip .count { color: var(--muted); font-size: 0.8rem; }
.chip-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem 1rem; margin-bottom: 1.1rem; }
.sort { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 2rem; }

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

/* ---- Recipe page ---- */

.recipe { max-width: 46rem; margin: 0 auto; }
.recipe h1 { font-size: 2.3rem; }

.recipe-meta { display: flex; flex-wrap: wrap; gap: 0.3rem 1.25rem; color: var(--muted); margin-bottom: 0.9rem; }
.recipe-meta strong { color: var(--ink); font-weight: 600; }

.recipe-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.1rem 0 1.6rem; }
.recipe-actions form { margin: 0; }

/* ---- Structured recipes ---- */
.recipe-body h2 { font-size: 1.25rem; margin: 1.4em 0 0.5em; }
.recipe-body h2:first-child { margin-top: 0; }
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredients li { padding: 0.3rem 0; border-bottom: 1px solid var(--line); margin: 0; }
.ingredients li:last-child { border-bottom: none; }
.steps { margin: 0; padding-left: 1.6rem; }
.steps li { margin-bottom: 0.7rem; padding-left: 0.25rem; }
.steps li::marker { font-weight: 700; color: var(--accent); }
.recipe-body .list-heading {
  list-style: none; font-family: var(--serif); font-weight: 600; font-size: 1.05rem;
  border-bottom: none; padding-top: 0.9rem;
}
.steps .list-heading { margin-left: -1.6rem; padding-left: 0; }
.recipe-body .list-heading:first-child { padding-top: 0; }
.recipe-notes { margin-top: 1.5rem; }
.recipe-notes h2 { font-size: 1.25rem; }
.recipe-notes p { white-space: pre-line; overflow-wrap: anywhere; }

.ingredients-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 1rem; margin-bottom: 0.5rem; }
.ingredients-head h2 { margin: 0; }
.scaler { display: flex; align-items: center; gap: 0.35rem; }
.scaler .chip { cursor: pointer; font: inherit; font-size: 0.9rem; padding: 0.15rem 0.65rem; }
.scale-note { margin: 0 0 0.5rem; }
.cook-mode .scaler .chip { font-size: 1rem; }

.subnav { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-bottom: 1.5rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 2rem; align-items: start; }
.two-col .import-row { margin-bottom: 0.75rem; }

/* ---- Recipe editor ---- */
.editor { max-width: 46rem; margin: 0 auto; }
.editor .input { background: var(--surface); }
.optional { font-weight: 400; color: var(--muted); font-size: 0.85rem; margin-left: 0.25rem; }
.hint { margin: -0.15rem 0 0.4rem; color: var(--muted); font-size: 0.9rem; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 0 1rem; }
.body-input { line-height: 1.6; min-height: 12rem; }
.checks { border: none; margin: 0 0 1rem; padding: 0; }
/* Columns, so the alphabetical list reads down each column rather than across. */
.check-grid { columns: 11.5rem; column-gap: 1.5rem; }
.check { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.25rem 0; cursor: pointer; break-inside: avoid; }
.check input { flex: none; width: 1.05rem; height: 1.05rem; accent-color: var(--accent); position: relative; top: 0.12rem; }
.legacy-box {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 1.1rem 1.2rem; margin-bottom: 1.25rem;
}
.legacy-box h2 { font-size: 1.25rem; }
.legacy-box .input { background: var(--bg); }
.legacy-preview { max-height: 22rem; overflow: auto; margin-bottom: 1rem; background: var(--bg); }
.convert-check { font-weight: 600; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.5rem; }

/* ---- Recipe photos ---- */
.recipe-photos {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.6rem; margin-bottom: 1.25rem;
}
.recipe-photos a { display: block; }
.recipe-photos img {
  display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--line);
}
.recipe-photos.single { display: block; }
.recipe-photos.single img { aspect-ratio: auto; max-height: 28rem; object-fit: contain; background: var(--surface); }
.cook-mode .recipe-photos { display: none; }

.photo-edit-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.75rem; margin-bottom: 0.9rem;
}
.photo-edit { display: block; cursor: pointer; }
.photo-edit img {
  display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--line);
}
.photo-edit:has(input:checked) img { opacity: 0.35; }
.label-plain { display: block; font-weight: 500; margin-bottom: 0.3rem; }

.import-box {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
  padding: 1rem 1.2rem 0.6rem; margin-bottom: 1.5rem;
}
.import-box .input { background: var(--bg); }
.import-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.import-row .input { flex: 1 1 16rem; width: auto; }
.import-box .hint, .import-box .error { margin: 0 0 0.5rem; }
details.import-box { padding-bottom: 1rem; }
details.import-box summary { cursor: pointer; font-weight: 600; }
details.import-box form { margin-top: 0.75rem; }
details.import-box .btn { margin-top: 0.5rem; }

.editor.narrow { max-width: 36rem; }
.danger-zone {
  margin-top: 3rem; padding: 1.1rem 1.2rem;
  border: 1px solid var(--danger); border-radius: var(--radius);
}
.danger-zone h2 { font-size: 1.15rem; color: var(--danger); }
.danger-zone .btn { margin-top: 0.6rem; }

/* ---- Admin tables ---- */
.table-wrap {
  overflow-x: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.55rem 1rem; text-align: left; vertical-align: baseline; white-space: nowrap; }
.table th {
  color: var(--muted); font-size: 0.8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.table td { border-top: 1px solid var(--line); }
.table tbody tr:hover { background: var(--accent-soft); }
.table .row-off td { color: var(--muted); }
.table td:last-child { text-align: right; }

/* ---- Switch (keep screen on) ---- */
.switch { display: inline-flex; align-items: center; gap: 0.55rem; cursor: pointer; font-weight: 500; padding: 0.3rem 0.25rem; position: relative; }
.switch[hidden] { display: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  flex: none; width: 2.75rem; height: 1.6rem; border-radius: 999px;
  background: var(--muted); position: relative; transition: background 0.15s;
}
.switch-track::after {
  content: ""; position: absolute; top: 0.2rem; left: 0.2rem;
  width: 1.2rem; height: 1.2rem; border-radius: 50%; background: #fff;
  transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(1.15rem); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--accent); outline-offset: 2px; }

.recipe-body {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem 1.5rem; line-height: 1.7; overflow-wrap: anywhere;
}
.recipe-body > :first-child { margin-top: 0; }
.recipe-body > :last-child { margin-bottom: 0; }
.recipe-body img { max-width: 100%; height: auto; border-radius: 6px; }
.recipe-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.recipe-body td, .recipe-body th { padding: 0.2rem 0.6rem 0.2rem 0; vertical-align: top; text-align: left; }
.recipe-body li { margin-bottom: 0.35rem; }
.recipe-body h1, .recipe-body h2, .recipe-body h3, .recipe-body h4 { font-size: 1.15rem; margin: 1.2em 0 0.4em; }

.recipe-footer { color: var(--muted); font-size: 0.9rem; margin-top: 1rem; }

.panel { margin-top: 2.25rem; }

.rating { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.rating form { display: inline-flex; margin: 0; }
.star-btn {
  font-size: 1.7rem; line-height: 1; padding: 0 0.1rem; background: none; border: none; cursor: pointer;
  color: var(--line);
}
.star-btn.on { color: var(--star); }
.star-btn:hover { color: var(--star); transform: scale(1.12); }

.comment { border-top: 1px solid var(--line); padding: 0.9rem 0; }
.comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.3rem 0.75rem; margin-bottom: 0.25rem; }
.comment-head form { margin: 0 0 0 auto; }
.comment-text { white-space: pre-line; overflow-wrap: anywhere; margin: 0; }

/* ---- Cook mode: big text, nothing else on screen ---- */

.cook-mode .site-header,
.cook-mode .recipe-extras,
.cook-mode .recipe-meta,
.cook-mode .lead { display: none; }

.cook-mode .recipe { max-width: 54rem; }
.cook-mode .recipe-body { font-size: 1.4rem; line-height: 1.75; padding: 1.5rem; }
.cook-mode .recipe-actions { position: sticky; top: 0; background: var(--bg); padding: 0.6rem 0; margin: 0 0 1rem; z-index: 1; }
.cook-mode .recipe-actions > :not(.cook-toggle):not(.switch) { display: none; }

/* ---- Print: just the recipe ---- */

@media print {
  :root { --bg: #fff; --surface: #fff; --ink: #000; --muted: #333; --line: #bbb; --accent: #000; }
  html { font-size: 12pt; }
  .site-header, .recipe-actions, .recipe-extras, .pagination, .scaler { display: none !important; }
  main { padding: 0; }
  .recipe { max-width: none; }
  .recipe h1 { font-size: 22pt; }
  .recipe-body { border: none; padding: 0; }
  .recipe-body a { text-decoration: none; }
  a { color: #000; }
}
