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

body {
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.7;
  color: #222;
  background: #fafafa;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header { background: #fff; border-bottom: 1px solid #eee; }
nav {
  max-width: 1000px; margin: 0 auto; padding: 1rem;
  display: flex; justify-content: space-between; align-items: center;
}
.logo { font-weight: bold; font-size: 1.3rem; color: #222; text-decoration: none; }
.links a { margin-inline-start: 1.2rem; color: #555; text-decoration: none; }
.links a:hover { color: #0066cc; }

main { flex: 1; max-width: 1000px; margin: 0 auto; padding: 2rem 1rem; width: 100%; }
.hero { text-align: center; padding: 4rem 0; }
h1 { font-size: 2.2rem; margin-bottom: 1rem; }
p { margin-bottom: 1rem; }
a { color: #0066cc; }

footer { text-align: center; padding: 1.5rem; color: #888; border-top: 1px solid #eee; }

/* ===== דף פתיחה ===== */
body.opening {
  background: url("images/mainpage.jpg") center / cover no-repeat fixed;
  min-height: 100vh;
}
.opening-overlay {
  min-height: 100vh;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10vh;
  background: linear-gradient(to top, rgba(0,0,0,0.55), rgba(0,0,0,0) 45%);
}
.start-btn {
  font-size: 1.8rem;
  font-weight: bold;
  color: #fff;
  background: #0077cc;
  padding: 0.8rem 3.5rem;
  border-radius: 50px;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  transition: transform 0.2s, background 0.2s;
}
.start-btn:hover { background: #005fa3; transform: scale(1.06); }

/* ===== דף תפריט ===== */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
  margin-top: 1.5rem;
}
.menu-card {
  display: block;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  padding: 1.5rem;
  color: #222;
  text-decoration: none;
  transition: box-shadow 0.2s, transform 0.2s;
}
.menu-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.1); transform: translateY(-3px); }
.menu-card h2 { font-size: 1.3rem; margin-bottom: 0.4rem; color: #0077cc; }

/* ===== דף הסבר: זרם חשמלי ===== */
.lesson h1 { text-align: center; }
.lesson h2 { margin: 2rem 0 0.8rem; }
.lead { font-size: 1.2rem; text-align: center; max-width: 700px; margin: 0 auto 1.5rem; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
@media (max-width: 760px) { .compare { grid-template-columns: 1fr; } }
.panel { background: #fff; border-radius: 14px; padding: 1rem 1.2rem; box-shadow: 0 2px 10px rgba(0,0,0,0.07); margin: 0; }
.panel h2 { margin: 0 0 0.5rem; font-size: 1.3rem; text-align: center; }
.panel.water { border-top: 6px solid #3a9be0; }
.panel.wire  { border-top: 6px solid #e08a1e; }
.panel svg { width: 100%; height: auto; direction: ltr; }
.panel figcaption { text-align: center; color: #444; }
.panel .p { animation: flow 4s linear infinite; }
@keyframes flow { from { transform: translateX(-40px); } to { transform: translateX(340px); } }
.spin { transform-origin: 42px 100px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.analogy { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
.analogy th { background: #0077cc; color: #fff; padding: 0.7rem; }
.analogy td { padding: 0.6rem 0.8rem; border-bottom: 1px solid #eee; }
.analogy td:first-child { color: #2b6cb0; font-weight: bold; }
.analogy td:nth-child(2) { color: #c05000; font-weight: bold; }
.facts { padding-inline-start: 1.5rem; }
.facts li { margin-bottom: 0.8rem; }
.back { margin-top: 2rem; text-align: center; }

/* ===== תפריט קוביות ===== */
.crumbs { color: #888; font-size: 0.95rem; margin-bottom: 0.5rem; }
.crumbs a { color: #0077cc; text-decoration: none; }
.page-title { text-align: center; margin-bottom: 2rem; }
.cube-grid { display: flex; flex-wrap: wrap; gap: 2.5rem; justify-content: center; padding: 1rem 0 2rem; }
.cube {
  width: 230px; height: 230px;
  background: #fff;
  border: 3px solid #0077cc;
  border-radius: 18px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: 1rem;
  text-decoration: none; color: #1a3a5c;
  box-shadow: 10px 10px 0 #0b5c99, 10px 10px 18px rgba(0,0,0,0.25);
  transition: transform 0.2s, box-shadow 0.2s;
}
.cube:hover { transform: translate(-4px, -4px); box-shadow: 14px 14px 0 #0b5c99, 14px 14px 24px rgba(0,0,0,0.25); }
.cube:active { transform: translate(6px, 6px); box-shadow: 4px 4px 0 #0b5c99; }
.cube-img { flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; }
.cube-img svg { width: 150px; height: 150px; }
.cube-title { font-size: 1.35rem; font-weight: bold; }

/* ===== דף מתח ===== */
.lesson h2.sec { color: #0b5c99; border-inline-start: 5px solid #0077cc; padding-inline-start: 0.6rem; }
.lesson .compare { margin-bottom: 0.5rem; }
.jet { stroke-dasharray: 8 6; animation: jet 0.6s linear infinite; }
@keyframes jet { to { stroke-dashoffset: -14; } }
.bright { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.7; } }
.volts td:first-child { color: #222; }
.volts td.danger { color: #c0392b; font-weight: bold; }

/* ===== דף התנגדות ===== */
.pour { animation: pour 0.5s linear infinite; }
@keyframes pour { 50% { opacity: 0.6; } }
.ohm { background: #fff; border: 2px solid #0077cc; border-radius: 14px; padding: 1.2rem 1.5rem; text-align: center; }
.ohm-formula { font-size: 1.6rem; font-weight: bold; color: #0b5c99; }
.ohm-sym { font-size: 1.4rem; font-family: Georgia, serif; color: #c05000; margin-bottom: 0.6rem; }
.ohm-ex { background: #f3f8fc; border-radius: 8px; padding: 0.6rem; margin-top: 0.5rem; }
.cube-img img { width: 165px; height: 165px; object-fit: contain; border-radius: 8px; }

/* ===== דף לד ===== */
.lesson ul.facts { list-style: disc; }
.code-box { background: #0e1a26; border-radius: 12px; overflow: hidden; margin-top: 0.8rem; }
.code-head { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.9rem; background: #16283a; color: #9fb3c8; font-size: 0.9rem; }
.code-head button { font: inherit; font-size: 0.9rem; padding: 0.3rem 0.9rem; border-radius: 8px; border: 1px solid #4a6a88; background: transparent; color: #e6eef5; cursor: pointer; }
.code-head button:hover { background: #22405c; }
.code-head button.ok { background: #1D9E75; border-color: #1D9E75; }
.code-box pre { margin: 0; padding: 1rem; overflow-x: auto; text-align: left; color: #7dffb0; font-size: 0.9rem; line-height: 1.55; }
.code-box code { font-family: Consolas, Menlo, monospace; }

/* ===== לוגו ===== */
.logo { display: flex; align-items: center; }
.logo-svg { height: 40px; width: auto; display: block; direction: ltr; }

/* ===== דף בקרים ===== */
.panel.flow { margin-top: 0.5rem; }
.lesson code { background: #eef3f7; padding: 0 6px; border-radius: 4px; }
.uses { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.8rem 0 0.5rem; }
.uses span { background: #fff; border: 1px solid #d6e4f0; border-radius: 30px; padding: 0.35rem 0.9rem; font-size: 0.98rem; }

/* ===== לוחות אינטראקטיביים ===== */
.board-wrap { background: #fff; border-radius: 14px; box-shadow: 0 2px 10px rgba(0,0,0,0.07); padding: 1rem; }
.board-wrap svg { width: 100%; height: auto; display: block; direction: ltr; }
.hot { cursor: pointer; fill: #fff; fill-opacity: 0; transition: fill-opacity .15s; }
.hot:hover, .hot:focus { fill-opacity: .18; outline: none; }
#hl { fill: none; stroke: #ffd166; stroke-width: 5; stroke-dasharray: 14 7; pointer-events: none; display: none; animation: hlmove 1s linear infinite; filter: drop-shadow(0 0 6px rgba(255,209,102,.9)); }
@keyframes hlmove { to { stroke-dashoffset: -21; } }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0; }
.chips button { font: inherit; font-size: .95rem; padding: .35rem .9rem; border-radius: 30px; border: 1.5px solid #0077cc; background: #fff; color: #0b5c99; cursor: pointer; }
.chips button.on { background: #0077cc; color: #fff; }
.hint { color: #666; font-size: .95rem; margin: .3rem 0 0; }
.info { background: #fff; border-radius: 14px; border-top: 6px solid #0077cc; box-shadow: 0 2px 10px rgba(0,0,0,0.07); padding: 1rem 1.3rem; margin-top: 1rem; min-height: 160px; }
.info h3 { margin: 0 0 .6rem; font-size: 1.35rem; color: #0b5c99; }
.info ul { padding-inline-start: 1.3rem; margin: .4rem 0; }
.info li { margin-bottom: .35rem; }
.info .em { background: #fff4e0; border-inline-start: 4px solid #f08c00; padding: .5rem .8rem; border-radius: 6px; margin: .6rem 0; }
.info .warn { background: #fdecea; border-inline-start: 4px solid #c0392b; padding: .5rem .8rem; border-radius: 6px; margin: .6rem 0; }
.info .mini { width: 100%; border-collapse: collapse; margin: .5rem 0; font-size: .95rem; }
.info .mini td, .info .mini th { border-bottom: 1px solid #eee; padding: .35rem .5rem; text-align: right; }
.info .mini th { background: #f3f8fc; }
.info pre { direction: ltr; text-align: left; background: #0e1a26; color: #7dffb0; border-radius: 8px; padding: .7rem .9rem; overflow-x: auto; font-size: .88rem; margin: .5rem 0; }
.info code { direction: ltr; unicode-bidi: embed; background: #eef3f7; padding: 0 5px; border-radius: 4px; }
.info pre code { background: none; padding: 0; }
.adc { background: #f3f8fc; border-radius: 10px; padding: .8rem 1rem; margin: .7rem 0; }
.adc input { width: 100%; direction: ltr; accent-color: #0077cc; }
.adc .row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.adc .big { font-size: 1.6rem; font-weight: bold; color: #0b5c99; direction: ltr; }
.adc .bar { height: 14px; background: #dde7f0; border-radius: 7px; overflow: hidden; direction: ltr; margin-top: .4rem; }
.adc .bar div { height: 100%; background: linear-gradient(90deg, #4dabf7, #0077cc); width: 50%; }
.legend { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.legend span { padding: .2rem .7rem; border-radius: 6px; font-weight: bold; color: #fff; }

/* ===== חיישן רטט ===== */
.sim-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; align-items: center; }
@media (max-width: 760px) { .sim-grid { grid-template-columns: 1fr; } }
.ctrls { display: flex; flex-direction: column; gap: .5rem; }
.ctrls input { width: 100%; direction: ltr; accent-color: #0077cc; }
.bigbtn { font: inherit; font-size: 1.15rem; font-weight: bold; padding: .7rem; border-radius: 12px; border: none; background: #e8590c; color: #fff; cursor: pointer; box-shadow: 0 4px 0 #a33f08; }
.bigbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #a33f08; }
.state { font-size: 1.2rem; background: #f3f8fc; border-radius: 8px; padding: .4rem .7rem; }
.leds-row { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; font-size: .95rem; margin-top: .3rem; }
.dot13 { display: inline-block; width: 16px; height: 16px; border-radius: 50%; background: #555; vertical-align: middle; transition: background .1s, box-shadow .1s; }
.dot13.on { background: #ffd43b; box-shadow: 0 0 10px #ffd43b; }
#scope { width: 100%; height: auto; border-radius: 8px; margin-top: .8rem; display: block; }
.scope-lbl { display: flex; justify-content: space-between; font-size: .85rem; color: #666; }
.simvib pre { direction: ltr; text-align: left; background: #0e1a26; color: #7dffb0; border-radius: 8px; padding: .7rem .9rem; font-size: .9rem; margin: .8rem 0 0; min-height: 190px; }
.code-box code, .code-box pre code { background: none !important; padding: 0 !important; }
.code-title { color: #0b5c99; margin: 1.4rem 0 .3rem; font-size: 1.15rem; }
.ard-row { display: flex; align-items: center; gap: 1rem; margin-top: .8rem; background: #f3f8fc; border-radius: 12px; padding: .6rem; flex-wrap: wrap; }
.ard-row svg { flex: 1 1 420px; width: 100%; max-width: 640px; height: auto; direction: ltr; }
.ledstate { flex: 0 0 auto; font-size: 1.4rem; font-weight: bold; padding: .6rem 1.2rem; border-radius: 30px; background: #dee2e6; color: #495057; transition: all .15s; margin-inline: auto; }
.ledstate.on { background: #ff3b30; color: #fff; box-shadow: 0 0 18px rgba(255,59,48,.6); }
.scene { position: relative; border-radius: 12px; padding: .6rem .6rem .3rem; transition: background .2s; }
.scene svg { width: 100%; height: auto; direction: ltr; display: block; }
.scene #sky { position: absolute; top: .4rem; left: .7rem; font-size: 1.8rem; }
