/* ================================================================
   KMS Zodiac Signs App — Style V0.01
   Premium redesign: glassmorphism, element colours, mobile-first
   ================================================================ */

/* ---------- CSS Custom Properties ---------- */
:root {
  --bg-deep: #07051a;
  --bg-mid: #130d3a;
  --bg-surface: #1c1540;

  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-bg-hover: rgba(255, 255, 255, 0.13);
  --glass-border: rgba(255, 255, 255, 0.18);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);

  --text-primary: #f0e8ff;
  --text-muted: rgba(240, 232, 255, 0.55);
  --gold: #f5c842;
  --gold-glow: rgba(245, 200, 66, 0.35);

  /* Element palette — Balanced for borders */
  --fire-main: #ff6b35;
  --fire-glow: rgba(255, 107, 53, 0.35);
  --earth-main: #6fbf73;
  --earth-glow: rgba(111, 191, 115, 0.3);
  --air-main: #55cfff;
  --air-glow: rgba(85, 207, 255, 0.3);
  --water-main: #a06bff;
  --water-glow: rgba(160, 107, 255, 0.3);

  /* Target text colors V0.01 */
  --fire-text: #ff3333;
  --earth-text: #3399ff;
  --air-text: #ffffff;
  --water-text: #1a1aff;

  --radius-card: 18px;
  --radius-modal: 24px;
  --transition-std: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  background: radial-gradient(ellipse at 20% 10%, #1d1060 0%, var(--bg-deep) 60%),
    radial-gradient(ellipse at 80% 90%, #0c1a50 0%, transparent 60%);
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: "Lato", sans-serif;
  display: flex;
  flex-direction: column;
}

/* ---------- Starfield Canvas Background ---------- */
#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ---------- Header ---------- */
.main-header {
  position: relative;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.25rem;
  background: rgba(7, 5, 26, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.logo-container {
  flex: 1;
  display: flex;
  justify-content: center;
}

.main-header h1 {
  font-family: "Cinzel", serif;
  font-size: 20px;
  background: linear-gradient(100deg, #fff 10%, #c9aaff 50%, #55cfff 90%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  letter-spacing: 0.04em;
}

.controls {
  position: absolute;
  right: 1.25rem;
}

.btn-glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  cursor: pointer;
  font-size: 20px;
  font-family: "Lato", sans-serif;
  letter-spacing: 0.03em;
  transition: var(--transition-std);
  backdrop-filter: blur(6px);
}
.btn-glass:hover {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 0 14px var(--air-glow);
}

/* ---------- Main / App ---------- */
#app {
  flex: 1;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---------- Zodiac Grid ---------- */
.zodiac-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: min(8px, 1vh);
  padding: min(8px, 1vh) 10px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
  min-height: 0;
  height: 100%;
}

/* ---------- Cards ---------- */
.card {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3px;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  transition: all var(--transition-std);
  touch-action: manipulation;
  height: 100%;
  min-height: 0;
  min-width: 0;
  /* Default subtle shadow to separate from background */
  box-shadow: var(--glass-shadow);
}

.card .name-wrapper, .card .date-wrapper {
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
  display: flex;
  justify-content: center;
  min-height: 0;
}

.card h3 {
  display: inline-block;
  flex: none;
  font-size: clamp(14px, 2.5vh, 22px);
  margin: min(2px, 0.3vh) 0;
}

.card h3.marquee-slide, .card p.marquee-slide {
  animation: marqueeSlide 3.5s linear infinite alternate;
}

@keyframes marqueeSlide {
  0%, 20% { transform: translateX(0); }
  80%, 100% { transform: translateX(var(--slide-dist)); }
}
.card p {
  display: block;
  font-size: clamp(12px, 1.8vh, 16px);
  color: #ffd700 !important;
  margin: 0;
  min-height: 0;
  white-space: pre-line;
  line-height: 1.25;
  text-align: center;
}

.card .icon-wrapper {
  /* Force a centered square that fits the card's remaining height.
     This ensures rounded corners are tight around the zodiac image 
     and don't 'disappear' into the card's wide sides. */
  aspect-ratio: 1 / 1;
  width: auto;
  max-width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto min(2px, 0.3vh);
  border-radius: 24px;
  overflow: hidden;
}

.card .icon-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Shimmer sweep on hover (desktop) */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    transparent 0%,
    rgba(255, 255, 255, 0.06) 40%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.06) 60%,
    transparent 100%
  );
  transform: translateX(-110%);
  transition: transform 0.55s ease;
  pointer-events: none;
}
.card:hover::before {
  transform: translateX(110%);
}

/* Element top-bar accent */
.card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 2px 2px 0 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.card:hover::after {
  opacity: 1;
}
.card[data-element="fire"]::after {
  background: var(--fire-main);
}
.card[data-element="earth"]::after {
  background: var(--earth-main);
}
.card[data-element="air"]::after {
  background: var(--air-main);
}
.card[data-element="water"]::after {
  background: var(--water-main);
}

/* Hover lift */
.card:hover {
  background: var(--glass-bg-hover);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Element glow on hover — Restored original balance */
.card[data-element="fire"]:hover {
  box-shadow: var(--glass-shadow), 0 0 22px var(--fire-glow);
}
.card[data-element="earth"]:hover {
  box-shadow: var(--glass-shadow), 0 0 22px var(--earth-glow);
}
.card[data-element="air"]:hover {
  box-shadow: var(--glass-shadow), 0 0 22px var(--air-glow);
}
.card[data-element="water"]:hover {
  box-shadow: var(--glass-shadow), 0 0 22px var(--water-glow);
}

/* Specific text color for element indicators — Custom requested V0.01 */
.card[data-element="fire"] .element-indicator { color: var(--fire-text); text-shadow: 0 0 8px rgba(255, 51, 51, 0.4); }
.card[data-element="earth"] .element-indicator { color: var(--earth-text); text-shadow: 0 0 8px rgba(51, 153, 255, 0.4); }
.card[data-element="air"] .element-indicator { color: var(--air-text); text-shadow: 0 0 8px rgba(255, 255, 255, 0.5); }
.card[data-element="water"] .element-indicator { color: var(--water-text); text-shadow: 0 0 8px rgba(26, 26, 255, 0.6); }


/* ---------- Modal Overlay ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center; /* desktop: centred */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal.visible {
  opacity: 1;
  pointer-events: auto;
}
.modal.hidden {
  display: none;
}

/* ---------- Modal Content ---------- */
.modal-content.glass-panel {
  position: relative;
  background: linear-gradient(
    160deg,
    rgba(28, 18, 72, 0.97),
    rgba(10, 6, 40, 0.97)
  );
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-modal);
  width: 90%;
  max-width: 720px;
  max-height: 85vh;
  margin: 0 auto;
  overflow: hidden;
  padding: 2rem 2.2rem 2.2rem;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 0 60px rgba(100, 60, 200, 0.15);
  color: var(--text-primary);
  animation: modalUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  display: flex;
  flex-direction: column;
}

@keyframes modalUp {
  from {
    transform: translateY(40px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* ---------- Element accent line at top of modal ---------- */
.modal-content.glass-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 5%;
  right: 5%;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--modal-accent, var(--air-main));
  opacity: 0.8;
}

/* ---------- Close Button ---------- */
.close-btn {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  transition:
    color 0.2s,
    transform 0.2s;
  z-index: 2;
}
.close-btn:hover {
  color: #ff6b6b;
  transform: rotate(90deg);
}

/* ---------- Modal Header ---------- */
.modal-header {
  text-align: center;
  padding-bottom: min(1.2rem, 1vh);
  margin-bottom: min(1.4rem, 1vh);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}
.modal-icon-wrapper {
  margin-bottom: min(0.4rem, 0.5vh);
  display: flex;
  justify-content: center;
}
.zodiac-icon-large {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: clamp(80px, 22vh, 200px);
  height: clamp(80px, 22vh, 200px);
}
.zodiac-icon-large img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  /* Same clip-path technique — guaranteed 24px round corners */
  clip-path: inset(0 round 24px);
  filter: drop-shadow(0 0 30px rgba(255, 255, 255, 0.4));
}
.modal-header h2 {
  font-family: "Cinzel", serif;
  font-size: clamp(24px, 4vh, 42px);
  background: linear-gradient(90deg, #fff, #c9aaff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.2rem;
}
#modal-date {
  font-size: min(20px, 2.5vh);
  color: #ffd700;
  letter-spacing: 0.04em;
  margin: 0;
}

/* ---------- Modal Body ---------- */
.modal-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.6rem;
  background: transparent;
  padding: 0;
}
.tab-btn {
  width: 60px;
  height: 60px;
  flex: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.25s;
}
.tab-btn.active {
  background: rgba(0, 220, 200, 0.18);
  border-color: #00dcc8;
  box-shadow:
    0 0 12px #00dcc8,
    0 0 30px rgba(0, 220, 200, 0.4),
    inset 0 0 10px rgba(0, 220, 200, 0.1);
  transform: scale(1.12);
  color: #00dcc8;
}
.tab-btn:not(.active):hover {
  border-color: rgba(0, 220, 200, 0.3);
  box-shadow: 0 0 8px rgba(0, 220, 200, 0.2);
  color: #aaf7f0;
}

/* ---------- Tab Content ---------- */
.tab-content {
  display: none;
  font-size: clamp(16px, 2vh, 20px);
  line-height: 1.5;
  color: rgba(240, 232, 255, 0.88);
  max-height: 100%;
  overflow: hidden;
}
.tab-content.active {
  display: block;
  animation: fadeIn 0.35s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Best Matches ---------- */
.match-section {
  text-align: center;
}
.match-section > h3 {
  font-family: "Cinzel", serif;
  font-size: 1rem;
  color: var(--gold);
  margin-bottom: 1rem;
  letter-spacing: 0.06em;
}
.match-list {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.match-badge {
  background: rgba(245, 200, 66, 0.1);
  border: 1px solid rgba(245, 200, 66, 0.35);
  color: var(--gold);
  padding: 0.5rem 1.1rem;
  border-radius: 50px;
  font-size: 20px;
  font-family: "Cinzel", serif;
  letter-spacing: 0.03em;
  transition: background 0.2s;
  display: flex;
  align-items: center;
}
.match-badge:hover {
  background: rgba(245, 200, 66, 0.2);
}

/* ---------- Compatibility Calculator ---------- */
.match-calculator {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 1.4rem 1.6rem;
  border-radius: 16px;
  margin-top: 0.5rem;
}
.match-calculator h3 {
  font-family: "Cinzel", serif;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}
.match-calculator p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0;
}
.calc-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.8rem;
  margin: 1rem 0 0.5rem;
  flex-wrap: wrap;
}
select {
  flex: 1;
  min-width: 140px;
  max-width: 220px;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
  font-size: 20px;
  font-family: "Lato", sans-serif;
  cursor: pointer;
  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='%23aaa' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.2rem;
}
select option {
  background: #130d3a;
}

.element-indicator {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 700;
  font-size: clamp(10px, 1.5vh, 14px);
  letter-spacing: 0.05em;
  margin-bottom: min(2px, 0.4vh);
  text-transform: uppercase;
}

.btn-gold {
  background: linear-gradient(135deg, #f5c842, #e08b1a);
  color: #1a0d00;
  border: none;
  padding: 0.65rem 1.4rem;
  border-radius: 10px;
  font-weight: 700;
  font-family: "Lato", sans-serif;
  font-size: 0.92rem;
  cursor: pointer;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  white-space: nowrap;
}
.btn-gold:hover {
  transform: scale(1.05);
  box-shadow: 0 0 18px var(--gold-glow);
}

.match-result {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gold);
  margin-top: 0.9rem;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  text-align: center;
  animation: fadeIn 0.35s ease;
}

.main-footer {
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: min(20px, 2.5vw);
  color: rgba(255, 255, 255, 0.3);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.main-footer span {
  display: inline;
}
@media (max-width: 768px) {
  .main-footer p {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .main-footer span {
    display: block;
    font-size: 0.9em;
  }
}

/* ================================================================
   RESPONSIVE — Tablet ≤ 768px
   ================================================================ */
@media (max-width: 768px) {
  /* Compact header */
  .main-header {
    padding: 0 10px;
    justify-content: space-between;
    height: 54px;
    position: relative;
  }
  .controls {
    position: relative;
    right: 0;
  }
  .main-header h1 {
    font-size: 20px;
    margin: 0;
    text-align: center;
    flex: 1;
  }

  /* Grid — 4 cols × 3 rows, fit exactly in remaining space */
  .zodiac-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 4px 6px;
    flex: 1;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  /* Cards — fill grid cell completely */
  .card {
    height: 100%;
    padding: 6% 4%;
    border-radius: 12px;
    /* Disable desktop hover effects */
    transition: none !important;
  }
  .card:hover,
  .card:hover::before,
  .card:hover::after {
    transition: none !important;
  }
  /* Keep the element-bar visible always on mobile */
  .card::after {
    opacity: 1;
  }

  .element-indicator {
    font-size: 20px;
    padding: 0px 4px;
    line-height: 1;
    border-radius: 10px;
  }

  .card .icon-wrapper {
    /* Center the icons on mobile too */
    margin: 0 auto 0.1rem;
  }

  .card h3 {
    font-size: 20px;
    margin-bottom: 0;
    line-height: 1;
  }
  .card p {
    display: block;
    font-size: 20px;
    line-height: 1;
    margin-top: 2px;
  }

  /* Disable hover lift on touch */
  .card:hover {
    transform: none !important;
    background: var(--glass-bg) !important;
    border-color: var(--glass-border) !important;
    box-shadow: none !important;
  }

  /* ---- Modal — centered on mobile ---- */
  .modal {
    align-items: center; /* anchor to center */
  }
  .modal-content.glass-panel {
    width: 90%;
    max-width: 90%;
    max-height: 85dvh;
    border-radius: var(--radius-modal);
    padding: 1.4rem 1.2rem 2rem;
    animation: modalUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  }

  /* Drag handle indicator */
  .modal-content.glass-panel::after {
    content: "";
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.22);
  }

  .close-btn {
    top: 0.85rem;
    right: 1rem;
    font-size: 1.4rem;
  }

  .zodiac-icon-large {
    font-size: 3.5rem;
  }
  .modal-header h2 {
    font-size: 1.6rem;
  }
  .modal-header {
    padding-bottom: 0.9rem;
    margin-bottom: 1rem;
  }

  .tabs {
    display: flex;
    flex-direction: row;
    grid-template-columns: none;
    justify-content: center;
    gap: 1.5rem;
  }
  .tab-btn {
    width: 54px;
    height: 54px;
    font-size: 24px;
  }
  .tab-btn[data-tab="compatibility"] {
    grid-column: auto;
  }

  .tab-content {
    font-size: 20px;
    line-height: 1.5;
  }

  .match-list {
    gap: 0.5rem;
  }
  .match-badge {
    font-size: 20px;
    padding: 0.3rem 0.6rem;
  }

  .match-calculator {
    padding: 1rem 1rem;
  }
  .calc-controls {
    gap: 0.6rem;
  }
  select {
    min-width: 0;
    max-width: none;
    flex: 1;
    font-size: 20px;
  }
  .btn-gold {
    padding: 0.6rem 1rem;
    font-size: 20px;
  }
  .match-result {
    font-size: 20px;
  }


  .card h3 {
    font-size: 20px;
  }

  .main-footer {
    font-size: 20px;
    padding: 0.65rem;
    flex-shrink: 0;
  }
}

/* ----------------------------------------------------------------
   Tiny phones ≤ 390px
   ---------------------------------------------------------------- */
@media (max-width: 390px) {
  .zodiac-grid {
    gap: 5px;
    padding: 6px;
  }
  .card {
    border-radius: 12px;
  }

  .card h3 {
    font-size: 20px;
  }
}
