/* fonts load via <link> in index.html (preconnect + stylesheet) — an @import
   here would serialize the request chain behind this stylesheet */

:root {
  /* Default Dark Mode Theme */
  --bg: #020617;
  --surface: #0f172a;
  --surface-raised: #1e293b;
  --border: #334155;
  --border-hover: #475569;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  
  /* Aspect Colors for Dark Mode */
  --past-color: #818cf8;
  --past-bg: rgba(99, 102, 241, 0.15);
  --past-border: rgba(99, 102, 241, 0.3);
  
  --present-color: #38bdf8;
  --present-bg: rgba(14, 165, 233, 0.15);
  --present-border: rgba(14, 165, 233, 0.3);
  
  --future-color: #c084fc;
  --future-bg: rgba(168, 85, 247, 0.15);
  --future-border: rgba(168, 85, 247, 0.3);
  
  /* Grammar term styling */
  --color-verb: #f87171;
  --color-aux: #60a5fa;
  --color-part: #c084fc;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="light"] {
  /* Light Mode Theme overrides */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-raised: #f1f5f9;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #94a3b8;
  
  /* Aspect Colors for Light Mode */
  --past-color: #4f46e5;
  --past-bg: #e0e7ff;
  --past-border: #c7d2fe;
  
  --present-color: #0284c7;
  --present-bg: #e0f2fe;
  --present-border: #bae6fd;
  
  --future-color: #7c3aed;
  --future-bg: #f3e8ff;
  --future-border: #e9d5ff;
  
  /* Grammar term styling */
  --color-verb: #dc2626;
  --color-aux: #2563eb;
  --color-part: #9333ea;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
}

html {
  scroll-behavior: smooth;
  box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  background-color: var(--bg);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  transition: background-color 0.3s ease, color 0.3s ease;
}

#container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 24px 80px 24px;
}

/* Header & Controls */
header {
  margin-bottom: 40px;
  text-align: center;
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 12px 0;
  background: linear-gradient(135deg, var(--text-main) 0%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.125rem;
  max-width: 600px;
  margin: 0 auto;
}

/* Control Bar */
.control-bar {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  margin-bottom: 48px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.filter-btn:hover {
  background: var(--border);
  color: var(--text-main);
}

.filter-btn.active {
  background: var(--text-main);
  border-color: var(--text-main);
  color: var(--bg);
  box-shadow: var(--shadow-sm);
}

/* Theme Toggle Button */
.theme-btn {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.theme-btn:hover {
  background: var(--border);
  color: var(--text-main);
}

.theme-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.study-toggles {
  display: flex;
  align-items: center;
  gap: 16px;
}

.toggle-container {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.toggle-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 10px;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 24px;
  background-color: var(--border-hover);
  border-radius: 12px;
  transition: var(--transition);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: white;
  top: 3px;
  left: 3px;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-container.active .toggle-switch {
  background-color: var(--present-color);
}

.toggle-container.active .toggle-switch::after {
  left: 27px;
}

/* Timeline Components (SVG) */
.timeline-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.timeline-svg {
  width: 100%;
  max-width: 900px;
  height: auto;
  overflow: visible;
}

.timeline-axis {
  stroke: var(--border);
  stroke-width: 2px;
}

.timeline-marker {
  stroke: var(--text-light);
  stroke-width: 1px;
}

.timeline-now-line {
  stroke: var(--text-main);
  stroke-width: 2px;
  stroke-dasharray: 4 2;
}

.timeline-label {
  font-size: 0.75rem;
  font-weight: 700;
  fill: var(--text-muted);
  text-anchor: middle;
}

.timeline-label.now {
  fill: var(--text-main);
}

/* SVG Shapes */
.point-past { fill: var(--past-color); }
.point-present { fill: var(--present-color); }
.point-future { fill: var(--future-color); }

.range-bar {
  stroke-width: 8px;
  stroke-linecap: round;
}
.range-bar.past { stroke: var(--past-color); opacity: 0.7; }
.range-bar.present { stroke: var(--present-color); opacity: 0.7; }
.range-bar.future { stroke: var(--future-color); opacity: 0.7; }

.timeline-arc {
  fill: none;
  stroke-width: 2px;
  stroke-dasharray: 4 4;
}
.timeline-arc.past { stroke: var(--past-color); }
.timeline-arc.present { stroke: var(--present-color); }
.timeline-arc.future { stroke: var(--future-color); }

.arc-arrow {
  stroke-width: 2px;
  fill: none;
}
.arc-arrow.past { stroke: var(--past-color); }
.arc-arrow.present { stroke: var(--present-color); }
.arc-arrow.future { stroke: var(--future-color); }

/* Aspect Block Layout */
.aspect-section {
  margin-bottom: 56px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.aspect-title-group {
  margin-bottom: 24px;
}

.aspect-title-group h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: var(--text-main);
}

.aspect-title-group p {
  color: var(--text-muted);
  margin: 0;
}

.tense-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

@media (max-width: 1024px) {
  .tense-grid {
    grid-template-columns: 1fr;
  }
}

/* Tense Cards */
.tense-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
}

.tense-card:hover, .tense-card.highlight-hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-hover);
}

.tense-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.tense-name {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
}

.tense-badge {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
}

.tense-card.past .tense-name { color: var(--past-color); }
.tense-card.past .tense-badge { background: var(--past-bg); color: var(--past-color); }
.tense-card.past { border-top: 4px solid var(--past-color); }

.tense-card.present .tense-name { color: var(--present-color); }
.tense-card.present .tense-badge { background: var(--present-bg); color: var(--present-color); }
.tense-card.present { border-top: 4px solid var(--present-color); }

.tense-card.future .tense-name { color: var(--future-color); }
.tense-card.future .tense-badge { background: var(--future-bg); color: var(--future-color); }
.tense-card.future { border-top: 4px solid var(--future-color); }

.tense-usage {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  min-height: 48px;
}

/* Multi-Formula Styles (+, -, ?) */
.tense-formulas {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 20px;
}

.formula-row {
  display: flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.formula-type {
  font-size: 0.75rem;
  font-weight: 700;
  width: 24px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  margin-right: 8px;
  flex-shrink: 0;
}
.formula-row.pos .formula-type { background-color: rgba(34, 197, 94, 0.15); color: #22c55e; }
.formula-row.neg .formula-type { background-color: rgba(239, 68, 68, 0.15); color: #ef4444; }
.formula-row.q .formula-type { background-color: rgba(59, 130, 246, 0.15); color: #3b82f6; }

.formula-text {
  color: var(--text-main);
  word-break: break-word;
}

/* Signal Words Section */
.signal-words-box {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.signal-words-title {
  font-size: 0.6875rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 8px;
}

.signal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.signal-tag {
  font-size: 0.75rem;
  background-color: var(--surface-raised);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Examples */
.tense-examples {
  list-style: none;
  padding: 0;
  margin: 0 0 20px 0;
}

.tense-examples li {
  margin-bottom: 16px;
  font-size: 0.9375rem;
}

.tense-examples li:last-child {
  margin-bottom: 0;
}

.example-sentence {
  font-weight: 500;
  color: var(--text-main);
  display: block;
  margin-bottom: 4px;
}

/* Highlight grammar colors */
.txtgreen, .verb-past { color: var(--past-color); font-weight: 600; }
.txtred, .verb-present { color: var(--present-color); font-weight: 600; }
.txtblue, .verb-cont { color: #2563eb; font-weight: 600; }
.txtpurple, .verb-perf { color: var(--future-color); font-weight: 600; }
.aux-verb { color: var(--text-muted); font-weight: 600; border-bottom: 1px dashed var(--text-light); }

[data-theme="light"] .txtblue, [data-theme="light"] .verb-cont { color: #1d4ed8; }

.example-translation-box {
  background-color: var(--surface-raised);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  border-left: 3px solid var(--border-hover);
  transition: opacity 0.3s ease, filter 0.3s ease;
}
.translation-suffix {
  display: inline-block;
  color: var(--text-main);
  font-size: 0.875rem;
  font-weight: 600;
  margin-left: 6px;
}

.example-tr-verb {
  color: #0284c7;
  font-weight: 600;
}

[data-theme="dark"] .example-tr-verb {
  color: #38bdf8;
}

/* Self-Study Mode active styling */
body.study-mode-active .example-translation-box {
  filter: blur(4px);
  opacity: 0.25;
  cursor: pointer;
}

body.study-mode-active .example-translation-box:hover {
  filter: none;
  opacity: 1;
}

/* Study Table Section */
.study-table-section {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-top: 56px;
  box-shadow: var(--shadow-md);
}

.study-table-section h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 8px 0;
  color: var(--text-main);
}

.study-table-section p {
  color: var(--text-muted);
  margin: 0 0 24px 0;
}

.table-wrapper {
  overflow-x: auto;
}

.grid-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  min-width: 800px;
}

.grid-table th {
  background-color: var(--surface-raised);
  border-bottom: 2px solid var(--border);
  color: var(--text-main);
  font-weight: 700;
  padding: 16px;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.grid-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.9375rem;
}

.grid-table tr:hover td {
  background-color: var(--surface-raised);
}

.grid-table .time-col {
  font-weight: 700;
  width: 120px;
}

.grid-table .tense-col {
  font-weight: 600;
  width: 220px;
}

.grid-table .formula-col {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-muted);
  width: 250px;
}

.grid-table tr.past-row .tense-col { color: var(--past-color); }
.grid-table tr.past-row .time-col { color: var(--past-color); }
.grid-table tr.present-row .tense-col { color: var(--present-color); }
.grid-table tr.present-row .time-col { color: var(--present-color); }
.grid-table tr.future-row .tense-col { color: var(--future-color); }
.grid-table tr.future-row .time-col { color: var(--future-color); }

.grid-table .study-translation {
  background: var(--surface-raised);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.875rem;
  color: var(--text-muted);
  transition: opacity 0.3s ease, filter 0.3s ease;
}

body.study-mode-active .grid-table .study-translation {
  filter: blur(4px);
  opacity: 0.25;
  cursor: pointer;
}

body.study-mode-active .grid-table .study-translation:hover {
  filter: none;
  opacity: 1;
}

.comparison-tag {
  display: inline-block;
  background-color: #cbd5e1;
  color: #334155;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 4px;
}

.grid-table tr.past-row .comparison-tag { background-color: var(--past-bg); color: var(--past-color); }
.grid-table tr.present-row .comparison-tag { background-color: var(--present-bg); color: var(--present-color); }
.grid-table tr.future-row .comparison-tag { background-color: var(--future-bg); color: var(--future-color); }

/* Timeline animations & interactions */
.interactive-marker {
  cursor: pointer;
  transition: var(--transition);
}

.interactive-marker:hover {
  filter: brightness(1.2);
}

.interactive-marker.active {
  stroke-width: 3px;
  stroke: var(--text-main);
}

/* Footer credit */
footer {
  margin-top: 64px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: var(--transition);
}

footer a:hover {
  color: var(--text-main);
  text-decoration: underline;
}

/* Hide animations if user prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
