/* ============================================
 🇲🇾 MALAYSIA PAGE — GlobalTime.io
 Flag-Inspired Theme — Red & White Stripes + Blue Canton
============================================ */

:root {
  /* Light Mode Variables */
  --bg: linear-gradient(
    to bottom,
    #ef3340 0%,    /* red stripe */
    #ffffff 12.5%, /* white stripe */
    #ef3340 25%,   /* red stripe */
    #ffffff 37.5%, /* white stripe */
    #ef3340 50%,   /* red stripe */
    #ffffff 62.5%, /* white stripe */
    #ef3340 75%,   /* red stripe */
    #ffffff 87.5%, /* white stripe */
    #ef3340 100%   /* red stripe */
  );
  --canton: #012169; /* blue field (top-left) */
  --crescent: #ffcc00; /* yellow star & crescent */
  --card: rgba(255, 255, 255, 0.9);
  --text: #0d0d0d;
  --muted: #555;
  --accent: #ef3340;
  --radius: 16px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.12);
}

/* ---------- Body ---------- */
body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  line-height: 1.6;
  height: 100vh;
  overflow-x: hidden;
  position: relative;
  background: var(--bg);
  background-attachment: fixed;
  background-size: cover;
  background-repeat: no-repeat;
}

/* ---------- Blue Canton (Top-Left) ---------- */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 35%;
  height: 45%;
  background: var(--canton);
  z-index: -1;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.25);
}

/* ---------- Yellow Crescent + Star ---------- */
body::after {
  content: "☪★";
  position: fixed;
  top: 22%;
  left: 17%;
  transform: translate(-50%, -50%);
  font-size: 56px;
  color: rgba(255, 204, 0, 0.15); /* dim yellow */
  text-shadow: 0 0 12px rgba(255, 204, 0, 0.2);
  z-index: -1;
  opacity: 0.8;
  pointer-events: none;
  animation: glowStar 4s infinite alternate ease-in-out;
}

@keyframes glowStar {
  from { text-shadow: 0 0 6px rgba(255, 204, 0, 0.1); opacity: 0.4; }
  to   { text-shadow: 0 0 14px rgba(255, 204, 0, 0.4); opacity: 0.8; }
}

/* ---------- Dark Mode ---------- */
body.dark-mode {
  --bg: linear-gradient(
    to bottom,
    #3a0000 0%, #1a1a1a 20%, #3a0000 40%,
    #1a1a1a 60%, #3a0000 80%, #1a1a1a 100%
  );
  --canton: #000c3a;
  --crescent: #ffcc00;
  --card: rgba(30, 30, 30, 0.9);
  --text: #f4f4f4;
  --muted: #ccc;
  --accent: #ff5252;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

body.dark-mode::before {
  background: #000c3a;
}
body.dark-mode::after {
  color: rgba(255, 204, 0, 0.25);
  text-shadow: 0 0 12px rgba(255, 204, 0, 0.3);
}

/* ---------- Hero Section ---------- */
.hero {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin: 30px auto;
  max-width: 1280px;
  padding: 0 20px;
}

/* ---------- Card ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  transition: background 0.3s, box-shadow 0.3s;
}

/* ----------Main Clock ---------- */
.main-clock {
  position: relative;
  text-align: center;
  margin-bottom: 24px;
}
.main-clock .time {
  font-size: 64px;
  font-weight: 700;
  color: var(--accent);
}
.main-clock .tz {
  font-size: 16px;
  color: var(--muted);
  margin-top: 6px;
}
.utc-small {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 38, 84, 0.15);
  border-radius: 10px;
  padding: 6px 12px;
  text-align: right;
}
.utc-small .clock-time {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent);
}
.utc-small .clock-tz {
  font-size: 12px;
  color: var(--muted);
}

body.dark-mode .main-clock .time,
body.dark-mode .utc-small .clock-time {
  color: #ff4b4b;
  text-shadow: 0 0 10px rgba(255, 75, 75, 0.6);
}

/* ---------- Meta Info ---------- */
.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}
.meta {
  background: rgba(0, 0, 0, 0.05);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--muted);
}
body.dark-mode .meta {
  background: rgba(255, 255, 255, 0.05);
}

/* ---------- Cities Grid ---------- */
.cities {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.city-card {
  background: rgba(255, 255, 255, 0.15);
  padding: 14px;
  border-radius: var(--radius);
  text-align: center;
  backdrop-filter: blur(6px);
  transition: all 0.25s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}
.city-card:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.25);
}

/* ---------- City Name + Flag ---------- */
.city-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.city-name span.flag {
  font-size: 1.4em;
  line-height: 1;
}

/* ---------- City Time ---------- */
.city-time {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 4px;
}
body.dark-mode .city-card {
  background: rgba(0, 0, 0, 0.35);
}
body.dark-mode .city-name {
  color: #ffdede;
}
body.dark-mode .city-time {
  color: #ff4b4b;
}

/* ---------- Flags ---------- */
.flag-inline-title {
  height: 1em;
  margin-right: 0.4em;
  border-radius: 0.2em;
  box-shadow: 0 0.05em 0.15em rgba(0, 0, 0, 0.15);
}

/* ---------- Converter ---------- */
.converter-countries-wrapper {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.convert-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  margin-top: 12px;
}

.converter .row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.converter .row select,
.converter .row input {
  flex: 1 1 250px;
  min-width: 250px;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 14px;
}
body.dark-mode .converter select,
body.dark-mode .converter input {
  background: #161b22;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
}

/* ---------- Result Box ---------- */
.convert-result-box {
  position: relative;
  border: 3px double var(--accent);
  padding: 18px 22px;
  display: none;
}
body.dark-mode .convert-result-box {
  border: 3px double #ff4b4b;
}
.convert-result-box.show {
  display: block;
  animation: fadeInBox 0.4s ease-in-out;
}
@keyframes fadeInBox {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Copy button style */
.copy-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  transition: background 0.2s ease-in-out;
  white-space: nowrap;
}
.copy-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ---------- CTA Buttons ---------- */
.cta {
  background: linear-gradient(180deg, #012169 0%, #ffffff 50%, #ef3340 100%);
  border: none;
  color: #000;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 10px 18px;
  cursor: pointer;
  transition: 0.3s;
}
.cta:hover {
  background: linear-gradient(180deg, #ef3340 0%, #ffffff 50%, #012169 100%);
  box-shadow: 0 3px 12px rgba(0, 38, 84, 0.4);
  transform: translateY(-2px);
}

/* ---------- Regions List ---------- */
.malaysia-regions {
  text-align: center;
}
.states-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.division-link {
  display: inline-block;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid #4a4a4a;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  transition: 0.3s;
  text-align: center;
}
.division-link:hover {
  background: linear-gradient(180deg, #012169 0%, #ffffff 50%, #ef3340 100%);
  color: #000;
  font-weight: 600;
  transform: translateY(-2px);
}
body.dark-mode .division-link {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}
body.dark-mode .division-link:hover {
  color: #000;
}

/* ---------- Back Button ---------- */
.back-home-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, #012169 0%, #ffffff 50%, #ef3340 100%);
  color: #000;
  padding: 12px 24px;
  text-decoration: none;
  border-radius: 8px;
  font-weight: bold;
  transition: 0.3s;
}
.back-home-button:hover {
  background: linear-gradient(180deg, #ef3340 0%, #ffffff 50%, #012169 100%);
  box-shadow: 0 0 12px rgba(0, 38, 84, 0.4);
  transform: translateY(-2px);
}

.back-home-wrapper {
  text-align: center;
  margin: 40px 0;
}

/* ============================================
 🇲🇾 MALAYSIA PAGE — Responsive + Retina
 Optimized for mobile, tablet & 4K
============================================ */

/* =====================================================
   📱 Mobile Responsive — For ≤768px Devices
===================================================== */
@media (max-width: 768px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 20px;
  }
  .main-clock .time {
    font-size: 48px;
  }
  .utc-small {
    position: static;
    margin-top: 10px;
    text-align: center;
  }
  .card {
    padding: 20px;
  }
}

/* =====================================================
   📱 Extra Mobile Optimization — For ≤480px Devices
===================================================== */
@media (max-width: 480px) {
  .hero {
    padding: 0 12px;
    gap: 16px;
  }
  .main-clock .time {
    font-size: 40px;
  }
  .card {
    padding: 16px;
    border-radius: 12px;
  }
  .city-card {
    padding: 14px;
    font-size: 14px;
  }
  .cta {
    padding: 10px 20px;
    font-size: 15px;
  }
  .meta {
    font-size: 14px;
    line-height: 1.4;
  }
}

/* =====================================================
   💻 Extra-Large Screen — For ≥1600px Desktops
===================================================== */
@media (min-width: 1600px) {
  .hero {
    max-width: 1600px;
    gap: 40px;
    padding: 0 40px;
  }
  .main-clock .time {
    font-size: 80px;
  }
  .card {
    padding: 32px;
  }
  .city-card {
    padding: 18px;
  }
}

/* =====================================================
   🖥️ Super-Wide / 4K Displays — For ≥2400px
===================================================== */
@media (min-width: 2400px) {
  body {
    font-size: 18px;
  }
  .main-clock .time {
    font-size: 96px;
  }
}

/* ==========================================================
   💎 Retina / HiDPI Optimization — For 2×–3× Displays
========================================================== */
@media 
  (-webkit-min-device-pixel-ratio: 2),
  (min-resolution: 192dpi) {
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }
  .flag-inline-title {
    image-rendering: crisp-edges;
    filter: saturate(1.05) contrast(1.05);
  }
  .card {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  }
  .city-card {
    backdrop-filter: blur(8px);
  }
  .cta {
    filter: contrast(1.1) brightness(1.05);
  }
  .main-clock .time {
    letter-spacing: -0.02em;
  }
  .city-time {
    text-shadow: 0 0 2px rgba(0, 0, 0, 0.15);
  }
}

/* =====================================================
   💎 Super-Retina / 3× Density Screens
===================================================== */
@media 
  (-webkit-min-device-pixel-ratio: 3),
  (min-resolution: 288dpi) {
  .flag-inline-title {
    filter: saturate(1.15) brightness(1.1);
  }
  .cta {
    filter: contrast(1.2) brightness(1.1);
  }
  .main-clock .time {
    text-shadow: 0 0 4px rgba(255, 153, 51, 0.25);
  }
}
