:root {
  --wallpaper:
    radial-gradient(120% 80% at 15% 5%, #ff8a5c 0%, transparent 55%),
    radial-gradient(110% 90% at 95% 35%, #8a5cff 0%, transparent 60%),
    radial-gradient(120% 90% at 40% 110%, #1fb6ff 0%, transparent 60%),
    #2b1a5a;
  --label: #fff;
  --text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  --dock-bg: rgba(255, 255, 255, 0.28);
  --dock-border: rgba(255, 255, 255, 0.35);
  --icon-shadow:
    0 1px 1.5px rgba(20, 8, 50, 0.22),
    0 10px 22px -8px rgba(20, 8, 50, 0.55);
  --icon-shadow-lift:
    0 2px 3px rgba(20, 8, 50, 0.2),
    0 18px 30px -10px rgba(20, 8, 50, 0.6);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --focus: #fff;

  --cols: 4;
  --icon-size: 62px;
  --label-size: 12px;
  --row-gap: 28px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --wallpaper:
      radial-gradient(120% 80% at 15% 5%, #9c3a22 0%, transparent 55%),
      radial-gradient(110% 90% at 95% 35%, #3b2a8f 0%, transparent 60%),
      radial-gradient(120% 90% at 40% 110%, #0d5a85 0%, transparent 60%),
      #120c26;
    --dock-bg: rgba(40, 40, 50, 0.45);
    --dock-border: rgba(255, 255, 255, 0.12);
  }
}

@media (min-width: 600px) {
  :root { --cols: 6; --icon-size: 72px; --label-size: 13px; --row-gap: 32px; }
}

@media (min-width: 1024px) {
  :root { --cols: 8; --icon-size: 76px; }
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100dvh;
  color: var(--label);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  background: #2b1a5a;
}

/* Wallpaper fijo: background-attachment: fixed no funciona en iOS. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--wallpaper);
}

.screen {
  max-width: 960px;
  margin: 0 auto;
  padding:
    calc(48px + env(safe-area-inset-top))
    calc(20px + env(safe-area-inset-right))
    calc(140px + env(safe-area-inset-bottom))
    calc(20px + env(safe-area-inset-left));
}

.clock {
  margin-bottom: 44px;
  text-align: center;
  text-shadow: var(--text-shadow);
}

.clock__time {
  display: block;
  font-size: clamp(64px, 20vw, 104px);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}

.clock__date {
  margin: 8px 0 0;
  font-size: 17px;
  font-weight: 500;
}

.clock__date::first-letter { text-transform: uppercase; }

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  row-gap: var(--row-gap);
  justify-items: center;
}

.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  color: inherit;
  text-decoration: none;
  outline: none;
}

.icon {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--icon-size);
  height: var(--icon-size);
  overflow: hidden;
  border-radius: 22.5%;
  background-color: #fff;
  box-shadow: var(--icon-shadow);
  transition: transform 0.35s var(--spring), box-shadow 0.35s, filter 0.2s;
}

/* Squircle real donde el navegador lo soporta. */
@supports (corner-shape: squircle) {
  .icon { border-radius: 32%; corner-shape: squircle; }
}

/* Canto de cristal: luz arriba, sombra abajo. */
.icon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

.icon--image { background-color: transparent; }

.icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.icon--emoji,
.icon--initial {
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(0, 0, 0, 0.1));
  line-height: 1;
}

.icon--emoji { font-size: calc(var(--icon-size) * 0.56); }

.icon--initial {
  color: #fff;
  font-size: calc(var(--icon-size) * 0.46);
  font-weight: 600;
}

.app__label {
  max-width: calc(var(--icon-size) + 18px);
  overflow: hidden;
  font-size: var(--label-size);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
  text-overflow: ellipsis;
  text-shadow: var(--text-shadow);
  white-space: nowrap;
}

@media (hover: hover) {
  .app:hover .icon {
    transform: translateY(-4px) scale(1.04);
    box-shadow: var(--icon-shadow-lift);
  }
}

.app:active .icon {
  transform: scale(0.9);
  filter: brightness(0.85);
  transition-duration: 0.12s;
}

/* Entrada única al cargar: los iconos aparecen en cascada. */
.grid .app {
  animation: pop-in 0.55s var(--spring) both;
  animation-delay: calc(var(--i, 0) * 45ms + 80ms);
}

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

.app:focus-visible .icon {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  z-index: 1;
  display: flex;
  justify-content: space-around;
  gap: 20px;
  width: calc(100% - 24px);
  max-width: 420px;
  padding: 14px 18px;
  transform: translateX(-50%);
  border: 1px solid var(--dock-border);
  border-radius: 34px;
  background: var(--dock-bg);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}

.empty {
  text-align: center;
  font-size: 17px;
  text-shadow: var(--text-shadow);
}

@media (prefers-reduced-motion: reduce) {
  .icon { transition: none; }
  .grid .app { animation: none; }
  .app:hover .icon,
  .app:active .icon { transform: none; }
}
