:root {
  --background: #f7f8fb;
  --surface: #ffffff;
  --surface-soft: #f1f5fb;
  --brand-cream: #fffde1;
  --brand-yellow: #fff1a8;
  --brand-purple: #6e56cf;
  --brand-purple-dark: #5842b8;
  --brand-red: #c94b54;
  --text: #23262b;
  --muted: #5f6b7a;
  --primary: #0b3a8a;
  --primary-light: #245cb1;
  --border: #d5deeb;
  --success: #15803d;
  --shadow: 0 16px 36px rgba(11, 58, 138, 0.1);
  --brand-shadow: 0 7px 0 var(--primary);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    "Noto Sans Hebrew",
    "Montserrat",
    Arial,
    sans-serif;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
}

html[lang="en"] body {
  font-family:
    "Montserrat",
    "Manrope",
    Arial,
    sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button,
.fundamatics-home-link {
  font-family:
    "Manrope",
    "Noto Sans Hebrew",
    Arial,
    sans-serif;
}

#app {
  width: min(1160px, calc(100% - 32px));
  margin: 22px auto 36px;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
  padding: 16px 18px;
  border: 2px solid var(--primary);
  border-radius: 22px;
  background: var(--brand-cream);
  color: var(--text);
  box-shadow:
    var(--brand-shadow),
    var(--shadow);
}

.brand-product-lockup {
  display: flex;
  flex: 1 1 560px;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.fundamatics-brand {
  display: flex;
  width: min(230px, 42vw);
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 18px 7px;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  text-decoration: none;
}

.fundamatics-brand img {
  display: block;
  width: 100%;
  height: auto;
}

.brand-tagline {
  color: var(--brand-yellow);
  font-family: cursive;
  font-size: 0.92rem;
  font-style: italic;
  line-height: 1.15;
}

.brand-divider {
  color: var(--primary);
  font-family: "Montserrat", Arial, sans-serif;
  font-size: 2rem;
  font-weight: 600;
}

.product-identity {
  min-width: 0;
}

.app-header h1 {
  margin: 0 0 2px;
  color: var(--primary);
  font-family: "Montserrat", Arial, sans-serif;
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.language-option {
  width: auto;
  min-width: 0;
  padding: 7px 11px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 0.88rem;
}

.language-option:hover:not(:disabled) {
  background: var(--surface-soft);
  color: var(--primary);
  transform: none;
}

.language-option.is-active {
  background: var(--primary);
  color: white;
}

.language-option.is-active:hover:not(:disabled) {
  background: var(--primary);
  color: white;
}

.fundamatics-home-link {
  flex: 0 0 auto;
  padding: 10px 18px;
  border: 2px solid var(--brand-purple);
  border-radius: 999px;
  color: var(--brand-purple-dark);
  font-weight: 700;
  text-decoration: none;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.fundamatics-home-link:hover {
  background: var(--brand-purple);
  color: white;
  transform: translateY(-2px);
}

.fundamatics-brand:focus-visible,
.fundamatics-home-link:focus-visible,
button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(110, 86, 207, 0.35);
  outline-offset: 3px;
}

.lesson-step,
.lesson-complete,
.welcome-screen {
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.progress-wrapper {
  margin-bottom: 28px;
}

.progress-label {
  margin-bottom: 8px;
  font-weight: 700;
  color: var(--primary);
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ebf4;
}

.progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    var(--primary),
    var(--brand-purple)
  );
  transition: width 0.3s ease;
}

.step-content {
  min-height: 330px;
}

.step-number {
  margin: 0 0 6px;
  color: var(--muted);
  font-weight: 700;
}

.step-content h2,
.lesson-complete h2 {
  margin-top: 0;
  color: var(--primary);
  font-family: "Montserrat", Arial, sans-serif;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 800;
}

.teacher-prompt,
.reflection-box,
.claim-box,
.justification-box {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--brand-cream);
}

.claim-box label,
.justification-box label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 14px;
  border: 1px solid #b7c4d6;
  border-radius: 14px;
  background: white;
  color: var(--text);
}

textarea:focus {
  border-color: var(--brand-purple);
}

.interaction-area {
  margin-top: 24px;
}

.interaction-instruction {
  font-weight: 700;
}

.point-canvas {
  position: relative;
  min-height: 300px;
  margin-top: 12px;
  overflow: hidden;
  border: 2px dashed #8aa1c2;
  border-radius: 20px;
  background:
    linear-gradient(rgba(11, 58, 138, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 58, 138, 0.05) 1px, transparent 1px),
    #fffef3;
  background-size: 24px 24px;
  cursor: crosshair;
}

.created-point {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 4px solid white;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 4px 12px rgba(11, 58, 138, 0.3);
  transform: translate(-50%, -50%);
}

.interaction-feedback {
  margin-top: 12px;
  font-weight: 700;
  color: var(--success);
}

.concept-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 0;
  list-style: none;
}

.concept-list li {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
  text-align: center;
  font-weight: 700;
}

.lesson-navigation {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
}

button {
  min-width: 120px;
  padding: 12px 22px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--brand-purple);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    opacity 0.15s ease,
    background 0.15s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  background: var(--brand-purple-dark);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.lesson-complete {
  text-align: center;
}

.lesson-complete strong {
  color: var(--primary);
}

@media (max-width: 850px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-product-lockup {
    flex-basis: auto;
  }

  .fundamatics-home-link {
    align-self: flex-start;
  }

  .header-actions {
    justify-content: space-between;
  }
}

@media (max-width: 650px) {
  #app {
    width: min(100% - 16px, 1160px);
    margin: 10px auto 24px;
  }

  .lesson-step,
  .lesson-complete,
  .welcome-screen {
    padding: 20px;
    border-radius: 18px;
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    border-radius: 18px;
  }

  .brand-product-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .fundamatics-brand {
    width: min(220px, 100%);
  }

  .brand-divider {
    display: none;
  }

  .fundamatics-home-link {
    align-self: stretch;
    text-align: center;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .language-switcher {
    align-self: flex-start;
  }

  .language-option {
    width: auto;
  }

  .step-content {
    min-height: 260px;
  }

  .point-canvas {
    min-height: 240px;
  }

  .lesson-navigation {
    flex-direction: column-reverse;
  }

  button {
    width: 100%;
  }
}
.geometry-canvas {
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  cursor: crosshair;
}

.geometry-point-label {
  position: absolute;
  top: 12px;
  left: 12px;
  white-space: nowrap;
  font-weight: 700;
  pointer-events: none;
}
.geometry-ray {
  height: 4px;
  background: var(--primary);
  border-radius: 999px;
  pointer-events: none;
}

.geometry-ray-preview {
  opacity: 0.55;
}

.geometry-ray-arrow {
  color: var(--primary);
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
}

.ray-construction-canvas {
  cursor: crosshair;
}
.angle-construction-canvas {
  cursor: crosshair;
}
.geometry-angle-arc {
  fill: none;
  stroke: var(--brand-red);
  stroke-width: 4;
  stroke-linecap: round;
}

.geometry-angle-label {
  fill: var(--brand-red);
  font-size: 16px;
  font-weight: 700;
  font-family: "Heebo", Arial, sans-serif;
}

.measure-angle-canvas {
  margin-top: 12px;
  border: 2px dashed #8aa1c2;
  border-radius: 20px;
  background:
    linear-gradient(rgba(11, 58, 138, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 58, 138, 0.05) 1px, transparent 1px),
    #fffef3;
  background-size: 24px 24px;
  cursor: default;
}

.geometry-protractor {
  position: absolute;
  inset: 0;
  z-index: 6;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  touch-action: none;
  user-select: none;
}

.geometry-protractor-content {
  pointer-events: none;
}

.geometry-protractor-body {
  fill: rgba(125, 211, 252, 0.25);
  stroke: rgba(3, 105, 161, 0.9);
  stroke-width: 2;
  pointer-events: all;
  cursor: grab;
}

.geometry-protractor-body:active,
.geometry-protractor-center:active {
  cursor: grabbing;
}

.geometry-protractor-baseline {
  stroke: #075985;
  stroke-width: 3;
  pointer-events: stroke;
  cursor: grab;
}

.geometry-protractor-tick {
  stroke: #075985;
  stroke-width: 0.75;
  pointer-events: none;
}

.geometry-protractor-tick-medium {
  stroke-width: 1.25;
}

.geometry-protractor-tick-long {
  stroke-width: 1.8;
}

.geometry-protractor-label {
  fill: #0c4a6e;
  font-family: Arial, sans-serif;
  font-size: 9px;
  font-weight: 700;
  direction: ltr;
  pointer-events: none;
}

.geometry-protractor-label-inner {
  fill: #9a3412;
}

.geometry-protractor-center-guide {
  fill: none;
  stroke: #075985;
  stroke-width: 2;
  pointer-events: stroke;
  cursor: grab;
}

.geometry-protractor-center {
  fill: #ffffff;
  stroke: #075985;
  stroke-width: 3;
  pointer-events: all;
  cursor: grab;
}

.geometry-protractor-content.is-center-snapped
  .geometry-protractor-center {
  fill: #e0f2fe;
  stroke: var(--primary-light);
  filter: drop-shadow(0 0 4px rgba(47, 128, 201, 0.35));
}

.geometry-protractor-content.is-center-snapped
  .geometry-protractor-center-guide {
  stroke: var(--primary-light);
  stroke-width: 3;
}

.geometry-protractor-content.is-center-locked
  .geometry-protractor-center {
  fill: #dcfce7;
  stroke: var(--success);
  filter: drop-shadow(0 0 5px rgba(21, 128, 61, 0.45));
  animation: protractor-center-lock 0.45s ease-out;
}

.geometry-protractor-content.is-center-locked
  .geometry-protractor-center-guide {
  stroke: var(--success);
  stroke-width: 3;
}

.geometry-protractor-content.is-baseline-locked
  .geometry-protractor-baseline {
  stroke: var(--success);
  stroke-width: 4;
  filter: drop-shadow(0 0 3px rgba(21, 128, 61, 0.35));
}

.geometry-protractor-content.is-baseline-snapped
  .geometry-protractor-baseline {
  stroke: var(--primary-light);
  stroke-width: 4;
}

.geometry-protractor-content.is-center-locked
  .geometry-protractor-body,
.geometry-protractor-content.is-center-locked
  .geometry-protractor-center,
.geometry-protractor-content.is-center-locked
  .geometry-protractor-center-guide {
  cursor: default;
}

.geometry-protractor-content.is-baseline-locked
  .geometry-protractor-rotation-handle {
  opacity: 0.45;
  cursor: not-allowed;
}

@keyframes protractor-center-lock {
  0% {
    stroke-width: 3;
  }

  45% {
    stroke-width: 6;
  }

  100% {
    stroke-width: 3;
  }
}

.geometry-protractor-rotation-stem {
  stroke: #c2410c;
  stroke-width: 2;
  stroke-dasharray: 4 3;
  pointer-events: none;
}

.geometry-protractor-rotation-handle {
  fill: #fff7ed;
  stroke: #c2410c;
  stroke-width: 3;
  pointer-events: all;
  cursor: crosshair;
}

.measure-angle-response {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
}

.learning-moment {
  margin: 8px 0 18px;
}

.learning-moment-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: fit-content;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid #a8b8cf;
  border-radius: 999px;
  background: var(--brand-cream);
  color: var(--primary);
  font-weight: 600;
  text-align: start;
}

.learning-moment-button::after {
  content: "+";
  flex: 0 0 auto;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
}

.learning-moment-button[aria-expanded="true"]::after {
  content: "−";
}

.learning-moment-button:hover:not(:disabled) {
  border-color: var(--brand-purple);
  background: #f4f0ff;
  color: var(--primary);
  transform: none;
}

.learning-moment-button:focus-visible {
  outline-color: rgba(110, 86, 207, 0.35);
}

.learning-moment-content {
  margin-top: 10px;
  padding: 14px;
  border-inline-start: 3px solid var(--brand-purple);
  background: var(--brand-cream);
}

.learning-moment-media {
  width: 100%;
  max-width: 640px;
  margin: 0;
}

.learning-moment-video-frame {
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 18px;
  background: #111827;
}

.learning-moment-video {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.learning-moment-media figcaption {
  margin-top: 8px;
  color: var(--muted);
}

.learning-moment-media figcaption p {
  margin: 6px 0 0;
}

.protractor-lock-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 4px;
}

.protractor-lock-button {
  min-height: 44px;
  padding: 10px 16px;
  background: #eaf3fb;
  color: var(--primary);
  border: 1px solid #aebed2;
}

.protractor-lock-button:hover:not(:disabled) {
  background: #d9eaf8;
}

.protractor-lock-button[aria-pressed="true"] {
  background: #dcfce7;
  color: var(--success);
  border-color: var(--success);
}

.protractor-lock-button:focus-visible {
  outline: 3px solid rgba(47, 128, 201, 0.3);
  outline-offset: 2px;
}

.measure-angle-controls {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin-top: 10px;
}

.measure-angle-input {
  position: relative;
  display: inline-flex;
  width: min(220px, 100%);
}

.measure-angle-input input {
  width: min(220px, 100%);
  min-width: 0;
  padding: 12px 34px 12px 14px;
  border: 1px solid #aebed2;
  border-radius: 14px;
  background: white;
  color: var(--text);
  direction: ltr;
  text-align: center;
}

.measure-angle-degree-symbol {
  position: absolute;
  top: 50%;
  right: 14px;
  color: var(--text);
  font-weight: 700;
  line-height: 1;
  transform: translateY(-50%);
  pointer-events: none;
}

.measure-angle-input input:focus {
  border-color: var(--brand-purple);
}

.measure-angle-feedback {
  min-height: 1.6em;
  margin: 12px 0 0;
  color: var(--primary);
  font-weight: 700;
}

@media (max-width: 650px) {
  .protractor-lock-controls {
    flex-direction: column;
  }

  .protractor-lock-button {
    width: 100%;
  }

  .measure-angle-controls {
    flex-direction: column;
  }

  .measure-angle-input,
  .measure-angle-input input {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar,
  button,
  .fundamatics-home-link {
    transition: none;
  }

  button:hover:not(:disabled),
  .fundamatics-home-link:hover {
    transform: none;
  }
}
