/**
 * courses/public/css/widgets.css
 *
 * Styles for interactive lesson widgets. Every selector is prefixed
 * `.tow-w-*` (TinyOffice-Widget) so widget styles never accidentally
 * collide with lesson-body prose styles. Widgets render inside the
 * lesson body, not as full-page chrome — so they need to feel
 * embedded, not bolted on.
 *
 * Visual language: matches the existing course look — light cream
 * background (#fafaf9 ish), zinc text, teal (#5a8c8c) accent, serif
 * Playfair for headlines, Inter for body, JetBrains Mono for technical
 * labels.
 *
 * Per-widget sections are separated with =========== banners so each
 * one can be edited independently. Shared primitives (frame, eyebrow,
 * pane, error) live at the top.
 */

/* ── Shared primitives ────────────────────────────────────────────────── */

/* The <tinyoffice-widget> custom tag is unknown to the browser, which
   means by default it renders as inline. Force it to behave like a
   block-level container so its inner frame fills the lesson's reading
   width. */
tinyoffice-widget {
  display: block;
  margin: 32px 0;
}

.tow-w-frame {
  background: linear-gradient(180deg, #fafaf9 0%, #f5f5f4 100%);
  border: 1px solid rgba(115, 115, 115, 0.18);
  border-radius: 6px;
  padding: 24px 28px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #3f3f46;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.tow-w-eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #5a8c8c;
  margin-bottom: 12px;
  font-weight: 500;
}

.tow-w-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* ============================================================
   V1 — Magnifier Slider
   ============================================================ */

.tow-w-magnifier .tow-w-header {
  margin-bottom: 22px;
}

.tow-w-magnifier .tow-w-task {
  font-size: 14px;
  color: #52525b;
  line-height: 1.55;
}

.tow-w-magnifier .tow-w-task-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #71717a;
  margin-right: 8px;
}

.tow-w-magnifier .tow-w-task-text {
  font-style: italic;
  color: #27272a;
}

/* Slider row — label above, range + stops below. */
.tow-w-magnifier .tow-w-slider-row {
  margin-bottom: 24px;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(115, 115, 115, 0.12);
  border-radius: 4px;
}

.tow-w-magnifier .tow-w-slider-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #71717a;
  margin-bottom: 14px;
}

.tow-w-magnifier .tow-w-slider-current {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
  color: #27272a;
}

.tow-w-magnifier .tow-w-slider-current strong {
  font-weight: 600;
  color: #5a8c8c;
}

.tow-w-magnifier .tow-w-sublabel {
  color: #71717a;
  font-style: italic;
}

/* The actual <input type="range"> — restyled across browsers. The
   visual rail uses a teal accent so the slider matches the rest of
   the course's accent system without us having to inject a custom
   thumb shape. */
.tow-w-magnifier .tow-w-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: #e7e5e4;
  border-radius: 2px;
  outline: none;
  margin: 0 0 6px 0;
  cursor: pointer;
  accent-color: #5a8c8c;
}

.tow-w-magnifier .tow-w-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: #5a8c8c;
  border: 2px solid #fafaf9;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease, background 0.12s ease;
}

.tow-w-magnifier .tow-w-range::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.1);
  background: #4a7575;
}

.tow-w-magnifier .tow-w-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: #5a8c8c;
  border: 2px solid #fafaf9;
  border-radius: 50%;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

/* Stop buttons under the rail — clickable labels for keyboard /
   mouse users who'd rather jump than drag. */
.tow-w-magnifier .tow-w-stops {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
}

.tow-w-magnifier .tow-w-stop {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a1a1aa;
  transition: color 0.15s ease;
}

.tow-w-magnifier .tow-w-stop:hover { color: #52525b; }

.tow-w-magnifier .tow-w-stop-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d4d4d8;
  border: 1px solid #a1a1aa;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.tow-w-magnifier .tow-w-stop.is-passed .tow-w-stop-dot,
.tow-w-magnifier .tow-w-stop.is-active .tow-w-stop-dot {
  background: #5a8c8c;
  border-color: #5a8c8c;
}

.tow-w-magnifier .tow-w-stop.is-active {
  color: #5a8c8c;
}

.tow-w-magnifier .tow-w-stop.is-active .tow-w-stop-dot {
  transform: scale(1.3);
  box-shadow: 0 0 0 4px rgba(90, 140, 140, 0.18);
}

/* The two-pane comparison area: prompt on the left, AI output on the
   right, with a magnifier glyph between them that visually connects
   them. The output side scales subtly with the active stop — the
   higher the expertise, the more "amplified" the right side feels. */
.tow-w-magnifier .tow-w-panes {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 18px;
}

.tow-w-magnifier .tow-w-pane {
  background: #ffffff;
  border: 1px solid rgba(115, 115, 115, 0.16);
  border-radius: 4px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  min-height: 200px;
}

.tow-w-magnifier .tow-w-pane-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #71717a;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(115, 115, 115, 0.18);
}

.tow-w-magnifier .tow-w-pane-content {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.65;
  color: #27272a;
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  flex: 1;
}

.tow-w-magnifier .tow-w-pane-output .tow-w-pane-content {
  color: #18181b;
}

/* The center magnifier glyph — visually anchors the "tool" between the
   two sides. Subtle pulse on the active stop reinforces that it's the
   thing connecting input to output. */
.tow-w-magnifier .tow-w-magnifier-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a1a1aa;
  transition: color 0.2s ease, transform 0.2s ease;
  width: 36px;
}

.tow-w-magnifier[data-stop="2"] .tow-w-magnifier-icon {
  color: #5a8c8c;
  transform: scale(1.15);
}

.tow-w-magnifier[data-stop="1"] .tow-w-magnifier-icon {
  color: #7da5a5;
}

/* Output pane scales with stop — beginner shrinks, expert grows.
   This is the "magnification" effect made visual. Subtle on
   purpose: a 4% bump is enough to feel without being cartoonish. */
.tow-w-magnifier[data-stop="0"] .tow-w-pane-output {
  transform: scale(0.98);
  transform-origin: left center;
  opacity: 0.85;
}
.tow-w-magnifier[data-stop="2"] .tow-w-pane-output {
  transform: scale(1.02);
  transform-origin: left center;
  border-color: rgba(90, 140, 140, 0.4);
  box-shadow: 0 1px 3px rgba(90, 140, 140, 0.12);
}
.tow-w-magnifier .tow-w-pane-output {
  transition: transform 0.25s ease, opacity 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

/* Analysis line at the bottom — the "what you should notice" caption.
   Composed of an inline tag + body text so the active stop label is
   visually distinguishable from the explanation. */
.tow-w-magnifier .tow-w-analysis {
  font-size: 13px;
  line-height: 1.6;
  color: #52525b;
  padding: 12px 14px;
  background: rgba(90, 140, 140, 0.06);
  border-left: 3px solid #5a8c8c;
  border-radius: 0 4px 4px 0;
}

.tow-w-magnifier .tow-w-analysis-tag {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #5a8c8c;
  font-weight: 500;
  margin-right: 10px;
}

.tow-w-magnifier .tow-w-analysis-body {
  color: #3f3f46;
}

/* ── Mobile ────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .tow-w-frame { padding: 18px 16px; }
  .tow-w-magnifier .tow-w-panes {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .tow-w-magnifier .tow-w-magnifier-icon {
    width: auto;
    height: 28px;
    transform: rotate(90deg);
  }
  .tow-w-magnifier[data-stop="2"] .tow-w-magnifier-icon {
    transform: rotate(90deg) scale(1.15);
  }
  .tow-w-magnifier[data-stop="0"] .tow-w-pane-output,
  .tow-w-magnifier[data-stop="2"] .tow-w-pane-output {
    transform: none; /* skip scale on mobile — too tight to see */
  }
  .tow-w-magnifier .tow-w-stop-label {
    font-size: 8px;
  }
}
