/* ===================================
   Midnight Tokyo Theme
   Dark, elegant, magical Japanese aesthetic
   =================================== */

/* ===================================
   CSS Variables - Color Palette
   =================================== */
:root {
  /* Background Colors */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a26;
  --bg-elevated: #22223a;
  
  /* Accent Colors */
  --accent-primary: #7c6fe0;
  --accent-sakura: #e879a0;
  --accent-gold: #f0c85a;
  --accent-jade: #4ade80;
  
  /* Text Colors */
  --text-primary: #f0f0f8;
  --text-secondary: #9090b0;
  --text-tertiary: #505070;
  
  /* Borders & Effects */
  --border: rgba(120, 120, 180, 0.15);
  --glow: rgba(124, 111, 224, 0.3);
  
  /* JLPT Level Colors */
  --n5-jade: #4ade80;
  --n4-blue: #60a5fa;
  --n3-yellow: #fbbf24;
  --n2-orange: #fb923c;
  --n1-red: #f87171;
}

/* ===================================
   Base Styles
   =================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'DM Sans', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  min-height: 100vh;
  position: relative;
}

/* Subtle noise texture overlay */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 1;
}

/* Japanese text styling */
.jp-text {
  font-family: 'Noto Serif JP', serif;
  letter-spacing: 0.05em;
  line-height: 2;
}

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

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-sakura);
}

/* Selection color */
::selection {
  background: var(--accent-primary);
  color: var(--text-primary);
}

/* ===================================
   Header Banner
   =================================== */
.header-banner {
  position: relative;
  width: 100%;
  max-height: 200px;
  overflow: hidden;
  animation: fadeIn 0.8s ease;
}

.banner-image {
  width: 100%;
  height: 100%;
  max-height: 200px;
  object-fit: cover;
  object-position: center;
  display: block;
}

.banner-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 40%;
  background: linear-gradient(to bottom, transparent 0%, var(--bg-primary) 100%);
  pointer-events: none;
  z-index: 2;
}

@media (max-width: 768px) {
  .header-banner {
    max-height: 120px;
  }
  
  .banner-image {
    max-height: 120px;
  }
}

/* ===================================
   Main Container
   =================================== */
.main-container {
  position: relative;
  z-index: 2;
  min-height: calc(100vh - 280px);
  padding: 2rem 0;
}

.content-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===================================
   Tab Navigation
   =================================== */
.tab-navigation {
  display: flex;
  gap: 1rem;
  margin-bottom: 2.5rem;
  justify-content: center;
}

.tab-button {
  background: none;
  border: 2px solid var(--border);
  padding: 0.875rem 2rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s ease;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
}

.tab-button .bracket-left,
.tab-button .bracket-right {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.2em;
  opacity: 0.6;
  transition: opacity 0.3s ease;
}

.tab-button:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
  transform: translateY(-2px);
}

.tab-button:hover .bracket-left,
.tab-button:hover .bracket-right {
  opacity: 1;
}

.tab-button.active {
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-sakura) 100%);
  border-color: transparent;
  color: var(--text-primary);
  box-shadow: 0 4px 20px var(--glow);
}

.tab-button.active .bracket-left,
.tab-button.active .bracket-right {
  opacity: 1;
}

/* ===================================
   Tab Content
   =================================== */
.tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab-content.active {
  display: block;
}

/* ===================================
   Section Headers
   =================================== */
.section-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ===================================
   Articles Grid
   =================================== */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-sakura);
  border-radius: 12px;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.article-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px var(--glow);
  border-left-color: var(--accent-primary);
}

.article-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 1rem;
}

.article-title {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.5;
  flex: 1;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.article-topic {
  background: var(--bg-elevated);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.article-date {
  opacity: 0.7;
}

/* Loading skeleton */
.loading-skeleton {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.skeleton-card {
  background: linear-gradient(
    90deg,
    var(--bg-card) 0%,
    var(--bg-elevated) 50%,
    var(--bg-card) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
  border-radius: 12px;
  height: 150px;
  border: 1px solid var(--border);
}

/* ===================================
   JLPT Badges
   =================================== */
.jlpt-badge {
  display: inline-block;
  padding: 0.375rem 0.875rem;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.jlpt-badge.n5 {
  background: var(--n5-jade);
  color: var(--bg-primary);
}

.jlpt-badge.n4 {
  background: var(--n4-blue);
  color: var(--bg-primary);
}

.jlpt-badge.n3 {
  background: var(--n3-yellow);
  color: var(--bg-primary);
}

.jlpt-badge.n2 {
  background: var(--n2-orange);
  color: var(--bg-primary);
}

.jlpt-badge.n1 {
  background: var(--n1-red);
  color: var(--text-primary);
}

/* ===================================
   Text Input Card
   =================================== */
.text-input-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.textarea-wrapper {
  position: relative;
  margin-bottom: 1.5rem;
}

.japanese-textarea {
  width: 100%;
  height: 120px;
  min-height: 80px;
  max-height: 200px;
  padding: 1.25rem;
  font-family: 'Noto Serif JP', serif;
  font-size: 1.05rem;
  line-height: 2;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 2px solid var(--border);
  border-radius: 12px;
  resize: vertical;
  transition: all 0.3s ease;
}

.japanese-textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--glow);
}

.japanese-textarea::placeholder {
  color: var(--text-tertiary);
}

.character-counter {
  text-align: right;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.char-count-number {
  font-weight: 700;
  color: var(--accent-primary);
}

.char-count-max {
  opacity: 0.6;
}

/* ===================================
   Buttons
   =================================== */
.action-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.analyze-button {
  position: relative;
  padding: 1rem 3rem;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-sakura) 100%);
  color: var(--text-primary);
  font-family: 'Noto Serif JP', serif;
  font-size: 1.25rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
  box-shadow: 0 4px 20px var(--glow);
}

.analyze-button:hover {
  box-shadow: 0 6px 30px var(--glow), 0 0 40px rgba(232, 121, 160, 0.2);
}

.analyze-button:active {
  transform: scale(0.98);
}

.analyze-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-glow {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s;
}

.analyze-button:hover .button-glow {
  left: 100%;
}

/* ===================================
   Loading Spinner
   =================================== */
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.spinner-ring {
  width: 50px;
  height: 50px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ===================================
   Error Message
   =================================== */
.error-message {
  background: rgba(248, 113, 113, 0.1);
  color: var(--n1-red);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  border-left: 4px solid var(--n1-red);
  margin-top: 1rem;
  font-weight: 500;
}

/* ===================================
   Results Page
   =================================== */
.results-container {
  max-width: 900px;
  margin: 0 auto;
}

.results-section {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.results-section:last-of-type {
  border-bottom: none;
}

.results-section .section-title {
  font-size: 1.5rem;
  text-align: left;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

/* Original Text Card */
.original-text-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  position: relative;
}

.jlpt-badge-container {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
}

.original-text-display {
  font-size: 1.35rem;
  line-height: 2.2;
  margin-bottom: 1.5rem;
  padding-right: 5rem;
}

.original-text-display ruby {
  ruby-position: over;
}

.original-text-display rt {
  font-size: 0.55em;
  color: var(--text-secondary);
  opacity: 0.8;
}

.text-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.listen-button {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-sakura) 100%);
  color: var(--text-primary);
  font-family: 'Noto Serif JP', serif;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 12px var(--glow);
}

.listen-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px var(--glow);
}

.listen-button:active {
  transform: scale(0.98);
}

.listen-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Vocabulary Grid */
.vocabulary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.vocab-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  transition: all 0.3s ease;
  position: relative;
}

.vocab-card:hover {
  border-color: var(--accent-primary);
  box-shadow: 0 4px 20px var(--glow);
  transform: translateY(-2px);
}

.vocab-reading {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.vocab-word {
  font-family: 'Noto Serif JP', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.vocab-meaning {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

/* Grammar List */
.grammar-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.grammar-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-gold);
  border-radius: 12px;
  padding: 1.5rem;
}

.grammar-structure {
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 0.75rem;
}

.grammar-explanation {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.grammar-example {
  font-family: 'Noto Serif JP', serif;
  font-size: 0.95rem;
  color: var(--text-tertiary);
  font-style: italic;
  padding: 0.75rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-top: 0.5rem;
}

/* Translation Card */
.translation-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

/* Cultural Notes List */
.cultural-notes-list {
  list-style: none;
  padding: 0;
}

.cultural-notes-list li {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent-gold);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

/* Results Actions */
.results-actions {
  text-align: center;
  margin-top: 3rem;
  padding-top: 2rem;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2rem;
  background: var(--bg-card);
  border: 2px solid var(--border);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 12px;
  transition: all 0.3s ease;
}

.back-button:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px var(--glow);
}

.back-arrow {
  font-size: 1.2em;
}

/* ===================================
   Footer
   =================================== */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 4rem;
  position: relative;
  z-index: 2;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  text-align: center;
}

.footer-content p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

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

@keyframes inkReveal {
  from {
    opacity: 0;
    transform: translateY(8px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 4px 20px var(--glow);
  }
  50% {
    box-shadow: 0 6px 40px var(--glow), 0 0 60px rgba(232, 121, 160, 0.2);
  }
}

@keyframes shimmer {
  from {
    background-position: -200% 0;
  }
  to {
    background-position: 200% 0;
  }
}

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

/* Staggered reveal for results sections */
.reveal {
  animation: inkReveal 0.6s ease forwards;
  opacity: 0;
}

.reveal:nth-child(1) { animation-delay: 0.1s; }
.reveal:nth-child(2) { animation-delay: 0.2s; }
.reveal:nth-child(3) { animation-delay: 0.3s; }
.reveal:nth-child(4) { animation-delay: 0.4s; }
.reveal:nth-child(5) { animation-delay: 0.5s; }

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 768px) {
  .content-wrapper {
    padding: 0 1rem;
  }

  .section-title {
    font-size: 1.5rem;
  }

  .tab-navigation {
    flex-direction: column;
    gap: 0.75rem;
  }

  .tab-button {
    width: 100%;
  }

  .articles-grid {
    grid-template-columns: 1fr;
  }

  .vocabulary-grid {
    grid-template-columns: 1fr;
  }

  .text-input-card {
    padding: 1.5rem;
  }

  .japanese-textarea {
    min-height: 180px;
    font-size: 1rem;
  }

  .analyze-button {
    width: 100%;
    padding: 0.875rem 2rem;
    font-size: 1.1rem;
  }

  .original-text-display {
    font-size: 1.15rem;
    padding-right: 0;
  }

  .jlpt-badge-container {
    position: static;
    margin-bottom: 1rem;
  }
}

@media (max-width: 480px) {
  .main-container {
    padding: 1rem 0;
  }

  .section-title {
    font-size: 1.25rem;
  }

  .text-input-card {
    padding: 1rem;
  }

  .original-text-card {
    padding: 1.25rem;
  }
}

/* Made with Bob */
