

/* Fonts & reset */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Montserrat:wght@600;700&display=swap");

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
  background: #ecf0f1;
  font-family: "Inter", sans-serif;
  color: #2c3e50;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:root {
  --navy: #2c3e50;
  --softgray: #ecf0f1;
  --teal: #1abc9c;
  --gold: #f1c40f;
  --slate: #7f8c8d;
  --coral: #e74c3c;
  --white: #ffffff;
  --gray-100: #f7fafc;
  --gray-200: #edf2f7;
  --gray-300: #e2e8f0;

  --container-pad: 1.5rem;
  --card-radius: 12px;
  --shadow-lg: 0 20px 40px rgba(44, 62, 80, 0.08);
  --shadow-sm: 0 6px 18px rgba(20, 20, 20, 0.06);
}

/* Page container */
.container {
  max-width: 1200px;
  margin: 28px auto;
  padding: var(--container-pad);
  background: var(--white);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-lg);
}

/* Header */
.page-header {
  text-align: center;
  margin-bottom: 12px;
}
#title {
  font-family: "Montserrat", sans-serif;
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}
.instructions {
  color: var(--navy);
  background: rgba(26, 188, 156, 0.06);
  border: 2px solid rgba(26, 188, 156, 0.12);
  padding: 10px 14px;
  border-radius: 10px;
  display: block;
  max-width: 960px;
  margin: 0.4rem auto 0;
  font-size: 0.98rem;
  line-height: 1.4;
}

/* Two-column layout: canvas + controls */
.layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  margin-top: 18px;
  align-items: start;
}

/* Simulation / canvas area */
.simulation-area {
  background: var(--gray-200);
  border-radius: 12px;
  padding: 16px;
  border: 2px solid var(--gray-300);
  position: relative;
  min-height: 420px;
}

/* responsive circular canvas wrapper */
.canvas-wrap {
  /* let it scale with viewport but cap at a sensible max */
  width: min(80vw, 700px); /* uses up to 80% of viewport width, max 700px */
  max-width: 90%;          /* safety on tiny viewports */
  aspect-ratio: 1 / 1;     /* keep square */
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto;          /* center horizontally */
  /* visual styling moved to wrapper so the internal canvas is transparent */
  background: linear-gradient(#fcfdff, #f6f8fa);
  border: 1px solid rgba(16, 16, 16, 0.06);
  box-shadow: var(--shadow-sm);
  display: block;
}

/* canvas fills the circular wrapper exactly and has no own background/border */
#canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: transparent; /* make sure wrapper styling shows through */
  border: none;
  box-shadow: none;
  border-radius: 0;        /* wrapper clips to circle */
  touch-action: none;      /* helpful for pointer interactions on mobile */
}

/* optional: tweak max sizes for very small screens */
@media (max-width: 480px) {
  .canvas-wrap { width: min(94vw, 420px); }
}



/* Hints and radius */
.hint-row {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.hint {
  padding: 10px 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--teal), #16a085);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
}
.hint.hidden {
  display: none !important;
}

/* Radius input area */
.radius-input-wrap { margin-top: 12px; display:flex; flex-direction:column; gap:8px; }
.radius-row { display:flex; gap:8px; align-items:center; }
.radius-label { font-weight:600; color: #7F8C8D; font-size:0.92rem; }

/* input styling */
#radius-input {
  padding: 10px;
  font-size: 0.95rem;
  border-radius: 8px;
  border: 2px solid var(--gray-300);
  width: 140px;
  text-align: center;
}

/* feedback states */
#radius-input.correct { border-color: #2ecc71; box-shadow: 0 0 0 6px rgba(46,204,113,0.08); background: #E9F9F0; }
#radius-input.incorrect { border-color: #E74C3C; box-shadow: 0 0 0 6px rgba(231,76,60,0.06); background: #FDEDEC; }

/* feedback text */
.radius-feedback { font-weight:600; font-size:0.95rem; min-height: 1.2em; color: var(--navy); }
.radius-feedback .ok { color: #2ecc71; }
.radius-feedback .bad { color: #E74C3C; }

/* small responsive tweak */
@media (max-width:480px) {
  .radius-row { flex-direction: column; align-items: stretch; }
  #radius-input { width:100%; }
  #check-radius-button { width: 100%; }
}

/* Controls panel */
.controls {
  background: var(--white);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(16, 16, 16, 0.04);
  min-width: 220px;
}
.controls label {
  display: block;
  color: #7f8c8d;
  margin-top: 10px;
  margin-bottom: 6px;
  font-size: 0.9rem;
}
.control-input {
  width: 100%;
  padding: 10px;
  font-size: 0.95rem;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: white;
  outline: none;
}
.control-input:focus {
  box-shadow: 0 0 0 3px rgba(26, 188, 156, 0.12);
  border-color: var(--teal);
}

/* Buttons */
.button-group {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  margin-top: 10px;
  font-weight: 600;
}
.teal-btn {
  background-color: var(--teal);
  color: white;
}

.teal-btn:hover {
  background-color: rgba(26, 188, 156, 0.9);
}

.coral-btn {
  background-color: var(--coral);
  color: white;
}

.coral-btn:hover {
  background-color: rgba(231, 76, 60, 0.9);
}
.gold-btn {
  background-color: rgba(241, 196, 15, 0.8);
  color: var(--navy);
}

.gold-btn:hover {
  background-color: rgba(241, 196, 15, 0.7);
}
.btn-ghost {
  background: transparent;
  color: #7f8c8d;
  border: 1px solid rgba(16, 16, 16, 0.06);
}

/* Utilities */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .controls {
    order: 2;
    margin-top: 12px;
  }
  .data-table {
    margin-top: 18px;
  }
}

/* Visual toggle for "Toggle Magnetic Field" button */
#toggle-magnetic-field {
  /* reset to a track-like control */
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  border: none;
  background: rgba(0,0,0,0.06);
  color: var(--navy);
  cursor: pointer;
  min-width: 120px;
  justify-content: space-between;
  font-weight: 600;
  transition: background 180ms ease, box-shadow 180ms ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

/* hidden native text can be kept but we'll show text beside thumb */
#toggle-magnetic-field .toggle-label {
  pointer-events: none;
}

/* Track / thumb visuals */
#toggle-magnetic-field .toggle-track {
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(255,255,255,0.7);
  position: relative;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
  transition: background 160ms ease;
}
#toggle-magnetic-field .toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,0.12);
  transition: transform 160ms ease, background 160ms ease;
}

/* ON state */
#toggle-magnetic-field.on {
  background: linear-gradient(90deg, rgba(26,188,156,0.12), rgba(46,204,113,0.08));
   color: var(--navy);
  box-shadow: 0 6px 18px rgba(26,188,156,0.08);
}
#toggle-magnetic-field.on .toggle-track {
  background: linear-gradient(90deg, #16a085, #1abc9c);
}
#toggle-magnetic-field.on .toggle-thumb {
  transform: translateX(20px);
  background: white;
}

/* focus styles for keyboard users */
#toggle-magnetic-field:focus {
  outline: 3px solid rgba(26,188,156,0.18);
  outline-offset: 3px;
}

/* smaller screens: shrink */
@media (max-width: 480px) {
  #toggle-magnetic-field { min-width: 100px; padding: 6px 8px; gap: 8px; }
  #toggle-magnetic-field .toggle-track { width: 40px; height: 20px; }
  #toggle-magnetic-field.on .toggle-thumb { transform: translateX(18px); }
}
