/* ============================================================
   MATE 6TO BIMESTRE 3 — PWA STYLES (Mobile-First, Tablet-Optimized)
   ============================================================ */

:root {
  --bg: #0f0f23;
  --bg-card: #1a1a2e;
  --bg-input: #16213e;
  --text: #e0e0e0;
  --text-dim: #8888aa;
  --accent: #4fc3f7;
  --accent2: #81c784;
  --accent3: #ffb74d;
  --danger: #ef5350;
  --success: #66bb6a;
  --warning: #ffa726;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

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

html {
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── Header ── */
.header {
  background: var(--bg-card);
  padding: 1rem;
  text-align: center;
  border-bottom: 2px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 1.3rem;
  color: var(--accent);
  font-weight: 700;
}

.header .subtitle {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

/* ── Back button ── */
.back-btn {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Main content ── */
.main {
  flex: 1;
  padding: 1rem;
  padding-bottom: 5rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 2px solid rgba(79,195,247,0.3);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.3rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.65rem;
  cursor: pointer;
  min-height: 56px;
  transition: color 0.2s, background 0.2s;
}

.nav-tab .nav-icon {
  font-size: 1.4rem;
  margin-bottom: 0.15rem;
}

.nav-tab.active {
  color: var(--accent);
  background: rgba(79,195,247,0.08);
}

/* ── Home Screen ── */
.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.home-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.15s;
  box-shadow: var(--shadow);
}

.home-card:active { transform: scale(0.98); }

.home-card:nth-child(1) { border-color: var(--accent); }
.home-card:nth-child(2) { border-color: var(--accent2); }
.home-card:nth-child(3) { border-color: var(--accent3); }

.home-card .card-icon {
  font-size: 2.5rem;
  min-width: 60px;
  text-align: center;
}

.home-card .card-info h2 {
  font-size: 1.2rem;
  margin-bottom: 0.3rem;
}

.home-card .card-info p {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* ── Info banner ── */
.info-banner {
  background: rgba(79,195,247,0.1);
  border: 1px solid rgba(79,195,247,0.3);
  border-radius: var(--radius);
  padding: 1rem;
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.info-banner strong {
  color: var(--accent);
}

/* ── Topic List ── */
.topic-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

.topic-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.05);
  transition: border-color 0.2s, transform 0.1s;
  min-height: 56px;
}

.topic-item:active { transform: scale(0.98); }
.topic-item:hover { border-color: rgba(79,195,247,0.3); }

.topic-item .topic-icon { font-size: 1.5rem; min-width: 40px; text-align: center; }
.topic-item .topic-name { font-size: 0.9rem; flex: 1; }

.topic-item .topic-status {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  background: rgba(255,255,255,0.05);
  color: var(--text-dim);
}

.topic-item .topic-status.done {
  background: rgba(102,187,106,0.2);
  color: var(--success);
}

/* ── Content Area (Guía) ── */
.content-area {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-top: 1rem;
  line-height: 1.7;
  font-size: 0.95rem;
}

.content-area h3 {
  color: var(--accent);
  font-size: 1.2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(79,195,247,0.2);
}

.content-area h4 {
  color: var(--accent3);
  font-size: 1rem;
  margin: 1rem 0 0.5rem;
}

.content-area p { margin-bottom: 0.6rem; }

.content-area ul, .content-area ol {
  padding-left: 1.5rem;
  margin-bottom: 0.8rem;
}

.content-area li { margin-bottom: 0.3rem; }

.ejemplo {
  background: rgba(79,195,247,0.08);
  border-left: 3px solid var(--accent);
  padding: 0.8rem 1rem;
  margin: 0.8rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.8;
}

.formula {
  background: rgba(129,199,132,0.1);
  border: 1px solid rgba(129,199,132,0.3);
  padding: 0.8rem;
  margin: 0.8rem 0;
  border-radius: var(--radius);
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent2);
}

.tabla-equiv {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0;
}

.tabla-equiv th, .tabla-equiv td {
  padding: 0.5rem;
  border: 1px solid rgba(255,255,255,0.1);
  text-align: center;
  font-size: 0.85rem;
}

.tabla-equiv th {
  background: rgba(79,195,247,0.15);
  color: var(--accent);
}

.plano {
  font-family: monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  padding: 0.5rem;
  color: var(--accent);
}

/* ── Exercise Cards ── */
.exercise-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1rem;
  border: 2px solid rgba(255,255,255,0.05);
}

.exercise-card.correct { border-color: var(--success); }
.exercise-card.incorrect { border-color: var(--danger); }

.exercise-number {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.exercise-question {
  font-size: 1rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.exercise-input {
  width: 100%;
  padding: 0.8rem;
  background: var(--bg-input);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: var(--text);
  font-size: 1.1rem;
  outline: none;
  transition: border-color 0.2s;
}

.exercise-input:focus {
  border-color: var(--accent);
}

.exercise-input.correct { border-color: var(--success); }
.exercise-input.incorrect { border-color: var(--danger); }

/* ── Options ── */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option-btn {
  background: var(--bg-input);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  color: var(--text);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  min-height: 48px;
  transition: border-color 0.2s, background 0.2s;
}

.option-btn:active { background: rgba(79,195,247,0.1); }
.option-btn.selected { border-color: var(--accent); background: rgba(79,195,247,0.1); }
.option-btn.correct { border-color: var(--success); background: rgba(102,187,106,0.15); }
.option-btn.incorrect { border-color: var(--danger); background: rgba(239,83,80,0.1); }
.option-btn:disabled { opacity: 0.7; cursor: default; }

/* ── Comparison Buttons ── */
.comparison-btns {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
}

.comp-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 2px solid rgba(255,255,255,0.15);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.comp-btn:active { transform: scale(0.95); }
.comp-btn.selected { border-color: var(--accent); background: rgba(79,195,247,0.15); }
.comp-btn.correct { border-color: var(--success); background: rgba(102,187,106,0.2); }
.comp-btn.incorrect { border-color: var(--danger); background: rgba(239,83,80,0.15); }

/* ── Coordinate Inputs ── */
.coord-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  font-size: 1.2rem;
}

.coord-inputs input {
  width: 60px;
  text-align: center;
}

/* ── Feedback ── */
.feedback {
  margin-top: 0.8rem;
  padding: 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.5;
  display: none;
}

.feedback.show { display: block; }
.feedback.correct {
  background: rgba(102,187,106,0.12);
  border: 1px solid rgba(102,187,106,0.3);
  color: var(--success);
}
.feedback.incorrect {
  background: rgba(239,83,80,0.1);
  border: 1px solid rgba(239,83,80,0.3);
  color: #ff8a80;
}

/* ── Check Button ── */
.check-btn {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.8rem;
  min-height: 48px;
  width: 100%;
  transition: opacity 0.2s;
}

.check-btn:active { opacity: 0.8; }
.check-btn:disabled { opacity: 0.5; cursor: default; }

.next-btn {
  background: var(--accent2);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 0.8rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
  min-height: 48px;
  width: 100%;
}

/* ── Progress ── */
.progress-bar {
  background: rgba(255,255,255,0.1);
  border-radius: 20px;
  height: 8px;
  margin: 1rem 0;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.4s ease;
}

.progress-text {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

/* ── Score Screen ── */
.score-screen {
  text-align: center;
  padding: 2rem 1rem;
}

.score-big {
  font-size: 4rem;
  font-weight: 800;
  margin: 1rem 0;
}

.score-big.good { color: var(--success); }
.score-big.ok { color: var(--warning); }
.score-big.bad { color: var(--danger); }

.score-label {
  font-size: 1.2rem;
  color: var(--text-dim);
  margin-bottom: 2rem;
}

.score-breakdown {
  text-align: left;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1.5rem 0;
}

.score-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-size: 0.85rem;
}

.score-row:last-child { border-bottom: none; }
.score-row .right { color: var(--success); }
.score-row .wrong { color: var(--danger); }

/* ── Review Section ── */
.review-section {
  margin-top: 1.5rem;
}

.review-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.8rem;
  border-left: 4px solid var(--danger);
}

.review-item.was-correct {
  border-left-color: var(--success);
}

.review-q { font-size: 0.9rem; margin-bottom: 0.5rem; }
.review-answer { font-size: 0.8rem; color: var(--text-dim); }
.review-correct { font-size: 0.85rem; color: var(--success); font-weight: 600; }

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  padding: 0.8rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  display: inline-block;
  transition: opacity 0.2s;
}

.btn-primary:active { opacity: 0.8; }

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 0.8rem 2rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  display: inline-block;
}

.btn-group {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 1rem;
}

/* ── Stars/Emoji feedback ── */
.stars { font-size: 2rem; margin: 0.5rem 0; }

/* ── Scroll helper ── */
.section-title {
  font-size: 1.1rem;
  color: var(--accent);
  margin: 1.5rem 0 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Responsive ── */
@media (min-width: 600px) {
  .home-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .home-card {
    flex-direction: column;
    text-align: center;
    padding: 2rem 1rem;
  }
  .topic-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }
}

@media (min-width: 900px) {
  html { font-size: 20px; }
}

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

.main > * {
  animation: fadeIn 0.3s ease;
}

/* ── Exam timer ── */
.timer {
  background: rgba(255,183,77,0.15);
  color: var(--accent3);
  padding: 0.4rem 1rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-block;
  margin-bottom: 1rem;
}

/* ── Subject Selection ── */
.subjects-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.subject-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.15s;
  box-shadow: var(--shadow);
  position: relative;
}

.subject-card:active { transform: scale(0.98); }

.subject-card .card-icon {
  font-size: 2.5rem;
  min-width: 60px;
  text-align: center;
}

.subject-card .card-info h2 {
  font-size: 1.1rem;
  margin-bottom: 0.3rem;
}

.subject-card .card-info p {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.subject-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--bg);
}

@media (min-width: 600px) {
  .subjects-grid {
    grid-template-columns: 1fr 1fr;
  }
  .subject-card {
    flex-direction: column;
    text-align: center;
    padding: 2rem 1rem;
  }
}

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