/* ============================================================
   Directorio — estética iOS premium
   ============================================================ */

/* ---- Tokens ---- */
:root {
  --text: #ffffff;
  --text-dim: rgba(255, 255, 255, 0.6);
  --text-faint: rgba(255, 255, 255, 0.38);

  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-bg-strong: rgba(255, 255, 255, 0.18);
  --glass-edge: rgba(255, 255, 255, 0.22);
  --glass-edge-top: rgba(255, 255, 255, 0.4);

  --ios-blue: #0a84ff;
  --ios-green: #30d158;
  --ios-red: #ff453a;
  --offline: rgba(255, 255, 255, 0.32);

  --radius-card: 26px;
  --radius-input: 16px;

  /* curvas de animación estilo Apple */
  --ease-spring: cubic-bezier(0.34, 1.3, 0.4, 1);
  --ease-smooth: cubic-bezier(0.32, 0.72, 0, 1);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --text-shadow: 0 1px 14px rgba(0, 0, 0, 0.35);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  letter-spacing: -0.011em;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background-color: #0b0b1e;
}

/* ---- Wallpaper: mesh gradient con profundidad ---- */
body::before {
  content: "";
  position: fixed;
  inset: -10%;
  z-index: -2;
  background:
    radial-gradient(52% 44% at 22% 12%, rgba(122, 90, 248, 0.75), transparent 70%),
    radial-gradient(46% 42% at 82% 8%, rgba(255, 100, 130, 0.5), transparent 70%),
    radial-gradient(50% 46% at 88% 66%, rgba(64, 156, 255, 0.45), transparent 70%),
    radial-gradient(60% 52% at 12% 88%, rgba(48, 90, 210, 0.55), transparent 70%),
    radial-gradient(38% 34% at 55% 44%, rgba(190, 120, 255, 0.28), transparent 70%),
    linear-gradient(168deg, #181633 0%, #131230 40%, #0c0c22 78%, #08081a 100%);
  animation: wallpaper-drift 40s ease-in-out infinite alternate;
}

/* Grano fino: elimina el banding y da textura fotográfica */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@keyframes wallpaper-drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(-2.5%, 2%, 0) scale(1.06);
  }
}

.hidden {
  display: none !important;
}

::selection {
  background: rgba(10, 132, 255, 0.45);
}

/* ---- Material de vidrio (capa base + borde de luz) ---- */
.glass {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    var(--glass-bg);
  backdrop-filter: blur(32px) saturate(190%);
  -webkit-backdrop-filter: blur(32px) saturate(190%);
  border-radius: var(--radius-card);
  box-shadow:
    0 0 0 0.5px rgba(255, 255, 255, 0.14),
    inset 0 1px 0 0 var(--glass-edge-top),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.08),
    0 24px 48px -12px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   LOCK SCREEN
   ============================================================ */

.lock-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 52px;
  padding: 40px 24px;
}

.lock-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-shadow: var(--text-shadow);
  animation: rise-in 800ms var(--ease-smooth) both;
}

.lock-date {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: rgba(255, 255, 255, 0.85);
  text-transform: capitalize;
}

.lock-time {
  font-size: clamp(72px, 14vw, 104px);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.02;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff 30%, rgba(255, 255, 255, 0.72));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lock-form {
  width: 100%;
  max-width: 330px;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: rise-in 800ms 120ms var(--ease-smooth) both;
}

.lock-form.shake {
  animation: shake 500ms var(--ease-smooth);
}

.lock-avatar {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.9);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 0 0 0.5px rgba(255, 255, 255, 0.18),
    0 12px 28px -8px rgba(0, 0, 0, 0.45);
  margin-bottom: 26px;
}

/* Inputs agrupados estilo iOS: un contenedor, hairline divisoria */
.input-group {
  width: 100%;
  border-radius: var(--radius-input);
  overflow: hidden;
}

.input-group input {
  width: 100%;
  background: transparent;
  border: none;
  padding: 15px 20px;
  color: var(--text);
  font-family: inherit;
  font-size: 17px;
  letter-spacing: -0.01em;
  text-align: center;
  transition: background 250ms var(--ease-smooth);
}

.input-group input::placeholder {
  color: var(--text-faint);
}

.input-group input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.07);
}

.hairline {
  height: 0.5px;
  background: rgba(255, 255, 255, 0.16);
  margin: 0 14px;
}

.login-error {
  color: #ffb3ad;
  font-size: 14px;
  font-weight: 500;
  margin-top: 14px;
  text-align: center;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

.btn-unlock {
  width: 100%;
  margin-top: 16px;
  position: relative;
  background: linear-gradient(180deg, #ffffff, #e9e9ef);
  color: #16152e;
  border: none;
  border-radius: var(--radius-input);
  padding: 15px 24px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 10px 24px -6px rgba(0, 0, 0, 0.45);
  transition: transform 350ms var(--ease-spring), box-shadow 350ms var(--ease-spring), opacity 200ms;
}

.btn-unlock:hover {
  transform: translateY(-1px) scale(1.015);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 14px 30px -6px rgba(0, 0, 0, 0.5);
}

.btn-unlock:active {
  transform: scale(0.97);
}

.btn-unlock:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
}

.lock-hint {
  position: fixed;
  bottom: 28px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-faint);
  text-shadow: var(--text-shadow);
}

/* ============================================================
   HOME SCREEN
   ============================================================ */

.home-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* animación de desbloqueo: el home aparece desde un leve zoom */
.home-screen.unlocking {
  animation: unlock 700ms var(--ease-smooth) both;
}

.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 30px;
}

.status-time {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-shadow: var(--text-shadow);
}

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 350ms var(--ease-spring), background 250ms var(--ease-smooth);
}

.pill-btn:hover {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.04)),
    var(--glass-bg-strong);
}

.pill-btn:active {
  transform: scale(0.94);
}

.home-content {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 32px 150px;
}

/* ---- Widget ---- */
.widget {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 30px;
  margin-bottom: 52px;
  animation: rise-in 600ms 80ms var(--ease-smooth) both;
}

.widget-title {
  font-size: 27px;
  font-weight: 650;
  letter-spacing: -0.022em;
  line-height: 1.15;
}

.widget-sub {
  color: var(--text-dim);
  font-size: 15px;
  margin-top: 3px;
}

.widget-date {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: capitalize;
  text-align: right;
  flex-shrink: 0;
}

/* ---- Grid de apps ---- */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(98px, 1fr));
  gap: 34px 14px;
  justify-items: center;
}

.app-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: inherit;
  width: 98px;
  animation: pop-in 600ms var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * 45ms + 150ms);
}

/* el wrapper lleva la sombra (drop-shadow respeta el squircle) */
.app-icon-wrap {
  filter:
    drop-shadow(0 2px 3px rgba(0, 0, 0, 0.28))
    drop-shadow(0 14px 22px rgba(0, 0, 0, 0.35));
  transition: transform 400ms var(--ease-spring), filter 400ms var(--ease-smooth);
}

.app-item:hover .app-icon-wrap {
  transform: scale(1.09) translateY(-2px);
  filter:
    drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3))
    drop-shadow(0 22px 34px rgba(0, 0, 0, 0.42));
}

.app-item:active .app-icon-wrap {
  transform: scale(0.92);
  transition-duration: 120ms;
}

.app-icon {
  position: relative;
  width: 78px;
  height: 78px;
  clip-path: url(#squircle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 37px;
  isolation: isolate;
}

/* acabado del ícono: brillo superior + sombreado inferior + borde de luz */
.app-icon::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(120% 62% at 50% -12%, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.06) 55%, transparent 70%),
    linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.22));
  pointer-events: none;
}

.app-icon::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  clip-path: url(#squircle);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  pointer-events: none;
}

.app-icon .emoji {
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.app-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  z-index: 3;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--offline);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: background 400ms var(--ease-smooth), box-shadow 400ms var(--ease-smooth);
}

.app-badge.online {
  background: var(--ios-green);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.45),
    0 0 10px rgba(48, 209, 88, 0.65),
    0 1px 3px rgba(0, 0, 0, 0.4);
}

.app-name {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-align: center;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
  max-width: 98px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Dock flotante ---- */
.dock {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 13px 20px;
  border-radius: 32px;
  animation: dock-in 700ms 250ms var(--ease-spring) both;
}

.dock .app-icon {
  width: 58px;
  height: 58px;
  font-size: 28px;
}

.dock .app-item {
  width: auto;
  gap: 0;
  animation: none;
}

/* ============================================================
   Animaciones
   ============================================================ */

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.6) translateY(14px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes unlock {
  from {
    opacity: 0;
    transform: scale(1.12);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes dock-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(60px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* shake del passcode de iOS */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

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

/* ============================================================
   Mobile
   ============================================================ */

@media (max-width: 640px) {
  .lock-screen {
    gap: 40px;
    justify-content: flex-start;
    padding-top: 18vh;
  }

  .status-bar {
    padding: 16px 20px;
  }

  .home-content {
    padding: 12px 20px 140px;
  }

  .widget {
    padding: 22px 24px;
    margin-bottom: 40px;
  }

  .widget-date {
    display: none;
  }

  .apps-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 26px 8px;
  }

  .app-item {
    width: 100%;
  }

  .app-icon {
    width: 64px;
    height: 64px;
    font-size: 31px;
  }

  .dock {
    bottom: 14px;
    gap: 14px;
    padding: 11px 16px;
  }

  .dock .app-icon {
    width: 52px;
    height: 52px;
    font-size: 25px;
  }
}
