/* line-craft page-specific styles — inherits root CSS variables from ../styles.css */

.lc-app {
  width: min(960px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

/* ── Hero ─────────────────────────────────────────────────────────── */

.lc-hero {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(62, 40, 24, 0.08);
  padding: 28px;
  margin-bottom: 18px;
}

/* ── Panel ────────────────────────────────────────────────────────── */

.lc-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(62, 40, 24, 0.08);
  padding: 24px;
  margin-bottom: 18px;
}

.lc-form {
  display: grid;
  gap: 16px;
}

/* ── Spectrum Sliders ─────────────────────────────────────────────── */

.spectrums-container {
  display: grid;
  gap: 18px;
  padding: 16px;
  border: 1px solid rgba(31, 26, 23, 0.08);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.48)),
    radial-gradient(circle at top left, rgba(63, 107, 112, 0.06), transparent 42%);
}

.spectrum-row {
  display: grid;
  gap: 6px;
}

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

.spectrum-left,
.spectrum-right {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
  flex-shrink: 0;
}

.spectrum-desc {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  flex: 1;
}

.spectrum-track {
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
}

.spectrum-ticks {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
  pointer-events: none;
}

.spectrum-tick {
  width: 2px;
  height: 10px;
  border-radius: 1px;
  background: rgba(31, 26, 23, 0.15);
}

.spectrum-tick.center {
  height: 14px;
  background: rgba(31, 26, 23, 0.25);
}

.spectrum-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg,
    rgba(63, 107, 112, 0.25),
    rgba(31, 26, 23, 0.08) 50%,
    rgba(184, 92, 56, 0.25)
  );
  outline: none;
  cursor: pointer;
}

.spectrum-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(31, 26, 23, 0.2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.spectrum-slider::-webkit-slider-thumb:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(184, 92, 56, 0.2);
}

.spectrum-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(31, 26, 23, 0.2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* ── Metaphor Toggle ─────────────────────────────────────────────── */

.metaphor-toggle-row {
  padding: 16px;
  border: 1px solid rgba(31, 26, 23, 0.08);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.48)),
    radial-gradient(circle at bottom left, rgba(184, 92, 56, 0.06), transparent 42%);
}

.metaphor-toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.metaphor-toggle-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.metaphor-en {
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--muted);
}

.metaphor-switch {
  position: relative;
  width: 48px;
  height: 26px;
  border: 2px solid rgba(31, 26, 23, 0.15);
  border-radius: 999px;
  background: rgba(31, 26, 23, 0.08);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 200ms ease, border-color 200ms ease;
}

.metaphor-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.metaphor-switch[aria-pressed="true"] {
  background: rgba(184, 92, 56, 0.25);
  border-color: rgba(184, 92, 56, 0.4);
}

.metaphor-switch[aria-pressed="true"] .metaphor-switch-thumb {
  transform: translateX(22px);
}

.metaphor-hint {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.metaphor-micros {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(31, 26, 23, 0.06);
}

/* ── Micro-Principle Chips ────────────────────────────────────────── */

.micros-shell {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(31, 26, 23, 0.08);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.48)),
    radial-gradient(circle at top right, rgba(184, 92, 56, 0.08), transparent 42%);
}

.micros-shell-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.micros-shell-head h2 {
  margin: 0;
  font-size: 1rem;
}

.micros-shell-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.micro-group {
  display: grid;
  gap: 8px;
}

.micro-group-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.micro-group-title {
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.micro-group-subtitle {
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.7;
}

.micro-learn-link {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
  transition: opacity 120ms ease;
}

.micro-learn-link:hover {
  opacity: 0.7;
  text-decoration: underline;
}

/* ── Book Examples ───────────────────────────────────────────────── */

.micro-examples {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(31, 26, 23, 0.025);
  border: 1px solid rgba(31, 26, 23, 0.05);
}

.micro-example-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-size: 0.82rem;
  line-height: 1.5;
}

.ex-zh {
  color: var(--ink);
  font-weight: 500;
}

.ex-en {
  color: var(--muted);
  font-style: italic;
}

.ex-en::before { content: "— "; }

.ex-source {
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.6;
}

.ex-source::before { content: "("; }
.ex-source::after { content: ")"; }

.ex-hint {
  display: block;
  width: 100%;
  font-size: 0.75rem;
  color: var(--muted);
  opacity: 0.7;
  margin-top: 1px;
  padding-left: 1em;
  font-style: italic;
}

/* ── Collapsible Method Guide ────────────────────────────────────── */

.micro-method {
  margin-top: 6px;
  border-top: 1px solid rgba(31, 26, 23, 0.06);
  padding-top: 6px;
}

.micro-method summary {
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
  list-style: none;
  user-select: none;
}

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

.micro-method summary::before {
  content: "▸ ";
  font-size: 0.7rem;
}

.micro-method[open] summary::before {
  content: "▾ ";
}

.micro-method-body {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--ink);
}

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

.micro-chip {
  border: 1px solid rgba(31, 26, 23, 0.12);
  border-radius: 999px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.84rem;
  transition: all 120ms ease;
}

.micro-chip:hover {
  border-color: var(--accent);
}

.micro-chip.active {
  background: rgba(184, 92, 56, 0.15);
  border-color: rgba(184, 92, 56, 0.3);
  color: var(--accent);
  font-weight: 600;
}

/* ── Buttons ──────────────────────────────────────────────────────── */

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lc-generate-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #3f6b70 0%, #b85c38 100%);
  color: #fff8f0;
  cursor: pointer;
  font: inherit;
  transition: transform 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 12px 24px rgba(63, 107, 112, 0.18);
}

.lc-generate-btn:hover {
  transform: translateY(-1px);
}

.lc-generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.lc-clear-btn {
  border: 1px solid rgba(31, 26, 23, 0.18);
  border-radius: 999px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
}

.lc-clear-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
}

/* ── Status ───────────────────────────────────────────────────────── */

.lc-status {
  min-height: 1.4rem;
  margin-top: 12px;
  font-size: 0.92rem;
  color: var(--muted);
}

.lc-status[data-state="error"] {
  color: var(--warning);
}

.lc-status[data-state="loading"] {
  color: var(--accent);
}

/* ── Results ──────────────────────────────────────────────────────── */

.lc-results-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 50px rgba(62, 40, 24, 0.08);
  padding: 24px;
}

.lc-results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.lc-results-head p {
  color: var(--muted);
}

.results {
  display: grid;
  gap: 16px;
}

/* ── Line Card ────────────────────────────────────────────────────── */

.line-card {
  padding: 18px;
  border: 1px solid rgba(31, 26, 23, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.iteration-card {
  border-left: 3px solid rgba(184, 92, 56, 0.3);
}

.line-text {
  margin-bottom: 8px;
  font-size: 1.45rem;
  line-height: 1.25;
}

.line-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.86rem;
  color: var(--muted);
}

.line-register {
  background: rgba(184, 92, 56, 0.1);
  border-radius: 999px;
  padding: 2px 10px;
}

.line-craft-note {
  font-style: italic;
}

.line-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.action-btn {
  border: 1px solid rgba(31, 26, 23, 0.12);
  border-radius: 999px;
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  transition: all 120ms ease;
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.action-critique {
  border-color: rgba(63, 107, 112, 0.25);
  color: #3f6b70;
}

.action-critique:hover {
  border-color: #3f6b70;
}

/* ── Critique Block ───────────────────────────────────────────────── */

.critique-block {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(63, 107, 112, 0.15);
  border-radius: 14px;
  background: rgba(63, 107, 112, 0.04);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--ink);
}

.critique-section {
  margin-bottom: 6px;
}

.critique-section:last-child {
  margin-bottom: 0;
}

/* ── Iteration Group ──────────────────────────────────────────────── */

.iteration-group {
  margin-left: 20px;
  padding-left: 16px;
  border-left: 2px solid rgba(31, 26, 23, 0.08);
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

/* ── Debug ─────────────────────────────────────────────────────────── */

.lc-debug {
  margin-top: 12px;
  border: 1px solid rgba(31, 26, 23, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.42);
  overflow: hidden;
}

.lc-debug summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: 600;
}

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

.lc-debug-body {
  padding: 0 14px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.84rem;
  color: var(--muted);
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  max-height: 400px;
  overflow-y: auto;
}

/* ── Empty State ──────────────────────────────────────────────────── */

.empty-state {
  padding: 20px;
  border: 1px dashed rgba(31, 26, 23, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.4);
  color: var(--muted);
}

/* ── Teach Me Slide-Out Panel ─────────────────────────────────────── */

.teach-toggle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  border: 1px solid var(--line);
  border-right: none;
  border-radius: 12px 0 0 12px;
  padding: 16px 8px;
  background: var(--panel);
  color: var(--accent);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: -4px 0 16px rgba(62, 40, 24, 0.06);
  transition: background 150ms ease, box-shadow 150ms ease;
  z-index: 100;
}

.teach-toggle:hover {
  background: rgba(184, 92, 56, 0.08);
  box-shadow: -4px 0 20px rgba(184, 92, 56, 0.12);
}

.teach-toggle.hidden { display: none; }

.teach-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 26, 23, 0.2);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
  z-index: 200;
}

.teach-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.teach-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(440px, 85vw);
  height: 100vh;
  background: var(--paper);
  border-left: 1px solid var(--line);
  box-shadow: -12px 0 40px rgba(62, 40, 24, 0.1);
  transform: translateX(100%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 300;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.teach-panel.open {
  transform: translateX(0);
}

.teach-header {
  flex-shrink: 0;
  padding: 24px 24px 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.teach-header h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}

.teach-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.teach-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: none;
  font-size: 1.6rem;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 120ms ease;
}

.teach-close:hover {
  background: rgba(31, 26, 23, 0.06);
  color: var(--ink);
}

.teach-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 40px;
}

/* ── Teach Sections ─────────────────────────────────────────────── */

.teach-section {
  margin-bottom: 24px;
}

.teach-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--accent);
}

.teach-section-subtitle {
  font-size: 0.78rem;
  font-style: italic;
  color: rgba(31, 26, 23, 0.55);
  margin-top: -6px;
  margin-bottom: 14px;
}

/* Collapsible sections (via <details>) */
details.teach-section {
  padding: 0;
  background: transparent;
}

.teach-section-summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 0;
  display: flex;
  align-items: baseline;
  gap: 14px;
  user-select: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s, opacity 0.15s;
}

.teach-section-summary::-webkit-details-marker,
.teach-section-summary::marker {
  display: none;
  content: "";
}

.teach-section-summary::after {
  content: "›";
  margin-left: auto;
  color: rgba(31, 26, 23, 0.4);
  font-size: 1.1rem;
  font-weight: 600;
  transition: transform 0.2s ease;
  display: inline-block;
  align-self: center;
  transform: translateY(-1px);
}

details.teach-section[open] > .teach-section-summary::after {
  transform: translateY(-1px) rotate(90deg);
}

details.teach-section[open] > .teach-section-summary {
  border-bottom-color: rgba(31, 26, 23, 0.08);
  margin-bottom: 14px;
}

.teach-section-summary:hover {
  opacity: 0.85;
}

.teach-section-summary .teach-section-title {
  margin-bottom: 0;
  flex-shrink: 0;
}

.teach-section-teaser {
  font-size: 0.78rem;
  color: rgba(31, 26, 23, 0.55);
  font-style: italic;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
}

.teach-formula {
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid rgba(31, 26, 23, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
}

.teach-formula-name {
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--ink);
}

.teach-method {
  font-size: 0.8rem;
  line-height: 1.8;
  color: var(--ink);
  margin-bottom: 12px;
  padding: 10px 12px;
  background: rgba(184, 92, 56, 0.04);
  border-radius: 10px;
  border-left: 3px solid rgba(184, 92, 56, 0.2);
}

.teach-examples {
  display: grid;
  gap: 8px;
}

.teach-example {
  font-size: 0.8rem;
  line-height: 1.6;
  padding-left: 10px;
  border-left: 2px solid rgba(31, 26, 23, 0.06);
}

.teach-example .ex-zh {
  display: block;
  color: var(--ink);
  font-weight: 500;
}

.teach-example .ex-en {
  display: block;
  color: var(--muted);
  font-style: italic;
  font-size: 0.76rem;
}

.teach-example .ex-en::before { content: ""; }

.teach-example .ex-hint {
  display: block;
  font-size: 0.72rem;
  color: var(--accent);
  opacity: 0.8;
  margin-top: 2px;
}

.teach-example .ex-source {
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0.5;
}

.teach-example .ex-source::before { content: "— "; }
.teach-example .ex-source::after { content: ""; }

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .lc-app {
    padding-top: 20px;
  }

  .lc-hero,
  .lc-panel,
  .lc-results-shell {
    padding: 18px;
    border-radius: 20px;
  }

  .spectrum-labels {
    font-size: 0.82rem;
  }

  .line-text {
    font-size: 1.2rem;
  }

  .iteration-group {
    margin-left: 10px;
    padding-left: 10px;
  }
}
