/* ── EB Garamond (self-hosted) ───────────────────────────────────────────── */

@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/static/fonts/eb-garamond-latin-ext-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'EB Garamond';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/static/fonts/eb-garamond-latin-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/eb-garamond-latin-ext-italic.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'EB Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/eb-garamond-latin-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ── Tokens ─────────────────────────────────────────────────────────────── */

:root {
  --bg:     #faf8f3;
  --text:   #2a1a0e;
  --muted:  #7a6552;
  --rule:   #c4a882;
  --accent: #8b4513;
  --max:    660px;
}

/* system dark — only when user hasn't made an explicit choice */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:     #1c1712;
    --text:   #e8e0d0;
    --muted:  #9e8e78;
    --rule:   #5a4a36;
    --accent: #c8895a;
  }
}

/* explicit dark override */
:root[data-theme="dark"] {
  --bg:     #1c1712;
  --text:   #e8e0d0;
  --muted:  #9e8e78;
  --rule:   #5a4a36;
  --accent: #c8895a;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */

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

/* ── Base ────────────────────────────────────────────────────────────────── */

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'EB Garamond', Georgia, serif;
  line-height: 1.75;
  padding: 2rem;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.container {
  max-width: var(--max);
  margin: 0 auto;
}

.container--centered {
  text-align: center;
}


/* ── Back link ───────────────────────────────────────────────────────────── */

.back-link {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 2.5rem;
}

.back-link:hover {
  color: var(--accent);
}

/* ── Recipe header ───────────────────────────────────────────────────────── */

.recipe-title {
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: bold;
  line-height: 1.2;
  text-align: center;
  margin-bottom: 0.75rem;
}

.recipe-meta {
  text-align: center;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted);
}

.recipe-saves {
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--rule);
  margin-top: 0.4rem;
}

/* ── Divider ─────────────────────────────────────────────────────────────── */

.divider {
  border: none;
  height: auto;
  background: none;
  margin: 2.25rem 0;
  text-align: center;
  font-size: 0.7rem;
  line-height: 1;
  color: var(--rule);
  letter-spacing: 0.45em;
}

hr.divider::before { content: attr(data-fleurons); }

/* ── Section label ───────────────────────────────────────────────────────── */

.section-label {
  font-size: 0.68rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

/* ── Ingredients ─────────────────────────────────────────────────────────── */

.ingredients-list {
  list-style: none;
  padding: 0;
}

.ingredients-list li {
  position: relative;
  padding: 0.3rem 0 0.3rem 1.1rem;
  font-size: 1rem;
}

.ingredients-list li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 1.1em;
  line-height: 1.5;
}


/* ── Steps ───────────────────────────────────────────────────────────────── */

.steps-list {
  list-style: none;
  padding: 0;
  counter-reset: steps;
}

.steps-list li {
  counter-increment: steps;
  position: relative;
  padding: 0 0 1.75rem 3rem;
}

.steps-list li::before {
  content: counter(steps);
  position: absolute;
  left: 0;
  top: 0.05em;
  width: 2.2rem;
  text-align: right;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--rule);
  line-height: 1.2;
}

.steps-list li:last-child {
  padding-bottom: 0;
}

/* ── Quantities ──────────────────────────────────────────────────────────── */

.qty {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.05em;
  font-weight: bold;
  color: var(--accent);
  letter-spacing: -0.02em;
}

/* ── Notes ───────────────────────────────────────────────────────────────── */

.notes-text {
  font-style: italic;
  color: var(--muted);
  line-height: 1.7;
}

/* ── Source ──────────────────────────────────────────────────────────────── */

.source-line {
  font-size: 0.72rem;
  color: var(--rule);
  text-align: center;
  font-style: italic;
}

.source-line a {
  color: var(--rule);
  word-break: break-all;
}

/* ── Index: site title ───────────────────────────────────────────────────── */

.site-title {
  font-size: clamp(2.2rem, 9vw, 3.75rem);
  font-weight: bold;
  text-align: center;
  line-height: 1.1;
  margin-bottom: 0.5rem;
}

.recipman {
  display: block;
  margin: 0.75rem auto 0.5rem;
  width: clamp(120px, 30vw, 220px);
}

.recipman-sm {
  display: block;
  margin: 0.75rem auto 0.5rem;
  width: clamp(60px, 15vw, 110px);
}

.site-title-me {
  text-decoration: underline;
}

.site-subtitle {
  text-align: center;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted);
}

/* ── Index: search ───────────────────────────────────────────────────────── */

.search-input {
  display: block;
  width: 100%;
  max-width: 380px;
  margin: 1.5rem auto 0;
  padding: 0.55rem 0.85rem;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 2px;
  outline: none;
  appearance: none;
}

.search-input:focus {
  border-color: var(--accent);
}

/* ── Index: word form ───────────────────────────────────────────────────── */

.word-form {
  margin-top: 2rem;
}

.search-input--sm {
  max-width: 280px;
}

.search-input--stacked {
  margin-top: 0.5rem;
}

.word-status {
  min-height: 1.2em;
  font-size: 0.8rem;
  margin-top: 0.5rem;
  opacity: 0.8;
}

.word-status--checking::before {
  content: '';
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  margin-right: 0.4em;
  vertical-align: middle;
}

.form-error {
  font-size: 0.8rem;
  margin-top: 0.5rem;
  color: var(--accent);
}

.form-submit {
  margin-top: 0.75rem;
}

.index-tagline {
  margin-top: 1rem;
  font-size: 0.875rem;
  opacity: 0.7;
}

.index-tagline strong {
  color: var(--accent);
}

/* ── Index: recipe list ──────────────────────────────────────────────────── */

.recipe-list {
  list-style: none;
  padding: 0;
}

.recipe-list a {
  display: block;
  padding: 0.8rem 0.25rem;
  color: var(--text);
  text-decoration: none;
  font-size: 1.05rem;
  transition: padding-left 0.12s ease, color 0.12s ease;
}

.recipe-list a:hover {
  color: var(--accent);
  padding-left: 0.75rem;
}

.recipe-list li.hidden {
  display: none;
}

/* ── Responsive: iPad ────────────────────────────────────────────────────── */

@media (min-width: 768px) {
}

/* ── Responsive: iPhone ──────────────────────────────────────────────────── */

@media (max-width: 480px) {
  html {
    font-size: 16px;
  }


  .recipe-title {
    font-size: 1.75rem;
  }

  .steps-list li {
    padding-left: 2.5rem;
  }

  .steps-list li::before {
    font-size: 1.25rem;
    width: 1.9rem;
  }
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn,
.theme-toggle {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 0.65rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 2px 2px 0 var(--rule);
  white-space: nowrap;
  line-height: 1;
  transition: border-color 0.12s, box-shadow 0.08s, transform 0.08s;
}

.btn:hover,
.theme-toggle:hover {
  border-color: var(--accent);
  box-shadow: 2px 2px 0 var(--accent);
}

.btn:active,
.theme-toggle:active {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}

@keyframes btn-spin { to { transform: rotate(360deg); } }

.btn--loading {
  cursor: default;
  pointer-events: none;
  opacity: 0.7;
}

/* Icon: bookmark/save shape */
.btn--save::before {
  content: '';
  display: inline-block;
  width: 0.65em;
  height: 0.8em;
  background: currentColor;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
  margin-right: 0.45em;
  vertical-align: -0.05em;
}

/* Icon: document/copy shape (page with folded corner) */
.btn--copy::before {
  content: '';
  display: inline-block;
  width: 0.65em;
  height: 0.75em;
  background: currentColor;
  clip-path: polygon(0 0, 68% 0, 100% 32%, 100% 100%, 0 100%);
  margin-right: 0.45em;
  vertical-align: -0.05em;
}

/* Spinner overrides icon on left when loading — must come after icon rules */
.btn--loading::before {
  content: '';
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  background: none;
  clip-path: none;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  margin-right: 0.5em;
  vertical-align: middle;
}

.btn--bookmarklet {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 2rem;
  padding: 0.6rem 1.3rem 0.6rem 1rem;
  box-shadow: none;
  cursor: grab;
  letter-spacing: 0.12em;
  transition: background 0.12s, transform 0.08s;
}

.btn--bookmarklet::before {
  content: '';
  display: inline-block;
  width: 0.65em;
  height: 0.8em;
  background: currentColor;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
  margin-right: 0.45em;
  vertical-align: -0.05em;
}

.btn--bookmarklet:hover {
  background: var(--text);
  box-shadow: none;
  color: var(--bg);
}

.btn--bookmarklet:active {
  cursor: grabbing;
  transform: scale(0.97);
}

/* ── Theme toggle ────────────────────────────────────────────────────────── */

.theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 100;
}

@media (max-width: 480px) {
  .theme-toggle {
    top: 0.6rem;
    right: 0.6rem;
    font-size: 0.58rem;
    padding: 0.35rem 0.65rem;
    box-shadow: 1px 1px 0 var(--rule);
  }
}

/* ── Print ───────────────────────────────────────────────────────────────── */

@media print {
  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
    padding: 0;
  }

  .back-link,
  .search-input,
  .theme-toggle {
    display: none;
  }

  .divider {
    background: #999;
  }

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

  .source-line a::after {
    content: " (" attr(href) ")";
    font-size: 0.75em;
  }
}

/* ── User page ───────────────────────────────────────────────────────────── */

.recipe-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.recipe-list li.hidden {
  display: none;
}
.fav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0 0 0.5rem;
  color: var(--rule);
  line-height: 1;
  flex-shrink: 0;
}
.fav-btn--on {
  color: var(--accent);
}

.add-block {
  margin-top: 1.5rem;
}
.add-textarea {
  display: block;
  width: 100%;
  min-height: 6rem;
  resize: vertical;
  padding: 0.55rem 0.85rem;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 2px;
  outline: none;
}
.add-textarea:focus {
  border-color: var(--accent);
}
.add-submit-btn {
  display: block;
  margin-top: 0.5rem;
  margin-left: auto;
}
.add-status {
  text-align: center;
  font-size: 0.78rem;
  font-style: italic;
  color: var(--muted);
  margin-top: 0.5rem;
  min-height: 1.2em;
}
.bm-code-block {
  margin-top: 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}
.bm-code-header {
  background: var(--rule);
  padding: 0.2rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.bm-code-filename {
  font-size: 0.65rem;
  font-family: 'Courier New', monospace;
  color: var(--accent);
  opacity: 0.7;
  margin-left: 0.25rem;
}
.bm-code-block pre {
  background: var(--bg);
  color: var(--muted);
  padding: 0.65rem 0.75rem;
  margin: 0;
  font-size: 0.6rem;
  line-height: 1.6;
  overflow: auto;
  max-height: 200px;
  white-space: pre;
  font-family: 'Courier New', Courier, monospace;
}
.bm-kw  { color: var(--text); font-weight: bold; }
.bm-str { color: var(--accent); }
.bm-num { color: var(--accent); opacity: 0.75; }

.auth-gate-wrap {
  text-align: center;
}
.gate-error {
  font-size: 0.8rem;
  margin-top: 0.75rem;
  color: var(--accent);
}
.bm-drag-row {
  margin: 0.75rem 0 1.25rem;
  text-align: center;
}
.bm-code-label {
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
}
.bm-copy-btn {
  margin-top: 0.5rem;
}

/* ── Recipe: save button ─────────────────────────────────────────────────── */

.save-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  border-radius: 2rem;
  border: 2px solid currentColor;
  background: var(--bg);
  color: inherit;
  opacity: 0.85;
  transition: opacity 0.15s, background 0.15s;
  z-index: 100;
}
.save-btn:hover { opacity: 1; }
.save-btn.saved {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
.save-btn::before {
  content: '';
  display: inline-block;
  width: 0.7em;
  height: 0.85em;
  background: currentColor;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%);
  margin-right: 0.4em;
  vertical-align: -0.05em;
}
.save-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.save-btn:disabled::before {
  clip-path: none;
  background: none;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
  width: 0.6em;
  height: 0.6em;
}
