/* Théorème de Pythagore en images */
* { box-sizing: border-box; }
:root { --ca: #2563eb; --cb: #16a34a; --cc: #ea580c; --accent: #7c3aed; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; background: #f5f3ff; color: #1f2937; }
.hidden { display: none !important; }

header {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 18px; color: #fff; background: linear-gradient(135deg, #6d28d9, #db2777);
}
.brand { display: flex; align-items: center; gap: 12px; flex: 1 1 280px; min-width: 0; }
.brand > div { min-width: 0; }
.brand .logo { font-size: 2rem; }
.brand h1 { margin: 0; font-size: 1.35rem; }
.brand .subtitle { margin: 0; font-size: .85rem; opacity: .92; }
nav { display: flex; gap: 8px; }
.nav-btn {
  background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 8px;
  padding: 6px 12px; font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none;
}
.nav-btn:hover, .nav-btn.active { background: rgba(255,255,255,.32); }

.layout { display: flex; min-height: calc(100vh - 60px); }
#sidebar { width: 330px; flex: 0 0 330px; background: #fff; border-right: 1px solid #e5e7eb; padding: 14px; overflow-y: auto; }
#sidebar.hidden { display: none !important; }
.sidebar-head h2 { margin: 0 0 4px; font-size: 1.1rem; }
.sidebar-head .hint { margin: 0 0 10px; font-size: .85rem; color: #6b7280; }
.activity { border: 1px solid #e5e7eb; border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.activity .head { width: 100%; display: flex; align-items: center; gap: 8px; padding: 9px 10px; background: #f5f3ff; border: 0; cursor: pointer; text-align: left; font: inherit; font-size: .9rem; }
.activity .head:hover { background: #ede9fe; }
.activity .tp-num { background: var(--accent); color: #fff; border-radius: 6px; padding: 2px 6px; font-size: .75rem; font-weight: 700; }
.activity .tp-title { flex: 1; font-weight: 600; }
.activity .tp-level { font-size: .75rem; color: #6b7280; white-space: nowrap; }
.activity .body { display: none; padding: 10px 12px; font-size: .88rem; border-top: 1px solid #e5e7eb; }
.activity.open .body { display: block; }
.activity .body h3 { font-size: .8rem; text-transform: uppercase; color: var(--accent); margin: 10px 0 4px; }
.activity .body ol { margin: 4px 0; padding-left: 20px; }
.activity .body li { margin-bottom: 3px; }
.activity .question { background: #f5f3ff; border-left: 3px solid #a78bfa; padding: 5px 8px; margin: 5px 0; border-radius: 0 6px 6px 0; }
.activity .prof-note { background: #fefce8; border: 1px solid #fde68a; border-radius: 8px; padding: 4px 10px 8px; margin-top: 10px; }

#main { flex: 1; min-width: 0; padding: 16px; max-width: 1200px; margin: 0 auto; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.tab { border: 2px solid #ddd6fe; background: #fff; color: #5b21b6; border-radius: 999px; padding: 8px 16px; font: inherit; font-weight: 700; cursor: pointer; }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }
.spacer { flex: 1; }
.lbl { font-weight: 700; font-size: .9rem; display: block; margin-bottom: 6px; }
.ca { color: var(--ca); } .cb { color: var(--cb); } .cc { color: var(--cc); }

.see-grid { display: grid; grid-template-columns: minmax(250px, 320px) 1fr; gap: 14px; align-items: start; }
.controls .ctrl { margin-bottom: 14px; }
.controls label { font-weight: 700; display: block; margin-bottom: 4px; }
.controls output { font-weight: 800; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.check { font-weight: 600 !important; display: flex !important; gap: 8px; align-items: center; }
.intro { margin-top: 0; line-height: 1.5; }
.figure-card { padding: 6px; }
.figure-card svg { width: 100%; height: auto; display: block; max-height: 74vh; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 2px solid #ddd6fe; background: #fff; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .9rem; cursor: pointer; color: #4c1d95; }
.chip:hover { background: #f5f3ff; }
.chip.active { border-color: var(--accent); background: #ede9fe; font-weight: 700; }
.btn { background: var(--accent); color: #fff; border: 2px solid var(--accent); border-radius: 10px; padding: 8px 16px; font: inherit; font-weight: 700; cursor: pointer; }
.btn:hover { background: #6d28d9; }
.btn.ghost { background: #fff; color: #5b21b6; border-color: #c4b5fd; }
.btn.ghost:hover { background: #f5f3ff; }
.btn.small { padding: 4px 10px; font-size: .85rem; margin-top: 6px; }
.btn.big { width: 100%; font-size: 1.1rem; padding: 12px; }

.result { text-align: center; }
.eq-line { font-size: clamp(1.1rem, 2.6vw, 1.6rem); font-weight: 700; margin: 4px 0; }
.verdict { margin-top: 8px; font-size: 1.08rem; font-weight: 600; line-height: 1.5; }
.verdict.ok { color: #15803d; } .verdict.no { color: #b45309; }
.proof-text { margin-top: 14px; line-height: 1.55; min-height: 6em; }
.proof-text .big-eq { display: block; font-size: 1.5rem; font-weight: 800; text-align: center; margin-top: 8px; color: #4c1d95; }

/* SVG */
svg text { font-family: "Segoe UI", system-ui, sans-serif; }
.tri { transition: transform 1.4s cubic-bezier(.5,0,.3,1); }
.fade { transition: opacity .6s; }
@media (prefers-reduced-motion: reduce) { .tri { transition: none; } }

/* calculer */
.calc-inputs { display: flex; flex-wrap: wrap; gap: 14px; margin: 14px 0 6px; }
.calc-inputs label { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.calc-inputs input { width: 110px; font-size: 1.2rem; font-weight: 700; text-align: center; border: 2px solid #cbd5e1; border-radius: 10px; padding: 4px 6px; }
.calc-inputs input:focus, .t-answer input:focus { outline: none; border-color: var(--accent); }
.steps { margin-top: 14px; font-size: 1.15rem; line-height: 1.9; }
.steps .s { padding: 2px 10px; border-left: 4px solid #ddd6fe; margin: 4px 0; }
.steps .s.final { border-left-color: var(--accent); background: #f5f3ff; font-weight: 800; border-radius: 0 8px 8px 0; }
.steps .err { color: #b91c1c; font-weight: 700; }

/* entraînement */
.train-grid { display: grid; grid-template-columns: minmax(240px, 400px) 1fr; gap: 16px; align-items: center; }
#tfig { width: 100%; height: auto; }
.t-story { font-size: 1.1rem; line-height: 1.5; margin-top: 0; }
.t-answer { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; font-weight: 700; }
.t-answer input { width: 120px; font-size: 1.3rem; font-weight: 800; text-align: center; border: 2px solid #cbd5e1; border-radius: 10px; padding: 4px; }
.t-feed { min-height: 3em; font-weight: 600; line-height: 1.6; }
.t-feed.good { color: #15803d; } .t-feed.bad { color: #b91c1c; }
.streak { font-weight: 600; color: #475569; }
.aide h3 { margin: 0 0 6px; font-size: 1rem; }
.aide ol { margin: 0; padding-left: 20px; line-height: 1.7; }

@media (max-width: 860px) {
  .see-grid, .train-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  #sidebar { width: 100%; flex: none; border-right: none; border-bottom: 1px solid #e5e7eb; max-height: 45vh; }
  .brand h1 { font-size: 1.1rem; }
  #main { padding: 10px; }
}
