/* =============================================================================================
   main.css — Carta pública "La Princesa" (Etapa 4)
   Tokens y dirección visual: ver DESIGN.md en la raíz del proyecto (fuente de verdad).
   ============================================================================================= */

:root {
  color-scheme: dark;

  /* Paleta (DESIGN.md) */
  --ink: #0C0A06;
  --paper: #F0E8D8;
  --gold: #C8962A;
  --gold-dim: #5A3E0E;
  --card-bg: #181008;
  --border: #2A1A06;
  --shadow: rgba(0, 0, 0, 0.75);

  /* Acentos complementarios por sección (fallback; cada sección puede traer los suyos) */
  --accent-clasico: var(--gold);
  --accent-tropical: #2F6B4F;
  --accent-moderno: #7A4A6B;

  /* Tipografía */
  --font-display: "Fraunces", Georgia, serif;
  --font-ui: "Public Sans", system-ui, sans-serif;
  --font-badge: "Staatliches", sans-serif;

  /* Layout */
  --max-w: 430px;
  --radius-card: 18px;
  --radius-pill: 50px;
  --tap-min: 44px;

  /* Signature: greca escalonada dorada (DESIGN.md) — SVG inline, sin librerías. */
  --greca-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='8' viewBox='0 0 16 8'%3E%3Cpath d='M0 8 L4 8 L4 4 L8 4 L8 0 L12 0 L12 4 L16 4 L16 8' fill='none' stroke='%23C8962A' stroke-width='1.5' opacity='0.4'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------------------------------------
   Reset básico
   --------------------------------------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; overflow-anchor: none; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button, a, .card, .section-tab { touch-action: manipulation; }

h1, h2, h3, h4, h5 { font-family: var(--font-display); margin: 0; text-wrap: balance; }
p { margin: 0; }
img, video { max-width: 100%; display: block; }
button { font: inherit; }
a { color: inherit; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 8px;
  background: var(--gold);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  z-index: 1000;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 8px; }

/* Focus visible dorado, en todo el sitio (accesibilidad, brief 11) */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------------------------------------
   Contenedor general — capado a --max-w incluso en desktop (carta "de bolsillo", no landing full-width)
   --------------------------------------------------------------------------------------------- */

.page-shell {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  background: var(--ink);
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  body {
    background: linear-gradient(180deg, #120e08 0%, var(--ink) 240px);
  }
  .page-shell {
    box-shadow: 0 40px 90px var(--shadow);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* ---------------------------------------------------------------------------------------------
   Header / navegación por secciones (T7.1, T7.5)
   --------------------------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(12, 10, 6, 0.94);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  padding: 14px 16px 0;
}

.brand {
  display: block;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 20px;
  color: var(--paper);
  margin-bottom: 10px;
}

.section-nav__scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.section-nav__scroll::-webkit-scrollbar { display: none; }

.section-tabs {
  display: flex;
  gap: 4px;
  min-width: max-content;
}

.section-tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--gold-dim);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 10px 12px;
  min-height: var(--tap-min);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.section-tab:hover { color: var(--paper); }
.section-tab[aria-selected="true"] {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ---------------------------------------------------------------------------------------------
   Estado offline (T7.7)
   --------------------------------------------------------------------------------------------- */

.offline-banner {
  background: var(--gold-dim);
  color: var(--paper);
  font-size: 13px;
  text-align: center;
  padding: 8px 16px;
}

/* ---------------------------------------------------------------------------------------------
   Main / secciones / grid (T7.1, T7.3)
   --------------------------------------------------------------------------------------------- */

#app { flex: 1; }

.menu-section {
  padding: 28px 16px 8px;
  background: var(--section-bg, transparent);
  color: var(--section-text, var(--paper));
}

.menu-section__header { margin-bottom: 14px; }

.menu-section__title {
  font-size: 22px;
  font-weight: 600;
  color: var(--paper);
}

.menu-section__desc {
  margin-top: 4px;
  font-size: 13px;
  color: #b8ac96;
}

/* Signature: separador en greca escalonada dorada entre secciones */
.signature-divider {
  height: 8px;
  margin-top: 14px;
  background-image: var(--greca-svg);
  background-repeat: repeat-x;
  background-position: left center;
  opacity: 0.9;
}

.cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: minmax(150px, auto);
  gap: 14px;
  padding-bottom: 20px;
}

@media (min-width: 768px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-flow: dense;
    gap: 18px;
  }
  .card--w-completo { grid-column: span 2; }
  .card--w-medio { grid-column: span 1; }
  .card[data-fixed="true"] {
    grid-column-start: var(--fixed-col);
    grid-row-start: var(--fixed-row);
  }
  /* `grid-column: span 2` deja `grid-column-end: auto`; al fijar `grid-column-start` (más
     específico) la tarjeta perdía el span y se dibujaba de 1x1. Se reponen los "end" explícitos
     para que una tarjeta fijada conserve su ancho/alto (ej. el hero completo+doble fijado en la
     posición 0 del snapshot de ejemplo). */
  .card[data-fixed="true"].card--w-completo { grid-column-end: span 2; }
  .card[data-fixed="true"].card--w-medio { grid-column-end: span 1; }
  .card[data-fixed="true"].card--h-doble { grid-row-end: span 2; }
  .card[data-fixed="true"].card--h-estandar { grid-row-end: span 1; }
}

.card--h-doble { grid-row: span 2; }

/* ---------------------------------------------------------------------------------------------
   Skeleton loaders (T7.7)
   --------------------------------------------------------------------------------------------- */

.skeleton-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 20px 16px;
}

.skeleton-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 10px;
}

.skeleton-block {
  background: linear-gradient(90deg, var(--border) 0%, #3a2a10 50%, var(--border) 100%);
  border-radius: 8px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-media { height: 110px; margin-bottom: 10px; }
.skeleton-line { height: 12px; margin-top: 8px; }
.skeleton-line--title { width: 70%; }
.skeleton-line--price { width: 40%; }

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ---------------------------------------------------------------------------------------------
   Estado de error (T7.7)
   --------------------------------------------------------------------------------------------- */

.error-state {
  text-align: center;
  padding: 60px 24px;
}
.error-state__icon { font-size: 40px; color: var(--gold); margin-bottom: 12px; }
.error-state h2 { font-size: 20px; margin-bottom: 10px; color: var(--paper); }
.error-state p { color: #b8ac96; margin-bottom: 20px; font-size: 14px; }

.btn-pill {
  appearance: none;
  border: none;
  border-radius: var(--radius-pill);
  background: var(--gold);
  color: var(--ink);
  font-weight: 600;
  padding: 12px 28px;
  min-height: var(--tap-min);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.btn-pill:hover { filter: brightness(1.08); }
.btn-pill:active { transform: scale(0.98); }

/* ---------------------------------------------------------------------------------------------
   Tarjetas — base compartida
   --------------------------------------------------------------------------------------------- */

.card {
  position: relative;
  border-radius: var(--radius-card);
  background: var(--card-bg);
  border: 1px solid var(--border);
  overflow: hidden;
  opacity: 1;
  transform: none;
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}

/* Scroll-reveal (T7.11): estado inicial oculto, revela una sola vez al entrar en viewport */
@media (prefers-reduced-motion: no-preference) {
  .card:not(.is-visible) {
    opacity: 0;
    transform: translateY(12px);
  }
}
.card.is-visible { opacity: 1; transform: none; }

/* Rotación leve "hecha a mano" en tarjetas de ancho medio (heredado del sistema del ciclo anterior) */
.card--w-medio:nth-of-type(3n)  { --tilt: -1.5deg; }
.card--w-medio:nth-of-type(3n+1) { --tilt: 1deg; }
.card--w-medio:nth-of-type(3n+2) { --tilt: -2deg; }

/* Signature: borde superior en greca dorada (recommended_card / hero_video, DESIGN.md) */
.card--signature-top::before,
.card--recommended::before {
  content: "";
  display: block;
  height: 6px;
  background-image: var(--greca-svg);
  background-repeat: repeat-x;
  background-position: left center;
}

.card--recommended {
  border-color: var(--gold);
  animation: recommended-pulse 2.4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .card--recommended { animation: none; box-shadow: 0 0 0 1px var(--gold); }
}
@keyframes recommended-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(200, 150, 42, 0.55); }
  50% { box-shadow: 0 0 0 3px rgba(200, 150, 42, 0.85); }
}

.card-media { position: relative; background: var(--border); }
.card-media img,
.card-media video { width: 100%; height: 100%; object-fit: cover; }
.card-media__placeholder { width: 100%; height: 140px; background: var(--border); }

/* ---------------------------------------------------------------------------------------------
   Tarjeta flip (plato) — T7.4
   --------------------------------------------------------------------------------------------- */

.card--flip { padding: 0; perspective: 1200px; min-height: 260px; }
.card--flip.card--h-doble { min-height: 420px; }

.flip-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: inherit;
  flex: 1;
  transform-style: preserve-3d;
  transition: transform 0.3s cubic-bezier(0.4, 0.1, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) {
  .flip-card { transition: none; }
}
.flip-card[data-flip-state="back"] { transform: rotateY(180deg); }
@media (prefers-reduced-motion: reduce) {
  .flip-card[data-flip-state="back"] { transform: none; }
}

.flip-front, .flip-back {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flip-front { background: var(--card-bg); }
.flip-front .card-media { flex: 1; min-height: 120px; }

.flip-back {
  transform: rotateY(180deg);
  background: var(--card-bg);
  padding: 14px;
  overflow: hidden;
}
@media (prefers-reduced-motion: reduce) {
  .flip-back {
    transform: none;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
  }
  .flip-card[data-flip-state="back"] .flip-back {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
  }
  .flip-card[data-flip-state="back"] .flip-front {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
  }
}

.flip-back__scroll { flex: 1; overflow-y: auto; padding-right: 2px; }
.flip-back__title { font-size: 16px; font-style: italic; color: var(--gold); margin-bottom: 8px; }
.flip-back__description { font-size: 13.5px; line-height: 1.55; color: var(--paper); }
.flip-back__block { margin-top: 10px; }
.flip-back__block h5 {
  font-family: var(--font-badge);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 3px;
}
.flip-back__block p { font-size: 13px; color: #d8cdb8; }
.flip-back__badge {
  margin-top: 10px;
  display: inline-block;
  font-size: 12px;
  background: rgba(200, 150, 42, 0.15);
  color: var(--gold);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.flip-header {
  padding: 10px 12px 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.card-name {
  font-size: 15px;
  font-style: italic;
  font-weight: 500;
  color: var(--paper);
  line-height: 1.25;
}
.card-price {
  font-family: var(--font-badge);
  font-size: 15px;
  color: var(--gold);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.flip-attributes {
  display: flex;
  gap: 6px;
  padding: 6px 12px 0;
}

.attribute-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  color: var(--attr-color, var(--gold));
}

.flip-toggle {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--gold);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  padding: 8px 12px 12px;
  min-height: var(--tap-min);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.attribute-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.attribute-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
}
.attribute-row__name { color: var(--paper); font-weight: 600; }
.attribute-row__hint { color: #a89a80; font-size: 11.5px; }

/* ---------------------------------------------------------------------------------------------
   Tarjetas decorativas — hero / editorial / promocional / imagen / video (T7.3)
   --------------------------------------------------------------------------------------------- */

.card--decorativo { min-height: 160px; }
.card--hero, .card--editorial { min-height: 220px; }
.card--hero.card--h-doble, .card--editorial.card--h-doble, .card--promocional.card--h-doble { min-height: 360px; }

.card-media--fill { position: absolute; inset: 0; }
.card-media--fill img, .card-media--fill video { width: 100%; height: 100%; object-fit: cover; }

.card--imagen { min-height: 160px; }
.card--imagen.card--h-doble { min-height: 320px; }

.card-overlay {
  position: relative;
  margin-top: auto;
  padding: 16px;
  background: linear-gradient(180deg, rgba(12,10,6,0) 0%, rgba(12,10,6,0.85) 65%, rgba(12,10,6,0.95) 100%);
  color: var(--paper);
}
.card--hero .card-overlay__title {
  font-size: 22px;
  font-weight: 600;
  color: var(--paper);
}
.card--editorial .card-overlay__title,
.card--promocional .card-overlay__title {
  font-size: 17px;
  font-weight: 600;
  color: var(--gold);
}
.card-overlay__text { font-size: 13px; margin-top: 6px; color: #e2d8c4; line-height: 1.5; }

.card--promocional .card-overlay {
  background: linear-gradient(180deg, rgba(12,10,6,0.1) 0%, rgba(12,10,6,0.9) 70%);
}

.card--video { min-height: 220px; }
.card--video.card--h-doble { min-height: 360px; }
.video-play-btn {
  appearance: none;
  border: 2px solid var(--gold);
  background: rgba(12, 10, 6, 0.55);
  color: var(--gold);
  width: 48px;
  height: 48px;
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  margin-bottom: 8px;
}
.card-overlay__title { font-size: 13px; color: var(--paper); }

/* ---------------------------------------------------------------------------------------------
   Botón flotante de experiencias + modal (T7.6)
   --------------------------------------------------------------------------------------------- */

.floating-cta {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--gold);
  color: var(--ink);
  font-size: 22px;
  box-shadow: 0 8px 24px var(--shadow);
  cursor: pointer;
  z-index: 80;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.floating-cta:hover { filter: brightness(1.1); }
.floating-cta:active { transform: scale(0.96); }

@media (min-width: 768px) {
  .floating-cta { right: max(32px, env(safe-area-inset-right)); bottom: calc(32px + env(safe-area-inset-bottom)); }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 10, 6, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
/* [hidden] pierde contra .modal-overlay{display:flex} por orden de cascada (CSS de autor le
   gana al UA stylesheet aunque la especificidad "empate"); se refuerza explícitamente. */
.modal-overlay[hidden] { display: none; }

.modal {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--gold-dim);
  border-radius: 20px;
  padding: 24px 20px;
  position: relative;
  box-shadow: 0 20px 60px var(--shadow);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: var(--tap-min);
  height: var(--tap-min);
  border: none;
  background: transparent;
  color: var(--paper);
  font-size: 16px;
  cursor: pointer;
}

.modal h2 {
  font-size: 20px;
  color: var(--paper);
  margin-bottom: 6px;
  padding-right: 30px;
}
.modal-subtitle { font-size: 13px; color: #b8ac96; margin-bottom: 16px; }

.modal-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-option {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  background: rgba(200, 150, 42, 0.06);
  color: var(--paper);
  border-radius: 14px;
  padding: 12px 14px;
  min-height: var(--tap-min);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.modal-option:hover { border-color: var(--gold); background: rgba(200, 150, 42, 0.12); }
.modal-option__icon { font-size: 18px; }

.modal-placeholder {
  margin-top: 14px;
  font-size: 13px;
  color: var(--gold);
  text-align: center;
}

@media (min-width: 768px) {
  .modal-options { flex-direction: row; flex-wrap: wrap; }
  .modal-option { flex: 1 1 calc(50% - 5px); }
}

/* ---------------------------------------------------------------------------------------------
   Footer (T7.8)
   --------------------------------------------------------------------------------------------- */

.site-footer {
  padding: 24px 16px 32px;
  text-align: center;
  border-top: 1px solid var(--border);
}

.footer-reviews {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap-min);
  padding: 6px 4px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.footer-reviews:hover { text-decoration: underline; }

.footer-meta { margin-top: 8px; font-size: 11.5px; color: #8a7f68; }

/* ---------------------------------------------------------------------------------------------
   Responsive fino (T7.12): 375 ya cubierto por mobile-first; refuerzos puntuales 1024
   --------------------------------------------------------------------------------------------- */

@media (min-width: 1024px) {
  .brand { font-size: 22px; }
}
