/**
 * Story of Masses - Custom Styles
 * Modern, Premium Design with Glassmorphism
 */

/* Variables */
:root {
  /* Colors - Light Mode */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --accent-primary: #4f46e5;
  /* Indigo 600 */
  --accent-secondary: #818cf8;
  /* Indigo 400 */
  --accent-hover: #4338ca;
  /* Indigo 700 */
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;

  /* Glassmorphism */
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Noto Serif JP', serif;
}

.dark {
  /* Colors - Dark Mode */
  --bg-primary: #0f172a;
  /* Slate 900 */
  --bg-secondary: #1e293b;
  /* Slate 800 */
  --text-primary: #f1f5f9;
  /* Slate 100 */
  --text-secondary: #94a3b8;
  /* Slate 400 */
  --accent-primary: #6366f1;
  /* Indigo 500 */
  --accent-secondary: #818cf8;
  /* Indigo 400 */
  --accent-hover: #4f46e5;
  /* Indigo 600 */

  /* Glassmorphism Dark */
  --glass-bg: rgba(30, 41, 59, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Base Styles */
body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  background-image:
    radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(236, 72, 153, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
}

.story-text {
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 2;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

/* Glassmorphism Utilities */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 1rem;
}

/* Components */

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
  color: white;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.2);
  border: none;
  cursor: pointer;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--text-secondary);
  color: var(--text-primary);
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  transition: all 0.3s ease;
  cursor: pointer;
}

.btn-secondary:hover {
  background: rgba(128, 128, 128, 0.1);
}

/* Cards */
.card {
  background: var(--bg-secondary);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.dark .card {
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Title Card */
.title-card {
  /* Inherit .card styles manually since we can't use @apply in vanilla CSS */
  background: var(--bg-secondary);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  border: 1px solid rgba(0, 0, 0, 0.05);

  /* Title card specific */
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.dark .title-card {
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.title-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(to bottom, var(--accent-primary), var(--accent-secondary));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.title-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  border-color: var(--accent-secondary);
}

.title-card:hover::before {
  opacity: 1;
}

/* Section Card */
.section-card {
  /* Inherit .glass-panel styles */
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 1rem;

  padding: 2.5rem;
  margin-bottom: 2.5rem;
  position: relative;
}

.section-card::after {
  content: '§';
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-family: var(--font-serif);
  font-size: 4rem;
  opacity: 0.05;
  color: var(--text-primary);
  pointer-events: none;
}

/* Choice Card */
.choice-card {
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: 1rem;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.choice-card:hover {
  border-color: var(--accent-primary);
  transform: scale(1.01);
  box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.1);
}

.choice-card.voted {
  background-color: rgba(16, 185, 129, 0.1);
  border-color: var(--success);
}

.choice-card.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.phase-badge {
  font-family: var(--font-serif);
}

.phase-起 {
  background: #eff6ff;
  color: #1e40af;
}

.phase-承 {
  background: #fff7ed;
  color: #9a3412;
}

.phase-転 {
  background: #fef2f2;
  color: #991b1b;
}

.phase-結 {
  background: #f0fdf4;
  color: #166534;
}

.dark .phase-起 {
  background: #172554;
  color: #bfdbfe;
}

.dark .phase-承 {
  background: #431407;
  color: #fed7aa;
}

.dark .phase-転 {
  background: #450a0a;
  color: #fecaca;
}

.dark .phase-結 {
  background: #052e16;
  color: #bbf7d0;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

@keyframes pulse-soft {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.7;
  }
}

.animate-pulse-soft {
  animation: pulse-soft 2s infinite;
}

/* Modal */
.modal-backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.modal-content {
  /* Inherit .glass-panel styles */
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 1rem;

  background: var(--bg-secondary);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Loading Spinner */
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(79, 70, 229, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent-primary);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Notification */
.notification {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  background: var(--bg-secondary);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  border-left: 4px solid;
  z-index: 100;
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.notification:not(.hidden) {
  transform: translateX(0);
}

.notification.success {
  border-color: var(--success);
}

.notification.error {
  border-color: var(--error);
}

.notification.info {
  border-color: var(--accent-primary);
}

/* Progress Bar for Timer */
.timer-progress {
  height: 4px;
  background: #e2e8f0;
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.timer-bar {
  height: 100%;
  background: var(--accent-primary);
  transition: width 1s linear;
}

.dark .timer-progress {
  background: #334155;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.dark ::-webkit-scrollbar-thumb {
  background: #475569;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}