/* ================================================================
   WORLD CLOCKS — styles.css
   Design direction: deep-navy shell, white/dark cards with a
   "thermal top-border" that shifts from amber (☀️ Day) to indigo
   (🌙 Night) — the card's color temperature IS the content.
   ================================================================ */

/* ----------------------------------------------------------------
   CUSTOM PROPERTIES — Light theme (default)
   ---------------------------------------------------------------- */
:root {
  /* Surface */
  --bg:             #EEF3FA;
  --card-bg:        #FFFFFF;
  --card-border:    #D8E4F0;
  --card-shadow:    0 2px 12px rgba(11, 37, 69, 0.07);
  --card-shadow-lg: 0 8px 32px rgba(11, 37, 69, 0.14);

  /* Chrome */
  --header-bg:      #0B2545;
  --header-text:    #FFFFFF;
  --footer-bg:      #0B2545;

  /* Text */
  --text-primary:   #1A2B3C;
  --text-secondary: #5A7290;
  --text-muted:     #8AA3BB;

  /* Accent */
  --accent:         #0066CC;
  --accent-hover:   #004F9F;

  /* Day badge — warm amber */
  --day-border-a:   #F59E0B;
  --day-border-b:   #FBBF24;
  --day-badge-bg:   #FFF7ED;
  --day-badge-text: #92400E;

  /* Night badge — cool indigo */
  --night-border-a: #3B4FCC;
  --night-border-b: #2563EB;
  --night-badge-bg: #EEF2FF;
  --night-badge-text:#3730A3;

  /* Dark mode night — more visible on dark cards */
  --night-badge-bg-dark:   #1e2a4a;
  --night-badge-text-dark: #93C5FD;

  /* Pins */
  --pin-color:      #E53E3E;
  --pin-pulse:      rgba(229, 62, 62, 0.35);
  --pin-active:     #0066CC;
  --pin-active-pulse: rgba(0, 102, 204, 0.35);

  /* Converter */
  --conv-bg:        #EAF2FF;
  --conv-text:      #004F9F;
  --conv-border:    #BDD6F5;

  /* Misc */
  --divider:        #E8EFF7;
  --radius:         14px;
  --radius-sm:      8px;
  --transition:     all 0.28s ease;
}

/* ----------------------------------------------------------------
   CUSTOM PROPERTIES — Dark theme
   ---------------------------------------------------------------- */
[data-theme="dark"] {
  --bg:             #080F1A;
  --card-bg:        #0F1E35;
  --card-border:    #1C3050;
  --card-shadow:    0 2px 12px rgba(0, 0, 0, 0.35);
  --card-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);

  --header-bg:      #050C17;
  --footer-bg:      #050C17;

  --text-primary:   #D4E6F8;
  --text-secondary: #7A9EC0;
  --text-muted:     #4A6A88;

  --accent:         #4D9DE0;
  --accent-hover:   #70B6F0;

  --day-border-a:   #D97706;
  --day-border-b:   #F59E0B;
  --day-badge-bg:   #2D1A00;
  --day-badge-text: #FCD34D;

  --night-border-a: #1E40AF;
  --night-border-b: #3B82F6;
  --night-badge-bg: #0F1B35;
  --night-badge-text:#93C5FD;

  --pin-color:      #F87171;
  --pin-pulse:      rgba(248, 113, 113, 0.3);
  --pin-active:     #4D9DE0;
  --pin-active-pulse: rgba(77, 157, 224, 0.3);

  --conv-bg:        #0A1828;
  --conv-text:      #7EC8F7;
  --conv-border:    #1C3A5E;

  --divider:        #1C3050;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  color:            var(--text-primary);
  min-height:       100vh;
  display:          flex;
  flex-direction:   column;
  /* Smooth theme transition */
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ----------------------------------------------------------------
   MAP CONTAINER
   Responsive via padding-top aspect-ratio trick.
   Pins are absolute children; ::after adds a tint overlay.
   ---------------------------------------------------------------- */
#mapContainer {
  position:           relative;
  width:              100%;
  /* 5:2 aspect ratio — adjust if the map image crops differently */
  padding-top:        40%;
  background-image:   url('vecteezy_world-map-with-country-names_20833849.jpg');
  background-size:    cover;
  background-position:center center;
  background-repeat:  no-repeat;
  overflow:           hidden;
}

/* Subtle darkening overlay so pins are readable on any map color */
#mapContainer::after {
  content:        '';
  position:       absolute;
  inset:          0;
  background:     rgba(8, 15, 26, 0.22);
  pointer-events: none;
  z-index:        1;
}

/* ----------------------------------------------------------------
   MAP PINS
   ---------------------------------------------------------------- */
.map-pin {
  position:       absolute;
  /* Anchor the base of the pin needle to the coordinate */
  transform:      translate(-50%, -100%);
  z-index:        10;
  background:     none;
  border:         none;
  padding:        0;
  cursor:         pointer;
  display:        flex;
  flex-direction: column;
  align-items:    center;
  gap:            2px;
  transition:     var(--transition);
}

/* The circular dot at the pin's tip */
.pin-dot {
  width:        13px;
  height:       13px;
  background:   var(--pin-color);
  border-radius:50%;
  border:       2px solid rgba(255, 255, 255, 0.9);
  box-shadow:   0 0 0 4px var(--pin-pulse);
  transition:   var(--transition);
  animation:    pinPulse 2.4s ease-out infinite;
}

@keyframes pinPulse {
  0%   { box-shadow: 0 0 0 0   var(--pin-pulse); }
  65%  { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0   transparent; }
}

/* City label — hidden until hover */
.pin-label {
  background:     rgba(8, 15, 26, 0.82);
  color:          #fff;
  font-size:      0.62rem;
  font-weight:    700;
  letter-spacing: 0.4px;
  padding:        2px 7px;
  border-radius:  4px;
  white-space:    nowrap;
  opacity:        0;
  transform:      translateY(3px);
  transition:     var(--transition);
  pointer-events: none;
}

.map-pin:hover .pin-label,
.map-pin:focus-visible .pin-label {
  opacity:   1;
  transform: translateY(0);
}

.map-pin:hover .pin-dot,
.map-pin:focus-visible .pin-dot {
  transform: scale(1.35);
}

/* Active state: fired when a pin is clicked */
.map-pin.active .pin-dot {
  background:  var(--pin-active);
  box-shadow:  0 0 0 6px var(--pin-active-pulse);
  transform:   scale(1.5);
  animation:   none;
}

/* Keyboard focus ring */
.map-pin:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ----------------------------------------------------------------
   HEADER
   ---------------------------------------------------------------- */
header {
  background:      var(--header-bg);
  color:           var(--header-text);
  padding:         18px 28px 14px;
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  gap:             13px;
  position:        sticky;
  top:             0;
  z-index:         200;
  box-shadow:      0 2px 20px rgba(0, 0, 0, 0.35);
  transition:      background-color 0.3s ease;
}

.header-top {
  display:         flex;
  align-items:     center;
  justify-content: center;
  width:           100%;
  position:        relative;
}

header h1 {
  display:       flex;
  align-items:   center;
  gap:           9px;
  font-size:     1.55rem;
  font-weight:   800;
  letter-spacing:-0.4px;
  color:         var(--header-text);
}

.globe-icon {
  width:   1.3em;
  height:  1.3em;
  opacity: 0.9;
  flex-shrink: 0;
}

/* ----------------------------------------------------------------
   DARK MODE TOGGLE
   ---------------------------------------------------------------- */
.theme-toggle {
  position:  absolute;
  right:     0;
  display:   flex;
  align-items:center;
  gap:       8px;
  cursor:    pointer;
  user-select:none;
  outline:   none;
}

.theme-toggle input { display: none; }

.toggle-track {
  width:         44px;
  height:        24px;
  border-radius: 12px;
  background:    rgba(255, 255, 255, 0.18);
  border:        1.5px solid rgba(255, 255, 255, 0.35);
  position:      relative;
  transition:    var(--transition);
  flex-shrink:   0;
}

.toggle-thumb {
  position:      absolute;
  top:           2px;
  left:          2px;
  width:         16px;
  height:        16px;
  background:    white;
  border-radius: 50%;
  transition:    var(--transition);
  box-shadow:    0 1px 4px rgba(0,0,0,0.25);
}

.theme-toggle input:checked + .toggle-track { background: rgba(77, 157, 224, 0.3); }
.theme-toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
  background:#93C5FD;
}

.toggle-icons {
  display:    flex;
  flex-direction:column;
  font-size:  0.7rem;
  line-height:1;
  gap:        1px;
  opacity:    0.75;
}

/* ----------------------------------------------------------------
   SEARCH BAR
   ---------------------------------------------------------------- */
#searchBar {
  width:       100%;
  max-width:   460px;
  padding:     10px 18px;
  border-radius:50px;
  border:      1.5px solid rgba(255, 255, 255, 0.22);
  background:  rgba(255, 255, 255, 0.1);
  color:       var(--header-text);
  font-size:   0.93rem;
  outline:     none;
  transition:  var(--transition);
  backdrop-filter: blur(4px);
}

#searchBar::placeholder { color: rgba(255, 255, 255, 0.5); }

#searchBar:focus {
  background:    rgba(255, 255, 255, 0.18);
  border-color:  rgba(255, 255, 255, 0.5);
  box-shadow:    0 0 0 3px rgba(255, 255, 255, 0.1);
}

/* ----------------------------------------------------------------
   EVENT TIME CONVERTER BAR
   ---------------------------------------------------------------- */
.converter-bar {
  display:      flex;
  align-items:  center;
  gap:          10px;
  font-size:    0.82rem;
  color:        rgba(255, 255, 255, 0.72);
  flex-wrap:    wrap;
  justify-content:center;
}

.converter-bar label {
  display:    flex;
  align-items:center;
  gap:        5px;
  font-weight:500;
  cursor:     default;
}

#timeConverter {
  padding:      5px 11px;
  border-radius:var(--radius-sm);
  border:       1.5px solid rgba(255, 255, 255, 0.28);
  background:   rgba(255, 255, 255, 0.1);
  color:        white;
  font-size:    0.88rem;
  outline:      none;
  cursor:       pointer;
  transition:   var(--transition);
}

#timeConverter::-webkit-calendar-picker-indicator { filter: invert(1); opacity: 0.6; }

#timeConverter:focus {
  border-color: rgba(255,255,255,0.55);
  background:   rgba(255,255,255,0.18);
}

/* ----------------------------------------------------------------
   MAIN CLOCK GRID
   ---------------------------------------------------------------- */
#clockContainer {
  display:         flex;
  flex-wrap:       wrap;
  justify-content: center;
  align-items:     flex-start;
  padding:         32px 24px 40px;
  gap:             20px;
  flex:            1;
}

/* "No results" message (shown via JS) */
#noResults {
  width:       100%;
  text-align:  center;
  color:       var(--text-muted);
  font-size:   0.95rem;
  padding:     32px 0;
  display:     none;
}

/* ----------------------------------------------------------------
   CLOCK CARD
   ---------------------------------------------------------------- */
.clock {
  background:   var(--card-bg);
  border:       1px solid var(--card-border);
  border-radius:var(--radius);
  box-shadow:   var(--card-shadow);
  padding:      20px 18px 16px;
  width:        224px;
  display:      flex;
  flex-direction:column;
  gap:          10px;
  position:     relative;
  overflow:     hidden;
  cursor:       default;
  /* Smooth hover lift */
  transition:   transform 0.28s ease,
                box-shadow 0.28s ease,
                border-color 0.28s ease,
                opacity 0.28s ease;
}

/* ── Thermal top border: default is day (amber) ── */
.clock::before {
  content:      '';
  position:     absolute;
  top:          0; left: 0; right: 0;
  height:       3px;
  background:   linear-gradient(90deg, var(--day-border-a), var(--day-border-b));
  border-radius:var(--radius) var(--radius) 0 0;
  transition:   background 0.6s ease;
}

/* Night state — overridden by JS toggling .is-night on the card */
.clock.is-night::before {
  background: linear-gradient(90deg, var(--night-border-a), var(--night-border-b));
}

.clock:hover {
  transform:    translateY(-5px);
  box-shadow:   var(--card-shadow-lg);
  border-color: var(--accent);
}

/* Highlighted when a map pin is clicked */
.clock.highlighted {
  transform:    translateY(-7px);
  box-shadow:   0 0 0 3px var(--accent), var(--card-shadow-lg);
  border-color: var(--accent);
}

/* ----------------------------------------------------------------
   CARD HEADER ROW: city name + day/night badge
   ---------------------------------------------------------------- */
.clock-header {
  display:         flex;
  align-items:     flex-start;
  justify-content: space-between;
  gap:             8px;
}

.clock h2 {
  font-size:   0.92rem;
  font-weight: 800;
  color:       var(--text-primary);
  line-height: 1.25;
}

.clock h2 small {
  font-weight:5 00;
  color:       var(--text-secondary);
  font-size:   0.82em;
}

/* Day / Night badge */
.day-night-badge {
  font-size:     0.68rem;
  font-weight:   700;
  padding:       3px 8px 3px 6px;
  border-radius: 50px;
  white-space:   nowrap;
  flex-shrink:   0;
  letter-spacing:0.2px;
  transition:    background 0.6s ease, color 0.6s ease;
}

.day-night-badge.day {
  background: var(--day-badge-bg);
  color:      var(--day-badge-text);
}

.day-night-badge.night {
  background: var(--night-badge-bg);
  color:      var(--night-badge-text);
}

/* ----------------------------------------------------------------
   TIME DISPLAY
   ---------------------------------------------------------------- */
.time-display {
  font-size:         1.85rem;
  font-weight:       800;
  letter-spacing:    -1.5px;
  color:             var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height:       1;
}

/* ----------------------------------------------------------------
   DATE DISPLAY
   ---------------------------------------------------------------- */
.date-display {
  font-size:   0.78rem;
  color:       var(--text-secondary);
  font-weight: 500;
  margin-top: -4px;
}

/* ----------------------------------------------------------------
   CARD DIVIDER
   ---------------------------------------------------------------- */
.card-divider {
  border:        none;
  border-top:    1px solid var(--divider);
  margin:        2px 0;
}

/* ----------------------------------------------------------------
   WEATHER ROW
   ---------------------------------------------------------------- */
.weather-info {
  font-size:   0.80rem;
  color:       var(--text-secondary);
  display:     flex;
  align-items: center;
  gap:         5px;
  flex-wrap:   wrap;
}

.weather-info .weather-icon { font-size: 1rem; }

/* ----------------------------------------------------------------
   META ROW — currency + holiday
   ---------------------------------------------------------------- */
.meta-row {
  display:        flex;
  flex-direction: column;
  gap:            5px;
}

.meta-chip {
  font-size:   0.74rem;
  color:       var(--text-secondary);
  display:     flex;
  align-items: center;
  gap:         5px;
}

.meta-chip strong {
  color:       var(--text-primary);
  font-weight: 600;
}

.meta-chip .chip-icon {
  font-size:  0.85rem;
  flex-shrink:0;
}

/* ----------------------------------------------------------------
   CONVERTER RESULT — shown only when timeConverter has a value
   ---------------------------------------------------------------- */
.converter-result {
  font-size:     0.78rem;
  background:    var(--conv-bg);
  color:         var(--conv-text);
  border:        1px solid var(--conv-border);
  padding:       7px 10px;
  border-radius: var(--radius-sm);
  font-weight:   700;
  text-align:    center;
  letter-spacing:0.1px;

  /* Hidden by default; JS adds .visible to show it */
  max-height:    0;
  overflow:      hidden;
  opacity:       0;
  padding-top:   0;
  padding-bottom:0;
  margin-top:    -4px;
  transition:    max-height 0.3s ease,
                 opacity   0.3s ease,
                 padding   0.3s ease,
                 margin    0.3s ease;
}

.converter-result.visible {
  max-height:    48px;
  opacity:       1;
  padding:       7px 10px;
  margin-top:    0;
}

/* ----------------------------------------------------------------
   FOOTER
   ---------------------------------------------------------------- */
footer {
  text-align:  center;
  padding:     14px 20px;
  background:  var(--footer-bg);
  color:       rgba(255,255,255,0.45);
  font-size:   0.78rem;
  letter-spacing:0.2px;
  margin-top:  auto;
  transition:  background-color 0.3s ease;
}

/* ----------------------------------------------------------------
   RESPONSIVE — tablet (≤ 768px)
   ---------------------------------------------------------------- */
@media (max-width: 768px) {
  #mapContainer { padding-top: 52%; }

  header h1    { font-size: 1.25rem; }

  .theme-toggle { position: static; }

  .header-top {
    flex-wrap: wrap;
    gap:       10px;
  }

  .clock {
    width:   calc(50% - 10px);
    min-width:160px;
  }

  .time-display { font-size: 1.55rem; }
}

/* ----------------------------------------------------------------
   RESPONSIVE — mobile (≤ 480px)
   ---------------------------------------------------------------- */
@media (max-width: 480px) {
  #mapContainer   { padding-top: 65%; }

  header          { padding: 14px 16px 12px; }

  #clockContainer { padding: 16px 12px 28px; gap: 12px; }

  .clock          { width: 100%; }

  .time-display   { font-size: 2rem; }

  .converter-bar  { font-size: 0.76rem; gap: 8px; }
}

/* ----------------------------------------------------------------
   REDUCED MOTION — respect user preference
   ---------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:  0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
