/* Kotoba Web App - Japanese Minimalist Design */
/* Ma (間) — Negative space, breathing room */

:root {
  --bg: #ffffff;
  --surface: #fafafa;
  --surface-hover: #f5f5f5;
  --border: #e8e8e8;
  --text: #1a1a1a;
  --text-2: #666666;
  --text-3: #999999;
  --accent: #2c5aa0;
  --accent-hover: #1a3d6e;
  --warning: #e67e22;
  --warning-bg: #fdf2e9;
  --success: #27ae60;
  --n5: #3498db;
  --n4: #2ecc71;
  --n3: #f39c12;
  --n2: #e74c3c;
  --n1: #9b59b6;
  
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  --radius: 8px;
  --radius-lg: 12px;
  --max-width: 640px;
  
  --font-en: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-jp: 'Noto Sans JP', 'Hiragino Sans', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-en);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Typography */
h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.4;
}

.japanese {
  font-family: var(--font-jp);
  line-height: 1.8;
}

/* Screens */
.screen {
  display: none;
  min-height: 100vh;
}

.screen.active {
  display: block;
}

/* Auth Screen */
.auth-container {
  max-width: 400px;
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.logo {
  text-align: center;
  margin-bottom: var(--space-lg);
}

.logo-ja {
  display: block;
  font-family: var(--font-jp);
  font-size: 4rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: var(--space-sm);
}

.logo-en {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}

.tagline {
  color: var(--text-2);
  font-size: 0.9375rem;
  margin-bottom: var(--space-2xl);
  text-align: center;
}

/* Auth Tabs */
.auth-tabs {
  display: flex;
  gap: var(--space-sm);
  width: 100%;
  margin-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: var(--space-md);
  background: none;
  border: none;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  position: relative;
  transition: color 0.2s ease;
}

.auth-tab.active {
  color: var(--accent);
}

.auth-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
}

/* Forms */
.auth-form {
  width: 100%;
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input {
  width: 100%;
  padding: var(--space-md);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: var(--font-en);
  transition: border-color 0.2s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Buttons */
.btn {
  padding: var(--space-md) var(--space-xl);
  border: none;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: none;
  border: 1px solid var(--border);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--surface);
}

/* Main App */
.app-header {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.header-left .logo-small {
  font-family: var(--font-jp);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.header-nav {
  display: flex;
  gap: var(--space-xs);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  color: var(--text-3);
}

.nav-btn.active {
  color: var(--accent);
  background: var(--surface);
}

.nav-icon {
  font-family: var(--font-jp);
  font-size: 1.25rem;
  font-weight: 700;
}

.nav-label {
  font-size: 0.625rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* App Main */
.app-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
}

/* Views */
.view {
  display: none;
}

.view.active {
  display: block;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.view-label {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
}

/* Level Badges */
.level-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 100px;
  background: var(--surface);
}

.level-badge.n5 { background: rgba(52, 152, 219, 0.15); color: var(--n5); }
.level-badge.n4 { background: rgba(46, 204, 113, 0.15); color: var(--n4); }
.level-badge.n3 { background: rgba(243, 156, 18, 0.15); color: var(--n3); }
.level-badge.n2 { background: rgba(231, 76, 60, 0.15); color: var(--n2); }
.level-badge.n1 { background: rgba(155, 89, 182, 0.15); color: var(--n1); }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  margin-bottom: var(--space-lg);
}

/* Word Card */
.word-main {
  text-align: center;
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-xl);
}

.word-jp {
  font-family: var(--font-jp);
  font-size: 3rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  line-height: 1.3;
}

.word-reading {
  font-family: var(--font-jp);
  font-size: 1.25rem;
  color: var(--text-2);
  margin-bottom: var(--space-md);
}

.word-meaning {
  font-size: 1.125rem;
  color: var(--text);
  font-weight: 500;
}

/* Grammar Card */
.grammar-main {
  text-align: center;
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-xl);
}

.grammar-pattern {
  font-family: var(--font-jp);
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: var(--space-sm);
  line-height: 1.4;
}

.grammar-meaning {
  font-size: 1.125rem;
  color: var(--text-2);
}

/* Details Sections */
.detail-section {
  margin-bottom: var(--space-xl);
}

.detail-section:last-child {
  margin-bottom: 0;
}

.detail-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: var(--space-md);
}

.detail-label::before {
  content: '';
  width: 4px;
  height: 16px;
  background: var(--accent);
  border-radius: 2px;
}

.detail-label.warning::before {
  background: var(--warning);
}

.detail-text {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-2);
}

.detail-text.warning-text {
  background: var(--warning-bg);
  padding: var(--space-md);
  border-radius: var(--radius);
  border-left: 3px solid var(--warning);
}

/* Conjugation Box */
.conjugation-box {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  font-family: var(--font-jp);
  font-size: 1rem;
  line-height: 1.8;
}

/* Examples */
.examples-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.example-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.example-item .example-jp {
  color: var(--text);
  font-weight: 500;
}

.example-item .example-meaning {
  color: var(--text-2);
}

.example-item:hover {
  border-color: var(--accent);
}

.example-jp {
  font-family: var(--font-jp);
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: var(--space-xs);
  color: var(--text);
}

.example-reading {
  font-family: var(--font-jp);
  font-size: 0.875rem;
  color: var(--text-3);
  margin-bottom: var(--space-sm);
  display: none;
}

.example-item.show-reading .example-reading {
  display: block;
}

.example-meaning {
  font-size: 0.9375rem;
  color: var(--text-2);
  margin-bottom: var(--space-sm);
}

.example-context {
  font-size: 0.75rem;
  color: var(--text-3);
  font-style: italic;
}

.example-alt {
  font-size: 0.75rem;
  color: var(--accent);
  margin-top: var(--space-sm);
}

.example-context {
  font-size: 0.75rem;
  color: var(--text-3);
  font-style: italic;
}

.example-alt {
  font-size: 0.75rem;
  color: var(--accent);
  margin-top: var(--space-sm);
}

/* Related Patterns */
.related-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.related-item {
  background: rgba(44, 90, 160, 0.05);
  border-radius: var(--radius);
  padding: var(--space-md);
}

.related-pattern {
  font-family: var(--font-jp);
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.related-relationship {
  font-size: 0.75rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-xs);
}

.related-difference {
  font-size: 0.8125rem;
  color: var(--accent);
  line-height: 1.5;
}

/* Actions */
.actions {
  display: flex;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}

.actions .btn {
  flex: 1;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: var(--space-sm);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Progress Bars */
.level-progress {
  margin-top: var(--space-xl);
}

.progress-item {
  margin-bottom: var(--space-lg);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  margin-bottom: var(--space-sm);
}

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-fill.n5 { background: var(--n5); }
.progress-fill.n4 { background: var(--n4); }
.progress-fill.n3 { background: var(--n3); }
.progress-fill.n2 { background: var(--n2); }
.progress-fill.n1 { background: var(--n1); }

/* Loading */
#loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

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

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

/* Errors */
.auth-error {
  color: #e74c3c;
  font-size: 0.875rem;
  text-align: center;
  margin-top: var(--space-md);
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Responsive */
@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .word-jp {
    font-size: 4rem;
  }
  
  .grammar-pattern {
    font-size: 3rem;
  }
}

/* Force light mode - clean white like portfolio */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #ffffff;
    --surface: #fafafa;
    --surface-hover: #f5f5f5;
    --border: #e8e8e8;
    --text: #1a1a1a;
    --text-2: #666666;
    --text-3: #999999;
  }
}