/* tisch: editorial cookbook styles, loosely after Bon Appétit's recipe pages. */

:root {
  --ink: #111;
  --muted: #5f5f5f;
  --rule: #ddd;
  --paper: #fff;
  --chip: #e9f27d;
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.6 var(--sans); }
/* Footer sits at the bottom even when a search returns little. */
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
img { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }
.wrap-narrow { max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* ---------- Type ---------- */

.display {
  font-family: var(--display);
  font-weight: 800;
  font-stretch: 72%;
  letter-spacing: -0.01em;
  line-height: 0.98;
}
.kicker, .byline, .meta {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.byline, .kicker { color: var(--muted); }

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

.site-header { position: relative; background: #000; color: #fff; padding: 16px; text-align: center; }
.header-action {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  border: 1px solid #fff;
  padding: 7px 10px;
}
.header-action:hover { background: var(--chip); border-color: var(--chip); color: #000; }
.wordmark {
  font: 400 30px/1 var(--serif);
  letter-spacing: -0.02em;
  text-decoration: none;
}
.site-footer {
  margin-top: 96px;
  background: #000;
  color: #fff;
  text-align: center;
  padding: 40px 16px;
}
.site-footer p { margin: 8px 0 0; color: #aaa; font-size: 13px; }

/* ---------- Home: search + spreadsheet ---------- */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.home { max-width: 1040px; }

.search { position: relative; display: flex; align-items: stretch; gap: 16px; margin: 32px 0 8px; }
.search input {
  flex: 1;
  min-width: 0;
  width: 100%;
  font: 500 20px/1.2 var(--sans);
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  padding: 12px 8px 12px 36px;
  -webkit-appearance: none;
  appearance: none;
}
.search input::placeholder { color: #9a9a9a; }
.search input:focus { outline: none; box-shadow: 0 2px 0 #000; }
.search-icon { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); }

/* Tag dropdown: same underline as the search box; yellow like a tag chip once one is chosen. */
.tag-filter {
  flex: 0 0 auto;
  max-width: 34%;
  font: 600 15px/1.2 var(--sans);
  color: var(--ink);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23111' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 0;
  border-bottom: 2px solid var(--ink);
  border-radius: 0;
  padding: 12px 32px 12px 10px;
  cursor: pointer;
  text-overflow: ellipsis;
  -webkit-appearance: none;
  appearance: none;
}
.tag-filter:focus-visible { outline: none; box-shadow: 0 2px 0 #000; }
.tag-filter:not(:has(option[value=""]:checked)) { background-color: var(--chip); }
.search-go {
  font: 700 12px/1 var(--sans); letter-spacing: 0.08em; text-transform: uppercase;
  background: var(--ink); color: var(--paper); border: 0; padding: 0 14px; cursor: pointer;
}

.results-count { color: var(--muted); font-size: 13px; margin: 0 0 12px; min-height: 1.6em; }
.empty { color: var(--muted); padding: 32px 0; text-align: center; }

.sheet {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}
.sheet th, .sheet td {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  vertical-align: top;
}
.sheet thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f4f4f4;
  border-bottom: 2px solid var(--ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  padding: 0;
}
.sheet thead th.col-tags { padding: 10px 12px; }
.sheet th a { display: block; padding: 10px 12px; text-decoration: none; }
.sheet th a:hover { background: #e9e9e9; }
.sort-arrow { display: inline-block; width: 1.2em; font-size: 9px; padding-left: 4px; }
.sheet tbody tr:nth-child(even) { background: #fafafa; }
.sheet tbody tr { position: relative; }
.sheet tbody tr:hover { background: var(--chip); }

/* The title link covers the whole row, so any cell opens the recipe. */
.row-link { font-weight: 700; text-decoration: none; }
.row-link::after { content: ""; position: absolute; inset: 0; }
.row-link:focus-visible { outline: none; }
.sheet tbody tr:has(.row-link:focus-visible) { outline: 2px solid #000; outline-offset: -2px; }

.col-from { width: 18%; }
.col-tags { width: 26%; color: var(--muted); }
.col-added { width: 9.5em; white-space: nowrap; color: var(--muted); }


/* ---------- Recipe hero ---------- */

.recipe-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: min(70vh, 640px);
  border-bottom: 1px solid var(--rule);
}
.recipe-hero-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 48px 32px;
}
.recipe-hero-img { margin: 0; }
.recipe-hero-img img { width: 100%; height: 100%; object-fit: cover; }
.recipe-hero.no-photo { grid-template-columns: 1fr; min-height: 0; }
.recipe-hero.no-photo .recipe-hero-text { padding: 72px 16px 56px; }

.meta { display: flex; gap: 12px; align-items: center; margin: 0 0 22px; }
.pill { background: #000; color: #fff; padding: 5px 8px; }
.recipe-title { font-size: clamp(40px, 6vw, 72px); max-width: 14ch; }
.recipe-hero .byline { margin: 22px 0 0; }

/* ---------- Recipe body ---------- */

.recipe-body { padding-top: 48px; }
.headnote { max-width: 680px; font-size: 18px; line-height: 1.65; }
.headnote p { margin: 0 0 1em; }

.section-title {
  font: 800 28px/1.1 var(--display);
  font-stretch: 80%;
  padding-bottom: 12px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--ink);
}
.sub-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin: 24px 0 8px;
}

.recipe-cols {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 2fr;
  gap: 56px;
  margin-top: 40px;
  align-items: start;
}

.ingredients ul { list-style: none; margin: 0; padding: 0; }
.ingredients li {
  display: grid;
  grid-template-columns: 3.5em 1fr;
  gap: 10px;
  padding: 7px 0;
  font-size: 15px;
  line-height: 1.45;
}
.qty { font-weight: 700; text-align: right; }

.step { margin-bottom: 28px; }
.step h4 { font: 800 18px/1.2 var(--display); font-stretch: 85%; margin-bottom: 6px; }
.step p { margin: 0; font-size: 16px; }

.notes { margin-top: 48px; max-width: 680px; }
.notes p { margin: 0 0 1em; }

.tags { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; margin: 40px 0 0; padding: 0; }
.chip {
  display: inline-block;
  text-decoration: none;
  background: var(--chip);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  text-transform: capitalize;
}
a.chip:hover { background: #000; color: var(--chip); }

.edit-link { margin: 40px 0 0; }

/* ---------- Admin form ---------- */

.admin { padding-top: 48px; max-width: 760px; }
.admin-title { font-size: clamp(36px, 5vw, 56px); margin-bottom: 32px; }

.field { margin-bottom: 24px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.field input, .field textarea {
  width: 100%;
  font: 16px/1.5 var(--sans);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #bbb;
  border-radius: 0;
  padding: 10px 12px;
}
.field textarea { resize: vertical; }
.field textarea.mono { font-variant-numeric: tabular-nums; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
#title { font: 800 26px/1.2 var(--display); font-stretch: 80%; }
.field-hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.field [aria-invalid="true"] { border-color: #b00020; box-shadow: inset 0 0 0 1px #b00020; }
.field-error { margin: 6px 0 0; font-size: 13px; font-weight: 600; color: #b00020; }
.photo-picker { display: flex; gap: 16px; align-items: center; }
.photo-preview { width: 160px; aspect-ratio: 4 / 3; object-fit: cover; flex: none; background: var(--rule); }
.photo-preview.is-removed { opacity: 0.25; }
.photo-controls { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; min-width: 0; }
.field input[type="file"] { border: 0; padding: 0; font-size: 14px; color: var(--muted); }
.field input[type="file"]:focus { box-shadow: none; }
.field input[type="file"]:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.field input[type="file"]::file-selector-button {
  font: 700 13px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 11px 18px;
  margin-right: 14px;
  cursor: pointer;
}
.field input[type="file"]::file-selector-button:hover { background: var(--ink); color: var(--paper); }
.field .check {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  cursor: pointer;
}
.field .check input { width: auto; margin: 0; }

.form-error { background: #fde8eb; color: #b00020; font-weight: 600; padding: 12px 16px; margin: 0 0 24px; }

.form-actions { display: flex; align-items: center; gap: 20px; margin-top: 32px; }
.form-actions .button { margin: 0; border: 0; cursor: pointer; font-family: var(--sans); }
.button-quiet {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.button-quiet:hover { color: var(--ink); }

.danger-zone { margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--rule); }
.button-danger {
  font: 700 13px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: none;
  color: #b00020;
  border: 1px solid #b00020;
  padding: 11px 18px;
  cursor: pointer;
}
.button-danger:hover { background: #b00020; color: #fff; }

/* ---------- Misc ---------- */

.not-found { text-align: center; padding: 96px 16px; }
.not-found h1 { font-size: clamp(40px, 7vw, 64px); margin-bottom: 16px; }
.not-found p { color: var(--muted); }
.button {
  display: inline-block;
  margin-top: 16px;
  background: #000;
  color: #fff;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
}

/* ---------- Small screens ---------- */

@media (max-width: 760px) {
  .recipe-hero { grid-template-columns: 1fr; min-height: 0; }
  .recipe-hero-img { order: -1; aspect-ratio: 4 / 3; }
  .recipe-hero-text { padding: 32px 16px; }
  .recipe-cols { grid-template-columns: 1fr; gap: 40px; }
  .headnote { font-size: 17px; }
  .field-row { grid-template-columns: 1fr; }
  .photo-picker { flex-direction: column; align-items: flex-start; }
  .photo-preview { width: 100%; }
}

@media (max-width: 640px) {
  .search { margin-top: 20px; }
  .search input { font-size: 18px; }
  .search { gap: 10px; }
  .tag-filter { max-width: 40%; font-size: 14px; padding-left: 6px; padding-right: 26px; background-position: right 6px center; }
  .sheet { font-size: 15px; }
  .sheet .col-tags, .sheet .col-added { display: none; }
  .header-action { padding: 6px 8px; font-size: 10px; letter-spacing: 0.08em; }
  .col-from { width: 38%; }
}

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

@media print {
  .site-header, .site-footer, .tags, .edit-link { display: none; }
  body { font-size: 11pt; }
  .recipe-hero, .recipe-hero.no-photo { display: block; min-height: 0; border: 0; }
  .recipe-hero-text { padding: 0 0 12pt; align-items: flex-start; text-align: left; }
  .recipe-hero-img { display: none; }
  .meta { display: none; }
  .recipe-title { font-size: 28pt; max-width: none; }
  .recipe-body { padding: 0; max-width: none; }
  .recipe-cols { grid-template-columns: 1fr 2fr; gap: 24pt; margin-top: 16pt; }
  .step, .ingredients li { break-inside: avoid; }
}
