/* ==============================================
   Directorio Institucional · CESFAM La Unión
   CSS propio del sistema. Va SIEMPRE después de
   portal-shell.css: ese archivo trae los tokens,
   la tipografía y los componentes del portal.
   Acá solo lo que es exclusivo del directorio.
   ============================================== */

:root {
  /* Único token propio: el ancho de la barra lateral (layout, no color). */
  --sidebar-w: 244px;
}

/* ── Reset ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
}

a { transition: color .2s ease; }

img { max-width: 100%; display: block; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.hidden { display: none !important; }

[tabindex="-1"]:focus { outline: none; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

::selection { background: var(--goldsoft); color: var(--ink); }

/* El área táctil del toggle de tema mide 62x31 por diseño: se amplía a 44px. */
.portal-theme::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 44px;
  transform: translateY(-50%);
}

/* El ícono sol/luna lo inyecta app.js; hereda el color del pulgar. */
.portal-theme__thumb { color: var(--ondark); }
.portal-theme__thumb svg { width: 13px; height: 13px; }

.portal-id__logo img { transition: transform .25s var(--ease-out); }
.portal-id__logo:hover img { transform: translateY(-2px); }

/* ══════════════════════════════════════════════
   HERO — buscador del directorio
   El único bloque del sistema que va sobre el
   canvas generativo. Variante compacta: no lleva
   titular escalonado, solo eyebrow + buscador.
   ══════════════════════════════════════════════ */

.hero--search {
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
}

.hero--search .hero__inner {
  padding-top: clamp(32px, 4.4vw, 54px);
  padding-bottom: clamp(34px, 4.6vw, 58px);
}

.hero--search .eyebrow { margin-bottom: 18px; }

.hero-search { max-width: 760px; }

.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--hair2);
  clip-path: var(--chamfer-16);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.search-bar:focus-within {
  border-color: var(--goldline);
  box-shadow: 0 0 0 1px var(--goldline), 0 14px 34px -22px rgba(245, 185, 66, .8);
}

.search-icon {
  position: absolute;
  left: 18px;
  color: var(--faint);
  pointer-events: none;
  transition: color .2s ease;
}
.search-bar:focus-within .search-icon { color: var(--goldink); }

.search-input {
  width: 100%;
  padding: 20px 104px 20px 54px;
  background: transparent;
  border: none;
  color: var(--ink);
  font: 500 16px/1.2 var(--font-ui);
  outline: none;
}
.search-input::placeholder { color: var(--faint); }

.search-kbd-hint {
  position: absolute;
  right: 16px;
  padding: 6px 10px;
  border: 1px solid var(--hair2);
  background: var(--surface2);
  color: var(--faint);
  font: 700 11px/1 var(--font-ui);
  letter-spacing: .06em;
  white-space: nowrap;
  transition: opacity .2s ease;
}
.search-input:not(:placeholder-shown) ~ .search-kbd-hint { opacity: 0; }

.clear-btn {
  position: absolute;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  color: var(--muted);
  transition: color .2s ease, background .2s ease;
}
.clear-btn:hover { color: var(--ink); background: var(--hair); }

/* Pulso de atención en la primera visita. */
.hero-search.attract .search-bar { animation: attractPulse 1.6s ease-in-out 2; }

/* ══════════════════════════════════════════════
   SHELL — barra lateral + contenido
   ══════════════════════════════════════════════ */

.app-shell {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 var(--shell-pad);
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: clamp(26px, 3.6vw, 52px);
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 22px;
  margin-top: clamp(36px, 5vw, 60px);
  background: var(--surface);
  border: 1px solid var(--hair);
  clip-path: var(--chamfer-22);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-nav-btn {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 16px 18px;
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 600;
  text-align: left;
  border-left: 2px solid transparent;
  transition: color .2s ease, background .2s ease, border-color .2s ease;
}
.side-nav-btn .material-icons-round { font-size: 19px; color: var(--faint); transition: color .2s ease; }
.side-nav-btn:hover { color: var(--ink); background: var(--surface2); }
.side-nav-btn:hover .material-icons-round { color: var(--muted); }

.side-nav-btn.active {
  color: var(--ink);
  background: var(--goldsoft);
  border-left-color: var(--gold);
}
.side-nav-btn.active .material-icons-round { color: var(--goldink); }

.sidebar-footer {
  padding: 16px 18px 6px;
  border-top: 1px solid var(--hair);
}

/* Etiqueta de tarjeta del contrato (§3). */
.sidebar-badge {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.main-content {
  padding-top: clamp(36px, 5vw, 60px);
  padding-bottom: clamp(64px, 8vw, 110px);
  min-width: 0;
}

/* ── Encabezado de resultados ── */

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: clamp(30px, 4vw, 48px);
  padding-bottom: 22px;
  border-bottom: 1px solid var(--hair);
}

/* Hereda .section-title del shell (Quantico 700, mayúsculas). */
.results-title { min-width: 0; }

.results-meta {
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

/* ── Grupos de contactos ── */

.directory-grid {
  display: flex;
  flex-direction: column;
  gap: clamp(40px, 5vw, 68px);
}

.directory-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--hair);
}

.directory-group-title {
  font-family: var(--font-display);
  font-size: clamp(17px, 1.7vw, 22px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .01em;
  line-height: .98;
}

.directory-group-meta {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* Cada contacto es una unidad de lectura, no una celda contigua. */
.directory-group-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 270px), 1fr));
  gap: clamp(16px, 1.5vw, 20px);
}

/* ── Tarjeta de contacto ── */

.contact-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--hair2);
  clip-path: var(--chamfer-12);
  min-height: 194px;
  padding: clamp(22px, 1.8vw, 26px);
  display: flex;
  flex-direction: column;
  gap: clamp(24px, 2.5vw, 30px);
  animation: cardIn .5s var(--ease-out) both;
  transition: background .22s ease, border-color .22s ease,
              box-shadow .3s var(--ease-out), transform .3s var(--ease-out);
}
.contact-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--gold);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform .35s var(--ease-out);
}
.contact-card:hover,
.contact-card:focus-within {
  background: var(--surface2);
  border-color: var(--goldline);
  box-shadow: 0 18px 38px -30px rgba(0, 0, 0, .9);
  transform: translateY(-3px);
}
.contact-card:hover::before,
.contact-card:focus-within::before { transform: scaleY(1); }

.contact-card .card-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.contact-card .card-identity { min-width: 0; }

.contact-card .card-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--hair2);
  color: var(--goldink);
  transition: border-color .25s var(--ease-out), color .25s var(--ease-out), transform .25s var(--ease-out);
}
.contact-card .card-avatar .material-icons-round { font-size: 18px; }
.contact-card:hover .card-avatar {
  border-color: var(--goldline);
  transform: translateY(-2px);
}

.contact-card .card-title {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.35;
  color: var(--ink);
}

.contact-card .card-subtitle {
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.contact-card .card-body {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--hair);
}

.card-contact {
  display: grid;
  grid-template-columns: minmax(86px, .8fr) minmax(0, 1.25fr);
  align-items: end;
  gap: clamp(22px, 3vw, 34px);
}

.card-contact--single { grid-template-columns: minmax(0, 1fr); }

.phone-data {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.phone-data-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .17em;
  text-transform: uppercase;
  color: var(--faint);
}

.phone-data-value {
  max-width: 100%;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(18px, 1.4vw, 20px);
  font-weight: 700;
  letter-spacing: .025em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.phone-data:first-child .phone-data-value { color: var(--goldink); }

.phone-data-value.is-callable {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 2px 6px 2px 0;
  border-bottom: 1px solid transparent;
  transition: color .2s ease, border-color .2s ease, transform .2s var(--ease-out);
}
.phone-data-value.is-callable:hover,
.phone-data-value.is-callable:focus-visible {
  color: var(--goldink);
  border-bottom-color: var(--goldline);
  transform: translateX(3px);
}

.contact-card.search-highlight {
  background: var(--goldsoft);
  box-shadow: inset 0 0 0 1px var(--goldline);
}
.contact-card.search-highlight::before { transform: scaleY(1); }

/* ── Estado vacío ── */

.empty-state {
  margin-top: 8px;
  border: 1px dashed var(--hair2);
  background: var(--surface);
  padding: clamp(34px, 5vw, 60px);
  text-align: center;
}
.empty-state .material-icons-round {
  font-size: 34px;
  color: var(--faint);
}
.empty-state h3 {
  margin-top: 14px;
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .01em;
  line-height: .98;
}
.empty-state p {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14.5px;
}

/* ── Menú móvil ── */

.mobile-menu-btn {
  display: none;
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 45;
  width: 54px;
  height: 54px;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  color: var(--ondark);
  clip-path: var(--chamfer-12);
  box-shadow: 0 0 0 1px var(--goldline), 0 14px 34px -14px rgba(245, 185, 66, .8);
}
.mobile-menu-btn .material-icons-round { font-size: 24px; }

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 44;
  background: rgba(8, 12, 18, .6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.sidebar-overlay.open { opacity: 1; pointer-events: auto; }

/* ══════════════════════════════════════════════
   FOOTER — columnas propias sobre .portal-footer
   ══════════════════════════════════════════════ */

.footer-inner,
.footer-bottom {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding-left: var(--shell-pad);
  padding-right: var(--shell-pad);
}

.footer-inner {
  padding-top: clamp(48px, 6vw, 72px);
  padding-bottom: clamp(40px, 5vw, 56px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: clamp(30px, 4vw, 56px);
}

.footer-brand { display: flex; flex-direction: column; gap: 14px; }

/* Tarjeta del logo, igual que .portal-id__logo del shell: el filtro --logofx
   va en la imagen, nunca en la caja (arrastraría también su fondo). */
.footer-logo {
  width: 68px;
  height: 68px;
  border-radius: 18px;
  background: var(--logo);
  border: 1px solid var(--hair2);
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}
.footer-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: var(--logofx);
}

/* Marca del footer del shell: Quantico, mayúsculas. */
.footer-mark {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  line-height: 1.15;
}

.footer-brand-note {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
}

.footer h4 {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 16px;
}

.footer ul { list-style: none; display: flex; flex-direction: column; gap: 13px; }
.footer li { font-size: 13.5px; }
.footer li span { color: var(--muted); }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--goldink); }

.footer-social-links { display: flex; flex-direction: column; gap: 13px; }

.footer-social-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13.5px;
  transition: color .2s ease, transform .2s ease;
}
.footer-social-link:hover { color: var(--goldink); transform: translateX(2px); }
.footer-social-link svg { flex: none; }

.footer-bottom {
  padding-top: 22px;
  padding-bottom: 26px;
  border-top: 1px solid var(--hair);
}
.footer-bottom p { color: var(--faint); font-size: 12.5px; }

/* ══════════════════════════════════════════════
   PALETA DE COMANDOS (Ctrl+K)
   ══════════════════════════════════════════════ */

.cmdk[hidden] { display: none; }

.cmdk {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(40px, 12vh, 130px) 18px 18px;
}

.cmdk-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 18, .68);
  backdrop-filter: blur(4px);
  animation: cmdkFade .2s ease both;
}

.cmdk-panel {
  position: relative;
  width: min(640px, 100%);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--hair2);
  clip-path: var(--chamfer-22);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .75);
  animation: cmdkPop .28s var(--ease-out) both;
}

.cmdk-search {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--hair);
  color: var(--faint);
}

.cmdk-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ink);
  font: 500 16px/1.2 var(--font-ui);
}
.cmdk-input::placeholder { color: var(--faint); }

.cmdk-esc,
.cmdk-footer kbd {
  padding: 5px 9px;
  border: 1px solid var(--hair2);
  background: var(--surface2);
  color: var(--faint);
  font: 700 11px/1 var(--font-ui);
  letter-spacing: .04em;
}

.cmdk-list {
  overflow-y: auto;
  padding: 8px 0;
}

.cmdk-group-label {
  padding: 14px 22px 8px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
}

.cmdk-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background .15s ease, border-color .15s ease;
}
.cmdk-item[aria-selected="true"] {
  background: var(--goldsoft);
  border-left-color: var(--gold);
}

.cmdk-item-icon {
  flex: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px solid var(--hair2);
  color: var(--faint);
}
.cmdk-item-icon .material-icons-round { font-size: 16px; }

.cmdk-item-body { min-width: 0; flex: 1; }

.cmdk-item-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmdk-item-title mark {
  background: var(--goldsoft);
  color: var(--goldink);
  font-weight: 700;
}

.cmdk-item-desc {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmdk-item-tag {
  flex: none;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--hair);
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.cmdk-empty {
  padding: 34px 22px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.cmdk-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  padding: 14px 22px;
  border-top: 1px solid var(--hair);
  color: var(--faint);
  font-size: 12px;
}
.cmdk-footer span { display: inline-flex; align-items: center; gap: 6px; }

/* ══════════════════════════════════════════════
   MOTION propio del sistema
   (los reveals, dotPulse y rowIn viven en el shell)
   ══════════════════════════════════════════════ */

.results-meta.is-fresh,
.sidebar-badge.is-fresh { animation: freshIn .45s var(--ease-out) both; }

.results-title.is-fresh { animation: freshIn .5s var(--ease-out) both; }

@keyframes freshIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes attractPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 185, 66, 0); }
  50% { box-shadow: 0 0 0 4px var(--goldsoft); }
}

@keyframes cmdkFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cmdkPop {
  from { opacity: 0; transform: translateY(-12px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ══════════════════════════════════════════════
   RESPONSIVE — 1280 / 768 / 360
   ══════════════════════════════════════════════ */

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 46;
    width: min(280px, 84vw);
    height: 100vh;
    margin: 0;
    clip-path: none;
    border: none;
    border-right: 1px solid var(--hair2);
    padding: 18px 12px;
    transform: translateX(-102%);
    transition: transform .3s var(--ease-out);
    overflow-y: auto;
  }
  .sidebar.open { transform: none; }

  .mobile-menu-btn { display: flex; }
}

@media (max-width: 720px) {
  .portal-topbar__inner { height: auto; padding-top: 10px; padding-bottom: 10px; }
  .portal-clock__date { font-size: 13px; }

  .portal-nav__inner {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .portal-nav__inner::-webkit-scrollbar { display: none; }

  .portal-id__inner { padding-top: 24px; padding-bottom: 26px; }
  .portal-id__logo { width: 72px; height: 72px; border-radius: 18px; padding: 10px; }
  /* La identidad debe poder encoger sin desbordar. */
  .portal-id__copy { flex: 1 1 100%; min-width: 0; }
  .portal-id__title { overflow-wrap: anywhere; }

  .search-input { padding-right: 52px; padding-left: 48px; }
  .search-icon { left: 15px; }
  .search-kbd-hint { display: none; }

  .footer-inner { padding-top: 34px; }

  .cmdk { padding-top: 60px; }
  .cmdk-item-tag { display: none; }
}
