/* style.css (improved, deduplicated) */

/*-------------------------------------------------- */
/* Global Styles & Variable Definitions */
/*-------------------------------------------------- */

:root {
  --bg-main-roof: #ffffff;
  --text-color-primary: #2d3748;
  --text-color-secondary: #4a5568;
  --card-bg-base: rgba(255, 255, 255, 0.7);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --title-color: #4A5568;
  --font-color-hot: #ef4444;
  --font-color-cold: #3b82f6;
  --font-color-humid: #075985;
  --font-color-dry: #f59e0b;
  --divider-color: #d1d5db;

  /* spacing */
  --spacing-unit: min(0.3rem, 0.75vw);
  --card-unified-height: 90px;

  /* Light Mode Gradients */
  --gradient-header-light: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(220, 235, 250, 0.9));
  --gradient-location-light: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(220, 235, 250, 0.9));



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

body {
  font-family: 'Noto Sans KR', 'Inter', sans-serif;
  color: var(--text-color-primary);
  background: var(--bg-main-roof);
  display: flex;
  justify-content: center;
  align-items:  flex-start;
  min-height: 100vh;
  min-width: 290px;
}
a { color: inherit; text-decoration: none; }
/* 다크 배경은 토큰으로 처리되어 body 별도 중복 규칙 제거 */

/*-------------------------------------------------- */
/* Main Layout */
/*-------------------------------------------------- */

#weather-main-container {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-unit);
  width: 100%;
  max-width: 1540px;
  padding: var(--spacing-unit);
}

#weather-cards-container,
.connection-status-line,
.map-link {
  display: grid;
  gap: var(--spacing-unit);
}

/* Columns */
#weather-cards-container { grid-template-columns: repeat(2, 1fr); }
#general-info-cards { grid-template-columns: repeat(3, 1fr); }


/*-------------------------------------------------- */
/* Header */
/*-------------------------------------------------- */

/* Header layout composite */

#main-header {
  display: flex;
  flex-wrap: nowrap; 
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 100px;
  gap: 0.75rem;
  padding: 0.5rem var(--spacing-unit);
  border-radius: 1.5rem;
  box-shadow: var(--shadow-lg);
  background-color: rgba(255, 255, 255, 0.3);
  backdrop-filter: blur(3px);
}


#header-logo-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0.5rem;
  background: rgba(255, 255, 255, 0.3);
  box-shadow: var(--shadow-md);
  width: auto;
  height: 90px;
  flex-shrink: 0;
  justify-content: center;
  white-space: nowrap;
}

html.dark #header-logo-card { background: rgba(0, 0, 0, 0.2); }

.header-title-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  flex-grow: 1;
}

#header-logo { width: 75px; height: 75px; }
#roof-image { width: 65px; height: 65px; object-fit: cover; border-radius: 0.75rem; box-shadow: var(--shadow-md); flex-shrink: 0; }

#header-title {
  font-size: clamp(1rem, 5.2cqw, 1.5rem);
  font-weight: 700;
  color: var(--text-color-secondary);
}

#status-title {1rem, 5cqw, 1.25rem);
  font-weight: 600;
  color: var(--text-color-secondary);
}

/* Rooftop/Ground tags */
.rooftop-tag { font-weight: 700; color: var(--font-color-hot) !important; }
.ground-tag  { font-weight: 700; color: var(--font-color-cold) !important; }

#header-right-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  white-space: nowrap;
  height: 80px;
}

#time-status-card {
  background-color: rgba(255, 255, 255, 0);
  backdrop-filter: blur(10px);
  border-radius: 0.75rem;
  box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
}


.link-and-toggle-container {
  display: flex;
  width: 100%;
  justify-content: flex-end;
  align-items: center;
}

#current-time { font-size: clamp(0.6rem, 3.0cqw, 0.8rem); color: var(--text-color-secondary); line-height: 1.2; }


/*-------------------------------------------------- */
/* Special Report Card */
/*-------------------------------------------------- */

#special-report-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  border-radius: 1rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
  width: 100%;
  height: 90px;
  transition: all 500ms;
}

/*-------------------------------------------------- */
/* Equal Width for Header, Location, Special Report */
/*-------------------------------------------------- */
#main-header,
#location-card,
#special-report-card {
  width: 100%;
  max-width: 100%;
}


/*-------------------------------------------------- */
/* Device Card */
/*-------------------------------------------------- */

.device-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem;
  border-radius: 0.75rem;
  background-color: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(5px);
  box-shadow: var(--shadow-md);
}
html.dark .device-card { background-color: rgba(30, 25, 20, 0.2); }

#device-image { width: 2.8rem; height: 2.8rem; object-fit: cover; border-radius: 0.75rem; box-shadow: var(--shadow-md); }

.device-title { display: flex; align-items: center; }
.device-title i { font-size: clamp(1.5rem, 5.0cqw, 1.875rem); color: #075985; }
.device-title span { font-size: clamp(0.9rem, 3.8cqw, 1.125rem); font-weight: 700; color: #075985; }

#connection-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 9999px;
  background-color: #ef4444;
  margin-right: 0.5rem;
}

#connection-status { font-size: clamp(0.7rem, 3.2cqw, 0.875rem); font-weight: 600; color: #b91c1c; }
#recept-rate       { font-size: clamp(0.6rem, 2.8cqw, 0.75rem); margin-left: 0.25rem; }
#update-time       { font-size: clamp(0.7rem, 3.2cqw, 0.875rem); font-weight: 600; }

.connection-status-line { display: flex; align-items: center; gap: 0.25rem; }

/*-------------------------------------------------- */
/* Weather & Info Cards */
/*-------------------------------------------------- */

.weather-card {
  display: flex;
  flex-direction: column;
  min-height: 100px;
  padding: 0.75rem 0.5rem 0.5rem;
  border-radius: 1.5rem;
  box-shadow: var(--shadow-md);
  flex-grow: 1;
}

.weather-card-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  flex-grow: 1;
}

.card-title {
  font-weight: 700;
  font-size: clamp(1rem, 4.6cqw, 1.25rem);
  margin-bottom: 0.5rem;
  color: var(--title-color);
}

.glow-card {
  flex: 1 1 22.5%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  line-height: 1.375;
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  background-color: rgba(255, 255, 255, 0.4);
  transition: all 0.3s ease-in-out;
  gap: 0.25rem;
  text-align: center;
}
.glow-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.glow-card .text-sm   { font-size: clamp(0.75rem, 3.2cqw, 0.95rem); font-weight: 700; }
.glow-card .text-3xl  { font-size: clamp(1.25rem, 6.0cqw, 1.875rem); font-weight: 700; }
.glow-card .text-2xl  { font-size: clamp(1.125rem, 5.2cqw, 1.5rem); font-weight: 700; }
.glow-card .text-base { font-size: clamp(0.85rem, 3.6cqw, 1rem); }
.glow-card .text-xs   { font-size: clamp(0.65rem, 2.6cqw, 0.8rem); color: var(--text-color-secondary); }

/*-------------------------------------------------- */
/* glow card 레이아웃 수정 */
/* `unit`까지 가로, `time`만 아래로 */
/*-------------------------------------------------- */
.value-unit-time {
  /* 상위 컨테이너를 세로 방향 Flexbox로 변경 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-wrap: nowrap;
  width: 100%; /* 너비를 100%로 설정하여 한 줄에 표시 */
}

/* 값과 단위를 묶는 새로운 HTML 요소를 위한 클래스 */
/* HTML에서 `div`를 추가하여 `.value-unit-group` 클래스를 적용해야 합니다. */
/* 예: <div class="value-unit-group"> ... </div> */
.value-unit-group {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0;
}

/* `unit`과 `time`을 분리하기 위해 CSS 수정 */
/* HTML에서 `at hh:mma` 부분에 별도의 `span` 또는 `div`를 추가해야 합니다. */
.value-unit-time > .text-xs {
    /* 기존 `text-xs` 클래스에 display: block을 적용하여 새로운 줄에 배치 */
    display: block;
    text-align: center;
    width: 100%;
}


/* semantic text colors */
.text-hot { color: var(--font-color-hot); }
.text-cold { color: var(--font-color-cold); }
.text-humid { color: var(--font-color-humid); }
.text-dry { color: var(--font-color-dry); }


/*-------------------------------------------------- */
/* Location & Dark Mode */
/*-------------------------------------------------- */


.time-and-toggle-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1rem;
}


/*-------------------------------------------------- */
/* Animations & Gradients */
/*-------------------------------------------------- */

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}
.dot-pulse-red { animation: pulse-red 2s infinite; }

.gradient-left-to-center { background: #FFFFFF; }
.gradient-center-to-right { background: #FFFFFF; }

/*-------------------------------------------------- */
/* Responsive Overrides */
/*-------------------------------------------------- */

@media (max-width: 891px) {
  body { align-items: flex-start; }
  #weather-main-container { padding: var(--spacing-unit); }
  #weather-cards-container, #general-info-cards { grid-template-columns: 1fr; gap: var(--spacing-unit); }
  #main-header, #location-card, #special-report-card { flex-direction: column; text-align: center; gap: var(--spacing-unit); }
  #header-left-panel { justify-content: center; }
  #header-logo { margin: 0 auto; }
  #header-right-panel, .device-status-box, #location-card-content { align-items: center; }
  #header-right-panel { justify-content: center; gap: var(--spacing-unit); }
  .weather-card-grid { flex-wrap: wrap; }
  .special-report-title-line { flex-direction: column; gap: 0.25rem; }
  .device-status-box { width: fit-content; white-space: nowrap; }
  #connection-status, #update-time { font-size: clamp(0.6rem, 3.0cqw, 0.8rem); white-space: nowrap; }
  #recept-rate { font-size: clamp(0.5rem, 2.6cqw, 0.7rem); white-space: nowrap; }
  #header-logo-card { padding: 0.5rem; white-space: nowrap; }
  #header-logo, #roof-image { width: 45px; height: 45px; white-space: nowrap; }
  #main-header,
  #location-card,
  #special-report-card {
    width: 100%;
    max-width: 100%;
  }

 
  #dark-mode-toggler {
    justify-content: center;
    width: auto;
  }
}

@media (min-width: 290px) {
    .info-card {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 290px) and (max-width: 890px) {
  .weather-card-grid {
    display: flex;
    flex-wrap: wrap;
  }
  .glow-card {
    /* 한 행에 2개씩 배치 */
    flex: 0 0 calc(50% - var(--spacing-unit));
    max-width: calc(50% - var(--spacing-unit));
  }
}

@media (max-width: 289px) {
    /* 399px 이하에서 모든 주요 컨테이너를 1열로 변경 */
    #weather-cards-container,
    #general-info-cards,
    #location-card,
    .info-card {
        grid-template-columns: 1fr;
        flex-direction: column;
    }
    .device-status-box { 
        min-width: unset; 
        max-width: unset; 
        width: 100%; 
        text-align: center; 
    }
}

/*-------------------------------------------------- */
/* Design System Tokens (kept as-is; trimmed duplicates) */
/*-------------------------------------------------- */
/* 원본의 방대한 디자인 토큰 블록은 유지. 중복된 다크/라이트 토큰 반복 정의는 상단에서 통합. */
/* ... (필요시 별도 파일로 분리 권장) */ /* [5][10] */


/*-------------------------------------------------- */
/* Fluid Typography & Overflow-safe Enhancements */
/*-------------------------------------------------- */

/* 컨테이너 쿼리 활성화: 필요한 래퍼에 .cq 부여하여 사용 */
.cq { container-type: inline-size; } /* [13][12] */

/* 유동 폰트 유틸리티 */
.text-fluid-xs   { font-size: clamp(0.65rem, 2.6cqw, 0.8rem); }
.text-fluid-sm   { font-size: clamp(0.75rem, 3.2cqw, 0.95rem); }
.text-fluid-base { font-size: clamp(0.875rem, 3.8cqw, 1.125rem); }
.text-fluid-lg   { font-size: clamp(1rem,    4.6cqw, 1.375rem); }
.text-fluid-xl   { font-size: clamp(1.125rem,5.4cqw, 1.625rem); }
.text-fluid-2xl  { font-size: clamp(1.25rem, 6.2cqw, 1.875rem); } /* [14][12] */

/* 헤더 전용 기울기 */
.header-fluid-xs { font-size: clamp(0.7rem,  3.0cqw, 0.9rem); }
.header-fluid-sm { font-size: clamp(0.85rem, 3.8cqw, 1.1rem); }
.header-fluid-md { font-size: clamp(1rem,    4.6cqw, 1.3rem); }
.header-fluid-lg { font-size: clamp(1.125rem,5.2cqw, 1.5rem); } /* [14] */

/* Flex/Grid 축소 허용 + 오버플로우 안전장치(공통) */
#weather-main-container,
#main-header,
#header-left-panel, #header-right,
#time-status-card,
#weather-cards-container, #general-info-cards,
.weather-card, .weather-card-grid,
.glow-card, .info-card,

/* 줄바꿈 허용 유틸: 긴 문자열/URL도 분할 */
.text-wrap { white-space: normal; overflow-wrap: anywhere; word-break: normal; line-height: 1.3; } /* [15] */

/* 한 줄 고정이 필요한 경우(칩/버튼 등) */
.one-line-fit {
  white-space: nowrap;
  inline-size: 100%;
  overflow: clip;
  font-size: clamp(0.75rem, 4.2cqw, 1rem);
}

/* 가독성 보정 */
.fit-block { line-height: 1.3; letter-spacing: 0.005em; }

/* 컨테이너 타입 직접 부여(마크업에서 .cq 대신) */
#main-header,

.glow-card,
.info-card { container-type: inline-size; } /* [13] */

/* 폴백: cqw 미지원 시 뷰포트 기반 축소 */
@supports not (font-size: 1cqw) {
  .text-fluid-base, #special-report-message { font-size: clamp(0.875rem, 2.2vw, 1.125rem); }
  .text-fluid-lg, .card-title { font-size: clamp(1rem, 2.6vw, 1.25rem); }
  .text-fluid-2xl, .glow-card .text-3xl { font-size: clamp(1.25rem, 3.2vw, 1.875rem); }
  .header-fluid-lg, #header-title, #report-title { font-size: clamp(1rem, 3.0vw, 1.5rem); }
} /* [12][14] */
