/* The public host page (packages/ts/apps/src/public-host), in the product's
   language (docs/design-language.md): white, a near-black ink and neutral
   greys, Inter, pills for words, hairlines rather than boxes, a float for
   what floats. Copied as it is to services/api/internal/apps/public/static
   by `make apps-bundles`. */

:root {
  --tg-bg: #f8f8f8;
  --tg-surface: #ffffff;
  --tg-surface-2: #f4f4f4;
  --tg-hairline: #e7e7e7;
  --tg-hairline-2: #d4d4d4;
  --tg-text: #121212;
  --tg-text-2: #636363;
  --tg-text-3: #8b8b8b;
  --tg-accent-soft: rgb(18 18 18 / 0.07);
  --tg-accent-line: rgb(18 18 18 / 0.32);
  --tg-danger: #a2453c;
  --tg-float: rgb(255 255 255 / 0.94);
  --tg-float-line: rgb(18 18 18 / 0.1);
  --tg-highlight: rgb(255 255 255 / 0.6);
  --tg-shadow-float: 0 12px 40px -8px rgb(18 18 18 / 0.16), 0 2px 6px rgb(18 18 18 / 0.04);
  --tg-scrim: rgb(13 13 13 / 0.32);
  --tg-select: #cdeccb;
  --tg-font:
    Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --tg-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --tg-bg: #0d0d0d;
    --tg-surface: #171717;
    --tg-surface-2: #202020;
    --tg-hairline: #292929;
    --tg-hairline-2: #424242;
    --tg-text: #ebebeb;
    --tg-text-2: #afafaf;
    --tg-text-3: #808080;
    --tg-accent-soft: rgb(235 235 235 / 0.1);
    --tg-accent-line: rgb(235 235 235 / 0.36);
    --tg-danger: #e09186;
    --tg-float: rgb(32 32 32 / 0.92);
    --tg-float-line: rgb(255 255 255 / 0.08);
    --tg-highlight: rgb(255 255 255 / 0.06);
    --tg-shadow-float: 0 12px 40px -8px rgb(0 0 0 / 0.5), 0 2px 6px rgb(0 0 0 / 0.2);
    --tg-select: #24452d;
    color-scheme: dark;
  }
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--tg-surface);
  color: var(--tg-text);
  font-family: var(--tg-font);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--tg-select);
}

.tg-host {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* The bar: the app's name on the left, who made it and the report link on
   the right, a hairline under it. */
.tg-bar {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: 40px;
  padding: 0 16px;
  border-bottom: 1px solid var(--tg-hairline);
  background: var(--tg-surface);
  box-sizing: border-box;
}

.tg-bar-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tg-bar-meta {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  color: var(--tg-text-3);
  font-size: 12px;
  white-space: nowrap;
}

.tg-bar-meta a,
.tg-btn-text {
  color: var(--tg-text-2);
  text-decoration: none;
}

.tg-bar-meta a:hover,
.tg-btn-text:hover {
  color: var(--tg-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tg-visitor {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tg-visitor[hidden],
.tg-report[hidden] {
  display: none;
}

.tg-visitor-email {
  color: var(--tg-text-2);
}

/* Narrow, the bar takes two lines rather than drop who made the app: the
   attribution is what tells a visitor whose page this is. */
@media (max-width: 560px) {
  .tg-bar {
    flex-wrap: wrap;
    row-gap: 4px;
    height: auto;
    min-height: 40px;
    padding: 8px 16px;
  }

  .tg-bar-meta {
    flex-wrap: wrap;
    row-gap: 4px;
  }

  .tg-visitor-email {
    display: none;
  }
}

/* The stage: the app's frame, or a state in its place. */
.tg-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: var(--tg-surface);
}

.tg-stage > iframe {
  position: absolute;
  inset: 0;
}

.tg-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 100%;
  padding: 24px 16px;
  box-sizing: border-box;
  text-align: center;
}

.tg-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--tg-surface);
}

.tg-state-text {
  margin: 0;
  font-size: 15px;
  line-height: 24px;
}

.tg-state-detail {
  margin: 0 0 8px;
  color: var(--tg-text-2);
  font-size: 13px;
}

/* Pills for words: ink for the one primary action, a hairline pill for the
   rest, plain text for a way back. */
.tg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 110ms,
    border-color 110ms,
    opacity 110ms;
}

.tg-btn:focus-visible,
.tg-input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--tg-accent-soft);
  border-color: var(--tg-accent-line);
}

.tg-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.tg-btn-primary {
  background: var(--tg-text);
  color: var(--tg-surface);
}

.tg-btn-quiet {
  border-color: var(--tg-hairline-2);
  background: var(--tg-surface);
  color: var(--tg-text);
}

.tg-btn-quiet:hover:not(:disabled) {
  background: var(--tg-surface-2);
}

.tg-btn-text {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
  font-weight: 400;
}

.tg-bar .tg-btn-text {
  font-size: 12px;
}

/* What floats: a dialog on a scrim. */
.tg-scrim {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--tg-scrim);
  animation: tg-fade 160ms var(--tg-ease-out);
}

.tg-dialog {
  width: 100%;
  max-width: 400px;
  padding: 20px;
  border: 1px solid var(--tg-float-line);
  border-radius: 12px;
  background: var(--tg-float);
  box-shadow:
    inset 0 1px 0 var(--tg-highlight),
    var(--tg-shadow-float);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  backdrop-filter: blur(20px) saturate(1.4);
  box-sizing: border-box;
  animation: tg-rise 160ms var(--tg-ease-out);
}

.tg-dialog-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
  line-height: 20px;
}

.tg-dialog-body p {
  margin: 0 0 12px;
  color: var(--tg-text-2);
  font-size: 13px;
  line-height: 20px;
}

.tg-dialog-body strong {
  color: var(--tg-text);
  font-weight: 600;
}

.tg-dialog-url,
.tg-dialog-file {
  word-break: break-all;
}

.tg-dialog-error {
  margin: 0;
  color: var(--tg-danger);
  font-size: 12px;
}

.tg-dialog-error:not(:empty) {
  margin-bottom: 12px;
}

.tg-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.tg-meta {
  color: var(--tg-text-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.tg-input {
  display: block;
  width: 100%;
  height: 36px;
  margin: 0 0 12px;
  padding: 0 12px;
  border: 1px solid var(--tg-hairline-2);
  border-radius: 8px;
  background: var(--tg-surface);
  color: var(--tg-text);
  font: inherit;
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 110ms;
}

.tg-input:hover {
  border-color: var(--tg-text-3);
}

.tg-code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
}

.tg-challenge {
  min-height: 0;
  margin: 0 0 12px;
}

/* A form app: the sheet's form, drawn by the host with no frame — a column
   of questions read like a page, hairlines between sections, 36px fields,
   ink for the one thing to do (as the workspace's form view). */
.tg-stage-form {
  overflow-y: auto;
}

.tg-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 24px 96px;
  box-sizing: border-box;
}

@media (max-width: 560px) {
  .tg-form {
    padding: 32px 16px 64px;
  }
}

.tg-form-title {
  margin: 0;
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.025em;
  line-height: 34px;
  overflow-wrap: anywhere;
}

.tg-form-about {
  margin-top: -12px;
  color: var(--tg-text-2);
  font-size: 15px;
  line-height: 24px;
  overflow-wrap: anywhere;
}

.tg-form-about > :first-child {
  margin-top: 0;
}

.tg-form-about > :last-child {
  margin-bottom: 0;
}

.tg-form-about a {
  color: var(--tg-text);
  text-underline-offset: 2px;
}

.tg-form-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tg-form-section + .tg-form-section {
  padding-top: 24px;
  border-top: 1px solid var(--tg-hairline);
}

.tg-form-section-head {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  line-height: 22px;
}

.tg-form-question {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.tg-form-label {
  padding: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
}

.tg-form-required {
  margin-left: 4px;
  color: var(--tg-text-3);
}

.tg-form-help {
  margin: -4px 0 0;
  color: var(--tg-text-3);
  font-size: 13px;
  line-height: 18px;
}

.tg-form-problem {
  margin: 0;
  color: var(--tg-danger);
  font-size: 13px;
}

.tg-form-problem:empty,
.tg-form-general:empty {
  display: none;
}

.tg-form-general {
  margin: 0;
  color: var(--tg-danger);
  font-size: 13px;
  line-height: 20px;
}

.tg-form .tg-input {
  margin: 0;
}

.tg-form-question[data-invalid] .tg-input {
  border-color: var(--tg-danger);
}

.tg-textarea {
  height: auto;
  min-height: 108px;
  padding: 8px 12px;
  line-height: 20px;
  resize: vertical;
}

.tg-short {
  max-width: 280px;
}

/* A choice: native radios and boxes, drawn as pills; the one in force on
   the selected tone, its line in ink. */
.tg-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tg-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--tg-hairline-2);
  border-radius: 999px;
  color: var(--tg-text-2);
  font-size: 13px;
  cursor: pointer;
  transition:
    background 110ms,
    border-color 110ms,
    color 110ms;
}

.tg-pill:hover {
  background: var(--tg-surface-2);
}

.tg-pill-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}

.tg-pill:has(.tg-pill-input:checked) {
  border-color: var(--tg-accent-line);
  background: var(--tg-accent-soft);
  color: var(--tg-text);
}

.tg-pill:has(.tg-pill-input:focus-visible) {
  box-shadow: 0 0 0 3px var(--tg-accent-soft);
  border-color: var(--tg-accent-line);
}

.tg-form-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.tg-check {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--tg-text);
}

.tg-files-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.tg-file-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.tg-file-pick {
  height: 28px;
}

.tg-files-field:has(.tg-file-input:focus-visible) .tg-file-pick {
  box-shadow: 0 0 0 3px var(--tg-accent-soft);
  border-color: var(--tg-accent-line);
}

.tg-files {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tg-files:empty {
  display: none;
}

.tg-file {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.tg-file-name {
  overflow-wrap: anywhere;
}

.tg-form-challenge:empty {
  display: none;
}

.tg-form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

/* The field nobody sees: off the page rather than display:none, which a
   bot reads as a sign; out of the tab order and hidden from assistive
   technology by its markup. */
.tg-hp {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

@keyframes tg-fade {
  from {
    opacity: 0;
  }
}

@keyframes tg-rise {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tg-scrim,
  .tg-dialog {
    animation: none;
  }

  .tg-btn,
  .tg-input,
  .tg-pill {
    transition: none;
  }
}
