/* ==========================================================================
   Malapascua Weather — High-Tech Forecast UI
   ========================================================================== */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #0f1520;
  --bg-card: #141c2b;
  --bg-card-hover: #1a2436;
  --border: #1e2a3e;
  --border-glow: #2a4a7f;
  --text-primary: #e8ecf4;
  --text-secondary: #8892a4;
  --text-muted: #4a5568;
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.15);
  --accent-glow: rgba(0, 212, 255, 0.3);
  --warm: #ff6b35;
  --warm-dim: rgba(255, 107, 53, 0.15);
  --success: #00e676;
  --warning: #ffab00;
  --danger: #ff5252;
  --font-primary: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-primary);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

/* ==========================================================================
   Loader
   ========================================================================== */

.loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  transition: opacity 0.6s var(--ease), visibility 0.6s;
}

.loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.loader-ring {
  width: 64px;
  height: 64px;
  position: relative;
}

.loader-ring::before,
.loader-ring::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
}

.loader-ring::before {
  border-top-color: var(--accent);
  animation: loaderSpin 1s linear infinite;
}

.loader-ring::after {
  border-bottom-color: var(--warm);
  animation: loaderSpin 1.5s linear infinite reverse;
}

.loader-ring-inner {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-left-color: var(--accent);
  border-right-color: var(--warm);
  animation: loaderSpin 2s linear infinite;
}

@keyframes loaderSpin {
  to {
    transform: rotate(360deg);
  }
}

.loader-text {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--text-secondary);
  animation: loaderPulse 1.5s ease-in-out infinite;
}

@keyframes loaderPulse {
  0%, 100% {
    opacity: 0.4;
  }

  50% {
    opacity: 1;
  }
}

/* ==========================================================================
   App Container
   ========================================================================== */

.app {
  opacity: 0;
  transition: opacity 0.6s var(--ease) 0.3s;
}

.app.visible {
  opacity: 1;
}

/* ==========================================================================
   Header
   ========================================================================== */

.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(10, 14, 23, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.header-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--text-secondary);
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-coords {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.cache-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

.cache-indicator.live {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.cache-indicator.cached {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.cache-indicator.error {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

/* ==========================================================================
   Hero / Current Weather
   ========================================================================== */

.hero {
  min-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 100px 24px 60px;
  overflow: hidden;
}

.hero-bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 212, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 255, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black, transparent);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, black, transparent);
}

.hero-content {
  text-align: center;
  position: relative;
  z-index: 2;
}

.hero-location {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.hero-pin {
  font-size: 8px;
  animation: heroPinPulse 2s ease-in-out infinite;
}

@keyframes heroPinPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(1.5);
  }
}

.hero-temp {
  font-size: clamp(80px, 18vw, 180px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -4px;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.hero-condition {
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 300;
  color: var(--text-secondary);
  margin-bottom: 40px;
  text-transform: capitalize;
}

.hero-details {
  display: flex;
  gap: 32px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 32px;
}

.hero-detail {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hero-detail-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hero-detail-value {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
}

.hero-updated {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.hero-weather-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  font-size: clamp(200px, 40vw, 400px);
  opacity: 0.04;
  z-index: 1;
  line-height: 1;
  pointer-events: none;
}

/* ==========================================================================
   Sections Common
   ========================================================================== */

.section {
  padding: 80px 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.section-header {
  margin-bottom: 40px;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--accent);
  text-transform: uppercase;
  display: block;
  margin-bottom: 8px;
}

.section-title {
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 600;
  letter-spacing: -0.5px;
}

/* ==========================================================================
   Hourly Forecast
   ========================================================================== */

.hourly-section {
  max-width: 100%;
  padding-left: 24px;
  padding-right: 0;
}

.hourly-section .section-header {
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  padding-right: 24px;
}

.hourly-scroll {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 4px 24px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  scroll-snap-type: x mandatory;
}

.hourly-scroll::-webkit-scrollbar {
  height: 4px;
}

.hourly-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.hourly-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.hourly-card {
  flex: 0 0 90px;
  scroll-snap-align: start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: border-color 0.3s, background 0.3s;
}

.hourly-card:hover {
  border-color: var(--border-glow);
  background: var(--bg-card-hover);
}

.hourly-card.now {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.hourly-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.hourly-icon {
  font-size: 28px;
  line-height: 1;
}

.hourly-temp {
  font-size: 18px;
  font-weight: 600;
}

.hourly-rain {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
}

/* ==========================================================================
   Daily Forecast
   ========================================================================== */

.daily-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.daily-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 120px 50px 1fr 100px;
  align-items: center;
  gap: 16px;
  transition: border-color 0.3s, background 0.3s, transform 0.3s var(--ease);
}

.daily-card:hover {
  border-color: var(--border-glow);
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.daily-card.today {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.daily-day {
  font-weight: 500;
}

.daily-day-name {
  font-size: 15px;
}

.daily-day-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.daily-icon {
  font-size: 32px;
  text-align: center;
}

.daily-bar-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.daily-temp-low {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

.daily-temp-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.daily-temp-bar-fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--warm));
  transition: left 0.6s var(--ease), right 0.6s var(--ease);
}

.daily-temp-high {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  min-width: 36px;
}

.daily-meta {
  text-align: right;
}

.daily-condition {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.daily-rain-chance {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
}

/* ==========================================================================
   Details Grid
   ========================================================================== */

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s, transform 0.3s var(--ease);
}

.detail-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-2px);
}

.detail-card-icon {
  font-size: 20px;
  margin-bottom: 12px;
}

.detail-card-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.detail-card-value {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 4px;
}

.detail-card-sub {
  font-size: 13px;
  color: var(--text-secondary);
}

.detail-card-bg {
  position: absolute;
  bottom: -10px;
  right: -10px;
  font-size: 80px;
  opacity: 0.04;
  line-height: 1;
  pointer-events: none;
}

/* ==========================================================================
   Tides
   ========================================================================== */

.tide-timeline {
  display: flex;
  gap: 12px;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.tide-card {
  flex: 0 0 140px;
  scroll-snap-align: start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  position: relative;
  transition: border-color 0.3s, transform 0.3s var(--ease);
}

.tide-card:hover {
  transform: translateY(-2px);
}

.tide-card.next {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-dim);
}

.tide-card.past {
  opacity: 0.45;
}

.tide-card-type {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.tide-card.high .tide-card-type {
  color: var(--accent);
}

.tide-card.low .tide-card-type {
  color: var(--warm);
}

.tide-card-time {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.5px;
  margin-bottom: 2px;
}

.tide-card-date {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.tide-card-bar {
  width: 32px;
  height: 48px;
  margin: 0 auto 10px;
  background: var(--bg-secondary);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
}

.tide-card-bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  border-radius: 4px;
  transition: height 0.6s var(--ease);
}

.tide-card-bar-fill.high {
  background: linear-gradient(to top, var(--accent-dim), var(--accent));
}

.tide-card-bar-fill.low {
  background: linear-gradient(to top, var(--warm-dim), var(--warm));
}

.tide-card-height {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
}

.tide-card-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--accent);
  color: var(--bg-primary);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 100px;
}

@media (max-width: 480px) {
  .tide-card {
    flex: 0 0 120px;
    padding: 16px 12px;
  }

  .tide-card-time {
    font-size: 17px;
  }
}

/* ==========================================================================
   Advisory
   ========================================================================== */

.advisory-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.advisory-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  border-left: 3px solid var(--accent);
  transition: border-color 0.3s, transform 0.3s var(--ease);
}

.advisory-card:hover {
  transform: translateY(-2px);
}

.advisory-card.warning {
  border-left-color: var(--warning);
}

.advisory-card.danger {
  border-left-color: var(--danger);
}

.advisory-card.success {
  border-left-color: var(--success);
}

.advisory-card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.advisory-card-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ==========================================================================
   Astronomy
   ========================================================================== */

.astro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.astro-moon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
}

.astro-moon-emoji {
  font-size: 64px;
  line-height: 1;
  margin-bottom: 12px;
}

.astro-moon-name {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.astro-moon-illum {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.astro-moon-bar {
  width: 100%;
  max-width: 180px;
  height: 6px;
  margin: 0 auto;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}

.astro-moon-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 3px;
  transition: width 0.6s var(--ease);
}

.astro-times {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.astro-time-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.astro-time-icon {
  font-size: 20px;
  width: 32px;
  text-align: center;
}

.astro-time-label {
  font-size: 14px;
  color: var(--text-secondary);
  flex: 1;
}

.astro-time-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

@media (max-width: 600px) {
  .astro-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Island Insights
   ========================================================================== */

.insights-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: -28px;
  margin-bottom: 32px;
}

.insights-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.insight-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  border-left: 3px solid var(--accent);
  transition: transform 0.3s var(--ease);
}

.insight-card:hover {
  transform: translateX(4px);
}

.insight-card.warning {
  border-left-color: var(--warning);
}

.insight-card.danger {
  border-left-color: var(--danger);
}

.insight-card.success {
  border-left-color: var(--success);
}

.insight-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 40px;
  text-align: center;
}

.insight-content {
  flex: 1;
  min-width: 0;
}

.insight-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.insight-body {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
  border-top: 1px solid var(--border);
  padding: 48px 24px;
  text-align: center;
}

.footer-brand {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.footer-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.footer-copy {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.5;
}

/* ==========================================================================
   Reveal Animations
   ========================================================================== */

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Error State
   ========================================================================== */

.error-state {
  text-align: center;
  padding: 40px 24px;
}

.error-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-state-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.error-state-body {
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 400px;
  margin: 0 auto 24px;
}

.error-state-btn {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 2px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.3s;
}

.error-state-btn:hover {
  background: var(--accent-glow);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1024px) {
  .daily-card {
    grid-template-columns: 100px 40px 1fr 80px;
  }
}

@media (max-width: 768px) {
  .header {
    padding: 12px 16px;
  }

  .header-coords {
    display: none;
  }

  .hero {
    padding: 80px 16px 40px;
  }

  .hero-details {
    gap: 20px;
  }

  .section {
    padding: 60px 16px;
  }

  .daily-card {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 8px 16px;
    padding: 16px;
  }

  .daily-day {
    grid-column: 1;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .daily-icon {
    display: none;
  }

  .daily-bar-container {
    grid-column: 1 / -1;
  }

  .daily-meta {
    grid-column: 2;
    grid-row: 1;
  }

  .details-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .advisory-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .hero-temp {
    letter-spacing: -2px;
  }

  .hero-details {
    gap: 16px;
  }

  .hero-detail-value {
    font-size: 16px;
  }

  .hourly-card {
    flex: 0 0 76px;
    padding: 12px 8px;
  }

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

  .detail-card {
    padding: 16px;
  }

  .detail-card-value {
    font-size: 22px;
  }
}
