/* Dev101x Official Cinematic & Editorial Design System */

:root {
  --fh: 'Bricolage Grotesque', sans-serif;
  --fm: 'DM Mono', monospace;
  --bg: #f3f0ea;
  --bg2: #e9e5dd;
  --surface: #fdfcf9;
  --ink: #0c0d0e;
  --ink2: #282b29;
  --muted: #686d66;
  --accent: #005c38;
  --accent2: #003f27;
  --line: #d3cec5;
  --color-primary: #005c38;
  --color-primary-container: #003f27;
  --color-primary-fixed: #9ffdd3;
  --color-on-primary: #ffffff;
  --color-surface: #fdfcf9;
  --color-surface-container: #f3f0ea;
  --color-surface-container-low: #f9f8f5;
  --color-surface-container-lowest: #ffffff;
  --color-on-surface: #0c0d0e;
  --color-on-surface-variant: #686d66;
  --color-border-hairline: #d3cec5;
  --color-border-subtle: #e9e5dd;
}

html, body {
  font-family: var(--fh);
  background-color: #f3f0ea !important;
  color: var(--ink);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none !important;
  -webkit-overflow-scrolling: touch;
}

/* Página pública: tarjetas legibles sobre el fondo animado */
.landing-card {
  position: relative;
  background-color: rgba(253, 252, 249, 0.93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  box-shadow: 0 18px 48px rgba(12, 13, 14, 0.07), 0 2px 10px rgba(12, 13, 14, 0.03);
}

/* Pantalla de carga con la marca (js/views/loader.js) */
.ldr {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: rgba(243, 240, 234, 0.94);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.28s ease;
}
.ldr.is-on { opacity: 1; }
.ldr-stage { position: relative; width: 240px; height: 110px; }
.ldr-line {
  position: absolute;
  left: 40px;
  right: 40px;
  top: 54px;
  height: 2px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
  transform: scaleX(0);
  animation: ldr-line 0.7s 0.45s cubic-bezier(0.65, 0, 0.35, 1) forwards;
}
.ldr-line::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 45%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  transform: translateX(-110%);
  animation: ldr-shine 1.9s 1.2s ease-in-out infinite;
}
.ldr-tile {
  position: absolute;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(12, 13, 14, 0.12), 0 2px 6px rgba(12, 13, 14, 0.06);
}
.ldr-brand {
  left: 50%;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 20px;
  background: #fff;
  z-index: 2;
  animation: ldr-pop 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.ldr-brand img { width: 56px; height: 56px; border-radius: 14px; }
.ldr-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  border-radius: 22px;
  border: 2px solid var(--accent);
  opacity: 0;
  animation: ldr-ring 1.9s 1.1s ease-out infinite;
}
.ldr-g,
.ldr-gh { width: 46px; height: 46px; margin-top: -23px; z-index: 1; }
.ldr-g {
  left: 17px;
  background: #fff;
  border: 1px solid var(--line);
  animation: ldr-in-left 0.8s 0.15s cubic-bezier(0.34, 1.4, 0.64, 1) both, ldr-bob 2.6s 1.1s ease-in-out infinite;
}
.ldr-gh {
  right: 17px;
  background: #0c0d0e;
  animation: ldr-in-right 0.8s 0.25s cubic-bezier(0.34, 1.4, 0.64, 1) both, ldr-bob 2.6s 2.4s ease-in-out infinite;
}
.ldr-text {
  font-family: var(--fm);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
  opacity: 0;
  animation: ldr-fade 0.5s 0.6s ease forwards;
}
@keyframes ldr-pop {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes ldr-in-left {
  0% { opacity: 0; transform: translate(-64px, 30px) scale(0.55) rotate(-24deg); }
  55% { opacity: 1; transform: translate(-18px, -12px) scale(0.95) rotate(-6deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes ldr-in-right {
  0% { opacity: 0; transform: translate(64px, 30px) scale(0.55) rotate(24deg); }
  55% { opacity: 1; transform: translate(18px, -12px) scale(0.95) rotate(6deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes ldr-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes ldr-line { to { transform: scaleX(1); } }
@keyframes ldr-shine { to { transform: translateX(240%); } }
@keyframes ldr-ring {
  0% { opacity: 0.55; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.55); }
}
@keyframes ldr-fade { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .ldr-line, .ldr-line::after, .ldr-ring, .ldr-brand, .ldr-g, .ldr-gh, .ldr-text { animation: none; }
  .ldr-line { transform: none; }
  .ldr-text { opacity: 1; }
}

/* Móvil de muestra en la página pública (marco en CSS, capturas reales dentro) */
.phone-frame {
  position: relative;
  width: 232px;
  padding: 9px;
  border-radius: 38px;
  background: #121614;
  box-shadow: 0 24px 50px rgba(12, 13, 14, 0.18), inset 0 0 0 1.5px #2c332f;
  cursor: pointer;
  transition: transform 0.25s ease;
}
.phone-frame:hover { transform: translateY(-3px); }
.phone-frame::before { /* cámara */
  content: '';
  position: absolute;
  top: 17px;
  left: 50%;
  width: 64px;
  height: 17px;
  margin-left: -32px;
  border-radius: 999px;
  background: #121614;
  z-index: 2;
}
.phone-screen {
  position: relative;
  display: block;
  aspect-ratio: 488 / 1117; /* captura + barra de estado */
  border-radius: 30px;
  overflow: hidden;
  background: var(--surface);
}
.phone-shot {
  position: absolute;
  top: 5.55%; /* barra de estado, donde queda la cámara */
  left: 0;
  width: 100%;
  height: 94.45%;
  object-fit: cover;
  object-position: top;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.phone-shot.is-active { opacity: 1; }
/* Popup de acceso: los botones de Google centrados */
.login-modal-actions > * { align-self: center; }
.phone-tab {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid transparent;
  color: var(--muted);
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.phone-tab:hover { background: rgba(0, 92, 56, 0.05); }
.phone-tab[aria-selected="true"] {
  background: rgba(0, 92, 56, 0.07);
  border-color: rgba(0, 92, 56, 0.25);
  color: var(--accent);
}
@media (min-width: 640px) {
  .phone-frame { width: 250px; }
}
@media (prefers-reduced-motion: reduce) {
  .phone-shot, .phone-frame { transition: none; }
}

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

code, pre, .font-mono {
  font-family: var(--fm) !important;
}

/* Material Symbols standard setup */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined' !important;
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  vertical-align: middle;
}

/* Subtle transitions */
a, button {
  transition: all 0.15s ease-in-out;
}

/* Terminal Cursor */
.terminal-cursor {
  display: inline-block;
  width: 8px;
  height: 15px;
  background-color: #10b981;
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Modal animation */
.modal-enter {
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Print optimizations */
@media print {
  body {
    background-color: #ffffff !important;
    color: #000000 !important;
  }
  header, aside, #nav-bar, #app-footer, #mobile-nav, .no-print, button, .modal-backdrop {
    display: none !important;
  }
}

/* Water / Ink Canvas Background (Estilo MiMo Code) */
#water-bg-wrapper {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  min-width: 100%;
  min-height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background-color: var(--bg);
}

#water-bg-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-image: url('../assets/mimo-bg.webp');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  opacity: 0.95;
  filter: contrast(1.08) saturate(1.15);
}

#waterMaskCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* Tarjeta Editorial de Login */
.login-card-editorial {
  position: relative;
  z-index: 10;
  background-color: rgba(253, 252, 249, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(12, 13, 14, 0.08), 0 4px 16px rgba(12, 13, 14, 0.04);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.login-card-editorial:hover {
  box-shadow: 0 32px 80px rgba(12, 13, 14, 0.12), 0 6px 20px rgba(12, 13, 14, 0.05);
}

/* Botones de acceso con Google */
.login-btn {
  box-shadow: 0 1px 2px rgba(12, 13, 14, 0.05);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.login-btn:hover:not(:disabled) {
  border-color: rgba(0, 92, 56, 0.45);
  box-shadow: 0 10px 28px rgba(0, 92, 56, 0.10), 0 2px 6px rgba(12, 13, 14, 0.05);
  transform: translateY(-1px);
}
.login-btn:active:not(:disabled) {
  transform: translateY(0);
}
.login-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 92, 56, 0.25);
}
.login-btn:disabled {
  cursor: progress;
}
#login-actions button:disabled:not(.login-btn) {
  opacity: 0.4;
}

/* ---- Layout Improvements: Breathing Room & Mobile Polish ---- */

/* Smooth scroll for authenticated pages */
html:not(.login-active) {
  scroll-behavior: smooth;
}

/* Better card interaction feel */
.card-lift {
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.card-lift:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(12, 13, 14, 0.08), 0 2px 8px rgba(12, 13, 14, 0.04);
}

/* Section divider with breathing room */
.section-gap {
  padding-top: 1.25rem;
  padding-bottom: 1.25rem;
}

/* Responsive gutter for px-gutter utility */
@media (max-width: 640px) {
  .px-gutter {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
}
@media (min-width: 641px) {
  .px-gutter {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}
@media (min-width: 1024px) {
  .px-gutter {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* Command tab bar: hide scrollbar but keep scrollable */
.cmd-tab-bar::-webkit-scrollbar {
  height: 0;
  display: none;
}
.cmd-tab-bar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Terminal output smooth scroll */
#terminal-screen {
  scroll-behavior: smooth;
}

/* Resource card hover glow */
.resource-card {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.resource-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(0, 92, 56, 0.08);
}

/* ---- Paneles colapsables (columna lateral en móvil) ---- */
.panel-open {
  display: flex !important;
}

/* ---- Mobile: densidad, respiración y áreas táctiles ---- */

/* Nunca desbordar horizontalmente en pantallas estrechas */
body {
  overflow-x: hidden;
}

/* Espacio para la barra de navegación inferior fija */
body.has-mobile-nav {
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 768px) {
  body.has-mobile-nav {
    padding-bottom: 0;
  }
}

#mobile-nav {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mobile-nav-item {
  min-height: 56px;
  transition: color 0.15s ease, background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav-item:active {
  background-color: rgba(0, 92, 56, 0.06);
}

@media (max-width: 767px) {
  /* Evitar el zoom automático de iOS al enfocar la consola */
  input[type="text"],
  input[type="search"],
  textarea {
    font-size: 16px !important;
  }

  /* Áreas táctiles mínimas en botones y enlaces de acción */
  button,
  a[href^="#/"],
  .cmd-tab-btn,
  .nmap-cat-btn {
    -webkit-tap-highlight-color: transparent;
  }

  /* Texto pequeño más legible en móvil */
  .text-\[10px\] {
    font-size: 10.5px;
  }
  .text-\[11px\] {
    font-size: 11.5px;
    line-height: 1.45;
  }

  /* Las tarjetas no se levantan al tocar (evita "saltos" en scroll táctil) */
  .card-lift:hover {
    transform: none;
    box-shadow: none;
  }

  /* Tablas anchas (panel admin) con scroll propio en vez de romper el layout */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

/* Chevrons de los paneles colapsables */
[data-chevron] {
  transition: transform 0.2s ease;
}


/* ---- v23: navegación, accesibilidad y utilidades sin estilos inline ---- */

/* Enlaces de navegación (cabecera y barra inferior) */
.nav-link {
  color: var(--muted);
}
.nav-link:hover {
  color: var(--ink);
  background-color: var(--surface);
}
.nav-link.nav-active {
  color: var(--accent);
  background-color: var(--surface);
  font-weight: 600;
}
.mobile-nav-item {
  color: var(--muted);
}
.mobile-nav-item.nav-active {
  color: var(--accent);
  font-weight: 700;
}

/* Iconos pixel-art sin difuminado al escalar */
.pixelated {
  image-rendering: pixelated;
}

/* Enlace "saltar al contenido" visible solo con teclado */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 100;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
}
.skip-link:focus {
  top: 1rem;
}

/* Foco visible para navegación con teclado */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* El contenedor principal recibe el foco al cambiar de vista (lectores de pantalla): sin contorno,
   si no aparecen dos líneas verdes a los lados al entrar. */
[tabindex="-1"]:focus,
[tabindex="-1"]:focus-visible {
  outline: none;
}

/* Cabecera del perfil y anillo de progreso */
.profile-glow {
  background-image: radial-gradient(circle at 12% 0%, #0a7a4d 0, transparent 42%),
                    radial-gradient(circle at 95% 110%, #005c38 0, transparent 45%);
}
.progress-ring {
  transition: stroke-dashoffset 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Impresión de la hoja de comandos: solo el contenido de la ventana emergente */
@media print {
  body.printing-dialog > *:not(#app-dialog) { display: none !important; }
  body.printing-dialog { background: #fff !important; }
  body.printing-dialog #app-dialog { position: static !important; display: block !important; background: none !important; backdrop-filter: none !important; padding: 0 !important; }
  body.printing-dialog #app-dialog-panel { max-height: none !important; box-shadow: none !important; border: none !important; max-width: none !important; overflow: visible !important; }
  body.printing-dialog #app-dialog-body { overflow: visible !important; }
  body.printing-dialog .no-print,
  body.printing-dialog [data-action="close-modal"] { display: none !important; }
}

/* Pistas por niveles (details/summary sin el triángulo por defecto) */
#app-dialog details > summary::-webkit-details-marker { display: none; }
