/* styles.css */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Courier+Prime:ital,wght@0,400;0,700;1,400&display=swap');

:root {
  --bg-color: #050510;
  --accent: rgba(255, 255, 255, 0.2);
  --text-main: #e0e0e8;
  --text-muted: #8b8b9d;
  --card-bg: rgba(255, 255, 255, 0.04);
  --font-heading: 'Cormorant Garamond', serif;
  --font-ui: 'Courier Prime', monospace;
  --transition: 0.3s ease;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-ui);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

h1, h2, h3, h4, h5, h6, .dream-text {
  font-family: var(--font-heading);
  font-weight: 400;
}

/* Starfield */
#stars {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: -2;
  background: transparent;
  pointer-events: none;
}
.star {
  position: absolute;
  background: white;
  border-radius: 50%;
  animation: twinkle linear infinite;
}
@keyframes twinkle {
  0% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0.2; transform: scale(0.8); }
}

/* Ambient Radial Mood Glow */
#mood-glow {
  position: fixed;
  top: 50%; left: 50%;
  width: 150vw; height: 150vh;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, var(--accent) 0%, transparent 60%);
  opacity: 0.2;
  z-index: -1;
  transition: background 1s ease, opacity 1s ease;
  pointer-events: none;
}

/* Common Layout */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 30px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  transition: transform var(--transition), border-color var(--transition);
}
.card.hoverable:hover {
  transform: translateY(-4px);
  border-color: rgba(255,255,255,0.4);
}

/* Inputs & Buttons */
input, textarea, select {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  box-sizing: border-box;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--text-main);
  box-shadow: 0 0 10px rgba(255,255,255,0.1);
}

button {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--accent);
  padding: 12px 24px;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:hover {
  background: var(--text-main);
  color: var(--bg-color);
}
button.primary {
  background: rgba(255,255,255,0.1);
  border-color: var(--text-main);
}
button.primary:hover {
  background: var(--text-main);
  color: var(--bg-color);
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

a {
  color: var(--text-main);
  text-decoration: none;
  transition: opacity var(--transition);
}
a:hover {
  opacity: 0.7;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.error-msg {
  color: #ff8b8b;
  font-size: 0.85rem;
  margin-top: 5px;
  display: none;
}
.error-msg.visible {
  display: block;
}

/* Loading Spinner */
.spinner-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity var(--transition);
  flex-direction: column;
  gap: 20px;
}
.spinner-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.spinner {
  width: 40px; height: 40px;
  border: 2px solid var(--accent);
  border-top-color: var(--text-main);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* Nav */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.logo {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 600;
  letter-spacing: 1px;
}
.user-menu {
  display: flex;
  align-items: center;
  gap: 15px;
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--card-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--accent);
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}
.avatar img {
  width: 100%; height: 100%; object-fit: cover;
}

/* Home Hero */
.hero {
  text-align: center;
  padding: 60px 0;
}
.moon {
  width: 120px; height: 120px;
  background: radial-gradient(circle at 30% 30%, #fff, #d4d4d8, #52525b);
  border-radius: 50%;
  margin: 0 auto 30px;
  box-shadow: 0 0 40px rgba(255,255,255,0.2);
  animation: float 6s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}
.hero h1 {
  font-size: 3.5rem;
  margin-bottom: 20px;
}

/* Log Dream */
.mood-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}
.mood-pill {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--accent);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.9rem;
  user-select: none;
}
.mood-pill:hover, .mood-pill.active {
  background: rgba(255,255,255,0.2);
  border-color: var(--text-main);
}
textarea {
  min-height: 200px;
  resize: vertical;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  line-height: 1.6;
}

/* Dream Cards */
.dreams-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 30px;
}
.dream-card {
  cursor: pointer;
}
.dream-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.dream-fragment {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mood-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.1);
  font-size: 0.8rem;
}

/* Result / Archive Modal */
.fragment-quote {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-style: italic;
  border-left: 2px solid var(--accent);
  padding-left: 20px;
  margin: 0 0 30px 0;
  color: var(--text-muted);
}
.continuation-text {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  line-height: 1.8;
  white-space: pre-wrap;
}
.translate-panel {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.translate-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.translation-result {
  display: none;
  margin-top: 20px;
}
.translation-result.active {
  display: block;
}
.flag-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.1);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 0.9rem;
  margin-bottom: 15px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5,5,16,0.9);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal-content {
  width: 90%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 15px; right: 15px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--accent);
  border-radius: 50%;
  width: 40px; height: 40px;
  font-size: 1.5rem;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mt-40 { margin-top: 40px; }
.flex { display: flex; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-10 { gap: 10px; }
.w-full { width: 100%; }
.mb-20 { margin-bottom: 20px; }
.glass-panel {
  background: var(--card-bg);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 40px;
  backdrop-filter: blur(10px);
}

@media (max-width: 600px) {
  nav { padding: 15px 20px; }
  .hero h1 { font-size: 2.5rem; }
  .translate-controls { flex-direction: column; }
}
