/* =========================================
   1. VARIABLES & ACCESSIBLE THEMES
   ========================================= */
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/JetBrainsMono-Thin.ttf") format("truetype");
  font-weight: 100;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Arabic Sans";
  src: local("Arial"), local("Helvetica"), local("Tahoma");
  unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF;
}

:root {
  /* Base Colors */
  --color-black: #000000;
  --color-white: #ffffff;

  /* Semantic Thermal Themes (High Accessibility, Visually Distinct: Blue -> Red) */
  /* Day backgrounds are vibrant; text is pure black for AAA contrast ratio */
  --theme-freezing-bg: #64B5F6; /* Bright Blue */
  --theme-cold-bg: #4DD0E1;     /* Bright Cyan */
  --theme-cool-bg: #81C784;     /* Bright Green */
  --theme-mild-bg: #FFF176;     /* Bright Yellow */
  --theme-warm-bg: #FFB74D;     /* Bright Orange */
  --theme-hot-bg: #FF8A65;      /* Deep Orange */
  --theme-scorching-bg: #E57373;/* Red */

  --theme-day-text: #000000;

  /* Night text colors against pure black background */
  --theme-freezing-night: #90CAF9;
  --theme-cold-night: #80DEEA;
  --theme-cool-night: #A5D6A7;
  --theme-mild-night: #FFF59D;
  --theme-warm-night: #FFCC80;
  --theme-hot-night: #FFAB91;
  --theme-scorching-night: #EF9A9A;

  /* Layout Sizes */
  --size-icon-header: 10em;
  --size-icon-list: 6em;
  --size-icon-scroll: 3em;

  /* Borders */
  --border-thin: 1px solid var(--color-black);
  --border-bold: 2px solid var(--color-black);
  --border-heavy: 8px solid var(--color-black);

  /* Typography */
  --font-sm: 16px;
  --font-base: 18px;
  --font-lg: 24px;
}

/* Theme Dependency Injection mapping */
.theme-freezing { --current-bg: var(--theme-freezing-bg); --current-text: var(--theme-day-text); --current-night: var(--theme-freezing-night); }
.theme-cold { --current-bg: var(--theme-cold-bg); --current-text: var(--theme-day-text); --current-night: var(--theme-cold-night); }
.theme-cool { --current-bg: var(--theme-cool-bg); --current-text: var(--theme-day-text); --current-night: var(--theme-cool-night); }
.theme-mild { --current-bg: var(--theme-mild-bg); --current-text: var(--theme-day-text); --current-night: var(--theme-mild-night); }
.theme-warm { --current-bg: var(--theme-warm-bg); --current-text: var(--theme-day-text); --current-night: var(--theme-warm-night); }
.theme-hot { --current-bg: var(--theme-hot-bg); --current-text: var(--theme-day-text); --current-night: var(--theme-hot-night); }
.theme-scorching { --current-bg: var(--theme-scorching-bg); --current-text: var(--theme-day-text); --current-night: var(--theme-scorching-night); }

.themed-bg {
  background-color: var(--current-bg);
  color: var(--current-text);
}

.themed-bg.is-night {
  background-color: var(--color-black);
  color: var(--current-night);
}

/* Base override for week symbols to maintain contrast in dark mode */
.themed-bg.is-night .week-symbol {
  color: var(--current-night);
}

/* =========================================
   2. RESET & BASE
   ========================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--color-white);
  color: var(--color-black);
  font-family: "JetBrains Mono", "Arabic Sans", Arial, sans-serif;
  font-weight: 100;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

/* =========================================
   3. LAYOUT COMPONENTS
   ========================================= */

/* Header */
#now-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#city-badge {
  font-weight: 900;
  font-size: var(--font-sm);
  letter-spacing: 0.5px;
  padding: 0.5em;
}

#now-icon-box {
  width: var(--size-icon-header);
  height: var(--size-icon-header);
}


#now-temp-and-wind {
  display: flex;
  flex-direction: row;
  align-items: center;
}

#now-temp {
  font-size: var(--font-lg);
  font-weight: 900;
  line-height: 0.8;
}

/* Hourly Section */
.section-title {
  text-align: center;
  font-size: var(--font-base);
  font-weight: bold;
  border-top: var(--border-bold);
  border-bottom: var(--border-bold);
  padding: 0.25em 0;
}

#hourly-wrapper {
  width: 100%;
}

#hourly-container {
  display: flex;
  flex-direction: row;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--color-white);
  min-height: 6em;
  align-items: stretch;
  padding: 0 1em;
  -webkit-overflow-scrolling: touch;
}

.hour-item {
  padding-top: 0.5em;
  border-right: var(--border-thin);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  min-width: 4em;
  flex-shrink: 0;
}

.hour-item:first-child { border-left: var(--border-bold); }
.hour-item:last-child { border-right: var(--border-bold); }
.hour-item.is-current { border-right: var(--border-heavy); }

/* Night mode borders */
.hour-item.is-night {
  border-color: var(--color-white);
}

.hour-item.is-night:first-child {
  border-left-color: var(--color-white);
}

.hour-item.is-night:last-child {
  border-right-color: var(--color-white);
}

.hour-item.is-night.is-current {
  border-right-color: var(--color-white);
}

.hour-time { font-size: var(--font-base); font-weight: 900; }
.hour-icon { width: var(--size-icon-scroll); height: var(--size-icon-scroll); }
.hour-temp { font-size: var(--font-base); font-weight: bold; }
.hour-counts { display: flex; min-height: var(--size-icon-scroll); }
.count-icon { width: var(--size-icon-scroll); height: var(--size-icon-scroll); }

/* Daily Section */
#daily-container {
  width: 100%;
  background: var(--color-white);
  padding-bottom: 4em;
}

.day-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5em 1em;
  border-bottom: var(--border-thin);
}

.day-item:first-child { border-top: var(--border-bold); }
.day-item:last-child { border-bottom: var(--border-bold); }
.day-item.is-today { border-bottom: var(--border-heavy); }

.day-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5em;
}

.week-symbol {
  font-size: var(--font-base);
  line-height: 1;
  font-weight: 900;
  color: var(--color-black);
}

.day-number { font-size: var(--font-base); font-weight: 900; }
.day-icon { width: var(--size-icon-list); height: var(--size-icon-list); }
.day-temps { text-align: left; }
.temp-max { font-size: var(--font-lg); font-weight: 900; display: block; line-height: 0.9; }
.temp-min { font-size: var(--font-sm); opacity: 0.8; display: block; font-weight: bold; }
.day-counts { display: flex; justify-content: flex-end; }

/* Overlay */
#overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--color-white);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

#overlay-msg {
  font-size: var(--font-base);
  font-weight: 900;
  border: 4px solid var(--color-black);
  padding: 1em;
  text-align: center;
}

.loading-spinner { font-size: var(--font-lg); }
.loading-text { font-size: var(--font-sm); font-weight: normal; }