/* ========================================
   Fiches Visuelles - Design System
   ======================================== */

/* --- Subject Tabs --- */
.fiches-tabs {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.fiches-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 2px solid var(--border);
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  transition: all 0.25s ease;
  box-shadow: var(--shadow);
}

.fiches-tab:hover {
  border-color: var(--tab-color);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.fiches-tab.active {
  background: var(--tab-color, var(--primary));
  border-color: var(--tab-color, var(--primary));
  color: white;
  box-shadow: 0 4px 16px rgba(27, 42, 74, 0.25);
}

.fiches-tab-icon { font-size: 1.3rem; }

.fiches-tab-count {
  background: rgba(0,0,0,0.1);
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 800;
}

.fiches-tab.active .fiches-tab-count {
  background: rgba(255,255,255,0.25);
}

/* --- Level Sections --- */
.fiches-subject-content {
  animation: fadeIn 0.3s ease;
}

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

.fiches-level-section {
  margin-bottom: 2rem;
}

.fiches-level-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.fiches-level-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--level-color);
}

.fiches-level-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  margin-left: auto;
}

/* --- Index Page --- */
.fiches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.fiche-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-top: 4px solid var(--card-color, var(--primary));
  position: relative;
  overflow: hidden;
}

.fiche-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.fiche-card-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.fiche-card h4 {
  font-size: 1.05rem;
  color: var(--text);
  margin: 0;
}

.fiche-card p {
  font-size: 0.85rem;
  color: var(--text-light);
  margin: 0;
  line-height: 1.5;
}

.fiche-card .fiche-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: auto;
}

.fiche-tag {
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.fiche-tag-level {
  background: var(--primary-light);
  color: var(--primary);
}

.fiche-tag-diff {
  background: var(--success-light);
  color: var(--success);
}

/* --- Show Page --- */
.fiche-page {
  max-width: 900px;
  margin: 0 auto;
}

.fiche-hero {
  background: linear-gradient(135deg, var(--fiche-color, var(--primary)) 0%, color-mix(in srgb, var(--fiche-color, var(--primary)) 70%, #000) 100%);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  color: white;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.fiche-hero::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

.fiche-hero-icon { font-size: 3rem; margin-bottom: 0.5rem; }
.fiche-hero h1 { font-size: 1.8rem; margin-bottom: 0.5rem; position: relative; z-index: 1; }
.fiche-hero p { opacity: 0.9; font-size: 1rem; position: relative; z-index: 1; }

.fiche-body {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow);
  line-height: 1.9;
  font-size: 1.05rem;
}

.fiche-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2rem;
}

.fiche-nav-counter {
  display: flex;
  align-items: center;
  color: var(--text-light);
  font-size: 0.9rem;
}

/* ========================================
   Visual Components for Math Fiches
   ======================================== */

/* --- Concept Box --- */
.concept-box {
  background: linear-gradient(135deg, #667eea11, #764ba211);
  border: 2px solid #667eea33;
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  margin: 1.5rem 0;
  position: relative;
}

.concept-box::before {
  content: attr(data-label);
  position: absolute;
  top: -0.7rem;
  left: 1.5rem;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 0.15rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* --- Formula Card --- */
.formula-card {
  background: linear-gradient(135deg, #6C5CE7 0%, #a29bfe 100%);
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  margin: 1.5rem 0;
  color: white;
  text-align: center;
}

.formula-card .formula-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.8;
  margin-bottom: 0.5rem;
}

.formula-card .formula-main {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
  margin: 0.5rem 0;
}

.formula-card .formula-note {
  font-size: 0.85rem;
  opacity: 0.85;
  margin-top: 0.5rem;
}

/* --- Example Visual --- */
.example-visual {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  margin: 1.5rem 0;
  border-left: 5px solid var(--secondary);
}

.example-visual .example-label {
  display: inline-block;
  background: var(--secondary);
  color: white;
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.example-visual .example-content {
  font-size: 1.1rem;
}

/* --- Step-by-Step --- */
.steps-container {
  margin: 1.5rem 0;
}

.step {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px dashed var(--border);
  align-items: flex-start;
}

.step:last-child { border-bottom: none; }

.step-number {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
}

.step-content {
  flex: 1;
}

.step-content .step-title {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.3rem;
}

/* --- Tip / Warning / Remember --- */
.tip-visual {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  margin: 1.5rem 0;
}

.tip-visual.tip-info {
  background: #e3f2fd;
  border-left: 4px solid #2196F3;
}

.tip-visual.tip-warning {
  background: #fff3e0;
  border-left: 4px solid #FF9800;
}

.tip-visual.tip-success {
  background: #e8f5e9;
  border-left: 4px solid #4CAF50;
}

.tip-visual.tip-danger {
  background: #ffebee;
  border-left: 4px solid #f44336;
}

.tip-visual .tip-icon {
  font-size: 1.5rem;
  min-width: 2rem;
}

.tip-visual .tip-text {
  flex: 1;
}

.tip-visual .tip-text strong {
  display: block;
  margin-bottom: 0.3rem;
}

/* --- Comparison Table --- */
.compare-table {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0;
}

.compare-col {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 2px solid var(--border);
}

.compare-col.compare-good {
  border-color: var(--success);
  background: #00b89410;
}

.compare-col.compare-bad {
  border-color: var(--danger);
  background: #d6303110;
}

.compare-col .compare-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.compare-col.compare-good .compare-header { color: var(--success); }
.compare-col.compare-bad .compare-header { color: var(--danger); }

/* --- Number Line --- */
.number-line-container {
  margin: 1.5rem 0;
  padding: 1.5rem;
  background: var(--bg);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.number-line {
  position: relative;
  height: 80px;
  min-width: 500px;
}

.number-line .axis {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--text);
}

.number-line .axis::after {
  content: '';
  position: absolute;
  right: -8px;
  top: -5px;
  border: 6px solid transparent;
  border-left: 10px solid var(--text);
}

.number-line .tick {
  position: absolute;
  top: 32px;
  width: 3px;
  height: 18px;
  background: var(--text);
}

.number-line .tick-label {
  position: absolute;
  top: 55px;
  transform: translateX(-50%);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.number-line .point {
  position: absolute;
  top: 30px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transform: translateX(-50%);
  z-index: 2;
}

.number-line .point-label {
  position: absolute;
  top: 5px;
  transform: translateX(-50%);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

/* --- Visual Fraction --- */
.fraction-visual {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin: 0 0.5rem;
  vertical-align: middle;
}

.fraction-visual .fv-num,
.fraction-visual .fv-den {
  padding: 0.1rem 0.4rem;
  font-weight: 700;
  font-size: 1.1rem;
}

.fraction-visual .fv-bar {
  width: 100%;
  height: 2px;
  background: var(--text);
}

/* --- Fraction Pie --- */
.fraction-pies {
  display: flex;
  gap: 2rem;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 1.5rem 0;
  padding: 1.5rem;
  background: var(--bg);
  border-radius: var(--radius-lg);
}

.fraction-pie {
  text-align: center;
}

.fraction-pie svg {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.fraction-pie .pie-label {
  display: block;
  margin-top: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}

/* --- Geometry Diagram --- */
.geo-diagram {
  display: flex;
  justify-content: center;
  padding: 1.5rem;
  margin: 1.5rem 0;
  background: var(--bg);
  border-radius: var(--radius-lg);
}

.geo-diagram svg {
  max-width: 100%;
  height: auto;
}

.geo-diagram svg text {
  font-family: var(--font);
  font-weight: 700;
}

.geo-diagram svg .shape-fill { opacity: 0.15; }
.geo-diagram svg .shape-stroke { stroke-width: 2.5; fill: none; }
.geo-diagram svg .dimension { stroke-dasharray: 5,5; opacity: 0.6; }
.geo-diagram svg .label { font-size: 14px; fill: var(--text); }
.geo-diagram svg .label-accent { font-size: 14px; fill: var(--primary); font-weight: 800; }

/* --- Color-coded calculation --- */
.calc-steps {
  font-family: 'Courier New', monospace;
  font-size: 1.15rem;
  background: #1a1a2e;
  color: #e0e0e0;
  border-radius: var(--radius-lg);
  padding: 1.5rem 2rem;
  margin: 1.5rem 0;
  line-height: 2.2;
  overflow-x: auto;
}

.calc-steps .c-blue { color: #64b5f6; }
.calc-steps .c-green { color: #81c784; }
.calc-steps .c-orange { color: #ffb74d; }
.calc-steps .c-pink { color: #f48fb1; }
.calc-steps .c-red { color: #ef5350; }
.calc-steps .c-purple { color: #ce93d8; }
.calc-steps .c-yellow { color: #fff176; }
.calc-steps .c-white { color: #ffffff; font-weight: 700; }
.calc-steps .c-comment { color: #78909c; font-style: italic; }
.calc-steps .c-arrow { color: #4dd0e1; }
.calc-steps .c-result { color: #69f0ae; font-weight: 700; font-size: 1.3rem; }

/* --- Interactive Cards Grid --- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.info-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 2px solid var(--border);
  text-align: center;
  transition: all var(--transition);
}

.info-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

.info-card .card-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.info-card .card-title { font-weight: 700; color: var(--primary); margin-bottom: 0.3rem; }
.info-card .card-desc { font-size: 0.85rem; color: var(--text-light); }

/* --- Coordinate Grid --- */
.coord-grid {
  display: flex;
  justify-content: center;
  padding: 1.5rem;
  margin: 1.5rem 0;
  background: var(--bg);
  border-radius: var(--radius-lg);
}

.coord-grid svg .grid-line { stroke: #e0e0e0; stroke-width: 0.5; }
.coord-grid svg .axis-line { stroke: var(--text); stroke-width: 2; }
.coord-grid svg .axis-arrow { fill: var(--text); }
.coord-grid svg .plot-point { fill: var(--primary); }
.coord-grid svg .plot-line { stroke: var(--primary); stroke-width: 2.5; fill: none; }

/* --- Progress indicator --- */
.visual-progress {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0;
}

.visual-progress .vp-block {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--border);
  transition: all var(--transition);
}

.visual-progress .vp-block.filled {
  background: var(--success);
}

/* --- Section divider --- */
.section-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2.5rem 0 1.5rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
}

.section-divider::after {
  content: '';
  flex: 1;
  height: 3px;
  background: linear-gradient(to right, var(--primary), transparent);
  border-radius: 2px;
}

/* --- Math expression with highlight --- */
.math-expr {
  display: inline-block;
  background: var(--primary-light);
  padding: 0.3rem 0.7rem;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  font-size: 1.05em;
  color: var(--primary-dark);
}

.math-big {
  display: block;
  text-align: center;
  font-family: 'Courier New', monospace;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--primary);
  margin: 1rem 0;
  letter-spacing: 1px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .fiche-body { padding: 1.5rem; }
  .fiche-hero { padding: 1.5rem; }
  .compare-table { grid-template-columns: 1fr; }
  .fiches-grid { grid-template-columns: 1fr; }
  .fiches-tabs { gap: 0.5rem; }
  .fiches-tab { padding: 0.6rem 1rem; font-size: 0.85rem; }
  .fiches-tab-icon { font-size: 1.1rem; }
  .fraction-pies { gap: 1rem; }
  .calc-steps { font-size: 0.95rem; padding: 1rem; }
  .formula-card .formula-main { font-size: 1.2rem; }
}
