/* 12-Dimension Score widget — reuses site.css's tokens only (--ink, --bone,
   --orange, --stone, --line, --serif, --sans). No new colours, no
   box-shadow (the rest of the site is flat/border-based, not shadowed),
   and no animation beyond a 150ms opacity fade. */

.td-widget {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40; /* above the .cookie banner (30) */
  font-family: var(--sans);
  max-width: calc(100vw - 32px);
}

/* Extra clearance while the cookie banner (bottom:16px, up to 720px wide)
   is still showing — i.e. exactly while td_consent doesn't exist yet, the
   same condition that keeps the widget minimised. */
.td-widget.td-widget--tight { bottom: 88px; }

.td-widget [hidden] { display: none !important; }

/* ---------- minimised pill: a bordered control, not loose text ---------- */

.td-widget-pill {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  opacity: 1;
  transition: opacity 0.15s ease;
}
/* Set by JS after checking what's actually behind the pill (see
   updatePillContrast in widget.js) — defaults to this ink-on-bone form
   whenever detection isn't possible or the section isn't dark. */
.td-widget-pill.td-widget-pill--on-dark {
  color: var(--bone);
  border-color: var(--bone);
}

/* ---------- expanded card ---------- */

.td-widget-card {
  width: 340px;
  max-width: 100%;
  background: var(--bone);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 18px;
  opacity: 1;
  transition: opacity 0.15s ease;
}

.td-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.td-widget-label {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--stone);
}
.td-widget-close {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: var(--stone);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.td-widget-close:hover { color: var(--ink); }

.td-widget-mark {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 16px;
}
.td-widget-mark-value {
  font-family: var(--serif);
  font-size: 34px;
  line-height: 1;
  color: var(--ink);
}
.td-widget-mark-sub {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--stone);
}

.td-widget-form { display: block; }

.td-widget-input {
  display: block;
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
  padding: 8px 0;
}
.td-widget-input::placeholder { color: var(--stone); }
.td-widget-input:focus { border-bottom-color: var(--ink); }

/* Turnstile: interaction-only means this occupies no space at all unless
   Cloudflare actually needs a visible challenge (see widget.js) — the
   :empty rule keeps that state from leaving a stray gap. */
#td-widget-turnstile { margin-top: 10px; }
#td-widget-turnstile:empty { margin-top: 0; }

.td-widget-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 40px;
  margin-top: 10px;
  background: var(--ink);
  color: var(--bone);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.td-widget-submit:hover { background: var(--orange); }
.td-widget-submit:disabled { opacity: 0.6; cursor: default; }
.td-widget-arrow { margin-left: 6px; }

.td-widget-cap { margin-top: 10px; }
.td-widget-cap p { font-size: 13px; color: var(--stone); margin: 0; }
.td-widget-cap form { margin-top: 8px; }

.td-widget-message {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--stone);
  margin-top: 8px;
}
.td-widget-message.is-error { color: var(--orange); }

/* ---------- mobile: bottom bar under 12% of viewport height ---------- */

@media (max-width: 820px) {
  .td-widget { left: 12px; right: 12px; bottom: 0; max-width: none; }
  .td-widget.td-widget--tight { bottom: 72px; }

  .td-widget-pill { position: absolute; right: 0; bottom: 12px; }

  .td-widget-card {
    width: auto;
    max-height: 12vh;
    overflow: auto;
    border-radius: 6px 6px 0 0;
    border-bottom: none;
    padding: 12px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
  }
  .td-widget-header, .td-widget-mark { display: none; } /* no room at 12vh; label and mark hidden */

  /* Set by widget.js via Turnstile's before/after-interactive-callback —
     while a visible challenge is actually up, let the bar grow to fit it
     instead of clipping it under the 12vh cap. */
  .td-widget-card.td-widget-card--challenge { max-height: none; }

  .td-widget-form { display: flex; align-items: center; gap: 8px; flex: 1; }
  .td-widget-input { flex: 1; }
  #td-widget-turnstile { margin-top: 0; }
  .td-widget-submit { width: auto; flex: 0 0 auto; margin-top: 0; padding: 0 16px; white-space: nowrap; }
  .td-widget-arrow { display: none; } /* mobile button label is plain "Score it" */

  .td-widget-cap { flex: 1; margin-top: 0; }
  .td-widget-cap form { display: flex; gap: 8px; margin-top: 0; }
  .td-widget-cap .td-widget-input { flex: 1; }

  .td-widget-message { flex: 1 0 100%; margin-top: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .td-widget-pill, .td-widget-card { transition: none; }
}
