/* Scoped styles for the Ask overlay. Prefix tba-.
   Every element rule is under .tba-app, except:
   - html.tba-standalone / body.tba-standalone, which paint the standalone
     PHP page only. Never put tba-standalone on a host page.
   - body.tba-open, which only locks scroll while the dialog is open.
   Custom properties are --tba-* inside :where(), not on :root.
   Embedded (no tba-standalone) is light. data-tba-theme="auto" follows
   the OS. data-tba-theme="dark" is always dark. Any other value is light.
   Palette, type, radius, and the accent button match the transposer app. */

:where(.tba-app, body.tba-standalone) {
  color-scheme: light;
  --tba-bg: #f4f1ea;
  --tba-ink: #1c1917;
  --tba-muted: #57534e;
  --tba-card: #fffcf7;
  --tba-line: #76716c;
  --tba-accent: #1d4ed8;
  --tba-accent-ink: #fff;
  --tba-ok: #166534;
  --tba-warn: #9a3412;
}

:where(html.tba-standalone, html.tba-standalone body.tba-standalone,
       html.tba-standalone .tba-app:not([data-tba-theme])) { color-scheme: light dark; }
:where(html.tba-standalone[data-tba-theme="light"],
       html.tba-standalone[data-tba-theme="light"] body.tba-standalone,
       html.tba-standalone[data-tba-theme="light"] .tba-app:not([data-tba-theme])) { color-scheme: light; }
:where(html.tba-standalone[data-tba-theme="dark"],
       html.tba-standalone[data-tba-theme="dark"] body.tba-standalone,
       html.tba-standalone[data-tba-theme="dark"] .tba-app:not([data-tba-theme])) { color-scheme: dark; }
:where(.tba-app[data-tba-theme="auto"]) { color-scheme: light dark; }
:where(.tba-app[data-tba-theme="dark"]) { color-scheme: dark; }

:where(.tba-app[data-tba-theme="dark"],
       html.tba-standalone[data-tba-theme="dark"] body.tba-standalone,
       html.tba-standalone[data-tba-theme="dark"] .tba-app:not([data-tba-theme])) {
  --tba-bg: #1c1917;
  --tba-ink: #f5f5f4;
  --tba-muted: #a8a29e;
  --tba-card: #292524;
  --tba-line: #8a847e;
  --tba-accent: #93c5fd;
  --tba-accent-ink: #1c1917;
  --tba-ok: #86efac;
  --tba-warn: #fdba74;
}

@media (prefers-color-scheme: dark) {
  :where(.tba-app[data-tba-theme="auto"],
         html.tba-standalone:not([data-tba-theme="light"]):not([data-tba-theme="dark"]) body.tba-standalone,
         html.tba-standalone:not([data-tba-theme="light"]):not([data-tba-theme="dark"]) .tba-app:not([data-tba-theme])) {
    --tba-bg: #1c1917;
    --tba-ink: #f5f5f4;
    --tba-muted: #a8a29e;
    --tba-card: #292524;
    --tba-line: #8a847e;
    --tba-accent: #93c5fd;
    --tba-accent-ink: #1c1917;
    --tba-ok: #86efac;
    --tba-warn: #fdba74;
  }
}

body.tba-standalone {
  margin: 0;
  background: var(--tba-bg);
  color: var(--tba-ink);
}

body.tba-open { overflow: hidden; }

.tba-app[data-tba-theme="dark"],
.tba-app[data-tba-theme="auto"],
html.tba-standalone .tba-app[data-tba-theme] { background: var(--tba-bg); }

.tba-app {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 1rem;
  color: var(--tba-ink);
  line-height: 1.45;
  min-width: 0;
  isolation: isolate;
}

.tba-app, .tba-app *, .tba-app *::before, .tba-app *::after { box-sizing: revert; }

.tba-app.tba-dialog {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  box-sizing: border-box;
  height: 100dvh;
  max-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: rgb(28 25 23 / 45%);
}

@media (min-width: 48rem) {
  .tba-app.tba-dialog { align-items: center; }
}

.tba-app .tba-panel {
  box-sizing: border-box;
  width: min(40rem, 100%);
  max-width: 100%;
  max-height: 100dvh;
  overflow: auto;
  background: var(--tba-card);
  color: var(--tba-ink);
  border: 1px solid var(--tba-line);
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.tba-app h1, .tba-app h2 {
  font-family: inherit;
  font-weight: 650;
  line-height: inherit;
  letter-spacing: -0.02em;
  max-width: none;
  text-wrap: wrap;
  margin: 0 0 0.35rem;
  color: inherit;
}

.tba-app h1 { font-size: 1.75rem; }
.tba-app h2 { font-size: 1.15rem; }

.tba-app p { margin: revert; color: inherit; }
.tba-app .tba-note { color: var(--tba-muted); margin: 0 0 1rem; font-size: inherit; line-height: inherit; max-width: none; }
.tba-app :focus-visible { outline: revert; outline-offset: revert; }

.tba-app .tba-hp {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.tba-app label { display: block; font-size: 0.95rem; margin: 0.65rem 0 0.2rem; color: inherit; }
.tba-app textarea, .tba-app input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 16px;
  color: inherit;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--tba-line);
  border-radius: 0.4rem;
  background: transparent;
}
.tba-app textarea { min-height: 6rem; resize: vertical; }

.tba-app .tba-examples {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tba-app .cf-turnstile { margin-top: 14px; }
.tba-app button {
  margin-top: 1rem;
  font: inherit;
  font-size: 1rem;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: 0.4rem;
  background: var(--tba-accent);
  color: var(--tba-accent-ink);
  cursor: pointer;
  letter-spacing: normal;
  text-transform: none;
}
.tba-app .tba-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin: 0 0 1rem;
}
.tba-app .tba-header .tba-heading {
  flex: 1;
  min-width: 0;
  margin: 0;
}
.tba-app .tba-brand {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 0.4rem;
}
.tba-app .tba-examples button, .tba-app .tba-close {
  margin-top: 0;
  background: transparent;
  color: var(--tba-ink);
  border: 1px solid var(--tba-line);
}
.tba-app .tba-close {
  float: none;
  margin: 0;
  flex: 0 0 auto;
  align-self: flex-start;
}
@media (max-width: 30rem) {
  .tba-app .tba-header { gap: 0.5rem; }
  .tba-app .tba-brand { flex-basis: 40px; width: 40px; height: 40px; }
}

.tba-app .tba-result { margin-top: 1.25rem; }
.tba-app .tba-message { font-size: 1.15rem; }
.tba-app .tba-warn { color: var(--tba-warn); }

.tba-app button.tba-submit:disabled,
.tba-app button.tba-submit[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 1;
  background: var(--tba-line);
  color: var(--tba-card);
  border: 1px solid var(--tba-ink);
}
