:root {
  --paper: #f6f1e7;
  --paper-2: #efe9dc;
  --ink: #1a1714;
  --ink-2: #4a423b;
  --ink-3: #8a8077;
  --rule: #c9bfae;
  --rule-soft: #ddd2bd;
  --accent: oklch(0.55 0.10 50);
  --accent-soft: oklch(0.92 0.03 60);
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Montserrat', system-ui, sans-serif;
  --mono: 'Source Code Pro', ui-monospace, monospace;
  --maxw: 1200px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: radial-gradient(rgba(26,23,20,0.025) 1px, transparent 1.2px);
  background-size: 4px 4px;
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; text-decoration: none; }

.page {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 48px clamp(20px, 5vw, 64px) 96px;
}

/* masthead */
.mast {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--ink);
}
.mast-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(48px, 8vw, 96px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin: 0;
}
.mast-title em {
  font-style: normal;
  color: var(--accent);
}
.mast-meta {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  text-align: right;
  line-height: 1.6;
}
.mast-meta strong { color: var(--ink); font-weight: 500; }

/* section labels */
.section-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  margin: 40px 0 12px;
}

/* list */
.list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.list-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 24px;
  padding: 22px 4px;
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
  transition: padding 180ms ease, background 180ms ease;
  position: relative;
}
.list-item:hover {
  padding-left: 16px;
  background: linear-gradient(90deg, var(--accent-soft) 0%, transparent 60%);
}
.list-item:last-child { border-bottom: none; }
.list-item:hover .li-name { color: var(--accent); }

.li-name {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(22px, 2.8vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  transition: color 180ms ease;
}
.li-name .li-sub {
  display: block;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-3);
  letter-spacing: 0;
  margin-top: 4px;
}
.li-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .list-item { grid-template-columns: 1fr auto; gap: 14px; }
}

.list-foot {
  margin-top: 64px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-top: 1px solid var(--rule);
  padding-top: 22px;
}

/* recipe */
.recipe {
}
.recipe-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.back-link {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: color 180ms ease;
  background: none;
  border: none;
  padding: 0;
}
.back-link:hover { color: var(--accent); }
.wake-lock-btn { display: none; }
@media (max-width: 1024px) {
.wake-lock-btn {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  background: none;
  border: 1.5px solid var(--rule);
  border-radius: 14px;
  padding: 5px 12px;
  cursor: pointer;
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease;
}
.wake-lock-btn:hover { border-color: var(--ink-2); color: var(--ink-2); }
.wake-lock-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
}

.recipe-head {
  margin-top: 36px;
  position: relative;
}
.recipe-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(40px, 6vw, 68px);
  line-height: 1;
  letter-spacing: -0.02em;
  margin: 0;
  padding-right: 120px;
}
.recipe-blurb {
  font-family: var(--serif);
  font-size: 19px;
  color: var(--ink-2);
  line-height: 1.5;
  margin: 18px 0 0;
  max-width: 78ch;
}
.recipe-stats {
  position: absolute;
  top: 8px;
  right: 0;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  text-align: right;
}
@media (max-width: 640px) {
  .recipe-title { padding-right: 80px; }
  .recipe-stats { top: 4px; }
}
.stat .k {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  display: block;
  margin-bottom: 2px;
}
.stat .v {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
}

/* portion calculator */
.calc {
  margin-top: 44px;
  padding: 28px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 36px;
  align-items: center;
}
.calc-left .k {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-3);
  display: block;
}
.calc-left .v {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 80px;
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin-top: 6px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.calc-left .v small {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 16px;
  color: var(--ink-3);
  letter-spacing: 0;
}
.calc-right { padding-bottom: 6px; }
.calc--yield { grid-template-columns: 1fr; }
.calc-time-print { display: none; }
.calc--yield .v {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  margin-top: 4px;
}

.slider-wrap { position: relative; }
.slider-input {
  -webkit-appearance: none; appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 0;
  position: relative;
  z-index: 2;
}
.slider-input:focus { outline: none; }
.slider-input::-webkit-slider-runnable-track {
  height: 2px; background: var(--ink); border-radius: 2px;
}
.slider-input::-moz-range-track {
  height: 2px; background: var(--ink); border-radius: 2px;
}
.slider-input::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px;
  background: var(--accent);
  border-radius: 50%;
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 1.5px var(--accent);
  margin-top: -10px;
  cursor: grab;
  transition: transform 120ms ease;
}
.slider-input::-webkit-slider-thumb:active { transform: scale(1.15); cursor: grabbing; }
.slider-input::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  border: 3px solid var(--paper);
  box-shadow: 0 0 0 1.5px var(--accent);
  cursor: grab;
}

.slider-ticks {
  position: absolute;
  left: 0; right: 0;
  top: 11px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 1;
}
.slider-ticks span {
  width: 1px; height: 6px; background: var(--ink-3); transform: translateY(-2px);
}
.slider-labels {
  position: relative;
  height: 16px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 8px;
  letter-spacing: 0.04em;
}
.slider-labels span {
  position: absolute;
  transform: translateX(-50%);
  font-weight: 500;
}
.slider-labels span:first-child { transform: none; }
.slider-labels span:last-child { transform: translateX(-100%); }
.slider-labels span.active { color: var(--accent); }

@media (max-width: 640px) {
  .calc { grid-template-columns: 1fr; gap: 12px; }
  .calc-left .v { font-size: 60px; }
  .calc--yield .v { font-size: 14px; }
}

/* recipe body */
.recipe-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 56px;
  margin-top: 48px;
}

.h-section {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 28px;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
  display: flex;
  align-items: baseline;
  gap: 14px;
}
.h-section::before {
  content: "";
  flex: none;
  width: 18px;
  height: 1px;
  background: var(--accent);
  transform: translateY(-6px);
}

/* ingredients */
.ing { list-style: none; padding: 0; margin: 0; }
.ing-row {
  display: grid;
  grid-template-columns: 26px 110px 1fr;
  align-items: baseline;
  gap: 12px 24px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--rule);
  cursor: pointer;
  user-select: none;
  transition: padding 180ms ease;
}
.ing-row:hover { padding-left: 6px; }
.ing-row:last-child { border-bottom: none; }

.ckbx {
  width: 18px; height: 18px;
  border: 1.5px solid var(--ink-2);
  border-radius: 3px;
  display: inline-block;
  flex: none;
  background: transparent;
  position: relative;
  transition: background 160ms ease, border-color 160ms ease;
}
.ing-row.checked .ckbx,
.step-row.checked .ckbx {
  background: var(--accent);
  border-color: var(--accent);
}
.ing-row.checked .ckbx::after,
.step-row.checked .ckbx::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 6px; height: 11px;
  border-right: 2px solid var(--paper);
  border-bottom: 2px solid var(--paper);
  transform: rotate(40deg);
}

.ing-qty {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 300;
  color: var(--ink);
  letter-spacing: 0.02em;
  transition: color 200ms ease;
  white-space: nowrap;
}
.ing-qty .num { color: var(--accent); }
.ing-name {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.35;
  color: var(--ink);
}
.ing-row.checked .ing-name,
.ing-row.checked .ing-qty {
  color: var(--ink-3);
}

/* steps */
.steps { list-style: none; padding: 0; margin: 0; }
.step-row {
  display: grid;
  grid-template-columns: 26px 44px 1fr;
  gap: 16px;
  align-items: baseline;
  padding: 18px 0;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
  transition: padding 180ms ease;
}
.step-row:hover { padding-left: 6px; }
.step-row:last-child { border-bottom: none; }
.step-num {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 28px;
  color: var(--accent);
  line-height: 1;
}
.step-text {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink);
}
.step-row.checked .step-text {
  color: var(--ink-3);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--rule);
}

/* ingredient & step section headers */
.ing-section, .step-section {
  list-style: none;
  margin: 22px 0 6px;
  padding: 0 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-2);
  border-bottom: 1px solid var(--rule);
}
.ing-section:first-child, .step-section:first-child { margin-top: 0; }

/* cover image — sits between stats and calc */
.recipe-cover {
  margin: 36px 0 0;
  padding: 0;
}
.recipe-cover img {
  display: block;
  width: 100%;
  aspect-ratio: 5 / 2;
  object-fit: cover;
  border-radius: 4px;
}
/* drop calc top border + padding when cover above */
.recipe-cover + .calc {
  border-top: none;
  padding-top: 12px;
  margin-top: 16px;
}

/* gallery */
.recipe-gallery {
  margin-top: 8px;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 640px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
}
.gallery-item {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: none;
  border-radius: 4px;
  overflow: hidden;
  cursor: zoom-in;
  background: var(--paper-2);
  transition: transform 200ms ease;
}
.gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms ease;
}
.gallery-item:hover img { transform: scale(1.04); }

/* lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(26, 23, 20, 0.94);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade 200ms ease both;
}
.lightbox-inner {
  position: relative;
  max-width: 96vw;
  max-height: 96vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-img {
  max-width: 96vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 4px;
  user-select: none;
}
.lightbox-close,
.lightbox-nav {
  position: absolute;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  transition: background 180ms ease;
}
.lightbox-close:hover,
.lightbox-nav:hover { background: var(--accent); }
.lightbox-close {
  top: 12px; right: 12px;
  width: 40px; height: 40px;
  font-size: 24px;
  line-height: 1;
}
.lightbox-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 48px; height: 48px;
  font-size: 32px;
  line-height: 1;
}
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }
.lightbox-counter {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: white;
  background: rgba(0,0,0,0.5);
  padding: 6px 12px;
  border-radius: 12px;
}

/* footer */
.foot {
  margin-top: 80px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
}

/* view fade-in */
.view { animation: fade 280ms ease both; }
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* print button */
.foot-print {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  cursor: pointer;
  transition: color 180ms ease;
}
.foot-print:hover { color: var(--accent); }

/* url span — only in print */
.foot-url { display: none; }

/* print / pdf */
@media print {
  @page { size: A4 portrait; margin: 0; }

  body::before { display: none; }
  body { background: white; font-size: 11pt; }

  .back-link,
  .wake-lock-btn,
  .calc-right,
  .foot-print,
  .recipe-cover,
  .recipe-gallery,
  .lightbox,
  .ckbx { display: none !important; }

  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .calc { grid-template-columns: 1fr; gap: 0; border-bottom: none; padding-bottom: 0; }
  .calc-left .v { font-size: 18pt; margin-top: 2pt; }

  .page { padding: 15mm 20mm 24mm; max-width: none; }
  .view { animation: none; }

  .foot-url { display: block; }

  .mast { padding-bottom: 12pt; }
  .mast-title { font-size: 40pt; }

  .recipe-head { margin-top: 16pt; padding-bottom: 8pt; border-bottom: none; position: static; }
  .recipe-title { font-size: 28pt; padding-right: 0; }
  .recipe-blurb { font-size: 10pt; margin-top: 8pt; }
  .recipe-stats { position: static; margin-top: 10pt; gap: 20pt; text-align: left; }
  .stat .v { font-size: 12pt; }

  /* hide top-right time chip if calc has its own */
  .recipe:has(.calc-time-print) .recipe-stats { display: none; }

  /* calc with inline time on right */
  .calc {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 24pt;
    border-top: none;
    border-bottom: none;
    padding: 0;
    margin-top: 4pt;
  }
  .calc-time-print {
    display: block;
    text-align: right;
  }
  .calc-time-print .k {
    font-family: var(--mono);
    font-size: 9pt;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--ink-3);
    display: block;
  }
  .calc-time-print .v {
    font-family: var(--serif);
    font-size: 14pt;
    font-weight: 500;
  }

  .recipe-body { margin-top: 16pt; gap: 16pt; }

  .h-section { font-size: 14pt; margin-bottom: 6pt; }

  .ing-row { padding: 5pt 0; gap: 5pt 16pt; grid-template-columns: 110px 1fr; }
  .ing-qty { font-size: 9pt; }
  .ing-name { font-size: 11pt; }

  .step-row { padding: 6pt 0; gap: 8pt; grid-template-columns: 44px 1fr; }
  .step-num { font-size: 16pt; }
  .step-text { font-size: 11pt; line-height: 1.4; }

  .foot {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: 6mm 20mm;
    margin: 0;
    background: white;
    border-top: 1px solid var(--rule);
  }

  .ing-row:hover,
  .step-row:hover { padding-left: 0; }

  a { color: inherit; }
}
