/* ==========================================================================
   VADER MOOD TRACKER - DESIGN SYSTEM & STYLES
   Imperial Theme: Deep Space Void, Sith Crimson Red, Gloss Black, White Glow
   ========================================================================== */

:root {
  --bg-space: #06080d;
  --bg-card: #0c0f17;
  --bg-card-hover: #141924;
  --sith-red: #ff1100;
  --sith-red-glow: rgba(255, 17, 0, 0.6);
  --sith-red-subtle: rgba(255, 17, 0, 0.15);
  --sith-red-bright: #ff3322;
  --text-primary: #ffffff;
  --text-muted: #8e9bb0;
  --border-subtle: rgba(255, 255, 255, 0.12);
  --font-meme: 'Anton', 'Impact', sans-serif;
  --font-sci-fi: 'Orbitron', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-space);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* --------------------------------------------------------------------------
   Canvas Background (Starfield)
   -------------------------------------------------------------------------- */
#starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  opacity: 0.65;
}

/* --------------------------------------------------------------------------
   App Layout
   -------------------------------------------------------------------------- */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 760px;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* --------------------------------------------------------------------------
   Top Bar
   -------------------------------------------------------------------------- */
.top-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(12, 15, 23, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.imperial-icon {
  font-size: 1.25rem;
  color: var(--sith-red);
  filter: drop-shadow(0 0 6px var(--sith-red));
  animation: spinSlow 30s linear infinite;
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.brand-text {
  font-family: var(--font-sci-fi);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 2px;
  color: #c5d1e8;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lang-switch {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 2px;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sci-fi);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn.active {
  background: var(--sith-red);
  color: #fff;
  box-shadow: 0 0 8px var(--sith-red-glow);
}

.action-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-pill-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}

/* --------------------------------------------------------------------------
   Meme Card Poster Wrapper (The Centerpiece)
   -------------------------------------------------------------------------- */
.meme-wrapper {
  width: 100%;
  background: #000000;
  border: 2px solid #1c2230;
  border-radius: var(--radius-lg);
  padding: 24px 20px 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.85), 0 0 40px rgba(255, 17, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.meme-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--sith-red), transparent);
}

.meme-title {
  font-family: var(--font-meme);
  font-size: clamp(2rem, 5.5vw, 3.2rem);
  letter-spacing: 2px;
  text-align: center;
  color: #ffffff;
  margin-bottom: 22px;
  text-transform: uppercase;
  text-shadow: 0 2px 10px rgba(255, 255, 255, 0.2);
  user-select: none;
}

/* --------------------------------------------------------------------------
   3x3 Mood Grid
   -------------------------------------------------------------------------- */
.grid-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
}

/* Tekil Duygu Kartı */
.mood-card {
  position: relative;
  background: #050608;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 8px 12px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.18s cubic-bezier(0.2, 0, 0.2, 1), box-shadow 0.18s ease;
  border: 4px solid transparent;
  outline: none;
}

.mood-card:hover {
  transform: translateY(-2px);
  background: #0a0d14;
}

.mood-card:active {
  transform: scale(0.97);
}

/* SEÇİLİ KART: Orijinal Meme'deki Kalın Kırmızı Çerçeve! */
.mood-card.selected {
  border: 6px solid var(--sith-red);
  background: #000000;
  box-shadow: 0 0 20px var(--sith-red-glow), inset 0 0 14px rgba(255, 17, 0, 0.25);
  animation: sithPulse 2.4s infinite alternate;
}

@keyframes sithPulse {
  0% {
    box-shadow: 0 0 15px var(--sith-red-glow), inset 0 0 10px rgba(255, 17, 0, 0.2);
    border-color: #ff0000;
  }
  100% {
    box-shadow: 0 0 28px rgba(255, 40, 20, 0.85), inset 0 0 18px rgba(255, 20, 0, 0.35);
    border-color: #ff3322;
  }
}

/* Vader Fotoğrafı */
.mood-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 3px;
  background: #0e121a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mood-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  filter: contrast(1.08) brightness(0.98);
  transition: transform 0.25s ease;
}

.mood-card:hover .mood-img {
  transform: scale(1.03);
}

/* Duygu Etiketi */
.mood-label {
  margin-top: 10px;
  font-family: var(--font-meme);
  font-size: clamp(0.95rem, 2.3vw, 1.4rem);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #ffffff;
  text-align: center;
  width: 100%;
  line-height: 1.1;
  transition: color 0.15s ease;
}

.mood-card.selected .mood-label {
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 50, 50, 0.7);
}

/* --------------------------------------------------------------------------
   Meme Altı Entegre Vader Mesaj Paneli (Integrated Quote Panel)
   -------------------------------------------------------------------------- */
.meme-footer-quote {
  width: 100%;
  max-width: 620px;
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.quote-divider {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  opacity: 0.85;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 17, 0, 0.5), transparent);
}

.divider-sith-gem {
  width: 8px;
  height: 8px;
  background: var(--sith-red);
  transform: rotate(45deg);
  box-shadow: 0 0 10px var(--sith-red), 0 0 18px var(--sith-red);
}

.quote-content-wrapper {
  width: 100%;
  background: linear-gradient(180deg, rgba(20, 24, 35, 0.9) 0%, rgba(8, 10, 16, 0.95) 100%);
  border: 1px solid rgba(255, 17, 0, 0.35);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), inset 0 0 15px rgba(255, 17, 0, 0.08);
  position: relative;
  overflow: hidden;
}

.quote-content-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
  background: var(--sith-red);
  box-shadow: 0 0 10px var(--sith-red);
}

.vader-avatar-wrap {
  flex-shrink: 0;
}

.vader-mini-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: url('assets/vader_hd.jpg') center/cover no-repeat;
  border: 2px solid var(--sith-red);
  box-shadow: 0 0 12px var(--sith-red-glow);
}

.vader-quote-bubble {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quote-text {
  font-size: 1.05rem;
  font-weight: 500;
  font-style: italic;
  color: #f1f5f9;
  line-height: 1.45;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
  transition: opacity 0.18s ease;
}

.quote-author-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.quote-author-tag {
  font-family: var(--font-sci-fi);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #94a3b8;
}

.selected-mood-badge {
  background: var(--sith-red);
  color: #ffffff;
  font-family: var(--font-meme);
  font-size: 0.85rem;
  letter-spacing: 1px;
  padding: 2px 8px;
  border-radius: 4px;
  box-shadow: 0 0 8px var(--sith-red-glow);
}

.breathe-pulse-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 17, 0, 0.15);
  border: 1px solid var(--sith-red);
  color: #ff9999;
  font-family: var(--font-sci-fi);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  margin-left: auto;
  transition: all 0.2s ease;
}

.breathe-pulse-btn:hover {
  background: var(--sith-red);
  color: #ffffff;
  box-shadow: 0 0 12px var(--sith-red-glow);
}

.breathe-pulse-btn.active-breathing {
  animation: breathingEffect 1.8s ease-in-out infinite;
}

@keyframes breathingEffect {
  0% { transform: scale(1); box-shadow: 0 0 6px var(--sith-red-glow); }
  50% { transform: scale(1.08); box-shadow: 0 0 20px rgba(255, 40, 20, 0.9); }
  100% { transform: scale(1); box-shadow: 0 0 6px var(--sith-red-glow); }
}

/* --------------------------------------------------------------------------
   Action Buttons
   -------------------------------------------------------------------------- */
.actions-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #ff1100, #cc0e00);
  color: #ffffff;
  border: none;
  font-family: var(--font-sci-fi);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 12px 22px;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 15px var(--sith-red-glow);
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #ff3322, #e61000);
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(255, 30, 10, 0.8);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: #e2e8f0;
  font-family: var(--font-sci-fi);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   Mood History Chips
   -------------------------------------------------------------------------- */
.history-panel {
  width: 100%;
  background: rgba(12, 15, 23, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}

.history-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sci-fi);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.history-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 30px;
}

.history-chip {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #cbd5e1;
}

.history-chip .chip-mood {
  font-family: var(--font-meme);
  color: var(--sith-red);
  letter-spacing: 0.5px;
}

/* --------------------------------------------------------------------------
   Custom Mood Modal
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-box {
  background: #0d111a;
  border: 1px solid rgba(255, 17, 0, 0.4);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.9), 0 0 30px rgba(255, 17, 0, 0.2);
  border-radius: var(--radius-lg);
  padding: 26px 24px;
  width: 100%;
  max-width: 440px;
  position: relative;
}

.modal-box h3 {
  font-family: var(--font-sci-fi);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 8px;
  color: #ffffff;
}

.modal-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 18px;
  line-height: 1.4;
}

.input-group {
  display: flex;
  gap: 10px;
}

.input-group input {
  flex: 1;
  background: #05070c;
  border: 1px solid #2a3449;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  color: #ffffff;
  font-family: var(--font-meme);
  font-size: 1.1rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.2s ease;
}

.input-group input:focus {
  border-color: var(--sith-red);
  box-shadow: 0 0 10px var(--sith-red-glow);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Meme Preview Modal (iPhone / Mobile Optimized)
   -------------------------------------------------------------------------- */
.preview-modal-box {
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.preview-img-container {
  width: 100%;
  max-height: 52vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255, 17, 0, 0.4);
  box-shadow: 0 0 15px rgba(255, 17, 0, 0.2);
  margin: 12px 0 16px;
  overflow: hidden;
}

.preview-meme-img {
  width: 100%;
  height: auto;
  max-height: 52vh;
  object-fit: contain;
  display: block;
  user-select: auto;
  -webkit-touch-callout: default; /* Enables iOS long-press Save Image menu */
}

.preview-modal-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  flex-wrap: wrap;
  justify-content: center;
}

.preview-modal-actions button,
.preview-modal-actions a {
  flex: 1;
  min-width: 160px;
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 10px;
  opacity: 0.7;
}

/* --------------------------------------------------------------------------
   Responsive Breakpoints
   -------------------------------------------------------------------------- */
@media (max-width: 540px) {
  .app-container {
    padding: 12px 10px 30px;
    gap: 14px;
  }
  
  .meme-wrapper {
    padding: 16px 10px 20px;
    border-radius: 12px;
  }

  .grid-container {
    gap: 6px;
  }

  .mood-card {
    padding: 4px 4px 8px;
  }

  .mood-card.selected {
    border-width: 4px;
  }

  .actions-panel {
    flex-direction: column;
    width: 100%;
  }

  .actions-panel button {
    width: 100%;
  }

  .input-group {
    flex-direction: column;
  }
}
