/* Álgebra Linear P1 - material de estudo
   Sistema de design: dashboard SaaS sóbrio, sans-serif de sistema, zero fontes externas. */

:root {
  --primary: #003d0d;
  --primary-dk: #00280a;
  --accent: #16a34a;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info-bg: #eff6ff;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0, 0, 0, .08);
  --max-width: 900px;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  overflow-x: hidden;
  width: 100%;
}

a { color: var(--primary); }
a:hover { text-decoration: none; }

code, pre, .mono {
  font-family: 'Courier New', monospace;
}

img { max-width: 100%; height: auto; }

mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}
mjx-container[display="true"] {
  margin: 0.6em 0;
}

/* ── Navbar ── */

header.site-header {
  background: var(--primary);
  padding: 0.9rem 1.2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}

header.site-header .bar {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

header.site-header .brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: #fff;
  text-decoration: none;
  margin-right: auto;
}

header.site-header .brand small {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, .75);
}

nav.top-nav {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
}

nav.top-nav a {
  text-decoration: none;
  color: rgba(255, 255, 255, .85);
  white-space: nowrap;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius);
  transition: background 0.15s;
}

nav.top-nav a:hover, nav.top-nav a.active {
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-weight: 600;
}

/* ── Dropdown de navegação (Dia X + submenu) ── */

.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, .85);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: background 0.15s;
}

.nav-dropdown-toggle::after {
  content: " \25BE";
  font-size: 0.7em;
}

.nav-dropdown-toggle:hover, .nav-dropdown-toggle.active {
  background: rgba(255, 255, 255, .18);
  color: #fff;
  font-weight: 600;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  min-width: 190px;
  max-width: 90vw;
  padding: 0.4rem;
  z-index: 200;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.3rem;
}

.nav-dropdown-menu.is-open {
  display: flex;
}

nav.top-nav .nav-dropdown-menu a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  white-space: normal;
}

nav.top-nav .nav-dropdown-menu a:hover, nav.top-nav .nav-dropdown-menu a.active {
  background: var(--info-bg);
  color: var(--primary);
  font-weight: 600;
}

/* ── Hero ── */

.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: #fff;
  text-align: center;
  padding: 4rem 1.2rem;
}

.hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  margin: 0 0 0.6rem;
  color: #fff;
}

.hero p.hero-subtitle {
  font-size: 1.05rem;
  color: rgba(255, 255, 255, .9);
  max-width: 640px;
  margin: 0 auto 2rem;
}

.hero-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  max-width: 1100px;
  margin: 2.5rem auto 0;
  text-align: left;
}

.hero-card {
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  text-decoration: none;
  color: #fff;
  transition: transform 0.15s, background 0.15s;
}

.hero-card:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, .22);
}

.hero-card h3 {
  margin: 0 0 0.4rem;
  color: #fff;
  font-size: 1.05rem;
}

.hero-card p {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, .85);
}

/* ── Botões ── */

.btn-primary, .btn-outline {
  display: inline-block;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.6rem 1.3rem;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border: 2px solid var(--primary);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-dk); border-color: var(--primary-dk); }

.btn-outline {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, .7);
}

.btn-outline:hover { background: rgba(255, 255, 255, .18); }

.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }

.btn-primary:active, .btn-outline:active { transform: scale(.97); }

/* ── Layout Principal ── */

.layout {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
  padding: 1.5rem 1.2rem 4rem;
}

aside.toc {
  position: sticky;
  top: 4.2rem;
  align-self: start;
  font-size: 0.85rem;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
}

aside.toc h2,
aside.toc summary {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

aside.toc ul {
  list-style: none;
  margin: 0 0 1.2rem;
  padding: 0;
}

aside.toc li { margin-bottom: 0.35rem; }
aside.toc a { text-decoration: none; color: var(--text-muted); }
aside.toc a:hover { color: var(--primary); }

aside.toc summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  padding: 0.3rem 0.5rem;
  margin: 0;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
}

aside.toc summary::-webkit-details-marker { display: none; }
aside.toc summary::marker { content: ""; }

aside.toc summary::after {
  content: " ▾";
  float: right;
}

aside.toc details[open] > summary::after { content: " ▴"; }

aside.toc details[open] > summary { margin-bottom: 0.6rem; }

main {
  min-width: 0;
  max-width: var(--max-width);
}

main h1 {
  font-size: 1.9rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
  color: var(--text);
}

main .subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0;
  margin-bottom: 1.8rem;
}

main h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-top: 2.6rem;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

main h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.8rem;
  color: var(--primary);
}

/* ── Cards / Caixas de teoria ── */

.theory-box {
  background: var(--info-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin: 1rem 0;
}

.eli5 {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-left: 4px solid var(--success);
  border-radius: var(--radius);
  padding: 0.9rem 1.2rem;
  margin: 1rem 0;
  font-size: 0.95rem;
}

.eli5-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--success);
  margin-bottom: 0.5rem;
}

.eli5 p { margin: 0 0 0.6rem; }
.eli5 p:last-child { margin-bottom: 0; }
.eli5 ul { margin: 0.4rem 0 0.6rem 1.2rem; padding: 0; }
.eli5 li { margin-bottom: 0.3rem; }

.example-box {
  border-left: 4px solid var(--accent);
  background: #f1f5f9;
  padding: 0.8rem 1.1rem;
  margin: 1rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.exercise {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin: 2rem 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.exercise > h3 {
  margin-top: 0;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.exercise .enunciado {
  font-style: italic;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

/* ── Phases / Steps ── */

.step {
  margin: 0.9rem 0;
}

.step > strong.step-label {
  display: inline-block;
  background: var(--primary);
  border-radius: var(--radius);
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.4rem;
}

/* ── Tabelas ── */

table.variations, table.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.92rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table.variations th, table.variations td,
table.data-table th, table.data-table td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

table.variations th, table.data-table th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

table.variations tr:nth-child(even) td, table.data-table tr:nth-child(even) td {
  background: #f1f5f9;
}

/* ── Badges ── */

.badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 600;
  white-space: nowrap;
}

.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-red { background: var(--danger-bg); color: #991b1b; }
.badge-gray { background: var(--border); color: var(--text-muted); }

.badge-ok { background: #dcfce7; color: #15803d; }
.badge-warn { background: #ffedd5; color: #c2410c; }
.badge-trap { background: var(--danger-bg); color: #991b1b; }
.badge-pattern { background: #dbeafe; color: #1e40af; }
.badge-prereq { background: var(--border); color: var(--text-muted); }

.answer-final {
  font-weight: 600;
  background: var(--success-bg);
  border: 1px solid var(--success);
  color: var(--success);
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius);
  display: inline-block;
  margin-top: 0.3rem;
}

/* ── Alertas ── */

.alert-info, .note-complement {
  border-left: 4px solid var(--primary);
  background: var(--info-bg);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin: 0.8rem 0;
}

.alert-success {
  border-left: 4px solid var(--success);
  background: var(--success-bg);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin: 0.8rem 0;
}

.alert-warning {
  border-left: 4px solid var(--warning);
  background: var(--warning-bg);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin: 0.8rem 0;
}

.note-complement {
  border-left-style: dashed;
}

/* ── Board-style recap ── */

.board-solve {
  border: 1.5px dashed var(--primary);
  background: #f8fafc;
  background-image: repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(0,61,13,.05) 28px);
  border-radius: var(--radius);
  padding: 0.9rem 1.2rem;
  margin: 1.2rem 0;
  font-family: 'Courier New', monospace;
  font-size: 0.93rem;
  color: #0f3d1e;
  line-height: 1.75;
  overflow-wrap: break-word;
  overflow-x: auto;
}

.board-solve .board-label {
  display: inline-block;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fff;
  background: var(--primary-dk);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius);
  margin-bottom: 0.55rem;
}

.board-solve .board-note {
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-style: italic;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

footer.site-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.2rem 3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.module-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.3rem;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}

.module-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.module-card h3 {
  margin: 0 0 0.4rem;
  color: var(--primary);
  font-size: 1.05rem;
}

.module-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ── Checklist de progresso (cronograma) ── */

.plan-day {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 1.2rem 1.4rem;
  margin: 1.2rem 0;
}

.plan-day h3 {
  margin-top: 0;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.plan-block {
  display: flex;
  gap: 0.8rem;
  padding: 0.55rem 0;
  border-top: 1px dashed var(--border);
  align-items: baseline;
  flex-wrap: wrap;
}

.plan-block:first-of-type { border-top: none; }

.plan-time {
  font-weight: 700;
  color: var(--primary-dk);
  min-width: 90px;
  font-size: 0.85rem;
}

/* ── Modal de gabarito ── */

.gabarito-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.4rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}

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

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 20, 5, 0.55);
  padding: 2rem 1rem;
  overflow-y: auto;
  align-items: flex-start;
  justify-content: center;
}

.modal-overlay.is-open { display: flex; }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 700px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 1.6rem 1.8rem 1.8rem;
  position: relative;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
  margin: auto;
}

.modal-box h3 {
  margin-top: 0;
  color: var(--primary);
  padding-right: 2rem;
}

.modal-close {
  position: absolute;
  top: 0.9rem;
  right: 1rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: none;
  background: var(--bg);
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover { background: var(--border); }

/* ── Responsivo ── */

@media (max-width: 768px) {
  .hero { padding: 2.6rem 1.2rem; }
  .hero h1 { font-size: 1.9rem; }
  .hero-card { padding: 0.9rem 1.1rem; }

  .layout {
    grid-template-columns: 1fr;
  }
  aside.toc {
    position: static;
    max-height: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
  }
}

@media (max-width: 600px) {
  header.site-header .bar { gap: 0.5rem; }
  header.site-header .brand { font-size: 1rem; }
  nav.top-nav { font-size: 0.78rem; gap: 0.15rem; }
  nav.top-nav a { padding: 0.25rem 0.5rem; }

  main h1 { font-size: 1.5rem; }
  main h2 { font-size: 1.2rem; }

  .example-box, code, pre { overflow-x: auto; }

  .btn-primary, .btn-outline { padding: 0.45rem 0.9rem; font-size: 0.85rem; }

  table.variations, table.data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .modal-box { padding: 1.2rem 1.2rem 1.4rem; }
}
