/* ASCII Art Designer
   Shared chrome: ../assets/css/tool-chrome.css (linked from index.html).
   Utility palette uses tool-chrome defaults — no :root override needed.
   --font-mono override below: this tool renders box-drawing/block chars
   (░▒▓█─│┌┐└┘├┤┬┴┼ etc.) where any fallback font mixed in breaks the
   spaltenbündig grid (different advance width on Android/iOS/Desktop).
   ../assets/fonts/jetbrains-mono/jetbrains-mono.css is self-hosted so the
   glyphs are guaranteed to load — no silent fallback to a system font. */

:root {
  --font-mono: var(--font-mono-ascii);
}

/* Tool widgets below — chrome is in ../assets/css/tool-chrome.css */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.75rem;
}

@media (min-width: 1024px) {
  .layout {
    grid-template-columns: minmax(0, 460px) minmax(0, 1fr);
    gap: 2.5rem;
  }
  #tool-form { grid-column: 1; grid-row: 1; }
  .preview-aside { grid-column: 2; grid-row: 1; }
}

.preview-aside { min-width: 0; }

@media (max-width: 1023px) {
  .preview-aside { display: contents; }
}

@media (min-width: 1024px) {
  .preview-sticky { position: sticky; top: 1.25rem; }
}

@media (max-width: 1023px) {
  .tool-section {
    scroll-margin-top: calc(var(--preview-dock-h, 14rem) + 0.5rem);
  }

  .preview-sticky {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--paper);
    margin-inline: -1.5rem;
    padding: 0.35rem 1.5rem 0.5rem;
    border-bottom: 1px solid var(--rule);
  }
}

@media (max-width: 549px) {
  .preview-sticky {
    margin-inline: -1rem;
    padding: 0.35rem 1rem 0.5rem;
  }
}

.preview-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.45rem;
  margin-top: 0.45rem;
}

.preview-jump__link {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-soft);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  transition: border-color 0.12s ease, color 0.12s ease, background-color 0.12s ease;
}

.preview-jump__link:hover { border-color: var(--ink); color: var(--ink); }
.preview-jump__link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .preview-jump__link { transition: none; }
}

/* ---------- Fieldsets & shared form tokens ---------- */
fieldset {
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem 1.25rem;
  margin: 0 0 1rem;
  background: var(--paper-raised);
  min-width: 0;
}

legend {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 0 0.4rem;
}

.section-hint {
  margin: -0.35rem 0 0.75rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.85rem;
}

.field:last-child { margin-bottom: 0; }

.field-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}

.field input[type="text"],
.field select {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  width: 100%;
}

.field input:focus-visible,
.field select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.option-row {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.field-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-faint);
  min-width: 1.2em;
  text-align: center;
}

.field--inline {
  flex: 1 1 8rem;
  min-width: 0;
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
  background: var(--paper-raised);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

.btn:hover { border-color: var(--ink); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn--primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--primary:hover { background: #000; }
html[data-theme="dark"] .btn--primary:hover { background: #f5f1e8; color: #1b1914; }
.btn--sm { font-size: 0.72rem; padding: 0.35rem 0.65rem; }
@media (prefers-reduced-motion: reduce) { .btn { transition: none; } }

/* ================= ASCII Art specific ================== */

.preview-dock {
  padding: 0.85rem 1rem 0.75rem;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius-md);
}

.banner-preview-wrap {
  position: relative;
  overflow: hidden;
  min-height: 7rem;
  transition: height 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
  .banner-preview-wrap { transition: none; }
}

.banner-preview {
  margin: 0;
  padding: 0.85rem 0.9rem;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.15;
  white-space: pre;
  color: var(--ink);
  display: inline-block;
  transform-origin: top left;
  box-sizing: border-box;
  width: max-content;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  margin-top: 0.75rem;
}

.status-line {
  margin: 0.55rem 0 0;
  min-height: 1.2em;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  text-align: center;
}

/* ---------- Frame templates ---------- */
.frame-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

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

.frame-card {
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  background: var(--paper);
  padding: 0.7rem 0.75rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.frame-card__title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
}

.frame-card pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.2;
  overflow-x: auto;
  white-space: pre;
  color: var(--ink);
}

.frame-card .btn { align-self: flex-start; }

/* ---------- Character library ---------- */
.char-category {
  margin-bottom: 1rem;
}

.char-category:last-child { margin-bottom: 0; }

.char-category__title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-faint);
  margin: 0 0 0.4rem;
}

.char-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.char-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: var(--paper-raised);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.1s ease;
}

.char-btn:hover { border-color: var(--accent); }
.char-btn:active { transform: scale(0.94); }
.char-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .char-btn, .btn { transition: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 500px) {
  fieldset { padding: 0.85rem 0.9rem 1rem; }
  .banner-preview { font-size: 0.62rem; }
}
