/* =============================================================================
   FALLING-BALL VISCOMETER — viscometer-styles.css
   SimpliPhys · Core Practical 2
   Dark theme · bg #0a0a1a · teal #1abc9c · navy #2c3e50 · gold #f1c40f · coral #e74c3c
   Font: Montserrat (Google Fonts — only permitted external dependency)
============================================================================= */

/* ── RESET ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── ROOT TOKENS ───────────────────────────────────────────────────────────── */
:root {
  --bg:           #0a0a1a;
  --panel-bg:     #0e1228;
  --panel-border: rgba(44, 62, 80, 0.48);
  --navy:         #2c3e50;
  --teal:         #1abc9c;
  --gold:         #f1c40f;
  --coral:        #e74c3c;
  --text:         #cdd6e4;
  --muted:        #6a8090;
  --dim:          #384a58;
  --heading:      #ffffff;
  --radius:       10px;
}

/* ── BASE ───────────────────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Montserrat', sans-serif;
  font-size: 0.875rem;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── HEADER ────────────────────────────────────────────────────────────────── */
.page-header {
  padding: 18px 28px 14px;
  border-bottom: 1px solid var(--panel-border);
}

.back-link {
  display: inline-block;
  color: var(--teal);
  text-decoration: none;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
  transition: opacity 0.15s ease;
}
.back-link:hover { opacity: 0.68; }

.page-title {
  font-size: clamp(1.2rem, 2.4vw, 1.7rem);
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.page-sub {
  margin-top: 3px;
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* ── MAIN LAYOUT ───────────────────────────────────────────────────────────── */
.sim-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px 24px 48px;
  max-width: 1060px;
  margin: 0 auto;
}

@media (min-width: 820px) {
  .sim-main {
    flex-direction: row;
    align-items: flex-start;
  }
}

/* ── CANVAS ────────────────────────────────────────────────────────────────── */
.canvas-wrap { flex: 0 0 auto; }

#simCanvas {
  display: block;
  border-radius: 8px;
  /* CSS size set in viscometer-script.js to match devicePixelRatio */
}

/* ── INFO PANEL ────────────────────────────────────────────────────────────── */
.info-panel {
  flex: 1 1 220px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 195px;
  max-width: 270px;
}

.panel-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.panel-heading {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 13px;
}

/* Apparatus list */
.apparatus-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.a-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.a-row dt {
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--muted);
  flex-shrink: 0;
}

.a-row dd {
  font-size: 0.79rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

/* Thermometer */
.therm-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

#thermCanvas { display: block; }

.therm-reading {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -0.02em;
  line-height: 1;
}

.panel-note {
  font-size: 0.69rem;
  color: var(--dim);
  line-height: 1.55;
}

/* ── STAGE 2: SIM-LEFT COLUMN ─────────────────────────────────────────────── */
.sim-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 0 auto;
}

/* ── STAGE 2: CONTROLS BAR ────────────────────────────────────────────────── */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 28px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 14px 20px;
}

.ball-tray {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.tray-label {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
}

.tray-row {
  display: flex;
  gap: 9px;
  align-items: center;
}

.ball-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(44, 62, 80, 0.85);
  background: radial-gradient(circle at 36% 34%, #20283a, #121820);
  color: #5a7585;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: border-color 0.14s ease, color 0.14s ease;
}

.ball-btn:hover:not(.selected) {
  border-color: var(--teal);
  color: var(--teal);
}

.ball-btn.selected {
  border-color: var(--gold);
  color: var(--gold);
  background: radial-gradient(circle at 36% 34%, #252a18, #131510);
}

/* ── STAGE 4: MICROMETER ──────────────────────────────────────────────────── */
.micr-card { padding-bottom: 16px; }

.micr-intro { margin-bottom: 10px; }

#micrCanvas {
  display: block;
  /* CSS size set by setupMicr() to match devicePixelRatio */
}

/* ── STAGE 4: RESULTS TABLE ───────────────────────────────────────────────── */
.results-section {
  padding: 0 24px 52px;
  max-width: 1060px;
  margin: 0 auto;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-heading {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--teal);
}

.results-controls { display: flex; gap: 10px; }

.results-controls .btn {
  padding: 9px 18px;
  font-size: 0.78rem;
}

.table-wrap { overflow-x: auto; }

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.results-table th {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  padding: 10px 12px;
  font-size: 0.70rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

.results-table td {
  border: 1px solid var(--panel-border);
  padding: 0;
}

.tbl-input {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: 'Montserrat', sans-serif;
  font-size: 0.82rem;
  padding: 9px 12px;
  outline: none;
  transition: background 0.12s ease;
}
.tbl-input:focus { background: rgba(26, 188, 156, 0.07); }

.tbl-ball { max-width: 70px; text-transform: uppercase; }

.table-note {
  margin-top: 12px;
  font-size: 0.69rem;
  color: var(--dim);
  line-height: 1.55;
}

/* ── STAGE 3: STOPWATCH ───────────────────────────────────────────────────── */
.sw-display {
  font-size: 2.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--teal);
  letter-spacing: 0.05em;
  text-align: center;
  padding: 6px 0 14px;
  line-height: 1;
}

.sw-btns {
  display: flex;
  gap: 8px;
}

.sw-btns .btn {
  flex: 1;
  padding: 9px 4px;
  font-size: 0.76rem;
}

/* ── STAGE 3: BAND DRAG HINT ──────────────────────────────────────────────── */
.band-hint {
  font-size: 0.69rem;
  color: var(--dim);
  text-align: center;
  padding: 0 2px;
  line-height: 1.5;
}

/* ── BUTTONS (used in later stages) ───────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease, opacity 0.15s ease;
}
.btn:disabled { opacity: 0.38; cursor: not-allowed; transform: none; }

.btn-teal  { background: var(--teal);  color: #0a1a14; }
.btn-coral { background: var(--coral); color: #ffffff; }
.btn-navy  { background: var(--navy);  color: #ffffff; }

.btn-teal:hover:not(:disabled)  { background: #16a085; transform: translateY(-1px); }
.btn-coral:hover:not(:disabled) { background: #c0392b; transform: translateY(-1px); }
.btn-navy:hover:not(:disabled)  { background: #233140; transform: translateY(-1px); }

/* ── STAGE 5: GUIDED INVESTIGATION ─────────────────────────────────────────── */
.guided-section {
  padding: 0 24px 72px;
  max-width: 1060px;
  margin: 0 auto;
}

.guided-details {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: var(--panel-bg);
  overflow: hidden;
}

.guided-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  cursor: pointer;
  list-style: none;
  -webkit-user-select: none;
  user-select: none;
  transition: background 0.15s ease;
}

.guided-summary::-webkit-details-marker { display: none; }
.guided-summary::marker                 { display: none; }

.guided-summary:hover { background: rgba(26, 188, 156, 0.05); }

.guided-label {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--teal);
}

.guided-chevron {
  color: var(--muted);
  font-size: 0.85rem;
  display: inline-block;
  transition: transform 0.22s ease;
  line-height: 1;
}

.guided-details[open] .guided-chevron { transform: rotate(180deg); }

.guided-body {
  padding: 0 24px 28px;
  border-top: 1px solid var(--panel-border);
}

.guided-intro {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.65;
  padding: 18px 0 22px;
  max-width: 680px;
}

.gi-cards {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  overflow: hidden;
}

.gi-card {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 18px 20px;
  background: var(--bg);
  transition: background 0.12s ease;
}

.gi-card:hover { background: rgba(10, 10, 30, 0.75); }

.gi-card + .gi-card { border-top: 1px solid var(--panel-border); }

.gi-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(26, 188, 156, 0.10);
  border: 1px solid rgba(26, 188, 156, 0.28);
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.gi-right { flex: 1; }

.gi-heading {
  font-size: 0.80rem;
  font-weight: 700;
  color: var(--heading);
  margin-bottom: 7px;
  letter-spacing: 0.01em;
}

.gi-text {
  font-size: 0.77rem;
  color: var(--text);
  line-height: 1.65;
}

.gi-list {
  margin-top: 12px;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gi-list li {
  font-size: 0.77rem;
  color: var(--text);
  line-height: 1.65;
  padding-left: 16px;
  position: relative;
}

.gi-list li::before {
  content: '\2014';
  position: absolute;
  left: 0;
  color: var(--dim);
}

.gi-list strong {
  color: var(--heading);
  font-weight: 600;
}

/* ── FOCUS RING ────────────────────────────────────────────────────────────── */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(26, 188, 156, 0.55);
  outline-offset: 3px;
}
