/* Episode editor (#edit/<slug>): surgical, line-by-line changes. Loaded by index.html. */

.ed { padding-bottom: 22rem; }

.ed-back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

.ed-back:hover,
.ed-back:focus-visible { color: var(--text); outline: none; }
.ed-back svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; }

.ed-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 2rem;
  margin: 1.75rem 0 1.5rem;
}

.ed-kicker {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.ed-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.02;
  color: var(--text);
  margin: 0;
}

.ed-meta { margin-top: 0.6rem; font-family: var(--sans); font-size: 0.8rem; color: var(--muted); }
.ed-meta .is-saving { color: var(--accent); }

.ed-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0 1.1rem;
  border: 1px solid var(--text);
  background: transparent;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.ed-btn:hover,
.ed-btn:focus-visible { background: var(--text); color: var(--bg); outline: none; }
.ed-btn.is-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.ed-btn.is-primary:hover,
.ed-btn.is-primary:focus-visible { background: var(--crimson-glow); border-color: var(--crimson-glow); }
.ed-btn.is-quiet { border-color: var(--hairline); color: var(--text-soft); }
.ed-btn.is-quiet:hover,
.ed-btn.is-quiet:focus-visible { background: var(--surface-hover); color: var(--text); border-color: var(--hairline); }
.ed-btn:disabled { opacity: 0.4; cursor: default; background: transparent; color: var(--text); }
.ed-btn svg { width: 14px; height: 14px; fill: currentColor; }

/* Player */
.ed-player {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  background: var(--bg);
  border-top: 1px solid var(--text);
  border-bottom: 1px solid var(--hairline);
}

.ed-play {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 0;
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ed-play:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ed-play svg { width: 14px; height: 14px; fill: currentColor; }

.ed-scrub {
  position: relative;
  flex: 1;
  height: 28px;
  cursor: pointer;
}

.ed-scrub-track { position: absolute; left: 0; right: 0; top: 13px; height: 2px; background: var(--hairline); }
.ed-scrub-fill { position: absolute; left: 0; top: 13px; height: 2px; background: var(--text); width: 0; }
.ed-scrub-tick { position: absolute; top: 7px; width: 2px; height: 14px; background: var(--accent); border-radius: 1px; }
.ed-scrub-sel { position: absolute; top: 9px; height: 10px; background: rgba(196, 22, 44, 0.14); }
.ed-time-readout { font-family: var(--sans); font-size: 0.76rem; font-variant-numeric: tabular-nums; color: var(--muted); min-width: 6.5rem; text-align: right; }

.ed-hint {
  margin: 1.1rem 0 0.4rem;
  font-family: var(--editorial);
  font-style: italic;
  font-size: 1rem;
  color: var(--muted);
}

/* Transcript */
.ed-lines { list-style: none; margin: 0; padding: 0; }

.ed-row {
  position: relative;
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 0 1rem;
  border-bottom: 1px solid var(--hairline);
}

.ed-row::before {
  content: "";
  position: absolute;
  left: -0.85rem;
  top: 0.6rem;
  bottom: 0.6rem;
  width: 3px;
  background: transparent;
  border-radius: 2px;
}

.ed-row.is-selected { background: var(--surface); }
.ed-row.is-selected::before { background: var(--accent); }
.ed-row.is-current .ed-text { color: var(--text); }
.ed-row.is-current .ed-time { color: var(--accent); }

.ed-time {
  align-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1rem;
  padding: 0.2rem 0.35rem;
  border: 0;
  background: none;
  font-family: var(--sans);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  cursor: pointer;
  border-radius: 2px;
}

.ed-time svg { width: 9px; height: 9px; fill: currentColor; opacity: 0.6; }
.ed-time:hover,
.ed-time:focus-visible { color: var(--text); background: var(--surface-hover); outline: none; }
.ed-time:hover svg { opacity: 1; }

.ed-line {
  display: block;
  width: 100%;
  padding: 0.9rem 0.75rem 0.95rem 0;
  border: 0;
  background: none;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.ed-line:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.ed-speaker {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--sans);
  font-size: 0.64rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.ed-edited {
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.ed-text {
  margin: 0.3rem 0 0;
  font-family: var(--editorial);
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--text-soft);
  transition: color 0.2s linear;
}

/* Sounds between lines */
.ed-sound-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 0 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--hairline);
}

.ed-sound-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }

.ed-sound {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 32px;
  padding: 0 0.75rem;
  border: 1px dashed #cfc6ba;
  border-radius: 999px;
  background: transparent;
  font-family: var(--sans);
  font-size: 0.74rem;
  color: var(--text-soft);
  cursor: pointer;
}

.ed-sound:hover,
.ed-sound:focus-visible,
.ed-sound[aria-expanded="true"] { border-style: solid; border-color: var(--text); color: var(--text); outline: none; }
.ed-sound svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.ed-sound-time { font-family: var(--sans); font-size: 0.7rem; color: var(--muted); align-self: center; font-variant-numeric: tabular-nums; }

.ed-sound-menu { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }

.ed-chip {
  min-height: 34px;
  padding: 0 0.85rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--bg);
  font-family: var(--sans);
  font-size: 0.76rem;
  color: var(--text-soft);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.ed-chip:hover,
.ed-chip:focus-visible { border-color: var(--text); color: var(--text); outline: none; }
.ed-chip.is-danger:hover,
.ed-chip.is-danger:focus-visible { border-color: var(--accent); color: var(--accent); }
.ed-chip:disabled { opacity: 0.4; cursor: default; }

/* Edit sheet docked at the bottom */
.ed-sheet {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 20;
  width: min(860px, calc(100vw - 2rem));
  transform: translateX(-50%);
  background: var(--bg);
  border: 1px solid var(--text);
  box-shadow: 0 18px 50px rgba(17, 16, 16, 0.18);
  animation: ed-rise 0.3s var(--ease);
}

@keyframes ed-rise {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.ed-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--hairline);
}

.ed-sheet-title { font-family: var(--sans); font-size: 0.78rem; font-weight: 500; color: var(--text); }
.ed-sheet-sub { font-family: var(--sans); font-size: 0.72rem; color: var(--muted); }

.ed-x {
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.ed-x:hover,
.ed-x:focus-visible { color: var(--text); outline: none; }
.ed-x svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.6; fill: none; }

.ed-tabs {
  display: flex;
  gap: 0;
  padding: 0 1.1rem;
  border-bottom: 1px solid var(--hairline);
  overflow-x: auto;
}

.ed-tab {
  min-height: 44px;
  padding: 0 0.9rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.ed-tab:hover,
.ed-tab:focus-visible { color: var(--text); outline: none; }
.ed-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.ed-tab.is-danger[aria-selected="true"] { border-bottom-color: var(--text); }

.ed-pane { padding: 1rem 1.1rem 1.15rem; }
.ed-pane-label { font-family: var(--sans); font-size: 0.72rem; color: var(--muted); margin: 0 0 0.65rem; }
.ed-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.ed-ask {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.ed-ask input,
.ed-words textarea {
  flex: 1;
  min-width: 0;
  min-height: 42px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--hairline);
  background: var(--surface);
  font-family: var(--editorial);
  font-size: 1.02rem;
  color: var(--text);
}

.ed-ask input:focus,
.ed-words textarea:focus { outline: none; border-color: var(--text); background: var(--bg); }

.ed-words { display: flex; flex-direction: column; gap: 0.5rem; }
.ed-words label { font-family: var(--sans); font-size: 0.64rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.ed-words textarea { width: 100%; resize: vertical; line-height: 1.45; }

.ed-row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-top: 0.85rem; }
.ed-note { font-family: var(--sans); font-size: 0.74rem; color: var(--muted); }
.ed-error { margin: 0.75rem 0 0; font-family: var(--sans); font-size: 0.78rem; color: var(--accent); }

.ed-busy {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.35rem 1.1rem;
  font-family: var(--editorial);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--text-soft);
}

.ed-dots { display: inline-flex; gap: 4px; }
.ed-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: ed-dot 1s infinite ease-in-out; }
.ed-dots span:nth-child(2) { animation-delay: 0.15s; }
.ed-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ed-dot {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

/* A proposed change */
.ed-compare { display: grid; grid-template-columns: 4.5rem minmax(0, 1fr); gap: 0.4rem 1rem; }
.ed-compare dt { font-family: var(--sans); font-size: 0.64rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding-top: 0.3rem; }
.ed-compare dd { margin: 0; font-family: var(--editorial); font-size: 1.08rem; line-height: 1.45; }
.ed-compare .is-old { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(132, 124, 116, 0.6); }
.ed-compare .is-new { color: var(--text); }
.ed-compare .is-same { color: var(--text-soft); }

.ed-listen { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.ed-listen-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 40px;
  padding: 0 0.95rem 0 0.4rem;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  background: var(--bg);
  font-family: var(--sans);
  font-size: 0.76rem;
  color: var(--text);
  cursor: pointer;
}

.ed-listen-btn .ed-listen-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ed-listen-btn.is-original .ed-listen-icon { background: var(--surface-hover); color: var(--text); }
.ed-listen-btn svg { width: 10px; height: 10px; fill: currentColor; }
.ed-listen-btn:hover,
.ed-listen-btn:focus-visible { border-color: var(--text); outline: none; }

.ed-decide { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--hairline); }

.ed-history { margin-top: 3rem; }
.ed-history summary { cursor: pointer; font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.ed-history ol { margin: 0.75rem 0 0; padding-left: 1.25rem; font-family: var(--sans); font-size: 0.82rem; line-height: 1.8; color: var(--text-soft); }

.ed-empty { padding: 3rem 0; font-family: var(--editorial); font-style: italic; font-size: 1.2rem; color: var(--muted); }

@media (max-width: 620px) {
  .ed-row, .ed-sound-row { grid-template-columns: 3.4rem minmax(0, 1fr); gap: 0 0.5rem; }
  .ed-text { font-size: 1.08rem; }
  .ed-time-readout { min-width: 0; }
  .ed-sheet { bottom: 0; width: 100vw; border-left: 0; border-right: 0; }
  .ed-compare { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .ed-sheet, .ed-dots span { animation: none; }
}

/* Entry points in L'Atelier */
.produced-actions { display: inline-flex; align-items: center; gap: 1.25rem; }
#pressing-edit-link { text-decoration: none; display: inline-flex; align-items: center; }
#pressing-edit-link[hidden] { display: none; }
.ed-sheet-tools { display: inline-flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }
