/* ==========================================================================
   EL BADR Industries — Interactive Gear Guide (learn.html)
   Reuses the design-system variables from main.css (adapts to dark mode).
   ========================================================================== */

.learn-hero { min-height: min(48vh, 460px); }
.learn-hero .hero__kicker { margin-bottom: 1.1rem; }

/* --------------------------------------------------------------------------
   Playground layout
   -------------------------------------------------------------------------- */
.gp {
  display: grid;
  grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: 1.8rem;
  align-items: stretch;
}
@media (max-width: 880px) { .gp { grid-template-columns: 1fr; } }

/* Controls ----------------------------------------------------------------- */
.gp-controls {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem 1.6rem;
  display: grid;
  gap: 1.15rem;
}
.gp-field label {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--font-head); font-weight: 600; color: var(--ink);
  font-size: 0.96rem; margin-bottom: 0.5rem;
}
.gp-sym { color: var(--red); font-weight: 700; font-style: italic; }
.gp-field small { display: block; margin-top: 0.4rem; color: var(--muted); font-size: 0.8rem; line-height: 1.4; }
.gp-inputrow { display: flex; align-items: center; gap: 0.9rem; }
.gp-inputrow output {
  flex: none; min-width: 92px; text-align: right;
  font-family: var(--font-head); font-weight: 700; color: var(--ink); font-size: 0.95rem;
}

/* Range slider (brand themed) */
.gp-inputrow input[type="range"] {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 6px; border-radius: 999px;
  background: var(--line); outline: none; cursor: pointer;
}
.gp-inputrow input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--red); border: 3px solid var(--surface);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25); cursor: pointer;
  transition: transform 0.12s ease;
}
.gp-inputrow input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.12); }
.gp-inputrow input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--red); border: 3px solid var(--surface); cursor: pointer;
}

/* Segmented control (pressure angle) */
.gp-segmented { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.gp-segmented button {
  flex: 1; padding: 0.55rem 0.4rem; border: 0; background: transparent;
  font-family: var(--font-head); font-weight: 600; font-size: 0.9rem;
  color: var(--muted); cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.gp-segmented button + button { border-inline-start: 1px solid var(--line); }
.gp-segmented button.is-active { background: var(--red); color: #fff; }

/* Stage / SVG -------------------------------------------------------------- */
.gp-stage {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  position: sticky; top: calc(var(--header-h) + 14px);
}
.gp-canvas-wrap {
  position: relative;
  background:
    radial-gradient(120% 120% at 50% 0%, rgba(210,14,16,0.06), transparent 60%),
    repeating-linear-gradient(0deg, var(--line) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 26px);
  border-radius: 12px;
  overflow: hidden;
}
#gp-svg { width: 100%; height: 100%; display: block; }
.gp-tooth1 { fill: var(--red); }
.gp-tooth2 { fill: var(--gray); }
[data-theme="dark"] .gp-tooth2 { fill: #6f6f7a; }
.gp-hub { fill: var(--surface); stroke: rgba(0,0,0,0.18); stroke-width: 1.5; }
.gp-bore { fill: var(--surface); stroke: var(--muted); stroke-width: 1.2; }
.gp-pitch { fill: none; stroke: rgba(255,255,255,0.55); stroke-dasharray: 4 5; stroke-width: 1; }
[data-theme="dark"] .gp-pitch { stroke: rgba(255,255,255,0.35); }
.gp-tooth1, .gp-tooth2 { stroke: rgba(0,0,0,0.12); stroke-width: 0.6; }
.gp-centerline { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 4; opacity: 0.5; }

.gp-playpause {
  position: absolute; bottom: 10px; inset-inline-end: 10px;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 0.95rem; cursor: pointer; display: grid; place-items: center;
  box-shadow: var(--shadow); transition: transform 0.12s ease;
}
.gp-playpause:hover { transform: scale(1.08); }

.gp-rpm-strip {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  margin-top: 0.9rem; flex-wrap: wrap;
}
.gp-rpm-strip > div { text-align: center; }
.gp-rpm-val { display: block; font-family: var(--font-head); font-weight: 800; font-size: 1.5rem; color: var(--red); line-height: 1; }
.gp-rpm-strip small { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.gp-rpm-arrow { color: var(--muted); font-size: 1.2rem; }

/* Results grid ------------------------------------------------------------- */
.gp-results {
  margin-top: 1.8rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.9rem;
}
.gp-result {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.95rem 1.1rem; display: flex; flex-direction: column; gap: 0.15rem;
  border-top: 3px solid var(--red);
}
.gp-result__label { font-size: 0.82rem; color: var(--muted); }
.gp-result__label em { color: var(--ink); font-style: italic; font-weight: 600; }
.gp-result__val { font-family: var(--font-head); font-weight: 800; font-size: 1.32rem; color: var(--ink); line-height: 1.1; }
.gp-result__eq { font-size: 0.74rem; color: var(--muted); font-family: var(--font-head); letter-spacing: 0.02em; }
.gp-note { margin-top: 1.1rem; color: var(--muted); font-size: 0.85rem; max-width: 70ch; }
.gp-note em { font-style: italic; }

/* --------------------------------------------------------------------------
   Reference glossary
   -------------------------------------------------------------------------- */
.gloss-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1.1rem;
}
.gloss {
  position: relative;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem 1.4rem 1.5rem; box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.gloss:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: rgba(210,14,16,0.4); }
.gloss__n {
  font-family: var(--font-head); font-weight: 800; font-size: 0.85rem;
  color: var(--red); letter-spacing: 0.12em; display: block; margin-bottom: 0.5rem;
}
.gloss h3 { font-size: 1.12rem; margin: 0 0 0.5rem; color: var(--ink); }
.gloss h3 em { font-style: italic; color: var(--red); }
.gloss h3 small { font-style: normal; font-weight: 600; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-inline-start: 0.35rem; }
.gloss p { color: var(--text); font-size: 0.92rem; margin: 0 0 0.6rem; }
.gloss p:last-child { margin-bottom: 0; }
.gloss__sub { color: var(--muted) !important; font-size: 0.84rem !important; }
.gloss__eq {
  font-family: "Cairo", var(--font-head); font-weight: 700;
  background: var(--paper); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.55rem 0.8rem; color: var(--ink); font-size: 0.95rem; margin: 0.2rem 0 0.7rem;
  text-align: center; letter-spacing: 0.01em;
}
.gloss__list { list-style: none; padding: 0; margin: 0.2rem 0 0; display: grid; gap: 0.35rem; }
.gloss__list li { position: relative; padding-inline-start: 1.1rem; font-size: 0.9rem; color: var(--text); }
.gloss__list li::before { content: ""; position: absolute; inset-inline-start: 0; top: 0.55em; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }

.gloss-cta {
  margin-top: 2rem; text-align: center;
  background: var(--steel); color: #fff; border-radius: var(--radius);
  padding: clamp(2rem, 5vw, 3.2rem);
}
.gloss-cta h3 { color: #fff; font-size: 1.6rem; margin: 0 0 0.5rem; }
.gloss-cta p { color: rgba(255,255,255,0.72); max-width: 56ch; margin: 0 auto 1.5rem; }
.gloss-cta__btns { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Single-tooth structure figures
   -------------------------------------------------------------------------- */
/* Right column: three diagrams stacked, sharing the controls-panel height */
.gp-stack {
  display: flex; flex-direction: column; gap: 1rem;
  min-height: 0;
}
.diagram {
  flex: 1 1 0; min-height: 0; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.7rem 0.85rem 0.75rem;
}
/* bottom half: pinion + gear teeth side by side */
.gp-teeth-row {
  flex: 1 1 0; min-height: 0;
  display: flex; gap: 1rem;
}
@media (max-width: 880px) { .gp-teeth-row { flex-direction: column; } }
.diagram-title {
  flex: none; margin: 0 0 0.45rem;
  font-family: var(--font-head); font-weight: 700; font-size: 0.98rem;
  color: var(--ink); display: flex; align-items: center; gap: 0.4rem;
}
.diagram-canvas {
  flex: 1 1 auto; min-height: 0; position: relative;
  border-radius: 12px; overflow: hidden;
}
.diagram-canvas svg { width: 100%; height: 100%; display: block; }
#tooth1-svg, #tooth2-svg {
  background:
    repeating-linear-gradient(0deg, var(--line) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(90deg, var(--line) 0 1px, transparent 1px 26px);
}
/* On narrow screens the stack drops below the controls — give each room. */
@media (max-width: 880px) {
  .diagram { min-height: 280px; }
}

/* tooth body */
.tf-context { fill: var(--muted); opacity: 0.16; }
.tf-main { stroke: rgba(0,0,0,0.18); stroke-width: 0.8; }
.tf-main--1 { fill: var(--red); }
.tf-main--2 { fill: var(--gray); }
[data-theme="dark"] .tf-main--2 { fill: #6f6f7a; }

/* reference lines */
.tf-tip, .tf-root { stroke: var(--muted); stroke-width: 1; opacity: 0.45; }
.tf-pitch { stroke: var(--red); stroke-width: 1.2; stroke-dasharray: 5 5; opacity: 0.85; }

/* dimensions */
.tf-dim, .tf-dim2 { stroke: var(--ink); stroke-width: 1; opacity: 0.6; }
.tf-tag {
  font-family: var(--font-head); font-weight: 600; font-size: 11px;
  fill: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
}
.tf-tag--pitch { fill: var(--red); }
.tf-dimlabel { font-family: var(--font-head); font-weight: 700; font-size: 12px; fill: var(--ink); }
.tf-slabel { font-family: var(--font-head); font-weight: 700; font-size: 12px; fill: var(--ink); }

/* face / helix strip */
.tf-face { fill: none; stroke: var(--muted); stroke-width: 1; opacity: 0.7; }
.tf-helix { stroke: var(--red); stroke-width: 1.4; opacity: 0.5; }
