/* ===== Fuentes (OFL, alojadas en el proyecto) ===== */
@font-face { font-family: "Fraunces"; src: url("../fonts/Fraunces-latin.woff2") format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("../fonts/DMSans-latin.woff2") format("woff2"); font-weight: 300 800; font-display: swap; }

/* ===== Temas: el restaurante solo cambia estas variables ===== */
:root, [data-theme="tierra"] {
  --bg: #F4ECE1; --surface: #FFFBF6; --surface-2: #F1E6D8; --ink: #2A1D14; --ink-2: #4A3828; --muted: #6E5847;
  --line: #E3D3C0; --accent: #A4441F; --accent-ink: #FFFFFF; --accent-2: #2F5D50; --band-3: #D9A441;
  --free-bg: #E1EEE2; --free-ink: #1E5631; --has-bg: #F7E0D2; --has-ink: #8A2F12;
  --on-photo-kicker: #F6D9A8; --scrim: rgba(28, 16, 8, .55); --shadow: 0 1px 2px rgba(60,30,10,.06), 0 10px 30px rgba(60,30,10,.10);
  color-scheme: light;
}
[data-theme="noche"] {
  --bg: #15110E; --surface: #1F1A16; --surface-2: #2A231D; --ink: #F4ECE3; --ink-2: #DCCFC1; --muted: #B5A595;
  --line: #3A312A; --accent: #E3A85C; --accent-ink: #1B130B; --accent-2: #7FB59C; --band-3: #B5553A;
  --free-bg: #1D3328; --free-ink: #A9DEBB; --has-bg: #3D261A; --has-ink: #F4C09F;
  --on-photo-kicker: #F3C987; --scrim: rgba(0,0,0,.65); --shadow: 0 1px 2px rgba(0,0,0,.4), 0 14px 34px rgba(0,0,0,.45);
  color-scheme: dark;
}
[data-theme="lima"] {
  --bg: #F2F5EA; --surface: #FFFFFF; --surface-2: #E8EEDC; --ink: #1C2618; --ink-2: #33412D; --muted: #55624E;
  --line: #D6E0C7; --accent: #3D7A1E; --accent-ink: #FFFFFF; --accent-2: #B4D25A; --band-3: #E07A3F;
  --free-bg: #DFF0CF; --free-ink: #285512; --has-bg: #FBE6D3; --has-ink: #8A3A0B;
  --on-photo-kicker: #DCEFA0; --scrim: rgba(12, 22, 8, .55); --shadow: 0 1px 2px rgba(20,40,10,.06), 0 10px 30px rgba(20,40,10,.10);
  color-scheme: light;
}
[data-theme="marino"] {
  --bg: #EDF2F5; --surface: #FFFFFF; --surface-2: #E1EAF0; --ink: #0F2233; --ink-2: #26394B; --muted: #4C6073;
  --line: #D2DEE7; --accent: #0D5A80; --accent-ink: #FFFFFF; --accent-2: #E58A3A; --band-3: #5FA8C9;
  --free-bg: #DCEFE5; --free-ink: #14512F; --has-bg: #FCE5D5; --has-ink: #8E3A10;
  --on-photo-kicker: #FFD2A8; --scrim: rgba(6, 18, 30, .55); --shadow: 0 1px 2px rgba(10,30,50,.06), 0 10px 30px rgba(10,30,50,.10);
  color-scheme: light;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.55 "DM Sans", system-ui, sans-serif; -webkit-font-smoothing: antialiased;
  transition: background-color .35s ease, color .35s ease;
}
body.locked { overflow: hidden; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -48px; background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: 10px; z-index: 99; }
.skip:focus { top: 12px; }

/* ===== Barra superior ===== */
.topbar {
  position: sticky; top: 0; z-index: 30; height: 64px; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.topbar::after { /* franja textil */
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 4px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 22px, var(--band-3) 22px 30px, var(--accent-2) 30px 44px, var(--bg) 44px 48px);
  opacity: .9;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; color: var(--accent); }
.brand-mark svg { width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font: 650 24px/1 "Fraunces", Georgia, serif; letter-spacing: -.01em; font-variation-settings: "opsz" 72, "SOFT" 50; }
.brand-sub { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 4px; font-weight: 500; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.mock-tag { font-size: 12px; font-weight: 500; color: var(--muted); border: 1px dashed var(--line); padding: 3px 9px; border-radius: 99px; letter-spacing: .02em; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  display: inline-grid; place-items: center; color: var(--ink); transition: transform .2s ease, background .2s;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:active { transform: scale(.94); }

/* Selector de tema */
.theme-panel {
  position: absolute; right: 12px; top: 70px; width: min(320px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 18px;
  box-shadow: var(--shadow), 0 24px 60px rgba(0,0,0,.18); transform-origin: top right; animation: pop .22s ease both;
}
.theme-title { font: 600 19px/1.2 "Fraunces", Georgia, serif; }
.theme-help { font-size: 14px; color: var(--muted); margin: 4px 0 14px; }
.theme-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-list button {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--surface); font-size: 15px; font-weight: 600; text-align: left;
}
.theme-list button[aria-checked="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.sw { width: 30px; height: 30px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,.12);
  background: conic-gradient(var(--a) 0 50%, var(--c) 50% 75%, var(--b) 75% 100%); }

/* ===== Hero ===== */
.layout { max-width: 1320px; margin: 0 auto; }
.main { padding-bottom: 32px; }
.hero { position: relative; margin: 16px 16px 0; height: 300px; border-radius: 26px; overflow: hidden; isolation: isolate; }
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 45%; transform: scale(1.02); }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(12,7,3,.88) 0%, rgba(12,7,3,.55) 38%, rgba(12,7,3,.05) 72%); }
.hero-copy { position: absolute; left: 22px; right: 22px; bottom: 22px; color: #fff; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--on-photo-kicker); }
.hero h1 { font: 600 42px/1.02 "Fraunces", Georgia, serif; letter-spacing: -.02em; margin: 6px 0 10px; font-variation-settings: "opsz" 144, "SOFT" 30; text-wrap: balance; }
.hero-meta { font-size: 15px; color: rgba(255,255,255,.9); display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Categorías ===== */
.cats { position: sticky; top: 68px; z-index: 20; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.cats-inner { display: flex; gap: 8px; padding: 14px 16px 12px; overflow-x: auto; scrollbar-width: none; }
.cats-inner::-webkit-scrollbar { display: none; }
.cat {
  flex: none; padding: 9px 16px; min-height: 42px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--surface); font-size: 15px; font-weight: 600; color: var(--ink-2); transition: background .2s, color .2s, border-color .2s;
}
.cat[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ===== Tarjeta “Pregúntale al menú” ===== */
.ask-card {
  margin: 6px 16px 8px; padding: 18px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line);
  display: grid; gap: 14px; position: relative; overflow: hidden;
}
.ask-card::before { content: ""; position: absolute; right: -58px; top: -58px; width: 120px; height: 120px; border-radius: 50%;
  border: 14px solid color-mix(in srgb, var(--accent-2) 22%, transparent); }
.ask-card h2 { font: 600 22px/1.15 "Fraunces", Georgia, serif; }
.ask-card p { color: var(--muted); font-size: 15.5px; margin-top: 4px; max-width: 34ch; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 16px; font-weight: 700; font-size: 16px; border: 1.5px solid transparent; transition: transform .15s ease, filter .2s; }
.btn:active { transform: scale(.98); }
.btn-ghost { border-color: var(--accent); color: var(--accent); background: transparent; justify-self: start; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-block { width: 100%; min-height: 54px; font-size: 17px; }

/* ===== Platos ===== */
.dishes { padding: 0 16px; }
.group-title { margin-top: 26px; justify-content: flex-start; display: flex; align-items: center; gap: 14px; font: 600 27px/1.1 "Fraunces", Georgia, serif; letter-spacing: -.01em; margin-bottom: 14px; }
.group-title::after { content: ""; flex: 1; height: 1px; background: var(--line); order: 1; }
.group-title small { order: 2; font: 500 14px/1 "DM Sans", sans-serif; color: var(--muted); letter-spacing: .02em; }
.dish-grid { display: grid; gap: 18px; }
.dish {
  display: block; width: 100%; text-align: left; padding: 0; border: 1px solid var(--line); border-radius: 24px;
  background: var(--surface); overflow: hidden; box-shadow: var(--shadow); transition: transform .25s ease, box-shadow .25s ease;
}
.dish:active { transform: scale(.985); }
.dish-photo { position: relative; display: block; aspect-ratio: 4 / 3; overflow: hidden; }
.dish-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.dish-shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(10,6,3,.86) 0%, rgba(10,6,3,.45) 32%, rgba(10,6,3,0) 60%); }
.dish-over { position: absolute; left: 18px; right: 16px; bottom: 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.dish-title { display: grid; gap: 4px; }
.dish-cat { font-size: 12.5px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--on-photo-kicker); }
.dish-name { color: #fff; font: 600 25px/1.08 "Fraunces", Georgia, serif; letter-spacing: -.01em; text-wrap: balance; text-shadow: 0 1px 12px rgba(0,0,0,.35); }
.dish-price { flex: none; background: rgba(255, 250, 244, .95); color: #1E140C; font-weight: 700; font-size: 17px; padding: 6px 12px; border-radius: 99px; }
.dish-body { display: grid; gap: 8px; padding: 14px 18px 18px; }
.dish-desc { font-size: 16px; color: var(--ink-2); }
.dish-meta { font-size: 14.5px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 99px; }
.tag-badge { background: var(--surface-2); color: var(--ink-2); }
.tag-free { background: var(--free-bg); color: var(--free-ink); }
.tag-has { background: var(--has-bg); color: var(--has-ink); }

.foot { margin: 34px 16px 0; padding-top: 18px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); display: grid; gap: 6px; }
.error { padding: 24px 0; color: var(--has-ink); }

/* Entrada escalonada */
.dishes.in .dish { animation: rise .55s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* ===== Ficha (hoja) ===== */
.scrim { position: fixed; inset: 0; z-index: 40; background: var(--scrim); opacity: 0; transition: opacity .28s ease; }
.scrim.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 28px 28px 0 0; transform: translateY(100%);
  transition: transform .34s cubic-bezier(.2,.8,.2,1); box-shadow: 0 -10px 40px rgba(0,0,0,.25);
}
.sheet.open { transform: none; }
.sheet-photo { position: relative; height: 300px; }
.sheet-photo img { width: 100%; height: 100%; object-fit: cover; }
.sheet-shade { position: absolute; inset: 0; background: linear-gradient(to top, rgba(10,6,3,.9) 0%, rgba(10,6,3,.45) 40%, rgba(10,6,3,.1) 75%, rgba(10,6,3,.35) 100%); }
.sheet-close { position: absolute; top: 14px; right: 14px; background: rgba(15,10,6,.55); border-color: rgba(255,255,255,.35); color: #fff; backdrop-filter: blur(6px); }
.sheet-over { position: absolute; left: 20px; right: 20px; bottom: 18px; color: #fff; }
.sheet-cat { font-size: 13px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--on-photo-kicker); }
.sheet-over h2 { font: 600 34px/1.05 "Fraunces", Georgia, serif; letter-spacing: -.015em; margin-top: 4px; text-wrap: balance; }
.sheet-body { padding: 18px 20px 24px; display: grid; gap: 18px; }
.sheet-price { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sheet-price .price { font: 650 30px/1 "Fraunces", Georgia, serif; color: var(--accent); }
.sheet-price .portion { font-size: 15px; color: var(--muted); font-weight: 500; }
.sheet-desc { font-size: 17px; color: var(--ink-2); line-height: 1.5; }
.facts h3 { font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.facts p { font-size: 16px; color: var(--ink-2); }
.ing, .als { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.ing li { font-size: 15px; padding: 6px 12px; border-radius: 12px; background: var(--surface-2); color: var(--ink-2); }
.al { display: inline-flex; align-items: center; gap: 7px; font-size: 15px; font-weight: 600; padding: 6px 12px 6px 7px; border-radius: 99px; }
.al-ico { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.al-has { background: var(--has-bg); color: var(--has-ink); }
.al-has .al-ico { background: var(--has-ink); color: var(--has-bg); }
.al-free { background: var(--free-bg); color: var(--free-ink); }
.al-free .al-ico { background: var(--free-ink); color: var(--free-bg); }
.fine { font-size: 14px; color: var(--muted); margin-top: 10px; }
.sheet-body > .fine { margin-top: -6px; }
.sheet-cta { position: sticky; bottom: 0; margin: 0 -20px -24px; padding: 14px 20px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--surface) 70%, color-mix(in srgb, var(--surface) 0%, transparent)); }

/* ===== Chat ===== */
.chat {
  position: fixed; inset: 0; z-index: 50; background: var(--surface); display: flex; flex-direction: column;
  transform: translateY(100%); visibility: hidden; transition: transform .34s cubic-bezier(.2,.8,.2,1), visibility 0s linear .34s;
}
body.chat-open .chat { transform: none; visibility: visible; transition: transform .34s cubic-bezier(.2,.8,.2,1), visibility 0s; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.chat-head::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: repeating-linear-gradient(90deg, var(--accent) 0 22px, var(--band-3) 22px 30px, var(--accent-2) 30px 44px, var(--surface) 44px 48px); }
.chat-kicker { font-size: 12.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.chat-head h2 { font: 600 24px/1.15 "Fraunces", Georgia, serif; }
.chat-context { display: flex; align-items: center; gap: 12px; margin: 12px 16px 0; padding: 8px; border-radius: 16px; background: var(--surface-2); }
.chat-context img { width: 64px; height: 48px; border-radius: 10px; object-fit: cover; }
.ctx-label { font-size: 12.5px; color: var(--muted); font-weight: 600; letter-spacing: .04em; }
.ctx-name { font-weight: 700; font-size: 16px; }
.ctx-name span { color: var(--muted); font-weight: 500; }
.ctx-empty { font-size: 15px; color: var(--muted); padding: 6px 8px; }
.chat-rule { font-size: 14px; color: var(--muted); margin: 10px 18px 0; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.log-note { align-self: center; font-size: 12.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding: 2px 10px; border: 1px dashed var(--line); border-radius: 99px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 20px; font-size: 16px; line-height: 1.45; animation: msgIn .28s ease both; }
.msg-user { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; font-weight: 500; }
.msg-bot { align-self: flex-start; background: var(--surface-2); color: var(--ink); border-bottom-left-radius: 6px; }
.msg-private { box-shadow: inset 3px 0 0 var(--accent-2); }
.msg-who { font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 2px; }
.msg-src { font-size: 13px; color: var(--muted); margin-top: 6px; }
.typing p:not(.msg-who) { letter-spacing: .2em; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.chat-suggest { display: flex; gap: 8px; padding: 4px 16px 10px; overflow-x: auto; scrollbar-width: none; }
.chat-suggest::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 40px; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 14.5px; font-weight: 600; color: var(--ink-2); }
.chat-form { display: flex; gap: 10px; align-items: center; padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; height: 52px; border-radius: 26px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); padding: 0 18px; font: inherit; font-size: 16px; }
.chat-form input::placeholder { color: var(--muted); }
.send { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.send svg { width: 24px; height: 24px; }

/* ===== Tablet ===== */
@media (min-width: 640px) {
  .hero { height: 380px; margin: 20px 24px 0; }
  .hero h1 { font-size: 56px; }
  .cats-inner, .dishes { padding-left: 24px; padding-right: 24px; }
  .ask-card { margin-left: 24px; margin-right: 24px; grid-template-columns: 1fr auto; align-items: center; }
  .dish-grid { grid-template-columns: 1fr 1fr; }
  .foot { margin-left: 24px; margin-right: 24px; }
}

/* ===== Escritorio: chat como columna integrada ===== */
@media (min-width: 1024px) {
  .topbar { padding: 0 32px; }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 28px; padding: 0 32px; }
  .hero, .cats-inner, .dishes, .ask-card, .foot { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
  .hero { margin-top: 24px; height: 340px; }
  .hero h1 { font-size: 64px; }
  .hero-copy { left: 36px; bottom: 32px; }
  .ask-card { display: none; }
  .dish:hover .dish-photo img { transform: scale(1.04); }
  .chat {
    position: sticky; top: 88px; inset: auto; height: calc(100vh - 112px); margin-top: 24px; transform: none; visibility: visible;
    border: 1px solid var(--line); border-radius: 26px; overflow: hidden; box-shadow: var(--shadow); z-index: 1;
  }
  .chat-head { position: relative; padding-top: 18px; }
  .chat-close { display: none; }
  .sheet {
    left: 50%; top: 50%; bottom: auto; right: auto; width: min(960px, calc(100vw - 64px)); max-height: min(720px, calc(100vh - 64px));
    border-radius: 28px; display: grid; grid-template-columns: 1.05fr 1fr; overflow: hidden;
    transform: translate(-50%, -48%) scale(.97); opacity: 0; transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .25s ease;
  }
  .sheet.open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet-photo { height: auto; min-height: 100%; }
  .sheet-body { overflow-y: auto; padding: 28px 30px 0; align-content: start; gap: 16px; }
  .sheet-cta { margin: 0 -30px; padding: 14px 30px 24px; }
}
@media (min-width: 1280px) { .dish-grid { grid-template-columns: 1fr 1fr 1fr; } .dish-name { font-size: 22px; } }

/* ===== Movimiento reducido / capturas ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
.static *, .static *::before, .static *::after { animation: none !important; transition: none !important; }
