/* Font & Color Setup */
@import url('https://fonts.googleapis.com/css2?family=Cinzel&family=Inter&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Cardo:wght@700&display=swap');


:root {
  --color-bg: #fefdf9;
  --color-surface: #ffffff;
  --color-primary: #8a3b12;
  --color-secondary: #4a3c2e;
  --color-accent: #009999;
  --color-outline: #c2b280;
  --color-muted: #e0e0dc;

  --font-heading: 'Cinzel', serif;
  --font-body: 'Inter', sans-serif;
}

body {
  font-family: 'Inter', sans-serif;
  margin: 0;
  padding: 20px;
  background: #f9f9f9;
  color: #333;
}


.container {
  max-width: 800px;
  margin: 0 auto;
  background: var(--color-surface);
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--color-muted);
}

h1, h2 {
  font-family: 'Cardo', serif;
  font-weight: 700;
  text-align: center;
  color: #3a2e2e;
  letter-spacing: 0.5px;
  margin-bottom: 20px;
}


form {
  margin-bottom: 25px;
}

label {
  display: block;
  margin-top: 20px;
  font-weight: 600;
  color: var(--color-secondary);
}

input, select, button {
  padding: 12px;
  margin: 6px 0;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--color-outline);
  border-radius: 6px;
  background: #fdfcf8;
  font-size: 1rem;
  transition: box-shadow 0.3s ease;
}

input:focus, select:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-accent);
}

button {
  background: linear-gradient(135deg, #7c2f2f, #ba7b48);
  color: white;
  font-weight: bold;
  border: none;
  cursor: pointer;
  padding: 12px;
  border-radius: 8px;
  transition: background 0.3s ease, transform 0.2s ease;
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

button:hover {
  background: linear-gradient(135deg, #5e1f1f, #a86630);
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}


/* Taste Keyword Group */
.taste-group {
  margin-bottom: 20px;
}

.taste-group .taste-keyword {
  width: 100%;
  padding: 10px;
  margin-bottom: 5px;
  box-sizing: border-box;
}

.taste-group {
  width: 100%;
}

.taste-weight-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: linear-gradient(to right, #cba135 0%, #4a2c0a 100%);
  outline: none;
  transition: background 0.3s ease;
  margin-top: 5px;
  margin-bottom: 8px;
}

/* Chrome & Safari thumb */
.taste-weight-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #4a2c0a;
  cursor: pointer;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}

.taste-weight-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Firefox thumb */
.taste-weight-slider::-moz-range-thumb {
  height: 18px;
  width: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #4a2c0a;
  cursor: pointer;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

.taste-group .weight-value {
  text-align: right;
  font-size: 0.85em;
  font-style: italic;
  color: #6b4e23;
}


.taste-group .weight-value {
  display: block;
  text-align: right;
  margin-top: 5px;
  font-size: 0.9em;
  color: var(--color-secondary);
}

/* ensure your #progressBar has a smooth width transition */
#progressBar { 
  transition: width 0.2s linear; 
}


#error {
  color: red;
  text-align: center;
  font-weight: bold;
  margin-top: 10px;
}

.result-item {
  background: #fffdf9;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  padding: 15px 20px;
  margin-bottom: 15px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.result-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.result-item h3 {
  margin-top: 0;
  color: #4a2c0a;
  font-size: 1.2em;
}

.result-item p {
  margin: 5px 0;
  font-size: 0.95em;
  color: #444;
}

@media (max-width: 600px) {
  .result-item {
    padding: 12px 15px;
  }

  .result-item h3 {
    font-size: 1.1em;
  }

  .result-item p {
    font-size: 0.9em;
  }
}




/* Locked Field Styling */
input[readonly], select[disabled] {
  background-color: #f2f2f2;
  color: #555;
  border-color: #ddd;
  cursor: not-allowed;
  opacity: 0.8;
}

input[readonly]:focus, select[disabled]:focus {
  box-shadow: none;
  outline: none;
}

/* ===== Polished UI Pack (add-on) ===== */

/* Layout container upgrade + subtle background bloom */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(0,153,153,.12), transparent 60%),
    radial-gradient(600px 500px at 10% 110%, rgba(138,59,18,.08), transparent 60%);
  pointer-events: none;
  z-index: -1;
}

.container {
  max-width: 1024px; /* was 800px */
  border-radius: 16px; /* a bit rounder */
}

/* Sticky header bar (optional: wrap your search form in .header) */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--color-surface) 75%, transparent);
  backdrop-filter: saturate(1.1) blur(10px);
  border-bottom: 1px solid var(--color-muted);
  padding: 10px 0;
}

/* Searchbar pill */
.searchbar {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--color-outline);
  border-radius: 999px;
  background: #fffdfa;
  box-shadow: 0 6px 16px rgba(0,0,0,.06);
}
.searchbar input[type="text"],
.searchbar input[type="search"] {
  background: transparent;
  border: 0;
  padding: 8px 6px;
  outline: none;
  font-size: 1rem;
  color: #2c2c2c;
}

/* Primary button (keeps your gradient vibe) */
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #7c2f2f, #ba7b48);
  box-shadow: 0 6px 16px rgba(186,123,72,.25);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.02); }
.btn:active { transform: translateY(0); filter: brightness(.98); }

/* Filter chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; font-size: 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--color-outline);
  background: #fffdf9; color: var(--color-secondary);
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .15s ease;
}
.chip:hover { transform: translateY(-1px); }
.chip.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

/* Results grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

/* Result “card” (works alongside your .result-item; use either) */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,.6), transparent 40%), #fffdf9;
  border: 1px solid var(--color-muted);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0,0,0,.06);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--color-outline) 70%, #8a3b12 30%);
  box-shadow: 0 12px 28px rgba(0,0,0,.10);
}
.card .media {
  display: block; width: 100%; aspect-ratio: 16/9; object-fit: cover;
  background: #f3efe7;
}
.card .body { padding: 14px 14px 16px; }
.card h3 {
  margin: 0 0 6px; font-size: 1.05rem; color: #4a2c0a; letter-spacing: .2px;
}
.card .meta {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  font-size: .9rem; color: #5a5147; opacity: .9;
}
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.badge {
  font-size: .75rem; padding: 4px 8px; border-radius: 999px;
  background: #f6f4ef; border: 1px solid var(--color-outline); color: #654b2d;
}
.badge--accent { background: rgba(0,153,153,.12); border-color: rgba(0,153,153,.45); color: #006a6a; }
.badge--veg { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.45); color: #166534; }
.badge--spicy { background: rgba(220, 38, 38, .10); border-color: rgba(220,38,38,.4); color: #7f1d1d; }

.price-pill {
  font-weight: 700; letter-spacing: .5px;
  padding: 2px 8px; border-radius: 999px;
  background: #fff; border: 1px dashed var(--color-outline); color: #4a3c2e;
}

/* Skeleton loaders (use when fetching results) */
.skeleton {
  border-radius: 12px;
  background: linear-gradient(90deg, #f3efe7 25%, #faf7f0 37%, #f3efe7 63%);
  background-size: 400% 100%;
  animation: shimmer 1.1s infinite linear;
}
@keyframes shimmer { 0%{background-position: 100% 0} 100%{background-position: 0 0} }
.skeleton.media { aspect-ratio: 16/9; }
.skeleton.line { height: 12px; margin-top: 8px; }

/* Empty state */
.empty {
  text-align: center;
  padding: 36px;
  border: 1px dashed var(--color-outline);
  background: #fffdf9;
  border-radius: 14px;
  color: #6b5e4e;
}
.empty .actions { margin-top: 10px; }
.empty .actions .chip { cursor: pointer; }

/* Progress bar container (pairs with your #progressBar transition) */
.progress-wrap {
  width: 100%;
  background: #f6f4ef;
  border: 1px solid var(--color-outline);
  border-radius: 999px;
  overflow: hidden;
  height: 10px;
  margin: 10px 0 16px;
}
.progress-wrap .bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-accent), #31bfbf);
  transition: width .2s linear;
}

/* Subtle error toast style that matches your palette */
.toast-error {
  background: #fff3f3;
  border: 1px solid #f2b2b2;
  color: #7a1d1d;
  padding: 10px 12px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,.06);
}

/* Mobile tweaks */
@media (max-width: 600px) {
  .searchbar { padding: 8px 12px; }
  .results-grid { gap: 12px; }
  .card .body { padding: 12px; }
}


.result-item {
  border: 1px solid var(--color-muted);
  background: #fffdf9;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(0,0,0,.06);
}
.result-item h3 { color: #4a2c0a; }


/* ===== Mobile-first fixes ===== */
@media (max-width: 720px) {
  /* Reduce page chrome */
  body { padding: 12px; }
  .container { padding: 16px; border-radius: 12px; }

  /* Header: keep sticky but tighter */
  .header { padding: 8px 0; }

  /* Searchbar: stack vertically for thumbs */
  .searchbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 14px;
  }
  .searchbar select,
  .searchbar input[type="search"],
  .searchbar input[type="text"] {
    width: 100%;
    min-height: 44px; /* comfortable touch size */
    font-size: 16px;  /* avoid iOS zoom */
  }
  .searchbar label { margin: 0; }
  .btn { width: 100%; padding: 12px 14px; border-radius: 12px; }

  /* Chips: horizontal scroll with momentum + snap */
  .chips {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    padding-bottom: 4px;
    margin: 10px -4px 0;
  }
  .chip { 
    display: inline-block; 
    margin: 0 4px 6px; 
    padding: 8px 12px; 
    border-radius: 999px; 
  }

  /* Taste sliders: tighter spacing */
  .taste-group { margin-bottom: 14px; }
  .taste-weight-slider { height: 8px; }

  /* Results: single column cards, friendlier media ratio */
  .results-grid { 
    grid-template-columns: 1fr !important; 
    gap: 12px; 
  }
  .card .media { aspect-ratio: 4 / 3; } /* taller thumbnails read better */
  .card .body { padding: 12px; }
  .card h3 { font-size: 1rem; }

  /* Progress pill: compact */
  .progress-wrap { height: 8px; margin: 8px 0 12px; }

  /* Toasts & empty state spacing */
  .empty { padding: 20px; border-radius: 12px; }
}

/* Respect iPhone safe area if you later add a bottom bar */
@supports (padding: max(0px)) {
  .container { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
}


/* Mobile-friendly slider thumb */
.taste-weight-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  height: 28px;   /* bigger thumb */
  width: 28px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #4a2c0a;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0,0,0,0.4);
  margin-top: -11px; /* centers thumb vertically on 6–8px track */
  touch-action: pan-x; /* ensure horizontal dragging works */
}

.taste-weight-slider::-moz-range-thumb {
  height: 28px;
  width: 28px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #4a2c0a;
  cursor: pointer;
  box-shadow: 0 0 4px rgba(0,0,0,0.4);
}


.taste-weight-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #cba135 0%, #4a2c0a 100%);
  outline: none;
  margin-top: 5px;
  margin-bottom: 8px;
  touch-action: none; /* prevents page scroll from hijacking */
}

/* --- Fix searchbar overflow / checkbox stretching --- */
.searchbar {
  display: flex;       /* already set, but reaffirm for clarity */
  flex-wrap: wrap;     /* allow wrapping on smaller widths */
  gap: 10px;
}

/* Let flex items shrink instead of forcing overflow */
.searchbar > * { 
  min-width: 0;        /* critical for flex children to shrink */
}

/* Controls inside the pill should NOT be full-width */
.searchbar select,
.searchbar input[type="search"],
.searchbar input[type="text"],
.searchbar button {
  width: auto;               /* override the global 100% */
  flex: 1 1 180px;           /* grow, shrink, with a sensible base width */
}

/* The toggle label ("Reduce Big Chains") should size-to-content */
.searchbar label {
  flex: 0 0 auto;            /* don't stretch like inputs */
  white-space: nowrap;       /* keep text on one line */
}

/* The checkbox itself must never be 100% wide */
.searchbar input[type="checkbox"] {
  width: auto;               /* override global 100% */
  flex: 0 0 auto;
}

/* Submit button should hug content, not take flex space */
.searchbar .btn {
  flex: 0 0 auto;
}

/* (Optional) tighten the toggle visuals a touch */
.searchbar label input[type="checkbox"] { margin-right: 6px; }


/* --- Neo-modern compact form --- */
.form--modern {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--color-outline);
  border-radius: 14px;
  background: #fffdfa;
  box-shadow: 0 6px 16px rgba(0,0,0,.06);
}

/* Each control block */
.form--modern .field {
  display: grid;
  gap: 6px;
  grid-column: span 1;
  min-width: 0; /* allow shrinking */
}
.form--modern label {
  font-size: .9rem;
  color: var(--color-secondary);
}

/* Outlined control style (Material-esque) */
.form--modern select,
.form--modern input[type="text"],
.form--modern input[type="search"] {
  width: 100%;
  border-radius: 10px;
  background: #fff;
  border: 1.5px solid var(--color-muted);
  padding: 12px 12px;
  min-height: 44px; /* mobile finger target */
  font-size: 16px;  /* prevent iOS zoom */
  transition: border-color .15s ease, box-shadow .2s ease;
}
.form--modern select:focus,
.form--modern input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 25%, transparent);
  outline: none;
}

/* Compact iOS/Android switch for 'Reduce Big Chains' */
.form--modern .switch {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--color-muted);
  background: #fff;
  min-height: 44px; /* 48-ish touch target */
  grid-column: span 1;
  white-space: nowrap;
}
.form--modern .switch input { position: absolute; opacity: 0; }
.form--modern .switch .track {
  position: relative; width: 44px; height: 26px; border-radius: 999px;
  background: #e6ecec; border: 1px solid #cde1e1; display: inline-block;
}
.form--modern .switch .thumb {
  position: absolute; top: 50%; left: 3px; transform: translateY(-50%);
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .18s ease;
}
.form--modern .switch input:checked + .track .thumb {
  transform: translate(18px, -50%);
}
.form--modern .switch input:checked + .track {
  background: color-mix(in srgb, var(--color-accent) 25%, #e6f7f7);
  border-color: var(--color-accent);
}
.form--modern .switch-label { font-size: .95rem; color: var(--color-secondary); }

/* Button should not stretch: */
.form--modern .btn { grid-column: span 1; min-height: 44px; }

/* Desktop: give City and Dietary more room, keep switch compact */
@media (min-width: 901px) {
  .form--modern .field:nth-child(1) { grid-column: span 2; }
  .form--modern .field:nth-child(2) { grid-column: span 1; }
  .form--modern .switch              { grid-column: span 1; }
  .form--modern .btn                 { grid-column: span 1; }
}

/* Mobile stacking — everything single-column and dense */
@media (max-width: 900px) {
  .form--modern { grid-template-columns: 1fr; gap: 8px; }
  .form--modern .field,
  .form--modern .switch,
  .form--modern .btn { grid-column: span 1; }
}

/* Ensure tap targets meet ~48px guidance */
.form--modern .btn,
.form--modern select,
.form--modern input,
.form--modern .switch { min-height: 48px; }


@media (max-width: 420px) {
  .form--modern .switch-label { font-size: .9rem; }
}


/* ---------- COMPACT HEADER FORM (phones) ---------- */
@media (max-width: 600px) {
  /* shrink the pill and spacing */
  .form--modern {
    grid-template-columns: 1fr 1fr;  /* 2 columns */
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
  }
  /* remove extra body padding so header doesn't feel huge */
  body { padding: 12px; }
  .header { padding: 6px 0; }

  /* denser fields (still readable) */
  .form--modern .field { gap: 4px; }
  .form--modern label { font-size: 0.85rem; line-height: 1.1; }

  .form--modern select,
  .form--modern input[type="text"],
  .form--modern input[type="search"] {
    min-height: 44px;        /* tap target ≥44px */
    font-size: 16px;         /* prevent iOS zoom-in */
    padding: 10px 12px;
  }

  /* place items into 2 rows:
     Row 1: City | Diet
     Row 2: Switch | Search
  */
  .field--city   { grid-column: 1 / span 1; }
  .field--diet   { grid-column: 2 / span 1; }
  .switch--chains{ grid-column: 1 / span 1; align-items: center; }
  .btn--submit   { grid-column: 2 / span 1; min-height: 48px; }

  /* compact switch: keep control visible, tuck the text */
  .form--modern .switch { padding: 6px 8px; min-height: 44px; }
  .form--modern .switch .track { width: 40px; height: 24px; }
  .form--modern .switch .thumb { width: 18px; height: 18px; left: 3px; }
  .form--modern .switch input:checked + .track .thumb { transform: translate(16px, -50%); }

  /* hide long label on very small screens; show short version via CSS */
  .form--modern .switch-label { font-size: .85rem; }
  @media (max-width: 380px) {
    .form--modern .switch-label::before { content: "No Chains"; }
    .form--modern .switch-label { font-size: .8rem; }
  }

  /* keep things from overflowing */
  .form--modern > * { min-width: 0; }
  .searchbar select,
  .searchbar button { width: 100%; } /* in the grid, full width per cell */
}

/* Make sure the button & switch still meet target size guidance on all screens */
.form--modern .btn,
.form--modern .switch { min-height: 48px; }  /* Apple HIG & WCAG target sizes. :contentReference[oaicite:2]{index=2} */


/* === Compact 2-row header form that matches your current HTML === */
/* Structure: [1]=City field, [2]=Diet field, [3]=Switch label, [4]=Search btn */
@media (max-width: 600px) {
  .form--modern {
    display: grid;
    grid-template-columns: 1fr 1fr;      /* two columns */
    gap: 8px;
    padding: 8px 10px;                   /* tighter */
    border-radius: 12px;
  }

  /* Put items into two rows:
     Row 1: City | Dietary
     Row 2: Switch | Search
  */
  .form--modern > :nth-child(1) { grid-column: 1 / span 1; } /* City  */
  .form--modern > :nth-child(2) { grid-column: 2 / span 1; } /* Diet  */
  .form--modern > :nth-child(3) { grid-column: 1 / span 1; } /* Switch*/
  .form--modern > :nth-child(4) { grid-column: 2 / span 1; } /* Button*/

  /* Labels & fields: smaller but readable */
  .form--modern .field { gap: 4px; min-width: 0; }
  .form--modern label { font-size: .85rem; line-height: 1.1; }
  .form--modern select,
  .form--modern input[type="text"],
  .form--modern input[type="search"] {
    min-height: 44px; font-size: 16px; padding: 10px 12px;
  }

  /* Keep switch compact and on one line */
  .form--modern .switch {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 8px; min-height: 44px; width: auto; white-space: nowrap;
    justify-self: start; border-radius: 10px;
  }
  .form--modern .switch .track { width: 40px; height: 24px; }
  .form--modern .switch .thumb { width: 18px; height: 18px; left: 3px; }
  .form--modern .switch input:checked + .track .thumb { transform: translate(16px, -50%); }
  .form--modern .switch-label { font-size: .85rem; }

  /* Prevent overflow from global width:100% rule inside the grid */
  .form--modern > * { min-width: 0; }
  .form--modern .switch, .form--modern .btn { width: auto; }
  .form--modern .btn { min-height: 48px; justify-self: end; }
}

/* Ultra-small phones: shorten the label without wrapping */
@media (max-width: 380px) {
  .form--modern .switch-label { font-size: .8rem; max-width: 10ch; overflow: hidden; text-overflow: ellipsis; }
}



/* ===== Tighten rhythm & edge polish (non-structural) ===== */
:root {
  /* micro spacing scale for denser layout without feeling cramped */
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
}

/* Slightly denser container on all screens (keeps your look) */
.container { padding: clamp(14px, 2.2vw, 24px); }

/* Description block tighter */
.description { margin-bottom: var(--space-3) !important; }

/* Sticky header: subtle shadow so it reads as a bar when scrolled */
.header { box-shadow: 0 2px 10px rgba(0,0,0,.04); }

/* Chips: better mobile scroll feel + soft edge fade */
.chips {
  padding-inline: 8px;
  scroll-snap-type: x proximity;
  mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
}
.chip { scroll-snap-align: start; }

/* Taste group: compact two-line layout without changing markup */
.taste-group {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 6px;
  margin-bottom: var(--space-3);
}
.taste-group .taste-keyword {
  grid-column: 1 / -1;
  margin: 0; /* remove extra vertical slack */
}
.taste-group .taste-weight-slider {
  grid-column: 1 / 2;
  align-self: center;
  margin: 0; /* track sits snug under input */
}
.taste-group .weight-value {
  grid-column: 2 / 3;
  align-self: center;
  margin: 0 0 0 8px;
  text-align: left;
}

/* Card grid: ensure nice 2-up on tablets; 1-up on phones already handled */
@media (min-width: 600px) and (max-width: 900px) {
  .results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Buttons & inputs: slightly denser default without altering style */
button, input, select { padding: 10px; }

/* Touch devices: keep hover effects from "jumping" */
@media (hover: none) {
  .card:hover, .result-item:hover {
    transform: none;
    box-shadow: 0 8px 20px rgba(0,0,0,.06);
  }
}

/* Motion sensitivity */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Prevent header overlap on tiny screens after sticky engages */
@media (max-width: 600px) {
  .header { padding: 6px 0; }
  .container:first-of-type { margin-top: 6px; }
}

/* Ensure any long meta/labels don’t overflow pills */
.meta, .badge, .price-pill, .switch-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }


.chip.active { outline: 2px solid currentColor; }


/* Solid variant for our ghost button so it’s always visible */
.btn.btn--ghost {
  background: var(--brand, #0ea5e9); /* use your base brand if you have one */
  color: #fff;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.btn.btn--ghost:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }


/* Ensure selected chips visibly “lock in” */
.chip.active {
  background: var(--brand, #0ea5e9);
  color: #fff;
  border-color: transparent;
}


.result-card { background:#fff; border:1px solid rgba(0,0,0,.08); border-radius:16px; padding:16px; box-shadow:0 4px 14px rgba(0,0,0,.06); }
.result-item__top { display:flex; align-items:center; gap:8px; justify-content:space-between; }
.badge { font-size:.75rem; padding:4px 8px; border-radius:999px; background:#eef7ff; }
.result-item__meta { color:#666; font-size:.9rem; display:flex; gap:6px; margin:6px 0 10px; }
.result-item__menu { display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; }
.result-item__desc { color:#333; line-height:1.45; margin-bottom:8px; }
.chip-row { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.chip { border:1px solid #ddd; padding:4px 8px; border-radius:999px; font-size:.8rem; }
.chip.active { background:#0ea5e9; color:#fff; border-color:transparent; }
.muted { color:#7a7a7a; font-size:.8rem; }


/* =========================
   Mobile Paint Patch (CSS-only)
   ========================= */

/* 1) Header height + safe anchor jumps */
:root {
  --header-h: clamp(52px, 9vh, 72px);
}
.header {
  min-height: var(--header-h);
  top: env(safe-area-inset-top, 0); /* keep away from notches */
}
html {
  /* So #ids and in-page jumps don’t hide under sticky header */
  scroll-padding-top: calc(var(--header-h) + 8px);
}

/* Optional: a touch of breathing room after the sticky bar */
.header + .container { margin-top: 6px; }

/* 2) Chips/tokens: keep one-line + sideways scroll on phones
      (your base rules already do most of this; these just tighten) */
@media (max-width: 480px) {
  .chips {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    padding-bottom: 4px;
    gap: 6px;
  }
  .chips .chip {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 6px 10px;
    font-size: 0.85rem;
  }
}

/* 3) “Reduce Big Chains” → unbreakable & short on very small screens
      No HTML or JS changes — we swap the visible text via pseudo element. */
@media (max-width: 360px) {
  .form--modern .switch-label {
    position: relative;
    /* Hide the original long text visually, but keep it for a11y */
    text-indent: -9999px;
    line-height: 1;
  }
  .form--modern .switch-label::after {
    content: "No Chains";
    position: absolute;
    left: 0;
    top: 0;
    text-indent: 0;
    white-space: nowrap; /* never breaks into 'few chai' */
    font-size: .9rem;
  }
}

/* 4) Extra guardrails for sticky overlap on iOS Safari’s dynamic bars */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
  }
}

/* 5) Touch targets compact but tappable */
@media (max-width: 480px) {
  .btn,
  .chip,
  .switch,
  select,
  input[type="search"],
  input[type="text"] { min-height: 44px; }
}

/* 6) Make sure form controls inside the pill never force overflow */
.searchbar > * { min-width: 0; } /* allows flex children to shrink */


.bubble-area {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
}

.bubble {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: white;
  background: linear-gradient(135deg, #5a9, #3c7);
  cursor: pointer;
  user-select: none;
  transition: box-shadow 0.2s ease;
}

.bubble:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

html {
  scroll-padding-top: var(--header-h);
}
#search-anchor {
  scroll-margin-top: var(--header-h);
}
section, form, #taste-fields {
  scroll-margin-top: var(--header-h);
}

/* ——— Sticky header should always sit on top ——— */
.header{
  position: sticky;            /* already set, re-assert */
  top: 0;
  z-index: 1000;               /* higher than any cards */
  isolation: isolate;          /* new stacking context: header sits above page */
  -webkit-backdrop-filter: saturate(1.1) blur(10px); /* iOS Safari */
  backdrop-filter: saturate(1.1) blur(10px);
}

/* Make the form the topmost thing inside the header */
.header .form--modern,
.header .searchbar{
  position: relative;
  z-index: 1001;               /* above header’s own background */
}

/* Everything else should NOT eclipse the header */
.results-grid,
.card,
.result-item,
.chips,
.btn.btn--ghost,
.container:not(.header .container){
  position: relative;
  z-index: 0;                   /* keep content below */
}

/* Defensive: avoid ancestor transforms breaking sticky on iOS */
html, body{
  transform: none !important;
}

/* iOS select/inputs weirdness guard (no click-through) */
.header{ pointer-events: auto; }


/* When we unpin, header behaves like normal flow */
.header.is-unpinned {
  position: static !important;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* --- Minimal Hero --- */
.hero {
  text-align: center;
  padding: clamp(10px, 3.5vw, 22px) 6px 6px;
}
.hero h1 {
  font-family: var(--font-heading, 'Cardo', serif);
  font-weight: 700;
  letter-spacing: .3px;
  margin: 0 0 6px;
  color: #3a2e2e;
  font-size: clamp(1.25rem, 4.8vw, 1.85rem);
}
.hero .sub {
  margin: 0;
  color: #6b5e4e;
  font-size: clamp(.9rem, 3.4vw, 1rem);
  opacity: .9;
}

/* Button micro-press without layout jumps */
.btn:active { transform: translateY(1px) scale(.995); }

/* Chip tap feedback (mobile-safe, no heavy transforms on hover devices) */
.chip { transition: transform .08s ease, box-shadow .12s ease; }
@media (hover: hover) {
  .chip:hover { transform: translateY(-1px); }
}
.chip:active { transform: scale(.98); }


/* Soft header search button – secondary, not screaming blue */
.btn--header-search {
  background: #ffffff;
  color: #1f2933; /* dark gray text */
  border: 1px solid rgba(148, 163, 184, 0.8); /* soft slate border */
  box-shadow: none;
  padding: 0.55rem 1.3rem;
  border-radius: 999px; /* pill shape */
  font-size: 0.95rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    transform 0.12s ease,
    box-shadow 0.12s ease;
}

/* Hover/focus: just a gentle lift, no heavy color */
.btn--header-search:hover,
.btn--header-search:focus-visible {
  background: #f9fafb;
  border-color: rgba(107, 114, 128, 0.95);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}

/* Make it sit nicely in the search bar row */
.searchbar .btn--header-search {
  align-self: flex-end;
  margin-left: 1rem;
}
