/* ============================================================
   COOK2SHOP — style.css v4
   Fond blanc pur, typographie éditoriale.
   ============================================================ */

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

:root {
  --bg:           #f5f0e6;
  --surface:      #fffdf7;
  --surface2:     #ebe4d7;
  --border:       #ded5c5;
  --border2:      #b9ad9b;
  --text:         #211d19;
  --text-dim:     #625a51;
  --text-muted:   #857b70;
  --accent:       #c4440a;
  --accent-light: #fff0ea;
  --accent-glow:  rgba(196, 68, 10, 0.12);
  --green:        #2d7a2d;
  --green-light:  #edf5ed;
}

body {
  font-family: 'DM Mono', monospace;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 28px 80px;
}

/* ── Header ── */
.header {
  padding: 32px 0 24px;
  border-bottom: 2px solid var(--text);
  margin-bottom: 48px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.title {
  font-family: 'Libre Baskerville', serif;
  font-size: clamp(30px, 6vw, 48px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
}

.title em { font-style: italic; color: var(--accent); }

.subtitle { font-size: 12px; color: var(--text-dim); margin-top: 8px; }

.add-recipe-btn { min-height: 44px; }
.recipes-section { margin-bottom: 48px; }
.section-intro { margin-top: 8px; max-width: 520px; font-size: 14px; color: var(--text-dim); }
.import-panel {
  background: var(--surface);
  border-top: 3px solid var(--accent);
  padding: 28px;
  margin: 32px 0 48px;
  box-shadow: 0 3px 10px rgba(56, 43, 27, 0.12);
}
.import-panel[hidden] { display: none; }
.backup-section { border-top: 1px solid var(--border); padding-top: 28px; margin-bottom: 32px; }
.backup-section .paste-area { margin-top: 16px; }
.backup-section[hidden], .backup-section .btn[hidden] { display: none; }
.backup-title { font-family: 'Libre Baskerville', serif; font-size: 18px; }
.fiche-link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; }
.import-heading { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.import-heading h2 { font-family: 'Libre Baskerville', serif; font-size: 24px; line-height: 1.25; }
.icon-btn {
  width: 44px; height: 44px; flex: 0 0 44px; border: 1px solid var(--border2);
  background: transparent; color: var(--text-dim); cursor: pointer; font-size: 16px;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* ── Étapes ── */
.step { margin-bottom: 28px; }

.step-label {
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-num {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--accent);
  flex-shrink: 0;
}

/* ── Inputs ── */
.input-row { display: flex; gap: 8px; align-items: flex-start; }

input[type="text"],
input[type="date"],
input[type="month"],
textarea#urlInput {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: 3px;
  padding: 12px 14px;
  font-family: 'DM Mono', monospace;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input::placeholder { color: var(--text-muted); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.paste-area {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: 3px;
  padding: 12px 14px;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--text);
  resize: vertical;
  min-height: 90px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.paste-area::placeholder { color: var(--text-muted); }
.paste-area:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

/* ── Boutons ── */
.btn {
  padding: 12px 18px;
  border-radius: 3px;
  border: none;
  cursor: pointer;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:focus-visible, .ai-chip:focus-visible, .recipe-tab:focus-visible, .icon-btn:focus-visible,
.recipe-card-main:focus-visible, .recipe-select-btn:focus-visible, .servings-step:focus-visible,
.step-row:focus-visible, .ing-btn:focus-visible, .store-btn:focus-visible {
  outline: 3px solid rgba(196, 68, 10, 0.3);
  outline-offset: 2px;
}

.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: #a83808; }

.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #246324; }

.btn-outline {
  background: transparent;
  color: var(--text-dim);
  border: 1.5px solid var(--border2);
}
.btn-outline:hover { border-color: var(--text); color: var(--text); }
.btn-text { background: transparent; color: var(--text-dim); padding-inline: 8px; text-decoration: underline; text-underline-offset: 4px; }
.btn-text:hover { color: var(--accent); }

.btn-sm { padding: 6px 10px; font-size: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ── Chips IA ── */
.ai-chips { display: flex; gap: 8px; margin-bottom: 12px; }

.ai-chip {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1.5px solid var(--border2);
  background: var(--surface);
  color: var(--text-dim);
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.ai-chip:hover { border-color: var(--accent); color: var(--accent); }
.ai-chip.active { background: var(--accent); border-color: var(--accent); color: white; }

/* ── Prompt box ── */
.prompt-box {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 3px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.7;
  white-space: pre-wrap;
  margin-bottom: 10px;
  word-break: break-word;
  max-height: 150px;
  overflow-y: auto;
}

/* ── Séparateur ── */
.divider { border: none; border-top: 1.5px solid var(--border); margin: 28px 0; }

/* ── Section recettes ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 30px;
  font-style: italic;
}

.filter-row { display: flex; gap: 6px; align-items: center; }
.recipe-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.shopping-mode-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* ── Carte recette ── */
.recipe-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 2px;
  margin-bottom: 14px;
  animation: fadeIn 0.2s ease both;
  overflow: hidden;
}

.recipe-card-new {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.new-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--accent);
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  margin-left: 8px;
  letter-spacing: 0.05em;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.recipe-card-header {
  display: flex;
  align-items: center;
  padding: 18px 20px;
  cursor: pointer;
  gap: 12px;
  transition: background 0.1s;
}
.recipe-card-header:hover { background: var(--surface2); }

.recipe-card-main {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.recipe-card-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.recipe-card-actions { display: flex; align-items: center; }

.recipe-select-btn {
  width: 44px; height: 44px; flex: 0 0 44px;
  display: grid; place-items: center;
  background: var(--surface); border: 1.5px solid var(--border2); color: white;
  cursor: pointer;
}
.recipe-select-btn span { width: 24px; height: 24px; display: grid; place-items: center; border: 1.5px solid var(--border2); font-size: 14px; }
.recipe-select-btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-light); }
.recipe-select-btn[aria-pressed="true"] span { background: var(--accent); border-color: var(--accent); }
.recipe-card.selected-for-shopping { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.recipe-card.shopping-mode .delete-btn { display: none; }
.recipe-card.shopping-mode .recipe-card-chevron { display: none; }

.shopping-servings {
  display: flex; align-items: center; gap: 8px;
  padding-left: 8px; border-left: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.servings-step {
  width: 44px; height: 44px; border: 1px solid var(--border2);
  background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: 16px;
}
.servings-step:hover { border-color: var(--accent); color: var(--accent); }

.shopping-bar {
  position: fixed; z-index: 90; left: 50%; bottom: 16px; transform: translateX(-50%);
  width: min(720px, calc(100% - 32px)); min-height: 72px;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border2);
  border-top: 3px solid var(--accent); box-shadow: 0 4px 16px rgba(56, 43, 27, 0.22);
}
.shopping-bar[hidden] { display: none; }
.shopping-bar-count { text-align: center; font-size: 13px; color: var(--text-dim); }
.shopping-bar .btn:disabled { background: var(--border2); color: var(--surface); cursor: not-allowed; }

.shopping-review { background: var(--surface); border-top: 3px solid var(--accent); padding: 28px; }
.shopping-review[hidden] { display: none; }
.shopping-review-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.shopping-review h2 { font-family: 'Libre Baskerville', serif; font-size: 28px; }
.shopping-review-heading p { max-width: 520px; margin-top: 8px; color: var(--text-dim); font-size: 13px; line-height: 1.6; }
.combined-list { border-top: 1px solid var(--border); margin-bottom: 24px; }
.combined-item { display: flex; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 15px; }
.combined-item input { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 22px; }
.combined-item:has(input:not(:checked)) span { text-decoration: line-through; color: var(--text-muted); }
.shopping-copy-btn { width: 100%; min-height: 48px; }
.showing-shopping-review .section-header { display: none; }

.recipe-card-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 17px;
  font-style: italic;
  flex: 1;
}

.recipe-card-meta { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.recipe-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.recipe-tag { 
  font-size: 9px; 
  color: var(--text-dim); 
  background: var(--surface2); 
  border: 1px solid var(--border); 
  padding: 1px 6px; 
  border-radius: 3px; 
  text-transform: lowercase; 
}

.recipe-card-chevron {
  color: var(--text-muted);
  font-size: 12px;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.recipe-card.open .recipe-card-chevron { transform: rotate(180deg); }

/* ── Corps de la carte ── */
.recipe-card-body { display: none; border-top: 1.5px solid var(--border); }
.recipe-card.open .recipe-card-body { display: block; }

/* ── Onglets ── */
.recipe-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.recipe-tab {
  flex: 1;
  padding: 10px 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: 'DM Mono', monospace;
  transition: all 0.15s;
}
.recipe-tab:hover { color: var(--text-dim); }
.recipe-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.recipe-tab-content { display: none; }
.recipe-tab-content.active { display: block; }

/* ── Onglet Fiche ── */
.fiche-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.fiche-col { padding: 16px; }
.fiche-col:first-child { border-right: 1px solid var(--border); }

.fiche-col-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.fiche-row { display: flex; flex-direction: column; margin-bottom: 8px; }
.fiche-label { font-size: 11px; color: var(--text-muted); }
.fiche-value { font-size: 13px; font-weight: 500; color: var(--text); }

.fiche-ing-list {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 2;
}

/* ── Onglet Courses ── */
.ing-list { padding: 0; }

.ingredient-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
}
.ingredient-row:last-child { border-bottom: none; }
.ingredient-row.done { opacity: 0.38; }

.ing-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: 'DM Mono', monospace;
  transition: background 0.1s;
}
.ing-btn:hover { background: var(--surface2); }

.ing-chevron { font-size: 13px; color: var(--text-muted); flex-shrink: 0; }
.ingredient-row.done .ing-chevron { color: var(--green); }

.ing-name { font-size: 13px; flex: 1; }
.ingredient-row.done .ing-name { text-decoration: line-through; color: var(--text-muted); }

.store-btn {
  padding: 0 14px;
  background: none;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-muted);
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  align-self: stretch;
  display: flex;
  align-items: center;
}
.store-btn:hover { background: var(--accent); color: white; border-left-color: var(--accent); }

/* ── Onglet Étapes ── */
.steps-hint {
  font-size: 11px;
  color: var(--text-muted);
  padding: 10px 16px 6px;
}

.steps-list { padding: 8px 12px 12px; }

.step-row {
  display: flex;
  gap: 12px;
  padding: 11px 10px;
  margin-bottom: 4px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  border: 1.5px solid transparent;
  user-select: none;
}
.step-row:hover { background: var(--surface2); }
.step-row.active {
  background: var(--surface2);
  border-color: var(--border2);
}
.step-row.done { opacity: 0.5; }

.step-circle {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.5px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.15s;
}
.step-row.active .step-circle {
  background: var(--text);
  border-color: var(--text);
  color: white;
}
.step-row.done .step-circle {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green);
}

.step-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
  padding-top: 2px;
  transition: color 0.15s;
}
.step-row.active .step-text { color: var(--text); font-weight: 500; }
.step-row.done .step-text { text-decoration: line-through; }

/* ── Bouton supprimer ── */
.delete-btn {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 3px;
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'DM Mono', monospace;
}
.delete-btn:hover { background: #fff0f0; border-color: #e88; color: #c44; }

/* ── État vide ── */
.empty { text-align: center; padding: 48px 0; color: var(--text-muted); }
.empty-icon { font-size: 40px; margin-bottom: 12px; display: block; }
.empty-title { font-family: 'Libre Baskerville', serif; font-size: 18px; font-style: italic; color: var(--text-dim); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: 3px;
  font-size: 12px;
  z-index: 100;
  white-space: normal;
  text-align: center;
  max-width: 80%;
  animation: toastIn 0.2s ease, toastOut 0.3s ease 2.1s forwards;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toastOut { to { opacity: 0; } }


textarea#urlInput {
  min-height: 100px;
  resize: vertical;
}

.short-link-warning {
  background: #fff3cd;
  border: 1px solid #ffe08a;
  color: #7a5c00;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 10px;
}
.short-link-warning code {
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 3px;
}

@media (max-width: 620px) {
  .app { padding: 0 16px 64px; }
  .header { padding: 24px 0 20px; margin-bottom: 32px; align-items: center; }
  .header .eyebrow { display: none; }
  .title { font-size: 27px; letter-spacing: -0.6px; }
  .add-recipe-btn { padding: 11px 13px; }

  .section-header { align-items: flex-start; }
  .section-title { font-size: 26px; }
  .section-intro { font-size: 14px; line-height: 1.55; }
  .filter-row { width: 100%; }
  .filter-row input { flex: 1; min-height: 44px; }

  .recipe-card-header { padding: 16px 14px; gap: 8px; align-items: flex-start; }
  .recipe-actions { width: 100%; justify-content: stretch; }
  .shopping-mode-btn { width: 100%; min-height: 48px; }
  .recipe-card-title { font-size: 16px; line-height: 1.4; }
  .recipe-card-meta { display: none; }
  .recipe-card-main { gap: 6px; }
  .recipe-select-btn { margin-top: 1px; }
  .recipe-card.selected-for-shopping .recipe-card-header { flex-wrap: wrap; }
  .shopping-servings { width: 100%; justify-content: space-between; padding: 10px 0 0 52px; border-left: 0; border-top: 1px solid var(--border); }
  .delete-btn { min-width: 36px; min-height: 36px; justify-content: center; }

  .shopping-bar { bottom: 8px; width: calc(100% - 16px); grid-template-columns: 1fr auto; gap: 8px; padding: 10px; }
  .shopping-bar .btn-text { grid-row: 2; grid-column: 1 / -1; min-height: 36px; padding: 4px; }
  .shopping-bar-count { text-align: left; font-size: 12px; }
  .shopping-review { margin-inline: -16px; padding: 24px 16px 32px; }
  .shopping-review-heading { flex-direction: column; gap: 8px; }
  .shopping-review-heading .btn { padding-left: 0; }

  .import-panel { margin-inline: -16px; padding: 24px 16px 32px; box-shadow: none; }
  .import-heading h2 { font-size: 21px; }
  .input-row { flex-direction: column; }
  .input-row .btn { width: 100%; min-height: 48px; }
  textarea#urlInput { width: 100%; min-height: 112px; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .btn-row .btn { min-height: 44px; }

  .fiche-grid { grid-template-columns: 1fr; }
  .fiche-col:first-child { border-right: 0; border-bottom: 1px solid var(--border); }
  .recipe-tab { min-height: 48px; font-size: 10px; }
  .ingredient-row { align-items: stretch; }
  .ing-btn { padding: 14px 12px; }
  .store-btn { padding: 0 10px; max-width: 105px; white-space: normal; text-align: center; justify-content: center; }
  .steps-hint { font-size: 12px; line-height: 1.5; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
