/* ============================================================================
 * NUEVARIFA.COM — SHELL COMPARTIDO DEL ÁREA DE ORGANIZADOR
 * Navegación superior unificada (.org-nav), migas de pan (.org-breadcrumb),
 * visibilidad condicionada por sesión ([data-auth-only]) y tarjeta de bienvenida
 * (.org-welcome-card). Apoyado en los tokens de home.css y WCAG 2.1 AA.
 * ========================================================================== */

/* Visibilidad condicionada por sesión en páginas mixtas (/comprar, /crear) */
html body:not([data-auth="signed-in"]) [data-auth-only] {
  display: none;
}

body[data-auth="signed-in"] .org-nav[data-auth-only],
body[data-auth="signed-in"] .org-breadcrumb[data-auth-only] {
  animation: org-shell-in 160ms var(--ease-out, ease-out);
}

@keyframes org-shell-in {
  from { opacity: 0; transform: translateY(-2px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Cabecera unificada del organizador ---------- */
.site-header > :is(.wrap, .header-inner):has(> .org-nav:not([data-auth-only])),
body[data-auth="signed-in"] .site-header > :is(.wrap, .header-inner):has(> .org-nav) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  height: auto;
  min-height: 64px;
  padding-block: 8px 6px;
  row-gap: 6px;
  column-gap: 12px;
}

.site-header .brand {
  flex: 0 0 auto;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.site-header .header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

/* En móvil y tablet (< 920px), la navegación principal pasa a segunda fila limpia sin comprimir */
.site-header .org-nav {
  order: 3;
  flex: 1 0 100%;
  width: 100%;
  min-width: 0;
  border-top: 1px solid var(--line, #e8e2d8);
  padding-top: 4px;
}

.org-nav ul,
.org-nav ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.org-nav li {
  flex: 0 0 auto;
  min-width: 0;
}

.org-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-sm, 8px);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-muted, #585043);
  text-decoration: none;
  white-space: nowrap;
  transition: color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .org-nav a:hover {
    color: var(--text, #12100d);
    background: var(--n-100, #f4efe8);
  }
}

.org-nav a:focus-visible {
  outline: 2px solid var(--ring, #0b6e4f);
  outline-offset: 2px;
}

.org-nav a[aria-current="page"] {
  color: var(--accent-ink, #065f46);
  background: var(--accent-soft, #ecfdf5);
  font-weight: 800;
  box-shadow: inset 0 -2.5px 0 var(--accent, #0b6e4f);
}

@media (max-width: 480px) {
  .site-header > :is(.wrap, .header-inner):has(> .org-nav:not([data-auth-only])) .brand-logo,
  body[data-auth="signed-in"] .site-header > :is(.wrap, .header-inner):has(> .org-nav) .brand-logo {
    width: clamp(114px, 32vw, 152px);
    height: auto;
  }

  .site-header .header-actions {
    gap: 6px;
  }

  .site-header .header-actions > .btn {
    min-height: 40px;
    padding: 0 11px;
    font-size: 0.84rem;
  }

  .org-nav a {
    padding: 8px 10px;
    font-size: 0.85rem;
  }
}

@media (min-width: 920px) {
  .site-header > :is(.wrap, .header-inner):has(> .org-nav:not([data-auth-only])),
  body[data-auth="signed-in"] .site-header > :is(.wrap, .header-inner):has(> .org-nav) {
    flex-wrap: nowrap;
    height: 64px;
    min-height: 64px;
    padding-block: 0;
    gap: 16px;
  }

  .site-header .org-nav {
    order: 0;
    flex: 0 1 auto;
    width: auto;
    border-top: 0;
    padding-top: 0;
    margin-left: clamp(8px, 1.5vw, 20px);
  }
}

/* ---------- Migas de pan (.org-breadcrumb) ---------- */
.org-breadcrumb {
  margin: 0 0 10px;
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--text-muted, #585043);
  min-width: 0;
}

.org-breadcrumb > ol {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}

.org-breadcrumb > ol > li {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.org-breadcrumb > ol > li + li::before {
  content: "/" / "";
  color: var(--n-400, #a79c8d);
  margin-inline: 8px;
  font-weight: 600;
}

.org-breadcrumb a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 2px;
  border-radius: 4px;
  color: var(--text-muted, #585043);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}

@media (hover: hover) and (pointer: fine) {
  .org-breadcrumb a:hover {
    color: var(--accent-ink, #065f46);
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

.org-breadcrumb a:focus-visible {
  outline: 2px solid var(--ring, #0b6e4f);
  outline-offset: 2px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.org-breadcrumb a[aria-current="page"] {
  color: var(--text, #12100d);
  font-weight: 700;
}

/* ---------- Tarjeta de bienvenida y pasos siguientes (.org-welcome-card) ---------- */
.org-welcome-card {
  display: grid;
  gap: 16px;
  padding: clamp(18px, 3vw, 26px);
  border-radius: var(--radius-lg, 20px);
  background: var(--surface, #ffffff);
  border: 1px solid var(--line, #e8e2d8);
  box-shadow: var(--shadow-sm, 0 1px 2px rgb(23 21 18 / 0.05));
  min-width: 0;
}

.org-welcome-head {
  display: grid;
  gap: 6px;
}

.org-welcome-kicker {
  margin: 0;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-ink, #065f46);
}

.org-welcome-title {
  margin: 0;
  font-family: var(--display, var(--font, 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif));
  font-size: clamp(1.12rem, 1rem + 0.6vw, 1.35rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text, #12100d);
}

.org-welcome-lead {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--text-muted, #585043);
  max-width: 62ch;
}

.org-welcome-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: org-welcome-step;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}

@media (min-width: 640px) {
  .org-welcome-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.org-welcome-steps > li {
  counter-increment: org-welcome-step;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 12px;
  align-content: start;
  padding: 14px 16px;
  border-radius: var(--radius-md, 12px);
  background: var(--n-50, #faf8f5);
  border: 1px solid var(--line, #e8e2d8);
}

.org-welcome-steps > li::before {
  content: counter(org-welcome-step, decimal-leading-zero);
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-soft, #ecfdf5);
  color: var(--accent-ink, #065f46);
  border: 1px solid rgba(11, 110, 79, 0.22);
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.78rem;
  font-weight: 800;
}

.org-welcome-steps > li > strong {
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text, #12100d);
}

.org-welcome-steps > li > span {
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--text-muted, #585043);
}

.org-welcome-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.org-welcome-actions .btn {
  min-height: 44px;
}

@media (max-width: 480px) {
  .org-welcome-actions .btn {
    flex: 1 1 100%;
    justify-content: center;
  }
}

/* ---------- Preferencias de sistema: contraste alto y movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  body[data-auth="signed-in"] .org-nav[data-auth-only],
  body[data-auth="signed-in"] .org-breadcrumb[data-auth-only] {
    animation: none;
  }

  .org-nav a {
    transition: none;
  }
}

@media (forced-colors: active) {
  .org-nav a[aria-current="page"] {
    outline: 2px solid Highlight;
    text-decoration: underline;
  }

  .org-breadcrumb a[aria-current="page"] {
    text-decoration: underline;
  }
}
