/* =========================================================
   SEDIMENT TRANSPORT SIMULATION — main.css
   Layout, theming, controls
   ========================================================= */

:root {
  /* Palette */
  --c-sand:      #D4A574;
  --c-gravel:    #8B7355;
  --c-pebble:    #654321;
  --c-water:     #87CEEB;
  --c-water-dk:  #4A90E2;
  --c-bg:        #F5F1E8;
  --c-page:      #F2F4F8;
  --c-surface:   #FFFFFF;
  --c-text:      #333333;
  --c-muted:     #6E7280;
  --c-line:      #E2E5EA;
  --c-ui:        #0066CC;
  --c-ui-dk:     #003F80;
  --c-success:   #00AA00;
  --c-caution:   #FF9900;
  --c-alert:     #FF0000;
  --c-grid:      #CCCCCC;

  /* Spacing */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.10);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--c-text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #E9F0F8 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 0%, #FFF6E2 0%, transparent 55%),
    var(--c-page);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.45;
}

/* =================== HEADER =================== */
.app-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 32px 18px;
  max-width: 1400px;
  margin: 0 auto;
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.brand-logo {
  /* SVG aspect is ~4:1, so let width follow height — no empty padding. */
  height: 110px;
  width: auto;
  flex: 0 0 auto;
  display: block;
}
.brand .subtitle {
  margin: 0;
  color: var(--c-muted);
  font-size: 14px;
  text-align: center;
  max-width: 600px;
}
.tabs {
  display: inline-flex;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 999px;
  padding: 4px;
  box-shadow: var(--shadow-sm);
}
.tab {
  border: none;
  background: transparent;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  color: var(--c-muted);
  font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
.tab:hover { color: var(--c-text); }
.tab.is-active {
  background: var(--c-ui);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0,102,204,0.28);
}

/* =================== TOOLBAR =================== */
.toolbar {
  max-width: 1400px;
  margin: 0 auto 18px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  border-radius: var(--r-md);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn:active { transform: translateY(0); }
.btn-play  { color: var(--c-success); }
.btn-pause { color: var(--c-caution); }
.btn-reset { color: var(--c-alert);   }
.btn.is-active {
  background: var(--c-ui);
  color: #fff;
  border-color: var(--c-ui);
}
.btn[disabled] { opacity: .5; cursor: default; }

.speed-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--c-muted);
}
.speed-select select {
  border: none;
  background: transparent;
  font: inherit;
  color: var(--c-text);
  cursor: pointer;
  outline: none;
}

.status-pill {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--c-muted);
}
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #999;
  transition: background .2s ease;
}
.status-pill.is-running .status-dot { background: var(--c-success); animation: pulse 1.4s infinite ease-out; }
.status-pill.is-paused  .status-dot { background: var(--c-caution); }
.status-pill.is-reset   .status-dot { background: #999; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0,170,0,0.5); }
  100% { box-shadow: 0 0 0 8px rgba(0,170,0,0); }
}

/* =================== LAYOUT =================== */
.layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 32px;
}

/* =================== WIZARD STEPS =================== */
/* Only the active step is visible; others are hidden. */
.wizard-step {
  display: none;
  flex-direction: column;
  gap: 28px;
}
.wizard-step.is-active {
  display: flex;
}

/* =================== WIZARD PROGRESS INDICATOR =================== */
.wizard-progress {
  max-width: 720px;
  margin: 0 auto 24px;
  padding: 0 24px;
}
.wizard-progress ol {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}
/* Connector line behind the dots */
.wizard-progress ol::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 12%;
  right: 12%;
  height: 2px;
  background: var(--c-line);
  z-index: 0;
}
.wizard-progress .step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
  z-index: 1;
}
.wizard-progress .step-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--c-surface);
  border: 2px solid var(--c-line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--c-muted);
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.wizard-progress .step-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-muted);
  text-align: center;
}
.wizard-progress .step.is-active .step-num {
  background: var(--c-ui);
  color: #fff;
  border-color: var(--c-ui);
  box-shadow: 0 2px 8px rgba(0,102,204,0.28);
}
.wizard-progress .step.is-active .step-label {
  color: var(--c-text);
}
.wizard-progress .step.is-done .step-num {
  background: var(--c-success);
  border-color: var(--c-success);
  color: #fff;
}
.wizard-progress .step.is-done .step-num::after {
  content: '✓';
}
.wizard-progress .step.is-done .step-num > * { display: none; }

/* =================== QUIZ CARD =================== */
.quiz-card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-md);
}
.quiz-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
  letter-spacing: -0.01em;
}
.quiz-hint {
  margin: 0 0 16px;
  color: var(--c-muted);
  font-size: 13px;
  line-height: 1.45;
}
.quiz-hint strong { color: var(--c-text); }

.quiz-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.quiz-table thead th {
  font-weight: 600;
  background: #F4F6FA;
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid var(--c-line);
  font-size: 12px;
}
.quiz-table thead th:first-child { background: transparent; }
.quiz-table tbody th {
  text-align: left;
  font-weight: 600;
  padding: 12px;
  background: transparent;
  border-bottom: 1px solid var(--c-line);
}
.quiz-table tbody th .legend-dot {
  margin-right: 8px;
}
.quiz-table tbody td {
  text-align: center;
  padding: 12px;
  border-bottom: 1px solid var(--c-line);
}
.quiz-table tbody tr:last-child th,
.quiz-table tbody tr:last-child td { border-bottom: none; }

.quiz-table .cbx {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  color: var(--c-muted);
}
.quiz-table .cbx input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--c-ui);
}
.quiz-table .cbx:hover { color: var(--c-text); }

.quiz-table tr.bonus-row th {
  background: #FFF4E5;
  color: var(--c-caution);
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.quiz-table .bonus-header { padding-top: 14px; padding-bottom: 8px; }

/* =================== STEP NAVIGATION =================== */
.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.btn-step {
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  border-radius: var(--r-md);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn-step:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.btn-step.btn-next {
  background: var(--c-ui);
  color: #fff;
  border-color: var(--c-ui);
}
.btn-step.btn-next:hover { background: var(--c-ui-dk); }
.btn-step.btn-restart {
  background: var(--c-caution);
  color: #fff;
  border-color: var(--c-caution);
}

/* =================== RESULTS CARD =================== */
.results-card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-md);
}
.results-header {
  text-align: center;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--c-line);
}
.results-header h2 {
  margin: 0 0 6px;
  font-size: 22px;
}
.results-summary-text {
  margin: 0;
  font-size: 16px;
  color: var(--c-muted);
}
.results-summary-text strong {
  color: var(--c-ui);
  font-size: 22px;
}
.score-label {
  display: inline-block;
  margin-left: 10px;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #EEE;
}
.score-label.score-perfect { background: var(--c-success); color: #fff; }
.score-label.score-good    { background: #BFE8C5; color: #0F5A1A; }
.score-label.score-ok      { background: #FFE0A6; color: #6B4400; }
.score-label.score-low     { background: #FFC8C8; color: #7B0E0E; }

.results-table-title {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--c-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.results-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
}
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.results-table th,
.results-table td {
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid var(--c-line);
}
.results-table thead th {
  background: #F4F6FA;
  font-weight: 700;
  font-size: 12px;
}
.results-table tbody tr:last-child td { border-bottom: none; }
.results-table tbody tr.correct { background: #E8F7EC; }
.results-table tbody tr.wrong   { background: #FDECEC; }

.results-table .ans { font-weight: 600; }
.results-table .ans.yes { color: var(--c-success); }
.results-table .ans.no  { color: #6F6F6F; }
.results-table .verdict {
  font-size: 16px;
  font-weight: 700;
}
.results-table tr.correct .verdict { color: var(--c-success); }
.results-table tr.wrong   .verdict { color: var(--c-alert);   }

/* =================== RESPONSIVE =================== */
@media (max-width: 700px) {
  .wizard-progress .step-label { display: none; }
  .quiz-table thead th { font-size: 10px; padding: 8px 6px; }
  .quiz-table tbody td { padding: 8px 6px; }
  .quiz-table tbody th { padding: 8px; font-size: 12px; }
  .step-nav { flex-direction: column-reverse; gap: 8px; }
  .step-nav .btn-step { width: 100%; }
}

/* =================== EXPERIMENT CARDS =================== */
.exp-card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.exp-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--c-line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #fff;
}
.exp-header.wind  {
  background: linear-gradient(135deg, #B07744, #8B5A2B);
}
.exp-header.water {
  background: linear-gradient(135deg, #4A90E2, #0066CC);
}
.exp-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.25);
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 2px;
  width: max-content;
}
.exp-header h2 {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 700;
}
.exp-sub {
  margin: 6px 0 0;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
}

/* =================== STAGE (SVG container) =================== */
.stage {
  background: var(--c-bg);
  padding: 14px;
  border-bottom: 1px solid var(--c-line);
  perspective: 1200px;
  /* Clip the rotated channel inside this box so the pente tilt
     doesn't bleed into the controls (or header) below. */
  overflow: hidden;
}
.stage svg {
  display: block;
  width: 100%;
  height: auto;
  background: transparent;
  border-radius: 8px;
}
.water-tilt {
  /* Rotation is now applied inside the SVG via <g id="tilt-group">. */
}

/* =================== CONTROLS =================== */
.controls {
  padding: 16px 20px;
  border-bottom: 1px solid var(--c-line);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.slider-row {
  display: grid;
  grid-template-columns: 150px 1fr 56px;
  gap: 12px;
  align-items: center;
}
.slider-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-muted);
}
.slider-row output {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-ui);
  text-align: right;
}

/* Range slider styling */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--c-grid);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--c-ui);
  border: 2px solid var(--c-ui-dk);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform .12s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.1); }
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--c-ui);
  border: 2px solid var(--c-ui-dk);
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.preset-row {
  display: flex;
  gap: 6px;
  margin-left: 162px;
}
.preset {
  flex: 1;
  border: 1px solid #999;
  background: #E8E8E8;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: #333;
  cursor: pointer;
  transition: background .12s ease, transform .12s ease;
}
.preset:hover  { background: #D8DCE2; }
.preset.is-active {
  background: #CCE5FF;
  border-color: var(--c-ui);
  color: var(--c-ui-dk);
}

/* =================== RESULTS =================== */
.results {
  padding: 14px 20px 18px;
}
.results h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-text);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.results-hint {
  margin: 0 0 10px;
  font-size: 11px;
  color: var(--c-muted);
  line-height: 1.4;
  font-style: italic;
}
.results .mech-info em,
.results li em {
  font-style: normal;
  font-weight: 500;
  color: var(--c-muted);
  font-size: 0.85em;
}
.results ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.results li {
  display: grid;
  grid-template-columns: 14px 1fr 110px 50px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}
.legend-dot.sand   { background: var(--c-sand);   }
.legend-dot.gravel { background: var(--c-gravel); width: 13px; height: 13px;}
.legend-dot.pebble { background: var(--c-pebble); width: 14px; height: 11px; border-radius: 50%/40%;}

.legend-label { color: var(--c-text); }
.bar {
  height: 6px;
  background: var(--c-line);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--c-ui), #3399FF);
  border-radius: 3px;
  width: 0%;
  transition: width .25s ease;
}
.results output {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-ui);
  text-align: right;
}

/* mechanism list (water) */
.results .mech {
  display: grid;
  grid-template-columns: 14px 1fr 80px;
  gap: 10px;
  padding: 8px 10px;
  background: #F8F9FB;
  border: 1px solid var(--c-line);
  border-radius: 6px;
  transition: background .2s ease, border-color .2s ease;
}
.results .mech.is-active {
  background: #EFF7FF;
  border-color: #BFDDF6;
}
.mech-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mech-info strong {
  font-size: 12px;
  color: var(--c-text);
}
.mech-desc {
  font-size: 11px;
  color: var(--c-muted);
}
.status-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-muted);
  text-align: right;
  align-self: center;
}
.mech.is-active .status-tag {
  color: var(--c-success);
}

/* =================== INFO PANELS =================== */
.info-grid {
  max-width: 1400px;
  margin: 24px auto 24px;
  padding: 0 32px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 900px) {
  .info-grid { grid-template-columns: 1fr; }
}
.info-panel {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-left: 3px solid var(--c-ui);
  border-radius: var(--r-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.info-panel h3 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--c-ui-dk);
}
.info-panel p {
  margin: 0;
  font-size: 12.5px;
  color: var(--c-text);
  line-height: 1.55;
}

/* =================== FOOTER =================== */
.app-footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 32px 28px;
  color: var(--c-muted);
  font-size: 11px;
  text-align: center;
}

/* =================== SVG inner styles =================== */
.wind-arrows path,
.water-arrows path {
  fill: none;
}
.wind-arrows .arrow {
  /* Stroke colour / width are set inline per-streak in JS so each streak
     can have its own thickness and shade (the curly wind look). */
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* =================== RESPONSIVE =================== */
@media (max-width: 700px) {
  .app-header { padding: 18px 16px 12px; }
  .toolbar    { padding: 0 16px; }
  .layout     { padding: 0 16px; gap: 16px; }
  .info-grid  { padding: 0 16px; }
  .slider-row { grid-template-columns: 110px 1fr 48px; gap: 8px; }
  .preset-row { margin-left: 118px; }
  .results li { grid-template-columns: 14px 1fr 70px 42px; }
  .results .mech { grid-template-columns: 14px 1fr 60px; }
}
