/*
 * Wave Properties — GCSE interactive simulation (styles)
 *
 * Spec points covered:
 *   - Two-column responsive layout (controls + canvas stack)
 *   - Analogue dial faces (frequency, amplitude, wave speed)
 *   - Medium toggle, tool toggles, extension checkbox
 *   - Wavelength ruler and time cursor overlays
 *   - Spatial / temporal canvas blocks with rotated y-axis labels
 *   - Collapsible Guided Investigation card
 *
 * Reading-instrument principle: the styling supports labelled scales and
 * draggable probes. No hidden styles for on-screen readouts of derived
 * quantities — students read raw values off the scales themselves.
 */

:root {
  --navy: #2c3e50;
  --softgray: #e9ecef;
  --teal: #1abc9c;
  --gold: #f1c40f;
  --slate: #556366;
  --coral: #e74c3c;
  --white: #ffffff;
  --gray-100: #f7fafc;
  --gray-200: #edf2f7;
  --gray-300: #e2e8f0;
  --canvas-bg: #fafbfc;
  --max-width: 1120px;
  --container-pad: 16px;
  --radius: 10px;
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.06);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  font-size: 17px;
  color: var(--navy);
  background: linear-gradient(135deg, #ecf0f1 0%, #d6dbdf 100%);
  padding: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
}

/* Header */
.page-header {
  text-align: center;
  color: var(--navy);
  padding: 1rem;
  position: relative;
}

.header-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.header-left {
  justify-self: start;
}

.header-actions {
  justify-self: end;
}

.page-title {
  margin: 0;
  justify-self: center;
  font-size: 2.25rem;
  font-weight: 700;
  font-family: 'Montserrat', sans-serif;
}

@media (max-width: 767px) {
  .header-grid {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .page-title {
    justify-self: start;
  }
  .header-actions {
    justify-self: start;
    width: 100%;
    margin-top: 8px;
  }
}

/* Experiment area */
.experiment-area {
  background: var(--gray-100);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}

/* Two-column layout: stacked on mobile, side-by-side on desktop. */
.cols {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (min-width: 768px) {
  .cols {
    flex-direction: row;
    align-items: flex-start;
  }
}

/* Controls column - empty placeholder for now */
.controls {
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  min-height: 120px;
}

@media (min-width: 768px) {
  .controls {
    flex: 0 0 320px;
    width: 320px;
    order: 1;
  }
}

/* Canvas stack column */
.canvas-stack {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

@media (min-width: 768px) {
  .canvas-stack {
    flex: 1;
    order: 2;
  }
}

.canvas-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.canvas-title {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
}

.canvas-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

.canvas-y-label {
  flex: 0 0 26px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  text-align: center;
}

.canvas-x-label {
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  text-align: center;
  /* Aligns roughly with the centre of the canvas (offset for the y-label width). */
  padding-left: 26px;
}

.canvas-frame {
  background: var(--canvas-bg);
  border: 1px solid var(--navy);
  border-radius: 6px;
  padding: 0;
  width: 100%;
  overflow: hidden;
  position: relative;
}

#spatial-canvas {
  display: block;
  width: 100%;
  height: 280px;
}

#temporal-canvas {
  display: block;
  width: 100%;
  height: 220px;
}

/* Medium toggle (Rope / Slinky) */
.medium-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  width: 100%;
}

.toggle-btn {
  flex: 1;
  padding: 8px 6px;
  border-radius: 6px;
  border: 1.5px solid var(--teal);
  background: white;
  color: var(--teal);
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn .toggle-sub {
  display: block;
  font-size: 10px;
  font-weight: 500;
  opacity: 0.8;
  margin-top: 2px;
}

.toggle-btn.is-active {
  background: var(--teal);
  color: white;
}

.toggle-btn:hover:not(.is-active) {
  background: rgba(26, 188, 156, 0.08);
}

/* Dials */
.dial-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 18px;
}

.dial-group[hidden] {
  /* Class display:flex above would otherwise win over the UA hidden default. */
  display: none;
}

/* Wave speed extension toggle */
.speed-toggle-row {
  border-top: 1px solid var(--gray-300);
  padding-top: 12px;
  margin-bottom: 12px;
}

.speed-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--slate);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.speed-toggle input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
  cursor: pointer;
  margin: 0;
}

.dial-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--slate);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.dial {
  width: 120px;
  height: 120px;
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.dial:active,
.dial.is-dragging {
  cursor: grabbing;
}

.dial svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.dial .dial-face circle {
  fill: var(--gray-100);
  stroke: var(--gray-300);
  stroke-width: 1.5;
}

.dial .dial-ticks line {
  stroke: var(--slate);
  stroke-linecap: round;
}

.dial .dial-labels text {
  fill: var(--navy);
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
}

.dial .pointer-line {
  stroke: var(--coral);
  stroke-width: 3;
  stroke-linecap: round;
}

.dial .pointer-hub {
  fill: var(--navy);
}

.dial:focus {
  outline: none;
}
.dial:focus-visible .dial-face circle {
  stroke: var(--teal);
  stroke-width: 2;
}

.dial-reset {
  width: 100%;
  margin-top: 6px;
  padding: 10px 16px;
  font-size: 14px;
}

/* Pause + Reset stack below the dials */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.action-buttons .btn {
  width: 100%;
  padding: 10px 16px;
  font-size: 14px;
}

.gold-btn {
  background-color: rgba(241, 196, 15, 1);
  color: var(--navy);
  opacity: 0.9;
}

.gold-btn:hover {
  background-color: rgba(241, 196, 15, 0.7);
  transform: translateY(-2px);
}

/* Tools (e.g. ruler toggle) */
.tools-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.tool-btn {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1.5px solid var(--coral);
  background: white;
  color: var(--coral);
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.tool-btn:hover:not(.is-active) {
  background: rgba(231, 76, 60, 0.08);
}

/* Wavelength ruler overlay */
.ruler {
  position: absolute;
  /* Spatial canvas covers 2.0 m, ruler covers 1.5 m. */
  width: 75%;
  height: 32px;
  background: white;
  border: 1.5px solid var(--coral);
  border-radius: 3px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  z-index: 5;
}

.ruler[hidden] {
  display: none;
}

.ruler.is-dragging {
  cursor: grabbing;
}

.ruler-tick {
  position: absolute;
  top: 0;
  width: 1px;
  background: var(--navy);
  pointer-events: none;
}

.ruler-tick.minor {
  height: 6px;
}

.ruler-tick.major {
  height: 10px;
}

.ruler-label {
  position: absolute;
  top: 12px;
  font-family: 'Montserrat', sans-serif;
  font-size: 9px;
  font-weight: 600;
  color: var(--navy);
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
}

/* Time cursors (temporal canvas) */
.time-cursor {
  position: absolute;
  top: 0;
  width: 14px;
  height: 100%;
  margin-left: -7px;
  cursor: ew-resize;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  z-index: 5;
}

.time-cursor[hidden] {
  display: none;
}

.time-cursor.is-dragging {
  cursor: grabbing;
}

.time-cursor-line {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1.5px;
  background: var(--coral);
  transform: translateX(-50%);
  pointer-events: none;
}

.time-cursor-handle {
  position: absolute;
  top: 18px;
  left: 50%;
  width: 10px;
  height: 10px;
  background: var(--coral);
  border-radius: 1px;
  transform: translateX(-50%);
  pointer-events: none;
}

.time-cursor-label {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Montserrat', sans-serif;
  font-size: 10px;
  font-weight: 600;
  color: var(--coral);
  background: white;
  border: 1px solid var(--coral);
  padding: 0 4px;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
  line-height: 14px;
}

/* Guided Investigation — collapsible section */
.section-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  margin-top: 24px;
  overflow: hidden;
}

#guided-investigation {
  padding: 0;
}

.guided-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px;
  background: none;
  border: none;
  font-family: 'Montserrat', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy);
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.guided-toggle:hover {
  background: var(--gray-100);
}

.guided-toggle:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: -2px;
}

.guided-chevron {
  font-size: 1.1rem;
  color: var(--slate);
  transition: transform 0.3s ease;
  display: inline-block;
}

.guided-toggle[aria-expanded='true'] .guided-chevron {
  transform: rotate(180deg);
}

.guided-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.guided-content-inner {
  padding: 0 22px 22px;
}

.guided-part {
  margin-bottom: 20px;
}

.guided-part:last-child {
  margin-bottom: 0;
}

.guided-part-title {
  margin: 0 0 10px 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
}

.guided-list {
  margin: 0;
  padding-left: 22px;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--navy);
}

.guided-list li {
  margin-bottom: 10px;
}

.guided-list li:last-child {
  margin-bottom: 0;
}

@media (max-width: 600px) {
  .guided-toggle {
    padding: 18px;
    font-size: 1rem;
  }
  .guided-content-inner {
    padding: 0 18px 18px;
  }
}

/* Buttons (used in header) */
.btn {
  display: inline-block;
  border-radius: 0.375rem;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 24px;
}

.navy-btn {
  background-color: rgba(44, 62, 80, 0.8);
  color: white;
}

.navy-btn:hover {
  background-color: rgba(44, 62, 80, 0.7);
  transform: translateY(-2px);
}

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

.teal-btn:hover {
  background-color: rgba(26, 188, 156, 0.7);
  transform: translateY(-2px);
}

button:focus,
input:focus,
select:focus {
  outline: 3px solid rgba(26, 188, 156, 0.18);
  outline-offset: 2px;
}

/* Footer */
.site-footer {
  background: #2c3e50;
  color: #fff;
  text-align: center;
  padding: 16px;
  font-size: 0.8rem;
  margin: 32px -16px -16px;
}

.site-footer p {
  margin: 0;
}
