/* =========================================================
   assets\css\environment_table.css
   ========================================================= */

:root {
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.48);
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 14px 40px rgba(15, 23, 42, 0.12);
  --text-main: #0f172a;
  --text-soft: #64748b;
  --line-soft: rgba(148, 163, 184, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text-main);
  background:
    radial-gradient(circle at top left, rgba(14, 165, 233, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(99, 102, 241, 0.10), transparent 24%),
    radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.10), transparent 24%),
    linear-gradient(180deg, #f8fbff 0%, #eef5fb 100%);
}

.page-wrap {
  position: relative;
  z-index: 1;
}

.floating-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.floating-bg span {
  position: absolute;
  display: block;
  border-radius: 999px;
  filter: blur(8px);
  opacity: 0.32;
  animation: floatBlob 12s ease-in-out infinite;
  will-change: transform;
}

.floating-bg span:nth-child(1) {
  width: 180px;
  height: 180px;
  left: 4%;
  top: 10%;
  background: rgba(14, 165, 233, 0.15);
}

.floating-bg span:nth-child(2) {
  width: 220px;
  height: 220px;
  right: 8%;
  top: 18%;
  background: rgba(129, 140, 248, 0.14);
  animation-delay: -2s;
}

.floating-bg span:nth-child(3) {
  width: 160px;
  height: 160px;
  left: 18%;
  bottom: 12%;
  background: rgba(16, 185, 129, 0.12);
  animation-delay: -5s;
}

.floating-bg span:nth-child(4) {
  width: 210px;
  height: 210px;
  right: 14%;
  bottom: 8%;
  background: rgba(251, 191, 36, 0.12);
  animation-delay: -7s;
}

@keyframes floatBlob {
  0%, 100% {
    transform: translateY(0) translateX(0) scale(1);
  }
  50% {
    transform: translateY(-16px) translateX(8px) scale(1.04);
  }
}

.glass-card {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid rgba(226, 232, 240, 0.65);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.hero-card {
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 260px;
  height: 260px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.18), transparent 70%);
  pointer-events: none;
}

.summary-badge {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .45rem .8rem;
  border-radius: 9999px;
  font-size: .72rem;
  font-weight: 700;
  color: #0f172a;
  background: rgba(255,255,255,.74);
  border: 1px solid rgba(226,232,240,.9);
  box-shadow: 0 5px 14px rgba(15,23,42,.05);
}

.last-update-pill {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem .9rem;
  border-radius: 9999px;
  background: rgba(255,255,255,.78);
  border: 1px solid rgba(226,232,240,.85);
  font-size: .8rem;
  color: #334155;
  box-shadow: 0 6px 18px rgba(15,23,42,.06);
}

.last-update-dot {
  width: .6rem;
  height: .6rem;
  border-radius: 9999px;
  background: #10b981;
  box-shadow: 0 0 0 5px rgba(16,185,129,.14);
  animation: pulseDot 1.8s infinite;
}

@keyframes pulseDot {
  0% {
    box-shadow: 0 0 0 0 rgba(16,185,129,.24);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(16,185,129,0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16,185,129,0);
  }
}

.refresh-btn {
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 22px rgba(2, 132, 199, 0.25);
}

.refresh-btn:hover {
  transform: translateY(-1px);
}

.refresh-btn:disabled {
  cursor: wait;
}

.refresh-icon {
  transition: transform .5s ease;
}

.refresh-btn.loading .refresh-icon {
  animation: spinRefresh 0.9s linear infinite;
}

@keyframes spinRefresh {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* =======================
   ENV CARDS
   ======================= */
.env-card {
  position: relative;
  overflow: hidden;
  min-height: 220px;
  box-shadow: var(--shadow-card);
  isolation: isolate;
  will-change: transform, box-shadow;
  animation: cardFloat 6s ease-in-out infinite;
}

.env-card:nth-child(2) {
  animation-delay: -1s;
}

.env-card:nth-child(3) {
  animation-delay: -2s;
}

.env-card:nth-child(4) {
  animation-delay: -3s;
}

.env-card:nth-child(5) {
  animation-delay: -4s;
}

.env-card:nth-child(6) {
  animation-delay: -5s;
}

@keyframes cardFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

.env-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.10), transparent 45%);
  pointer-events: none;
}

.env-bg-glow {
  position: absolute;
  width: 180px;
  height: 180px;
  right: -40px;
  top: -40px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255,255,255,.26), transparent 72%);
  filter: blur(8px);
  pointer-events: none;
  animation: glowPulse 4.8s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% {
    transform: scale(1);
    opacity: .9;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

.avg-number {
  letter-spacing: -0.03em;
  line-height: 1;
}

.status-soft {
  display: inline-flex;
  align-items: center;
  padding: .38rem .7rem;
  border-radius: 9999px;
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(6px);
  font-weight: 600;
}

/* =======================
   PM CARD
   ======================= */
.pm-card {
  animation:
    cardFloat 6s ease-in-out infinite,
    pmSoftPulse 3s ease-in-out infinite;
}

.pm-card.high {
  animation:
    cardFloat 6s ease-in-out infinite,
    pmDangerPulse 1.8s ease-in-out infinite;
}

@keyframes pmSoftPulse {
  0%, 100% {
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.12);
  }
  50% {
    box-shadow: 0 18px 42px rgba(56, 189, 248, 0.22);
  }
}

@keyframes pmDangerPulse {
  0%, 100% {
    box-shadow: 0 14px 40px rgba(15, 23, 42, 0.12);
  }
  50% {
    box-shadow: 0 18px 42px rgba(220, 38, 38, 0.36);
  }
}

.pm-particles {
  position: absolute;
  inset: auto 0 0 0;
  height: 70px;
  pointer-events: none;
  overflow: hidden;
}

.pm-particles i {
  position: absolute;
  display: block;
  border-radius: 9999px;
  background: rgba(255,255,255,.72);
  opacity: .42;
  animation: floatDust 5s linear infinite;
  will-change: transform, opacity;
}

.pm-particles.fast i {
  opacity: .52;
}

@keyframes floatDust {
  0% {
    transform: translateY(0) translateX(0) scale(1);
    opacity: 0;
  }
  20% {
    opacity: .48;
  }
  100% {
    transform: translateY(-90px) translateX(16px) scale(.86);
    opacity: 0;
  }
}

/* =======================
   THERMO
   ======================= */
.thermo-shell {
  position: absolute;
  right: 16px;
  bottom: 12px;
  opacity: 0.96;
  animation: thermoBob 3.6s ease-in-out infinite;
}

@keyframes thermoBob {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.thermo-fill {
  transform-origin: center bottom;
  transition: transform .45s ease, fill .35s ease;
  animation: thermoPulse 2s ease-in-out infinite alternate;
}

@keyframes thermoPulse {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.25);
  }
}

/* =======================
   HUMIDITY
   ======================= */
.humidity-card {
  overflow: hidden;
}

.humidity-wave {
  position: absolute;
  left: -8%;
  right: -8%;
  bottom: -12px;
  height: 72px;
  background:
    radial-gradient(circle at 20px 20px, rgba(255,255,255,.20) 0 20px, transparent 21px) repeat-x;
  background-size: 72px 52px;
  opacity: .85;
  animation: moveWave 3s linear infinite;
  will-change: transform;
}

@keyframes moveWave {
  from { transform: translateX(0); }
  to { transform: translateX(72px); }
}

/* =======================
   LIGHT
   ======================= */
.light-card {
  color: #6b3d00;
}

.light-card .status-soft {
  background: rgba(255,255,255,.28);
  color: #6b3d00;
}

.sun-core {
  position: absolute;
  right: 18px;
  top: 20px;
  width: 68px;
  height: 68px;
  border-radius: 9999px;
  background:
    radial-gradient(circle, rgba(255,255,255,.95) 0%, rgba(255,247,204,.95) 34%, rgba(255,224,102,.74) 64%, rgba(255,224,102,0) 100%);
  box-shadow: 0 0 40px rgba(255,255,255,.40);
  animation: sunGlow 2.8s ease-in-out infinite;
}

@keyframes sunGlow {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 40px rgba(255,255,255,.40);
  }
  50% {
    transform: scale(1.06);
    box-shadow: 0 0 56px rgba(255,255,255,.50);
  }
}

/* =======================
   WIND CARD
   ======================= */
.wind-svg {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 84px;
  height: 84px;
  opacity: 0.95;
}

.wind-rotor {
  transform-origin: 32px 22px;
  animation: spinRotor 2.8s linear infinite;
  will-change: transform;
}

@keyframes spinRotor {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.wind-speed-chip {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem .72rem;
  border-radius: 9999px;
  font-size: .78rem;
  font-weight: 700;
  color: #ecfeff;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(6px);
}

/* =======================
   TABLE
   ======================= */
.table-shell {
  position: relative;
}

.table-row {
  opacity: 0;
  transform: translateY(8px);
  animation: rowFadeUp .45s ease forwards;
}

@keyframes rowFadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.metric-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: .38rem .68rem;
  border-radius: 9999px;
  font-size: .8rem;
  font-weight: 700;
  background: #f8fafc;
  color: #334155;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.metric-chip.pm.good {
  background: rgba(16,185,129,.10);
  color: #047857;
  border-color: rgba(16,185,129,.22);
}

.metric-chip.pm.mid {
  background: rgba(245,158,11,.10);
  color: #b45309;
  border-color: rgba(245,158,11,.22);
}

.metric-chip.pm.bad {
  background: rgba(239,68,68,.10);
  color: #b91c1c;
  border-color: rgba(239,68,68,.22);
}

.metric-chip.temp {
  background: rgba(251,113,133,.10);
  color: #be123c;
  border-color: rgba(251,113,133,.22);
}

.metric-chip.hum {
  background: rgba(59,130,246,.10);
  color: #1d4ed8;
  border-color: rgba(59,130,246,.22);
}

.metric-chip.light {
  background: rgba(250,204,21,.14);
  color: #854d0e;
  border-color: rgba(250,204,21,.25);
}

.metric-chip.wind {
  background: rgba(20,184,166,.12);
  color: #0f766e;
  border-color: rgba(20,184,166,.24);
}

/* =======================
   LOADING
   ======================= */
.loading-shimmer {
  position: relative;
  overflow: hidden;
  border-radius: 9999px;
  background: linear-gradient(90deg, #e2e8f0 25%, #f8fafc 50%, #e2e8f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.15s linear infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =========================================================
   Wind Direction Compass Arrow (map-style icon)
   ========================================================= */

.direction-card .direction-card-compass {
  display: flex;
  align-items: center;
  justify-content: center;
}

.direction-card .wind-compass {
  position: relative;
  width: 154px;
  height: 154px;
  margin: 0 auto;
  border-radius: 9999px;
  animation: compassFloat 4.5s ease-in-out infinite;
}

.direction-card .wind-compass.large {
  width: 154px;
  height: 154px;
}

@keyframes compassFloat {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.direction-card .compass-ring {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  border: 3px solid rgba(255, 255, 255, 0.34);
  box-shadow:
    inset 0 0 18px rgba(255,255,255,0.10),
    0 10px 25px rgba(0,0,0,0.10);
  backdrop-filter: blur(3px);
}

.direction-card .compass-label {
  position: absolute;
  z-index: 5;
  user-select: none;
  font-size: 13px;
  line-height: 1;
  font-weight: 800;
  color: rgba(255,255,255,0.96);
  text-shadow: 0 1px 4px rgba(0,0,0,0.20);
}

.direction-card .compass-n {
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.direction-card .compass-e {
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.direction-card .compass-s {
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.direction-card .compass-w {
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.direction-card .compass-tick {
  position: absolute;
  z-index: 2;
  border-radius: 999px;
  background: rgba(255,255,255,0.45);
}

.direction-card .tick-n,
.direction-card .tick-s {
  width: 2px;
  height: 12px;
  left: 50%;
  transform: translateX(-50%);
}

.direction-card .tick-n {
  top: 24px;
}

.direction-card .tick-s {
  bottom: 24px;
}

.direction-card .tick-e,
.direction-card .tick-w {
  width: 12px;
  height: 2px;
  top: 50%;
  transform: translateY(-50%);
}

.direction-card .tick-e {
  right: 24px;
}

.direction-card .tick-w {
  left: 24px;
}

.direction-card .compass-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 88px;
  height: 88px;
  z-index: 4;
  pointer-events: none;
  transform: translate(-50%, -50%) rotate(0deg);
  transform-origin: 50% 50%;
  transition: transform 0.45s ease;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.18));
  will-change: transform;
}

.direction-card .compass-arrow svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.direction-card .compass-arrow .arrow-body {
  fill: #28c7f7;
  stroke: rgba(255,255,255,0.96);
  stroke-width: 2.6;
  stroke-linejoin: round;
}

.direction-card .compass-arrow .arrow-core {
  fill: rgba(255,255,255,0.98);
}

.direction-card .compass-arrow .arrow-shadow {
  fill: rgba(0,0,0,0.08);
}

.direction-card .compass-center-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  z-index: 6;
  border-radius: 9999px;
  background: #ffffff;
  transform: translate(-50%, -50%);
  box-shadow:
    0 0 0 4px rgba(255,255,255,0.16),
    0 2px 8px rgba(0,0,0,0.12);
  animation: centerPulse 2.2s ease-in-out infinite;
}

@keyframes centerPulse {
  0%, 100% {
    box-shadow:
      0 0 0 4px rgba(255,255,255,0.16),
      0 2px 8px rgba(0,0,0,0.12);
  }
  50% {
    box-shadow:
      0 0 0 7px rgba(255,255,255,0.10),
      0 2px 10px rgba(0,0,0,0.14);
  }
}

.direction-card .wind-compass::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 9999px;
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: inset 0 0 18px rgba(255,255,255,0.06);
  pointer-events: none;
}

/* =======================
   MISC
   ======================= */
a, button {
  transition: all .2s ease;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(14, 165, 233, 0.35);
  outline-offset: 2px;
}

::selection {
  background: rgba(56, 189, 248, 0.22);
}

/* =======================
   RESPONSIVE
   ======================= */
@media (max-width: 1280px) {
  .env-card {
    min-height: 205px;
  }
}

@media (max-width: 768px) {
  .env-card {
    min-height: 190px;
  }

  .sun-core {
    width: 58px;
    height: 58px;
  }

  .wind-svg {
    width: 74px;
    height: 74px;
  }

  .thermo-shell {
    transform-origin: bottom right;
  }

  .last-update-pill {
    padding: .55rem .8rem;
    font-size: .76rem;
  }
}

@media (max-width: 640px) {
  .direction-card .wind-compass,
  .direction-card .wind-compass.large {
    width: 136px;
    height: 136px;
  }

  .direction-card .compass-label {
    font-size: 12px;
  }

  .direction-card .compass-arrow {
    width: 76px;
    height: 76px;
  }

  .direction-card .compass-center-dot {
    width: 12px;
    height: 12px;
  }

  .summary-badge {
    font-size: .68rem;
    padding: .4rem .7rem;
  }

  .metric-chip {
    min-width: 78px;
    font-size: .75rem;
  }

  .env-card {
    min-height: 180px;
  }
}

/* หมายเหตุ:
   ปิด reduced-motion ชั่วคราว เพื่อให้ animation แสดงผลครบ
   ถ้าต้องการรองรับ accessibility ภายหลัง ค่อยเปิดกลับได้ */