/* ============================================================
   BLASÓN — navegación, responsive y utilidades transversales
   Sprint 1: desbloquear móvil + nav común + volver arriba
   Cargar después de blason-shared.css
   ============================================================ */

/* ─────────── 1. Topbar global ─────────── */
.bx-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: rgba(31, 26, 20, 0.96);
  color: var(--b-paper, #F2EADB);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(242, 234, 219, 0.08);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
}
.bx-topbar a { color: inherit; text-decoration: none; }
.bx-topbar .bx-tb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}
.bx-topbar .bx-tb-brand svg { width: 22px; height: 22px; flex-shrink: 0; }
.bx-topbar .bx-tb-brand .bx-tb-sep { opacity: 0.4; margin: 0 4px; }
.bx-topbar .bx-tb-brand .bx-tb-doc { color: var(--b-paper, #F2EADB); }
.bx-topbar .bx-tb-jump {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid rgba(242, 234, 219, 0.18);
  border-radius: 999px;
  background: transparent;
  color: var(--b-paper, #F2EADB);
  font: inherit;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}
.bx-topbar .bx-tb-jump:hover {
  background: rgba(242, 234, 219, 0.06);
  border-color: rgba(242, 234, 219, 0.32);
}
.bx-topbar .bx-tb-jump .bx-tb-arrow { font-size: 9px; opacity: 0.7; }
.bx-topbar .bx-tb-back {
  font-size: 11px;
  letter-spacing: 0.08em;
  opacity: 0.85;
  transition: opacity 160ms ease;
}
.bx-topbar .bx-tb-back:hover { opacity: 1; }

/* push body content below topbar */
body.bx-has-topbar { padding-top: 44px !important; }

/* hide brand text on very narrow screens */
@media (max-width: 460px) {
  .bx-topbar .bx-tb-brand .bx-tb-sep,
  .bx-topbar .bx-tb-brand .bx-tb-doc { display: none; }
  .bx-topbar .bx-tb-jump { padding: 6px 10px; font-size: 10px; }
}

/* ─────────── 2. Overlay de navegación ─────────── */
.bx-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 26, 20, 0.88);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  z-index: 10000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 24px 40px;
  overflow-y: auto;
  animation: bxFadeIn 220ms ease;
}
.bx-overlay.bx-open { display: flex; }
@keyframes bxFadeIn { from { opacity: 0; } to { opacity: 1; } }
.bx-overlay-panel {
  background: var(--b-paper, #F2EADB);
  color: var(--b-ink, #1F1A14);
  border-radius: 12px;
  padding: 36px 36px 32px;
  max-width: 720px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
  position: relative;
}
.bx-overlay-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--b-line, #D8C9AE);
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--b-ink, #1F1A14);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 160ms ease;
}
.bx-overlay-close:hover { background: var(--b-paper-2, #EADFC8); }
.bx-overlay h2 {
  font-family: var(--serif, 'Fraunces', serif);
  font-weight: 500;
  font-size: 26px;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.bx-overlay .bx-overlay-sub {
  font-family: var(--mono, monospace);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--b-ink-2, #5C4F3F);
  margin: 0 0 24px;
}
.bx-doc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (max-width: 560px) {
  .bx-doc-grid { grid-template-columns: 1fr; }
  .bx-overlay-panel { padding: 28px 20px 24px; }
}
.bx-doc-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--b-line, #D8C9AE);
  border-radius: 8px;
  background: var(--b-card, #FBF6EC);
  text-decoration: none;
  color: inherit;
  transition: border-color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}
.bx-doc-item:hover {
  border-color: var(--b-clay, #9B3A26);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(31,26,20,0.08);
}
.bx-doc-item.bx-current {
  border-color: var(--b-clay, #9B3A26);
  background: var(--b-paper-2, #EADFC8);
}
.bx-doc-item .bx-doc-num {
  font-family: var(--mono, monospace);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--b-clay, #9B3A26);
  text-transform: uppercase;
}
.bx-doc-item .bx-doc-title {
  font-family: var(--serif, serif);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.bx-doc-item .bx-doc-desc {
  font-size: 13px;
  color: var(--b-ink-2, #5C4F3F);
  line-height: 1.4;
}

/* ─────────── 3. Botón "volver arriba" ─────────── */
.bx-totop {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--b-ink, #1F1A14);
  color: var(--b-paper, #F2EADB);
  border: 0;
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease, background 160ms ease, bottom 220ms ease;
  box-shadow: 0 6px 20px rgba(31,26,20,0.25);
}
.bx-totop.bx-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.bx-totop:hover { background: var(--b-clay, #9B3A26); }
@media (max-width: 480px) {
  .bx-totop { bottom: 16px; right: 16px; width: 40px; height: 40px; }
}

/* ─────────── 5. Responsive shim — patrones comunes ─────────── */

/* 5.0 — Guardar contra scroll horizontal accidental */
html, body { overflow-x: hidden; max-width: 100vw; }

/* 5.1 — Páginas A4 (menu, alergias, manual) en pantallas pequeñas */
@media screen and (max-width: 820px) {
  body > .page,
  .page-stack > .page {
    width: 100% !important;
    min-height: auto !important;
    padding: 24px 18px !important;
    box-shadow: none !important;
    margin: 0 0 16px !important;
    border-radius: 0 !important;
  }
  .page-stack { padding: 0 !important; }
}

/* 5.2 — Wraps con padding generoso → reducir en móvil */
@media (max-width: 640px) {
  .wrap,
  main.wrap,
  body > .wrap {
    padding-left: 18px !important;
    padding-right: 18px !important;
    padding-top: 32px !important;
  }
  section { padding-left: 18px !important; padding-right: 18px !important; }
}

/* 5.3 — Grids comunes que rompen sin shim — colapsar a 1 columna en móvil */
@media (max-width: 720px) {
  .doc-meta,
  .pal-grid,
  .typ-grid,
  .cards,
  .dl-grid,
  .templates,
  .stn-grid,
  .state-grid,
  .floor-grid,
  .two,
  .three,
  .four,
  .values,
  .ck-grid,
  .org,
  .tk-grid,
  .alg-grid,
  .alg-contact,
  .logo-lab,
  .atmos-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .floor-grid .tables-row { grid-template-columns: repeat(2, 1fr) !important; }
}

/* 5.4 — Imágenes y SVGs no overflow */
@media (max-width: 720px) {
  img, svg, iframe, video { max-width: 100%; height: auto; }
}

/* 5.5 — Tipografías hero más razonables en móvil */
@media (max-width: 560px) {
  h1.doc-title,
  .hero h1,
  .doc-title { font-size: clamp(28px, 8vw, 40px) !important; line-height: 1.05 !important; }
  .lede { font-size: 15.5px !important; }
}

/* 5.5b — Specimens tipográficos en Brand System: bajar tamaños y wrap */
@media (max-width: 640px) {
  .type-row { grid-template-columns: 1fr !important; gap: 8px !important; }
  .type-sample.h1 { font-size: clamp(28px, 9vw, 40px) !important; line-height: 1.05 !important; }
  .type-sample.h2 { font-size: clamp(22px, 6vw, 28px) !important; line-height: 1.1 !important; }
  .type-sample.h3 { font-size: 19px !important; }
  .type-sample.body { font-size: 15px !important; }
  .type-sample.mono { font-size: 11.5px !important; word-break: break-word; }
  .alt-dm { font-size: 26px !important; }
  .alt-plex { font-size: 14.5px !important; }
}

/* 5.5c — Escala tipográfica (grid inline 5 cols en Brand System) */
@media (max-width: 720px) {
  /* Selector de atributo para el inline style de la escala */
  [style*="repeat(5, 1fr)"],
  [style*="repeat(5,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 380px) {
  [style*="repeat(5, 1fr)"],
  [style*="repeat(5,1fr)"] {
    grid-template-columns: 1fr !important;
  }
}

/* 5.6 — POS mockups: scroll horizontal controlado en móvil */
@media (max-width: 720px) {
  .floor-plan,
  .kds,
  .order-mock,
  .mock {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
}

/* 5.7 — Tabla de tokens en móvil */
@media (max-width: 720px) {
  .tk-row {
    grid-template-columns: 40px 1fr !important;
    grid-template-areas: "swatch name" "swatch value" "swatch hex" !important;
    gap: 4px 12px !important;
  }
}

/* 5.8 — Paneles del Brand System: padding más amable en móvil */
@media (max-width: 560px) {
  .panel { padding: 18px !important; }
  .panel h3 { font-size: 22px !important; }
  .sec-title, h2.sec-title { font-size: clamp(24px, 6.5vw, 36px) !important; }
}

/* ─────────── 6. Print: ocultar nav y back-to-top ─────────── */
@media print {
  .bx-topbar,
  .bx-totop,
  .bx-overlay {
    display: none !important;
  }
  body.bx-has-topbar { padding-top: 0 !important; }
}

/* ─────────── 7. Reduced motion ─────────── */
@media (prefers-reduced-motion: reduce) {
  .bx-topbar,
  .bx-totop,
  .bx-doc-item,
  .bx-overlay-close,
  .bx-overlay {
    animation: none !important;
    transition: none !important;
  }
}

/* ─────────── 8. Botón de información (tooltip) ─────────── */
.bx-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--b-line, #D8C9AE);
  background: transparent;
  color: var(--b-stone, #6E6457);
  font-family: var(--serif, 'Fraunces', serif);
  font-size: 11px;
  font-style: italic;
  font-weight: 500;
  line-height: 1;
  cursor: help;
  padding: 0;
  margin-left: 4px;
  vertical-align: 1px;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
  position: relative;
  flex-shrink: 0;
}
.bx-info:hover,
.bx-info:focus-visible,
.bx-info.bx-info-open {
  background: var(--b-clay, #9B3A26);
  color: var(--b-paper, #F2EADB);
  border-color: var(--b-clay, #9B3A26);
  outline: none;
}
.bx-info:focus-visible {
  outline: 2px solid var(--b-clay, #9B3A26);
  outline-offset: 2px;
}
/* On dark surfaces */
.bx-on-dark .bx-info,
[data-bx-dark] .bx-info {
  border-color: rgba(242, 234, 219, 0.25);
  color: rgba(242, 234, 219, 0.65);
}
.bx-on-dark .bx-info:hover,
[data-bx-dark] .bx-info:hover {
  background: var(--b-paper, #F2EADB);
  color: var(--b-ink, #1F1A14);
  border-color: var(--b-paper, #F2EADB);
}

/* Popover contenedor */
.bx-info-pop {
  position: absolute;
  z-index: 10001;
  max-width: 280px;
  min-width: 220px;
  background: var(--b-ink, #1F1A14);
  color: var(--b-paper, #F2EADB);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--sans, 'Inter Tight', sans-serif);
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 12px 32px rgba(31, 26, 20, 0.32);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
  font-style: normal;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}
.bx-info-pop.bx-info-pop-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.bx-info-pop .bx-info-term {
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--b-ochre, #B8862B);
  margin-bottom: 4px;
  display: block;
}
.bx-info-pop .bx-info-arrow {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--b-ink, #1F1A14);
  transform: rotate(45deg);
}
.bx-info-pop[data-bx-pos="bottom"] .bx-info-arrow {
  top: -4px;
  left: var(--bx-arrow-x, 14px);
}
.bx-info-pop[data-bx-pos="top"] .bx-info-arrow {
  bottom: -4px;
  left: var(--bx-arrow-x, 14px);
}

@media (max-width: 480px) {
  .bx-info-pop {
    max-width: calc(100vw - 24px);
    min-width: 0;
    font-size: 12.5px;
  }
}

@media print {
  .bx-info,
  .bx-info-pop { display: none !important; }
}

/* ─────────── 9. Toggle bilingüe ES/EN ─────────── */
.bx-lang {
  display: none;
  align-items: center;
  gap: 0;
  padding: 0;
  margin-right: 12px;
  border: 1px solid rgba(242, 234, 219, 0.18);
  border-radius: 999px;
  overflow: hidden;
  background: transparent;
  font-family: var(--mono, 'JetBrains Mono', monospace);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
body.bx-bilingual .bx-lang { display: inline-flex; }
.bx-lang button {
  appearance: none;
  background: transparent;
  border: 0;
  color: rgba(242, 234, 219, 0.55);
  padding: 6px 12px;
  cursor: pointer;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  transition: background 160ms ease, color 160ms ease;
}
.bx-lang button:hover { color: var(--b-paper, #F2EADB); }
.bx-lang button.bx-lang-active {
  background: var(--b-paper, #F2EADB);
  color: var(--b-ink, #1F1A14);
}
@media (max-width: 460px) {
  .bx-lang { margin-right: 8px; }
  .bx-lang button { padding: 5px 9px; font-size: 9.5px; }
}
@media print {
  .bx-lang { display: none !important; }
}
