/* ═══════════════════════════════════════════════════════════
   style.css — Personal Dashboard
   Tema dark · CSS Grid 12 cols · Responsive
═══════════════════════════════════════════════════════════ */

/* ─── Variables ───────────────────────────────────────────── */
:root {
  /* Base */
  --bg: #0f0f13;
  --surface: #16161e;
  --surface-alt: #1c1c28;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 20px;
  --font: system-ui, -apple-system, "SF Pro Display", "Segoe UI", sans-serif;

  /* Text */
  --text-primary: #f0f0f5;
  --text-secondary: #8888aa;
  --text-dim: #55556a;

  /* Widget accent colors */
  --accent-weather: #3a7bd5;
  --accent-spotify: #1db954;
  --accent-youtube: #ff0000;
  --accent-calendar: #5c6bc0;
  --accent-letterboxd: #e9a13b;
  --accent-reddit: #ff4500;
  --accent-news: #64b5f6;
  --accent-movies: #ab47bc;

  /* Layout */
  --cols: 12;
  --gap: 16px;
  --hero-height: 55vh;
}

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

html,
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ─── Grid helpers ────────────────────────────────────────── */
.zone {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: var(--gap);
  padding: var(--gap);
}

/* ─── Widget base ─────────────────────────────────────────── */
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.widget:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.widget__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.widget__icon {
  font-size: 1rem;
}
.widget__title {
  flex: 1;
}

.widget__body {
  flex: 1;
  padding: 16px;
  overflow: hidden;
}

/* ─── Placeholder state ───────────────────────────────────── */
.widget-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 80px;
  color: var(--text-dim);
  font-size: 0.85rem;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

/* ─── Fade-in animation (widgets al cargar) ───────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.widget {
  animation: fadeInUp 0.5s ease forwards;
}

/* ═══════════════════════════════════════════════════════════
   HERO
═══════════════════════════════════════════════════════════ */
#hero {
  position: relative;
  min-height: var(--hero-height);
  background: #1a1a2e center/cover no-repeat;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px 32px;
  border-radius: 0;
  border: none;
  border-bottom: 1px solid var(--border);
  overflow: visible;
}
#hero:hover {
  transform: none;
  box-shadow: none;
}

.hero__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(10, 10, 18, 0.65) 0%,
    rgba(10, 10, 18, 0.3) 40%,
    rgba(10, 10, 18, 0.8) 100%
  );
  pointer-events: none;
}

.hero__top,
.hero__bottom {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 24px;
}
.hero__bottom {
  align-items: flex-end;
  justify-content: space-between;
}

/* Reloj */
.hero__clock {
  display: flex;
  flex-direction: column;
}
.clock-time {
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 200;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.clock-date {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: capitalize;
}

/* Clima (hero) */
.hero__weather {
  margin-left: auto;
  text-align: right;
  min-height: unset;
  animation: none;
}
.weather__temp {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 300;
  line-height: 1;
}
.weather__icon {
  font-size: 1.4rem;
}
.weather__city {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.weather__condition {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: capitalize;
}

/* Frase */
.hero__quote {
  max-width: 600px;
  min-height: unset;
  animation: none;
  display: block;
  border-left: 3px solid rgba(255, 255, 255, 0.3);
  padding-left: 16px;
}
.quote__text {
  font-size: 1rem;
  font-style: italic;
  line-height: 1.6;
  color: var(--text-primary);
}
.quote__author {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 6px;
  display: block;
}

.hero__apod-credit {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: right;
  min-width: 120px;
}

/* ═══════════════════════════════════════════════════════════
   ZONA MEDIA — col spans desktop
═══════════════════════════════════════════════════════════ */
#widget-spotify {
  grid-column: span 6;
  min-height: 320px;
}
#widget-youtube-stream {
  grid-column: span 3;
  min-height: 320px;
}
#widget-calendar {
  grid-column: span 3;
  min-height: 320px;
}

/* Accent borders */
#widget-spotify {
  border-top: 2px solid var(--accent-spotify);
}
#widget-youtube-stream {
  border-top: 2px solid var(--accent-youtube);
}
#widget-calendar {
  border-top: 2px solid var(--accent-calendar);
}

/* ═══════════════════════════════════════════════════════════
   ZONA BAJA — col spans desktop
═══════════════════════════════════════════════════════════ */
#widget-letterboxd {
  grid-column: span 2;
  min-height: 380px;
}
#widget-reddit {
  grid-column: span 2;
  min-height: 380px;
}
#widget-news {
  grid-column: span 2;
  min-height: 380px;
}
#widget-movies {
  grid-column: span 3;
  min-height: 380px;
}
/* Stack: Deportes arriba + Playlists abajo — comparten la última columna */
#widget-stack-right {
  grid-column: span 3;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#widget-stack-right .widget {
  flex: 1;
  min-height: 0;
}
#widget-sports,
#widget-youtube-feed {
  overflow: hidden;
}

/* Accent borders */
#widget-letterboxd {
  border-top: 2px solid var(--accent-letterboxd);
}
#widget-reddit {
  border-top: 2px solid var(--accent-reddit);
}
#widget-news {
  border-top: 2px solid var(--accent-news);
}
#widget-movies {
  border-top: 2px solid var(--accent-movies);
}
#widget-youtube-feed {
  border-top: 2px solid var(--accent-youtube);
}

/* ═══════════════════════════════════════════════════════════
   BOTONES
═══════════════════════════════════════════════════════════ */
.btn-primary {
  background: linear-gradient(135deg, #4a6cf7, #6a3de8);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-primary:hover {
  opacity: 0.85;
}

.btn-icon {
  background: transparent;
  color: var(--text-dim);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 6px;
  transition:
    color 0.2s,
    background 0.2s;
}
.btn-icon:hover {
  color: var(--text-primary);
  background: var(--border);
}

/* ═══════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(6px);
}
.modal__content {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(90vw, 900px);
  padding: 24px;
}
.modal__close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
}
.modal__close:hover {
  color: var(--text-primary);
}

/* ═══════════════════════════════════════════════════════════
   MODO AMBIENT
═══════════════════════════════════════════════════════════ */
body.ambient .widget__header,
body.ambient #zone-media,
body.ambient #zone-bottom {
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s ease;
}
body.ambient #hero {
  min-height: 100vh;
}
body.ambient .hero__overlay {
  background: linear-gradient(
    180deg,
    rgba(10, 10, 18, 0.85) 0%,
    rgba(10, 10, 18, 0.5) 100%
  );
}
body.ambient .clock-time {
  font-size: clamp(4rem, 12vw, 9rem);
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Tablet (768–1023px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 1023px) {
  :root {
    --cols: 8;
    --hero-height: 45vh;
  }

  #widget-spotify {
    grid-column: span 3;
  }
  #widget-youtube-stream {
    grid-column: span 5;
  }
  #widget-calendar {
    grid-column: span 8;
  }

  #widget-letterboxd {
    grid-column: span 4;
  }
  #widget-reddit {
    grid-column: span 4;
  }
  #widget-news {
    grid-column: span 4;
  }
  #widget-movies {
    grid-column: span 4;
  }
  #widget-youtube-feed {
    grid-column: span 8;
  }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE — Móvil (<768px)
═══════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  :root {
    --cols: 1;
    --hero-height: 40vh;
    --gap: 12px;
  }

  #hero {
    padding: 16px;
  }
  .clock-time {
    font-size: 3rem;
  }

  .zone {
    grid-template-columns: 1fr;
  }

  #widget-spotify,
  #widget-youtube-stream,
  #widget-calendar,
  #widget-letterboxd,
  #widget-reddit,
  #widget-news,
  #widget-movies,
  #widget-youtube-feed {
    grid-column: span 1;
  }

  /* Orden en móvil: Hero → Spotify → Clima → Calendario → YouTube → Noticias → Letterboxd → Reddit */
  #widget-youtube-stream {
    order: 4;
  }
  #widget-news {
    order: 5;
  }
  #widget-letterboxd {
    order: 6;
  }
  #widget-reddit {
    order: 7;
  }
  #widget-movies {
    order: 8;
  }
  #widget-youtube-feed {
    order: 9;
  }

  .hero__bottom {
    flex-direction: column;
    gap: 12px;
  }
  .hero__top {
    flex-direction: column;
    gap: 8px;
  }
  .hero__weather {
    margin-left: 0;
    text-align: left;
  }
}

/* ─── Scrollbar styling ───────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
