/* ============================================================
   World Clock v2 — Premium Dark Glassmorphism
   ============================================================ */

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

:root {
  --page-bg: #0a0a12;
  --page-bg-2: #0f0f1e;
  --page-text: #e8e8f0;
  --page-muted: #6666aa;
  --page-accent: #6c63ff;
  --grid-gap: 1.75rem;
  --widget-radius: 1.5rem;
  --transition-fast: 0.15s ease;
  --transition-med: 0.25s ease;
  --font-mono: 'SF Mono', 'JetBrains Mono', 'Fira Mono', 'Roboto Mono', monospace;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--page-bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(108, 99, 255, 0.18) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 90%,  rgba(0, 188, 212, 0.1)  0%, transparent 60%);
  background-attachment: fixed;
  color: var(--page-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── App Header ───────────────────────────────────────────── */
.app-header {
  padding: 2rem 2rem 1.75rem;
  text-align: center;
  position: relative;
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  max-width: 400px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(108, 99, 255, 0.4),
    rgba(0, 188, 212, 0.4),
    transparent
  );
}

.header-inner {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.logo-mark {
  font-size: 2.25rem;
  line-height: 1;
  filter: drop-shadow(0 0 12px rgba(108, 99, 255, 0.6));
  animation: globe-pulse 4s ease-in-out infinite;
}

@keyframes globe-pulse {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(108, 99, 255, 0.5)); }
  50%       { filter: drop-shadow(0 0 20px rgba(108, 99, 255, 0.9)); }
}

.app-title {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff 0%, #a0a0ff 50%, #6c63ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-subtitle {
  font-size: 0.875rem;
  color: var(--page-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
}

/* ── Clocks Grid ──────────────────────────────────────────── */
.clocks-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--grid-gap);
  padding: 2rem 2rem 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

/* ── Clock Widget ─────────────────────────────────────────── */
.clock-widget {
  /* CSS custom properties set per-widget by JS (theme) */
  background: var(--cw-glass);
  border: 1px solid var(--cw-border);
  border-radius: var(--widget-radius);
  padding: 1.5rem 1.5rem 1.75rem;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.45),
    0 2px 8px  rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: box-shadow var(--transition-med), transform var(--transition-med);
  position: relative;
  overflow: hidden;
}

.clock-widget::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--cw-accent),
    transparent
  );
  opacity: 0.6;
}

.clock-widget:hover {
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.55),
    0 4px 16px  rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.clock-widget[data-theme="light"] {
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 2px 8px  rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.clock-widget[data-theme="neon"] {
  box-shadow:
    0 0 0 1px rgba(57, 255, 20, 0.18),
    0 8px 32px rgba(0, 0, 0, 0.6),
    0 0 40px rgba(57, 255, 20, 0.07);
}

/* ── Controls Row ─────────────────────────────────────────── */
.cw-controls {
  display: flex;
  gap: 0.625rem;
  align-items: center;
}

/* City select */
.city-select {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.35);
  color: var(--cw-text);
  border: 1px solid var(--cw-border);
  border-radius: 0.625rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238888aa' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.city-select:hover,
.city-select:focus {
  border-color: var(--cw-accent);
}

.city-select optgroup {
  font-weight: 700;
  font-size: 0.8rem;
  color: #8888aa;
  background: #1a1a2e;
}

.city-select option {
  background: #1a1a2e;
  color: #e0e0f0;
  font-weight: 400;
}

.clock-widget[data-theme="light"] .city-select {
  background-color: rgba(255, 255, 255, 0.75);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23444466' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Face toggle button */
.face-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: rgba(0, 0, 0, 0.28);
  color: var(--cw-text-muted);
  border: 1px solid var(--cw-border);
  border-radius: 0.625rem;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.03em;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.face-toggle-btn:hover {
  background: var(--cw-accent);
  color: #fff;
  border-color: var(--cw-accent);
  box-shadow: 0 0 12px rgba(108, 99, 255, 0.35);
}

.clock-widget[data-theme="neon"] .face-toggle-btn:hover {
  box-shadow: 0 0 16px rgba(57, 255, 20, 0.5);
}

.clock-widget[data-theme="light"] .face-toggle-btn {
  background: rgba(255, 255, 255, 0.6);
}

.btn-icon {
  font-size: 1rem;
  line-height: 1;
}

/* ── Theme Swatches ───────────────────────────────────────── */
.theme-swatches {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.theme-swatches::before {
  content: 'THEME';
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--cw-text-muted);
  opacity: 0.7;
  margin-right: 0.2rem;
  white-space: nowrap;
}

.theme-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.12);
  background: var(--swatch-color, #888);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
}

.theme-swatch:hover {
  transform: scale(1.22);
  box-shadow: 0 0 10px var(--swatch-color), 0 0 0 2px rgba(255,255,255,0.18);
}

.theme-swatch.active {
  border-color: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 10px var(--swatch-color), 0 0 0 2px rgba(255,255,255,0.35);
  transform: scale(1.15);
}

/* ── Face Container ───────────────────────────────────────── */
.cw-face-container {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0;
}

/* ── Analog SVG Face ──────────────────────────────────────── */
.analog-face {
  width: 100%;
  max-width: 220px;
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.5));
}

.analog-face .face-bg {
  fill: var(--cw-face-bg);
}

.analog-face .face-rim {
  stroke: var(--cw-border);
}

.analog-face .tick-major {
  stroke: var(--cw-text-muted);
  opacity: 0.8;
}

.analog-face .tick-minor {
  stroke: var(--cw-text-muted);
  opacity: 0.3;
}

.analog-face .hour-num {
  fill: var(--cw-text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 600;
}

.analog-face .hand-hour {
  stroke: var(--cw-text);
  stroke-width: 5;
  opacity: 0.95;
}

.analog-face .hand-minute {
  stroke: var(--cw-text);
  stroke-width: 3;
  opacity: 0.9;
}

.analog-face .hand-second {
  stroke: var(--cw-accent);
  stroke-width: 1.5;
  filter: drop-shadow(0 0 3px var(--cw-accent));
}

.analog-face .centre-dot {
  fill: var(--cw-accent);
  filter: drop-shadow(0 0 4px var(--cw-accent));
}

.analog-face .centre-dot-inner {
  fill: rgba(255,255,255,0.6);
}

/* Neon glow on hands */
.clock-widget[data-theme="neon"] .analog-face .hand-hour,
.clock-widget[data-theme="neon"] .analog-face .hand-minute {
  filter: drop-shadow(0 0 3px rgba(57, 255, 20, 0.6));
  stroke: #ccffcc;
}

.clock-widget[data-theme="neon"] .analog-face .hand-second {
  filter: drop-shadow(0 0 6px #39ff14);
}

/* ── Digital Face ─────────────────────────────────────────── */
.digital-face {
  text-align: center;
  padding: 1.5rem 0.5rem 1rem;
  width: 100%;
}

.digital-time {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  font-weight: 700;
  color: var(--cw-accent);
  letter-spacing: 0.05em;
  line-height: 1;
  text-shadow: 0 0 20px color-mix(in srgb, var(--cw-accent) 45%, transparent);
  margin-bottom: 0.625rem;
}

.clock-widget[data-theme="neon"] .digital-time {
  text-shadow:
    0 0 8px #39ff14,
    0 0 20px rgba(57, 255, 20, 0.6),
    0 0 40px rgba(57, 255, 20, 0.3);
}

.digital-date {
  font-size: 0.8rem;
  color: var(--cw-text-muted);
  font-weight: 500;
  letter-spacing: 0.03em;
}

/* ── Info Row ─────────────────────────────────────────────── */
.cw-info {
  border-top: 1px solid var(--cw-border);
  padding-top: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.cw-city-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cw-text);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.cw-date {
  font-size: 0.8rem;
  color: var(--cw-text-muted);
  font-weight: 400;
}

.cw-time-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.125rem;
}

.cw-local-time {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--cw-accent);
  letter-spacing: 0.04em;
}

.cw-offset {
  font-size: 0.7rem;
  color: var(--cw-text-muted);
  font-weight: 500;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--cw-border);
  border-radius: 0.3rem;
  padding: 0.1rem 0.35rem;
  letter-spacing: 0.04em;
}

.clock-widget[data-theme="light"] .cw-offset {
  background: rgba(0, 0, 0, 0.06);
}

/* ── Footer ───────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  padding: 1.25rem;
  font-size: 0.75rem;
  color: var(--page-muted);
  letter-spacing: 0.04em;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  margin-top: auto;
}

/* Sync status badge in footer */
.sync-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  border: 1px solid currentColor;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  transition: color 0.4s ease, background 0.4s ease;
}

.sync-badge[data-status="synced"] {
  color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
}

.sync-badge[data-status="offline"] {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .clocks-grid {
    grid-template-columns: 1fr 1fr;
    max-width: 760px;
  }

  .clock-slot:last-child {
    grid-column: 1 / -1;
    max-width: 360px;
    margin: 0 auto;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .clocks-grid {
    grid-template-columns: 1fr;
    padding: 1rem;
    gap: 1.25rem;
    max-width: 440px;
  }

  .clock-slot:last-child {
    grid-column: auto;
    max-width: 100%;
  }

  .app-title {
    font-size: 1.5rem;
  }

  .digital-time {
    font-size: 2.5rem;
  }
}

@media (max-width: 380px) {
  .clock-widget {
    padding: 1.25rem 1rem 1.5rem;
  }

  .face-toggle-btn .btn-label {
    display: none;
  }
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(108, 99, 255, 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(108, 99, 255, 0.5);
}

/* ── Selection ────────────────────────────────────────────── */
::selection {
  background: rgba(108, 99, 255, 0.4);
  color: #fff;
}

/* ── Focus visible ────────────────────────────────────────── */
button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--cw-accent, var(--page-accent));
  outline-offset: 2px;
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Fade-in on load ──────────────────────────────────────── */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.clock-slot:nth-child(1) .clock-widget { animation: fade-in-up 0.5s ease 0.05s both; }
.clock-slot:nth-child(2) .clock-widget { animation: fade-in-up 0.5s ease 0.15s both; }
.clock-slot:nth-child(3) .clock-widget { animation: fade-in-up 0.5s ease 0.25s both; }
