/* ============================================================
   NOTIGUÍA — "Parte del Caribe"
   Sistema de diseño: base clara (espuma) + acento aqua + tinta marina.
   Display: Bricolage Grotesque · Cuerpo: Plus Jakarta Sans
   ============================================================ */

:root {
  /* Color */
  --espuma: #eef4f7;
  --espuma-2: #e3edf1;
  --surface: #ffffff;
  --mar: #06303f;
  --ink: #0b2a3a;
  --muted: #5b7282;
  --muted-soft: #8aa0ad;
  --line: rgba(11, 42, 58, 0.1);
  --line-2: rgba(11, 42, 58, 0.06);

  /* Acento único + señales funcionales */
  --aqua: #00b4c4;
  --aqua-deep: #0090a8;
  --aqua-soft: rgba(0, 180, 196, 0.12);
  --verde: #14b87a;
  --ambar: #f0a52e;
  --coral: #ff6b4a;

  /* Tipografía */
  --display: "Bricolage Grotesque", "Plus Jakarta Sans", system-ui, sans-serif;
  --body: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;

  /* Forma y profundidad */
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --shadow-sm: 0 1px 2px rgba(11, 42, 58, 0.05), 0 6px 16px -10px rgba(11, 42, 58, 0.18);
  --shadow-md: 0 2px 6px rgba(11, 42, 58, 0.05), 0 18px 40px -18px rgba(11, 42, 58, 0.28);
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);

  /* Cielo reactivo del hero (lo cambia data-cond) */
  --sky: linear-gradient(160deg, #0a7d9c 0%, #0f9bb4 45%, #18c2d6 100%);
  --sky-glow: rgba(24, 194, 214, 0.35);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 50% -10%, #ffffff 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, var(--espuma) 0%, var(--espuma-2) 100%);
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--mar);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 12px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- App bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  padding: 0.85rem 1.1rem;
  padding-top: calc(0.85rem + env(safe-area-inset-top));
  background: rgba(238, 244, 247, 0.82);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line-2);
}
.appbar-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.appbar-tagline { margin: 0; font-size: 0.82rem; font-weight: 500; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-mark { display: grid; place-items: center; filter: drop-shadow(0 4px 10px rgba(6, 48, 63, 0.25)); }
.brand-logo { height: 60px; width: auto; object-fit: contain; display: block; position: relative; top: 4px; }
.brand-name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.32rem;
  letter-spacing: -0.02em;
  color: var(--mar);
}
.appbar-actions { display: flex; align-items: center; gap: 0.7rem; }
.updated { font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--mar);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}
.btn-refresh:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-refresh:active { transform: translateY(0) scale(0.97); }
.btn-refresh:disabled { opacity: 0.6; cursor: wait; }
.btn-refresh .ico-refresh { color: var(--aqua-deep); }
.btn-refresh.is-loading .ico-refresh { animation: spin 0.9s linear infinite; }

/* ---------- Layout ---------- */
.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.1rem 1.1rem 2rem;
  display: grid;
  gap: 1.1rem;
}

/* ---------- HERO reactivo ---------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  background: var(--sky);
  color: #fff;
  min-height: 232px;
  box-shadow: 0 24px 50px -22px var(--sky-glow), var(--shadow-sm);
  isolation: isolate;
  animation: rise 0.6s var(--ease) both;
}
.hero::after { /* viñeta sutil para legibilidad */
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 80% at 80% 0%, rgba(255, 255, 255, 0.18), transparent 55%),
    linear-gradient(180deg, rgba(0, 0, 0, 0) 40%, rgba(2, 24, 33, 0.28) 100%);
  z-index: -1;
}
.hero-inner { padding: 1.3rem 1.4rem 2.2rem; }
.hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 8px rgba(2, 24, 33, 0.25);
}
.pin {
  width: 8px; height: 8px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25);
}
.hero-temp-row { display: flex; align-items: flex-start; gap: 0.5rem; }
.hero-temp {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(4.2rem, 22vw, 6rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 6px 24px rgba(2, 24, 33, 0.28);
}
.hero-icon { margin-top: 0.5rem; filter: drop-shadow(0 4px 10px rgba(2, 24, 33, 0.25)); }
.hero-icon svg { width: 46px; height: 46px; display: block; }
.hero-cond {
  margin: 0.5rem 0 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 12px rgba(2, 24, 33, 0.28);
}
.hero-sub {
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.88);
  font-variant-numeric: tabular-nums;
}

/* Olas SVG animadas */
.hero-waves {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  width: 100%;
  height: 64px;
  z-index: -1;
}
.hero-waves .wave { fill: rgba(255, 255, 255, 0.16); }
.hero-waves .wave-2 { fill: rgba(255, 255, 255, 0.24); }
.wave-1 { animation: waveMove 11s linear infinite; }
.wave-2 { animation: waveMove 7s linear infinite reverse; }

/* Variantes reactivas del cielo */
.hero[data-cond="tarde"] { --sky: linear-gradient(160deg, #6a3b86 0%, #d65a6e 48%, #ff9a52 100%); --sky-glow: rgba(255, 138, 91, 0.4); }
.hero[data-cond="noche"] { --sky: linear-gradient(165deg, #041d28 0%, #07334a 60%, #0a4763 100%); --sky-glow: rgba(10, 71, 99, 0.5); }
.hero[data-cond="nublado"] { --sky: linear-gradient(160deg, #46627a 0%, #5d7c92 55%, #7493a6 100%); --sky-glow: rgba(93, 124, 146, 0.4); }
.hero[data-cond="lluvia"] { --sky: linear-gradient(160deg, #2d4a5e 0%, #3a5f78 55%, #4c7993 100%); --sky-glow: rgba(58, 95, 120, 0.45); }

/* ---------- Tiles (bento) ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.8rem;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  padding: 0.95rem 1rem 0.85rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
  animation: rise 0.6s var(--ease) both;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.tile-ico {
  display: inline-grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  color: var(--aqua-deep);
  background: var(--aqua-soft);
}
.tile-ico svg { width: 20px; height: 20px; }
.tile-data { display: flex; align-items: baseline; gap: 0.25rem; margin-top: 0.7rem; }
.tile-val {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--mar);
  font-variant-numeric: tabular-nums;
}
.tile-unit { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.tile-label { margin: 0.25rem 0 0; font-size: 0.82rem; color: var(--muted); }
.tile-extra { color: var(--aqua-deep); font-weight: 600; }

/* ---------- Semáforo: ¿salir al mar? ---------- */
.sea-card {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
  border-left: 5px solid var(--muted-soft);
  animation: rise 0.6s var(--ease) both;
}
.sea-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sea-title { margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; color: var(--mar); }
.sea-lights { display: inline-flex; gap: 0.4rem; }
.light { width: 13px; height: 13px; border-radius: 50%; background: rgba(11, 42, 58, 0.12); transition: box-shadow 0.25s var(--ease), background 0.25s var(--ease); }
.sea-estado {
  margin: 0.7rem 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  color: var(--mar);
}
.sea-reco { margin: 0.3rem 0 0; font-size: 0.9rem; color: var(--muted); line-height: 1.5; }

.sea-card[data-estado="ok"] { border-left-color: var(--verde); }
.sea-card[data-estado="ok"] .sea-estado { color: var(--verde); }
.sea-card[data-estado="ok"] .light-ok { background: var(--verde); box-shadow: 0 0 0 4px rgba(20, 184, 122, 0.18), 0 0 14px rgba(20, 184, 122, 0.5); }

.sea-card[data-estado="mid"] { border-left-color: var(--ambar); }
.sea-card[data-estado="mid"] .sea-estado { color: #c47e10; }
.sea-card[data-estado="mid"] .light-mid { background: var(--ambar); box-shadow: 0 0 0 4px rgba(240, 165, 46, 0.18), 0 0 14px rgba(240, 165, 46, 0.5); }

.sea-card[data-estado="no"] { border-left-color: var(--coral); }
.sea-card[data-estado="no"] .sea-estado { color: var(--coral); }
.sea-card[data-estado="no"] .light-no { background: var(--coral); box-shadow: 0 0 0 4px rgba(255, 107, 74, 0.18), 0 0 14px rgba(255, 107, 74, 0.5); }

/* ---------- Transcaribe ---------- */
.transit {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow-sm);
  animation: rise 0.6s var(--ease) both;
}
.transit-head { display: flex; align-items: center; gap: 0.6rem; }
.transit-ico { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #2b6a86; background: rgba(43, 106, 134, 0.12); }
.transit-ico svg { width: 21px; height: 21px; }
.transit-head h2 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.1rem; color: var(--mar); flex: 1; }
.transit-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--verde); box-shadow: 0 0 0 4px rgba(20, 184, 122, 0.16); animation: pulse 2.4s var(--ease) infinite; }
.transit-dot.is-alert { background: var(--ambar); box-shadow: 0 0 0 4px rgba(240, 165, 46, 0.16); }
.transit-summary { margin: 0.75rem 0 0; color: var(--ink); line-height: 1.55; }
.transit-alerts { margin: 0.7rem 0 0; padding: 0; list-style: none; display: grid; gap: 0.5rem; }
.transit-alerts li {
  position: relative;
  padding: 0.55rem 0.7rem 0.55rem 1.9rem;
  font-size: 0.88rem;
  color: var(--ink);
  background: var(--espuma);
  border-radius: var(--r-sm);
  line-height: 1.45;
}
.transit-alerts li::before {
  content: "";
  position: absolute;
  left: 0.7rem; top: 0.95rem;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ambar);
}
.transit-source { margin: 0.7rem 0 0; font-size: 0.78rem; color: var(--muted-soft); }
.transit-source a { color: var(--aqua-deep); }

/* ---------- Noticias (feed editorial) ---------- */
.news { animation: rise 0.6s var(--ease) both; }
.news-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.news-head h2 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; color: var(--mar); }
.news-status { font-size: 0.74rem; color: var(--muted-soft); font-variant-numeric: tabular-nums; }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.feed-item {
  display: block;
  padding: 1rem 0.2rem;
  border-bottom: 1px solid var(--line-2);
  text-decoration: none;
  color: inherit;
  transition: padding-left 0.2s var(--ease);
}
.feed-item:hover { padding-left: 0.5rem; }
.feed-item:last-child { border-bottom: none; }
.feed-eyebrow { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.feed-cat {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--aqua-deep);
}
.feed-cat svg { width: 14px; height: 14px; }
.feed-time { font-size: 0.72rem; color: var(--muted-soft); font-variant-numeric: tabular-nums; }
.feed-time::before { content: "·"; margin-right: 0.5rem; color: var(--line); }
.feed-title { margin: 0; font-family: var(--display); font-weight: 600; font-size: 1.04rem; line-height: 1.3; letter-spacing: -0.01em; color: var(--mar); text-wrap: balance; }
.feed-item:hover .feed-title { color: var(--aqua-deep); }
.feed-detail { margin: 0.3rem 0 0; font-size: 0.88rem; color: var(--muted); line-height: 1.5; text-wrap: pretty; }
.feed-source { margin: 0.4rem 0 0; font-size: 0.74rem; color: var(--muted-soft); }
.feed-source .open { color: var(--aqua-deep); font-weight: 600; }

/* Categorías con su propio matiz (señales sutiles, no decorativas) */
.feed-cat[data-cat="trafico"], .feed-cat[data-cat="movilidad"] { color: #c47e10; }
.feed-cat[data-cat="obras"] { color: #b85c2e; }
.feed-cat[data-cat="transcaribe"] { color: #2b6a86; }
.feed-cat[data-cat="tiempo"], .feed-cat[data-cat="maritimo"], .feed-cat[data-cat="pesca"] { color: var(--aqua-deep); }

/* Estado vacío */
.feed-empty {
  padding: 1.6rem 1rem;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}

/* ---------- Footer ---------- */
.foot { max-width: 760px; margin: 0 auto; padding: 1.4rem 1.2rem calc(2rem + env(safe-area-inset-bottom)); text-align: center; color: var(--muted-soft); }
.foot p { margin: 0.25rem 0; font-size: 0.78rem; line-height: 1.5; }
.foot-credit a { color: var(--aqua-deep); font-weight: 600; text-decoration: none; }
.foot-credit a:hover { text-decoration: underline; }

/* ---------- Skeletons ---------- */
.skeleton-text {
  position: relative;
  color: transparent !important;
  text-shadow: none !important;
  border-radius: 8px;
  background: linear-gradient(100deg, rgba(11, 42, 58, 0.07) 30%, rgba(11, 42, 58, 0.13) 50%, rgba(11, 42, 58, 0.07) 70%);
  background-size: 220% 100%;
  animation: shimmer 1.3s var(--ease) infinite;
}
.hero .skeleton-text { background: linear-gradient(100deg, rgba(255, 255, 255, 0.18) 30%, rgba(255, 255, 255, 0.34) 50%, rgba(255, 255, 255, 0.18) 70%); background-size: 220% 100%; }

/* Reveal escalonado de las secciones */
.hero { animation-delay: 0.02s; }
.metrics .tile:nth-child(1) { animation-delay: 0.08s; }
.metrics .tile:nth-child(2) { animation-delay: 0.13s; }
.metrics .tile:nth-child(3) { animation-delay: 0.18s; }
.metrics .tile:nth-child(4) { animation-delay: 0.23s; }
.sea-card { animation-delay: 0.28s; }
.transit { animation-delay: 0.34s; }
.news { animation-delay: 0.4s; }

/* ---------- Animaciones ---------- */
@keyframes waveMove { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -120% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Accesibilidad ---------- */
:where(a, button):focus-visible {
  outline: 3px solid var(--aqua);
  outline-offset: 2px;
  border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .skeleton-text { animation: none; }
  .wave-1, .wave-2, .transit-dot, .btn-refresh.is-loading .ico-refresh { animation: none; }
}

/* ---------- Responsive ---------- */
@media (min-width: 600px) {
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .hero-inner { padding: 1.6rem 1.8rem 2.4rem; }
}
@media (max-width: 380px) {
  .btn-refresh-label { display: none; }
  .btn-refresh { padding: 0.5rem; }
}
