/* Converter workbench: composer, style browser and result cards. Tokens live in site.css. */

.workbench {
  display: grid;
  gap: var(--s4);
  min-width: 0;
}

.composer,
.browser,
.card { min-width: 0; }

.composer {
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}

.field-label {
  display: block;
  margin-bottom: var(--s2);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 650;
}

textarea,
input[type="search"] {
  width: 100%;
  padding: var(--s3) 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-md);
  line-height: 1.45;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea::placeholder,
input[type="search"]::placeholder { color: #7a7484; }

textarea:hover,
input[type="search"]:hover { border-color: #b3ab9c; }

textarea:focus-visible,
input[type="search"]:focus-visible {
  border-color: var(--purple);
  outline: 2px solid var(--purple);
  outline-offset: 0;
  box-shadow: 0 0 0 4px var(--purple-soft);
}

textarea { min-height: 0; resize: vertical; }

.composer-actions,
.filters,
.card-top {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  align-items: center;
}

.composer-actions { margin-top: var(--s3); }

.hint {
  margin: var(--s3) 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.45;
}

/* Buttons: primary (copy, pressed), secondary (outlined), ghost (save) */
button {
  min-height: 44px;
  padding: 0 var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.workbench button {
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.workbench button:hover { border-color: var(--ink-2); background: var(--surface-2); }

.workbench button:active { background: #e8e4da; }

.workbench button:disabled {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--muted);
  cursor: not-allowed;
}

.filters button[aria-pressed="true"],
#favorites[aria-pressed="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.filters button[aria-pressed="true"]:hover,
#favorites[aria-pressed="true"]:hover {
  background: var(--ink-2);
  border-color: var(--ink-2);
}

#favorites::before,
button[data-t="favorite"]::before {
  content: "☆" / "";
  margin-inline-end: 6px;
  font-weight: 400;
}

#favorites[aria-pressed="true"]::before,
button[data-t="favorite"][aria-pressed="true"]::before { content: "★" / ""; }

/* Search + category chips */
.browser-bar { margin-bottom: var(--s4); }

.chip-row {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  margin-top: var(--s3);
}

.chip-row .filters { flex: 1 1 auto; min-width: 0; gap: 6px; }

.filters button { padding: 0 14px; }

.chip-row #favorites {
  flex: 0 0 auto;
  margin-inline-start: auto;
}

/* Result cards: actions on top, the preview gets the full width */
.results {
  display: grid;
  gap: var(--s3);
  min-width: 0;
}

.card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto 1fr;
  grid-template-areas:
    "top copy"
    "about about"
    "sample sample";
  column-gap: var(--s1);
  padding: var(--s3) var(--s3) var(--s4) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover,
.card:focus-within { border-color: var(--line-strong); box-shadow: var(--shadow-2); }

.card-top {
  grid-area: top;
  flex-wrap: nowrap;
  justify-content: space-between;
}

.card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.005em;
}

.card-about {
  grid-area: about;
  margin: 0;
  padding-inline-end: var(--s1);
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}

.sample {
  grid-area: sample;
  align-self: end;
  margin: var(--s3) 0 0;
  padding-inline-end: var(--s1);
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: "Noto Sans Math", var(--ui);
  font-size: 1.75rem;
  line-height: 1.3;
}

.sample.is-sample { color: var(--ink-2); }

button.copy {
  grid-area: copy;
  padding: 0 18px;
  border: 1px solid var(--purple);
  background: var(--purple);
  color: var(--purple-ink);
  font-weight: 700;
}

.workbench button.copy:hover {
  border-color: var(--purple-strong);
  background: var(--purple-strong);
}

.workbench button.copy:active { background: #4334ad; }

.workbench button.copy[data-state="ok"] {
  border-color: var(--ok);
  background: var(--ok);
  color: #fff;
}

.workbench button.copy[data-state="err"] {
  border-color: var(--err);
  background: var(--err);
  color: #fff;
}

/* Save: quiet ghost until pressed */
.workbench button[data-t="favorite"] {
  flex: 0 0 auto;
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 500;
}

.workbench button[data-t="favorite"]:hover { background: var(--surface-2); color: var(--ink); }

.workbench button[data-t="favorite"][aria-pressed="true"] {
  border-color: #ecd28a;
  background: var(--yellow-soft);
  color: var(--ink);
}

.empty {
  margin: 0;
  padding: var(--s6) var(--s4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  color: var(--muted);
  text-align: center;
}

.toast {
  min-height: 1.5rem;
  margin-top: var(--s3);
  font-size: var(--fs-sm);
  font-weight: 650;
}

.toast:empty { min-height: 0; }

.toast[data-state="ok"] { color: var(--ok); }

.toast[data-state="err"] { color: var(--err); }

.copy-fallback {
  position: fixed;
  top: 0;
  left: -10000px;
}

@media (min-width: 801px) {
  .workbench {
    grid-template-columns: 336px minmax(0, 1fr);
    align-items: start;
    gap: var(--s6);
  }

  .composer {
    position: sticky;
    top: var(--s4);
    padding: var(--s5) 20px 20px;
  }

  textarea { min-height: 9rem; }

  .results { gap: var(--s4); }
}

@media (min-width: 1080px) {
  .results { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 800px) {
  .composer { padding: var(--s3); }

  .field-label { margin-bottom: 6px; }

  textarea { padding: 10px var(--s3); }

  .composer-actions { margin-top: 10px; }

  .hint { margin-top: var(--s2); }

  .chip-row {
    flex-wrap: nowrap;
    align-items: center;
    max-width: none;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-padding-inline: var(--gutter);
    scrollbar-width: none;
  }

  .chip-row::-webkit-scrollbar { display: none; }

  .chip-row .filters {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    width: max-content;
  }

  .chip-row .filters button,
  .chip-row #favorites { flex: 0 0 auto; }

  .chip-row #favorites { margin-inline-start: 0; }

  .browser-bar { margin-bottom: var(--s3); }

  .card { padding: var(--s2) var(--s2) 14px 14px; }

  .sample { font-size: 1.5rem; }
}
