/* WeldMate Printreading Study Mode. Mirrors WeldMate's look: light cards, blue accent. */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #15191f;
  --muted: #5d6673;
  --stroke: #d9dee6;
  --accent: #246fd1;
  --accent-soft: #dcf1ff;
  --good: #168052;
  --good-soft: rgba(0, 128, 82, 0.1);
  --bad: #c2362b;
  --bad-soft: rgba(194, 54, 43, 0.1);
  --ink: #1d232b; /* symbol lines */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #181c22;
    --surface-2: #222831;
    --text: #e9edf2;
    --muted: #9aa4b1;
    --stroke: #2e3540;
    --accent: #6fb0ff;
    --accent-soft: #19324f;
    --good: #4fd08f;
    --good-soft: rgba(79, 208, 143, 0.12);
    --bad: #ff7b70;
    --bad-soft: rgba(255, 123, 112, 0.12);
    --ink: #e9edf2;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

a {
  color: var(--accent);
}

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--stroke);
}

.top .home {
  font-weight: 700;
  text-decoration: none;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

.loading {
  color: var(--muted);
}

/* ---------- headings and blocks ---------- */
.hero {
  margin: 8px 0 14px;
}

.hero h1,
.deck-title {
  margin: 4px 0 8px;
  font-size: 24px;
  line-height: 1.2;
}

.hero p {
  margin: 0 0 6px;
  color: var(--muted);
}

.eyebrow,
.kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.kicker {
  margin: 20px 0 8px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 14px 16px;
  margin: 12px 0;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.card p {
  margin: 0 0 6px;
}

.fine {
  font-size: 12px;
  color: var(--muted);
  margin: 16px 0;
}

.hint {
  color: var(--muted);
  margin: 10px 0;
}

.back {
  display: inline-block;
  margin: 6px 0;
  font-weight: 700;
  text-decoration: none;
}

/* ---------- lists ---------- */
.list {
  display: grid;
  gap: 9px;
}

.row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}

.row b {
  display: block;
  font-size: 16px;
}

.row small {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.row .num {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.row .pct {
  font-weight: 800;
  color: var(--good);
}

.row.is-later {
  opacity: 0.55;
  grid-template-columns: 40px 1fr;
}

.row.is-later .num {
  background: var(--surface-2);
  color: var(--muted);
}

.meter {
  display: block;
  height: 6px;
  margin-top: 6px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--good);
}

.meter.big {
  height: 10px;
  flex: 1;
  margin: 0;
}

.mastery {
  display: flex;
  align-items: center;
  gap: 12px;
}

.points {
  margin: 0;
  padding-left: 20px;
}

.points li {
  margin-bottom: 8px;
}

.terms dt {
  font-weight: 700;
  margin-top: 10px;
}

.terms dd {
  margin: 2px 0 0;
  color: var(--muted);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.btn small {
  font-weight: 600;
  opacity: 0.8;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

@media (prefers-color-scheme: dark) {
  .btn.primary {
    color: #0f1216;
  }
}

.btn.miss {
  color: var(--bad);
}

.btn.wide {
  width: 100%;
  margin-top: 8px;
}

.btn-grid {
  display: grid;
  gap: 8px;
}

.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

/* ---------- symbols ---------- */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  margin: 8px 0;
  border-radius: 14px;
  background: var(--surface-2);
}

.tabs a {
  padding: 10px 4px;
  border-radius: 11px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
}

.tabs a.on {
  background: var(--surface);
  color: var(--text);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  min-height: 40px;
  padding: 6px 14px;
  border: 1px solid var(--stroke);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

.symbol-box {
  margin: 10px 0;
  padding: 6px;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  background: var(--surface);
}

.weld-symbol {
  display: block;
  width: 100%;
  height: auto;
}

.weld-symbol .ln,
.weld-symbol .sym {
  stroke: var(--ink);
  stroke-width: 2.2;
  fill: none;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.weld-symbol .fill {
  fill: var(--ink);
}

.weld-symbol .dim {
  fill: var(--ink);
  font-size: 14px;
  font-weight: 600;
  font-family: system-ui, sans-serif;
}

.weld-symbol .dim.small {
  font-size: 12px;
}

/* Invisible tap areas: wide strokes on lines, plain boxes behind labels */
.weld-symbol line.hit {
  stroke: transparent;
  stroke-width: 16;
}

.weld-symbol rect.hit {
  fill: transparent;
  stroke: none;
}

.weld-symbol .side-zone {
  fill: transparent;
}

.tappable [data-part] {
  cursor: pointer;
}

/* Selected part */
.weld-symbol .on-part .ln,
.weld-symbol .on-part .sym,
.weld-symbol .ln.on-part {
  stroke: var(--accent);
  stroke-width: 3.2;
}

.weld-symbol .on-part .fill,
.weld-symbol .on-part .dim,
.weld-symbol tspan.on-part,
.weld-symbol .on-part tspan {
  fill: var(--accent);
}

.weld-symbol .side-zone.on-part,
.weld-symbol .on-part > .side-zone {
  fill: var(--accent-soft);
  opacity: 0.7;
}

.info {
  border-color: var(--accent);
}

/* ---------- read / build ---------- */
.choices {
  display: grid;
  gap: 8px;
}

.choice {
  padding: 12px 14px;
  border: 2px solid var(--stroke);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.choice.is-right {
  border-color: var(--good);
  background: var(--good-soft);
}

.choice.is-wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.choice.is-dim {
  opacity: 0.55;
}

.feedback {
  margin: 10px 0 0;
  padding: 10px 14px;
  border-radius: 14px;
  font-weight: 600;
}

.feedback.good {
  background: var(--good-soft);
  color: var(--good);
}

.feedback.bad {
  background: var(--bad-soft);
  color: var(--text);
}

.feedback ul {
  margin: 6px 0 0;
  padding-left: 20px;
  font-weight: 500;
}

.target p {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}

.builder {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field {
  display: grid;
  gap: 3px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.field select {
  min-height: 44px;
  padding: 6px 8px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--surface);
  font-size: 15px;
}

.toggle input {
  width: 20px;
  height: 20px;
}

.result {
  text-align: center;
}

/* ---------- flash cards ---------- */
.flash {
  min-height: 220px;
  margin: 10px 0;
  padding: 16px;
  border: 1px solid var(--stroke);
  border-radius: 18px;
  background: var(--surface);
  display: grid;
  align-content: center;
  gap: 12px;
  text-align: center;
}

.flash .weld-symbol {
  max-width: 420px;
  margin: 0 auto;
}

.card-term {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
}

.card-q {
  font-weight: 700;
  margin: 0;
}

.flash-back {
  padding-top: 12px;
  border-top: 1px dashed var(--stroke);
  font-size: 17px;
}

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: var(--surface);
  border-top: 1px solid var(--stroke);
}

.bottom-nav a {
  display: grid;
  place-items: center;
  min-height: 52px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.bottom-nav a.on {
  background: var(--accent-soft);
  color: var(--accent);
}
