/* ===========================================================================
   Recetas · Espresso Americano — hoja de estilos
   Paleta cálida café + crema, acento rojo de marca. Mobile-first.
   ========================================================================= */

:root {
  /* superficies */
  --bg:          #fbf7f0;
  --bg-grad:     #f5ecdd;
  --surface:     #ffffff;
  --surface-2:   #f6efe2;
  --surface-3:   #efe4d1;

  /* tinta */
  --ink:         #2a1d14;
  --ink-soft:    #6e5b48;
  --ink-faint:   #9b8a76;

  /* marca */
  --accent:      #be1622;
  --accent-deep: #960f1a;
  --accent-soft: #fbe7e6;
  --on-accent:   #ffffff;

  /* temperatura */
  --hot:         #c2611a;
  --hot-soft:    #fbe9d7;
  --cold:        #11808d;
  --cold-soft:   #d7eef0;

  /* líneas y sombras */
  --border:      #e9dcc6;
  --border-soft: #f0e7d6;
  --ring:        #be1622;

  --shadow-sm:   0 1px 2px rgba(58, 38, 22, .06), 0 2px 6px rgba(58, 38, 22, .05);
  --shadow-md:   0 4px 10px rgba(58, 38, 22, .08), 0 12px 28px rgba(58, 38, 22, .10);
  --shadow-lg:   0 10px 24px rgba(40, 25, 14, .14), 0 30px 60px rgba(40, 25, 14, .20);

  /* radios */
  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 28px;

  --maxw: 1180px;
  --ease: cubic-bezier(.22, .61, .36, 1);

  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

/* el atributo [hidden] debe ganar siempre, aunque la clase fije display */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 480px at 88% -8%, #fff8ec 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-grad) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
}

::selection { background: var(--accent-soft); color: var(--accent-deep); }

/* enlaces de teclado --------------------------------------------------------*/
.skip-link {
  position: absolute;
  left: 12px; top: -60px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-weight: 600;
  z-index: 200;
  transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; }

:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ===========================================================================
   Barra superior
   ========================================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(251, 247, 240, .86);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
  padding-top: env(safe-area-inset-top);
}

.topbar__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* marca */
.brand { display: flex; align-items: center; gap: 11px; }

.brand__mark {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  color: var(--on-accent);
  background: linear-gradient(160deg, var(--accent) 0%, var(--accent-deep) 100%);
  border-radius: 13px;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.18);
}

.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__name {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}
.brand__title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.32rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.01em;
}

/* búsqueda */
.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search__icon {
  position: absolute;
  left: 16px;
  color: var(--ink-faint);
  pointer-events: none;
}
#search {
  width: 100%;
  font: inherit;
  font-size: 1.02rem;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 14px 46px 14px 46px;
  box-shadow: var(--shadow-sm);
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
#search::placeholder { color: var(--ink-faint); }
#search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
#search::-webkit-search-decoration,
#search::-webkit-search-cancel-button { -webkit-appearance: none; }

.search__clear {
  position: absolute;
  right: 8px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: none;
  background: var(--surface-2);
  color: var(--ink-soft);
  border-radius: 50%;
  cursor: pointer;
  transition: background .15s var(--ease), transform .12s var(--ease);
}
.search__clear:hover { background: var(--surface-3); }
.search__clear:active { transform: scale(.9); }

/* filtros / chips */
.filters {
  display: flex;
  gap: 8px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 2px 16px 12px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.filters::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 9px 15px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .16s var(--ease), color .16s var(--ease),
              border-color .16s var(--ease), transform .12s var(--ease);
}
.chip:hover { border-color: var(--ink-faint); }
.chip:active { transform: scale(.96); }
.chip__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: none;
}
.chip__dot--hot  { background: var(--hot); }
.chip__dot--cold { background: var(--cold); }
.chip__dot--all  {
  background: conic-gradient(from 180deg, var(--hot), var(--cold), var(--hot));
}
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}
.chip[aria-pressed="true"] .chip__dot { box-shadow: 0 0 0 2px rgba(255,255,255,.55); }

/* ===========================================================================
   Contenido
   ========================================================================= */
.main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 18px 16px 28px;
}

.resultline {
  font-size: .86rem;
  font-weight: 500;
  color: var(--ink-faint);
  margin-bottom: 14px;
  padding-left: 2px;
}
.resultline b { color: var(--ink-soft); font-weight: 700; }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 13px;
}

/* tarjeta de receta */
.card {
  position: relative;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 16px 16px 15px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform .16s var(--ease), box-shadow .2s var(--ease),
              border-color .2s var(--ease);
}
/* la animación de entrada escalonada solo corre en la carga inicial,
   para que filtrar y buscar sea instantáneo */
.grid--intro .card { animation: card-in .42s var(--ease) both; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}
.card:active { transform: translateY(-1px) scale(.99); }
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 2px solid transparent;
  transition: border-color .2s var(--ease);
  pointer-events: none;
}
.card:hover::after { border-color: var(--accent-soft); }

.card__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.card__name {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.16rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -.01em;
  color: var(--ink);
}
.card__name mark {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-radius: 4px;
  padding: 0 1px;
}

.tempbadge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 5px 9px;
  border-radius: 999px;
}
.tempbadge--hot  { background: var(--hot-soft);  color: #8a3f0c; }
.tempbadge--cold { background: var(--cold-soft); color: #0a5b65; }
.tempbadge svg { width: 13px; height: 13px; }

.card__cat {
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent);
}

.card__ings {
  font-size: .9rem;
  color: var(--ink-soft);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}
.metapill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}
.metapill svg { width: 13px; height: 13px; color: var(--ink-faint); }
.card__go {
  margin-left: auto;
  color: var(--accent);
  display: grid; place-items: center;
  transition: transform .16s var(--ease);
}
.card:hover .card__go { transform: translateX(3px); }

/* estado vacío */
.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--ink-faint);
}
.empty svg { color: var(--surface-3); margin-bottom: 6px; }
.empty__title {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.empty__hint { font-size: .95rem; margin-top: 2px; }

/* pie */
.footer {
  text-align: center;
  padding: 24px 16px calc(26px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.footer__links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.footer__links a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .88rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 8px 15px;
  transition: background .15s var(--ease), border-color .15s var(--ease),
              transform .12s var(--ease);
}
.footer__links a:hover { background: var(--accent-soft); border-color: var(--accent-soft); }
.footer__links a:active { transform: scale(.96); }
.footer__links svg { width: 15px; height: 15px; }
.footer__meta {
  display: flex;
  gap: 7px;
  justify-content: center;
  font-size: .8rem;
  color: var(--ink-faint);
}
.footer__dot { opacity: .6; }

/* ===========================================================================
   Hoja de detalle (modal / bottom-sheet)
   ========================================================================= */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet__scrim {
  position: absolute;
  inset: 0;
  background: rgba(28, 18, 10, .52);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: scrim-in .22s var(--ease) both;
}
@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }

.sheet__panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  max-height: 92dvh;
  background: var(--bg);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sheet-up .34s var(--ease) both;
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.sheet.closing .sheet__scrim { animation: scrim-in .2s var(--ease) reverse both; }
.sheet.closing .sheet__panel { animation: sheet-up .26s var(--ease) reverse both; }

.sheet__grip {
  width: 42px; height: 5px;
  background: var(--surface-3);
  border-radius: 999px;
  margin: 9px auto 2px;
  flex: none;
}
.sheet__close {
  position: absolute;
  top: 12px; right: 12px;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: none;
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  z-index: 3;
  transition: transform .12s var(--ease), background .15s var(--ease);
}
.sheet__close:hover { background: var(--surface-2); }
.sheet__close:active { transform: scale(.9); }

.sheet__body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 20px calc(28px + env(safe-area-inset-bottom));
}

/* encabezado del detalle */
.detail__head { padding: 8px 0 4px; }
.detail__tags { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.detail__name {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 1.74rem;
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -.015em;
  color: var(--ink);
}

/* selector de tamaño */
.sizes {
  display: flex;
  gap: 7px;
  margin: 16px 0 4px;
  background: var(--surface-2);
  padding: 5px;
  border-radius: 999px;
}
.size-btn {
  flex: 1;
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 9px 6px;
  cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease),
              box-shadow .16s var(--ease);
}
.size-btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* secciones */
.section { margin-top: 22px; }
.section__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 11px;
}
.section__title svg { width: 16px; height: 16px; }

/* lista de ingredientes */
.ings { display: flex; flex-direction: column; gap: 2px; }
.ing {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.ing:last-child { border-bottom: none; }
.ing__name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
}
.ing__measure {
  flex: none;
  font-size: .98rem;
  font-weight: 700;
  color: var(--accent-deep);
  font-variant-numeric: tabular-nums;
  text-align: right;
  background: var(--accent-soft);
  padding: 3px 11px;
  border-radius: 999px;
}
.ing__measure--none { background: none; color: var(--ink-faint); font-weight: 500; }

/* pasos de preparación */
.steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: step;
}
.step {
  display: flex;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 13px 14px;
}
.step__num {
  counter-increment: step;
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-size: .82rem;
  font-weight: 700;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: 50%;
}
.step__num::before { content: counter(step); }
.step__text { font-size: .98rem; color: var(--ink-soft); line-height: 1.5; }

.note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--hot-soft);
  color: #7c3a0b;
  border-radius: var(--r-md);
  padding: 13px 14px;
  font-size: .92rem;
  line-height: 1.45;
}
.note svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }

/* ===========================================================================
   Responsive
   ========================================================================= */
@media (min-width: 560px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 720px) {
  .topbar__inner {
    flex-direction: row;
    align-items: center;
    gap: 20px;
    padding: 14px 20px 12px;
  }
  .brand { flex: none; }
  .search { flex: 1; max-width: 460px; }
  .filters { padding-bottom: 14px; }
  .detail__name { font-size: 1.95rem; }
}
@media (min-width: 940px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
}
@media (min-width: 720px) {
  .sheet { align-items: center; padding: 24px; }
  .sheet__panel {
    border-radius: var(--r-xl);
    max-height: 88vh;
    max-height: 88dvh;
    animation: sheet-pop .3s var(--ease) both;
  }
  @keyframes sheet-pop {
    from { opacity: 0; transform: scale(.94) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
  }
  .sheet.closing .sheet__panel { animation: sheet-pop .22s var(--ease) reverse both; }
  .sheet__grip { display: none; }
  .sheet__body { padding-top: 18px; }
}

/* accesibilidad: movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
