:root {
  --color-brand: #473ae0;
  --color-brand-strong: #18164c;
  --color-brand-subtle: #edebfc;
  --color-text-emphasis: #18164c;
  --color-text-secondary: #6b7280;
  --color-text-subtle: #9ca3af;
  --color-border-default: #ebecef;
  --color-border-strong: #d1d5db;
  --color-bg-subtle: #f9fafb;
  --color-error: #b3261e;
  --color-error-bg: #fdecea;
  --radius-6: 6px;
  --radius-8: 8px;
  --radius-12: 12px;
  --radius-16: 16px;
  --shadow-xsmall: 0 1px 2px rgba(24, 22, 76, 0.05);
  --shadow-small: 0 2px 8px rgba(24, 22, 76, 0.06);
  --shadow-medium: 0 8px 24px rgba(24, 22, 76, 0.12);
  --shadow-large: 0 16px 40px rgba(24, 22, 76, 0.16);
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

/* Several elements below (.loading-state, .unlock-gate) set their own
   `display` value unconditionally for layout - author CSS always overrides
   the browser's default `[hidden] { display: none }` UA rule regardless of
   selector specificity, so without this, toggling the `hidden` attribute in
   JS on those elements has no visual effect. This rule must win. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 1.5rem;
  background: #fff;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--color-text-emphasis);
}

.wrap {
  max-width: 880px;
  margin: 0 auto;
}

.tool-card {
  background: #fff;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-16);
  box-shadow: var(--shadow-small);
  padding: 24px;
}

.tool-fields {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  gap: 16px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-emphasis);
}

input[type="text"],
input[type="email"] {
  height: 44px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 16px;
  color: var(--color-text-emphasis);
  background: #fff;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-6);
  box-shadow: var(--shadow-xsmall);
  outline: none;
  width: 100%;
}

input[type="text"]:focus,
input[type="email"]:focus {
  border-color: var(--color-brand);
}

input::placeholder {
  color: var(--color-text-subtle);
}

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

.custom-select {
  position: relative;
}

button.custom-select-trigger {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-6);
  background: #fff;
  box-shadow: var(--shadow-xsmall);
  color: var(--color-text-emphasis);
  font-family: inherit;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  transition: border-color 120ms var(--ease-out);
}

button.custom-select-trigger:focus,
button.custom-select-trigger[aria-expanded="true"] {
  outline: none;
  border-color: var(--color-brand);
}

.combobox .combobox-input {
  width: 100%;
  padding-right: 40px;
}

.combobox .combobox-arrow {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  pointer-events: none;
}

.custom-select-option.is-empty {
  color: var(--color-text-subtle);
  cursor: default;
}

.custom-select-option.is-empty:hover {
  background: none;
}

.custom-select-value.is-placeholder {
  color: var(--color-text-subtle);
}

.custom-select-arrow {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--color-text-secondary);
}

.custom-select-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-8);
  box-shadow: var(--shadow-medium);
}

.custom-select-option {
  padding: 9px 12px;
  font-size: 14px;
  color: var(--color-text-emphasis);
  cursor: pointer;
}

.custom-select-option:hover,
.custom-select-option.is-active {
  background: var(--color-brand-subtle);
}

.button-primary {
  height: 44px;
  padding: 0 24px;
  background: var(--color-brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-6);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 120ms var(--ease-out);
}

.button-primary:hover:not(:disabled) {
  background: #32299f;
}

.button-primary:active:not(:disabled) {
  background: var(--color-brand-strong);
}

.button-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.button-compact {
  height: 40px;
  flex-shrink: 0;
}

.tool-note {
  margin: 16px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--color-text-subtle);
}

.error-message {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: var(--radius-8);
  background: var(--color-error-bg);
  color: var(--color-error);
  font-size: 14px;
  text-align: center;
}

.results {
  margin-top: 40px;
}

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 16px;
}

.results-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
}

.results-meta {
  font-size: 12px;
  color: var(--color-text-subtle);
  white-space: nowrap;
}

.table-card {
  position: relative;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-12);
  overflow: hidden;
  background: #fff;
}

.table-row {
  display: grid;
  grid-template-columns: 2fr 0.9fr 1.1fr 2fr;
  align-items: center;
}

.table-head {
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border-default);
}

.col {
  padding: 12px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.col-lang,
.col-searches {
  white-space: nowrap;
}

/* Its title names the market's category ("Traffic from "Translation
   Software" searches"), which can be long - let it wrap. */
.col-visits {
  line-height: 1.3;
}

.tip-trigger {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid var(--color-border-strong);
  background: #fff;
  color: var(--color-text-secondary);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: border-color 120ms var(--ease-out), color 120ms var(--ease-out), background-color 120ms var(--ease-out);
}

.tip-trigger:hover {
  border-color: var(--color-brand);
  color: var(--color-brand);
  background: var(--color-brand-subtle);
}

.tooltip {
  position: absolute;
  top: 40px;
  right: 12px;
  z-index: 20;
  width: 280px;
  background: #fff;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-8);
  box-shadow: var(--shadow-medium);
  padding: 12px;
}

.tooltip-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-emphasis);
  margin-bottom: 4px;
}

.tooltip-body {
  display: block;
  font-size: 12px;
  line-height: 1.4;
  color: var(--color-text-secondary);
}

.row {
  display: grid;
  grid-template-columns: 2fr 0.9fr 1.1fr 2fr;
  align-items: center;
  border-bottom: 1px solid var(--color-border-default);
}

.row-rank {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.row-rank .badge {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-6);
  background: var(--color-brand-subtle);
  color: var(--color-brand-strong);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.row-name {
  min-width: 0;
}

.row-name .label {
  display: block;
  font-size: 16px;
  font-weight: 500;
}

.row-name .domain {
  display: block;
  font-size: 12px;
  color: var(--color-text-subtle);
}

.logo {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-8);
  border: 1px solid var(--color-border-default);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-secondary);
  overflow: hidden;
}

.logo img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.row-name .description {
  display: block;
  font-size: 12px;
  line-height: 1.4;
  color: var(--color-text-secondary);
}

.row-lang,
.row-visits,
.row-searches {
  padding: 16px 20px;
  min-width: 0;
}

.lang-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.lang-badge.is-yes {
  background: #e7f6ec;
  color: #1b6b3a;
}

.lang-badge.is-no {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.lang-badge.is-unknown {
  background: var(--color-bg-subtle);
  color: var(--color-text-subtle);
}

.row-visits {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.row-visits {
  gap: 2px;
}

.row-visits .value {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row-visits .unit {
  font-size: 12px;
  color: var(--color-text-subtle);
  margin-bottom: 4px;
}

.row-visits .bar-track {
  width: 100%;
  max-width: 96px;
  height: 6px;
  border-radius: 999px;
  background: var(--color-bg-subtle);
  overflow: hidden;
}

.row-visits .bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--color-brand);
}

.row-searches {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.row-searches .evidence-chip {
  max-width: 100%;
  padding: 3px 10px;
  border-radius: 12px;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border-default);
  font-size: 11px;
  line-height: 1.5;
  color: var(--color-text-secondary);
  /* Wraps onto a second line rather than cutting the search or its volume. */
  white-space: normal;
  overflow-wrap: anywhere;
}

.row-searches .evidence-chip strong {
  font-weight: 600;
  color: var(--color-brand-strong);
}

.row-searches .evidence-chip .volume {
  color: var(--color-text-subtle);
}

.row-searches .empty {
  font-size: 12px;
  color: var(--color-text-subtle);
}

/* Email gate: the first rows are shown in full, the rest are blurred
   behind the unlock card. */
.locked-wrap {
  position: relative;
}

/* The unlock card (form + captcha) is taller than one or two blurred rows -
   without this it would be cut off when only a few competitors are locked. */
.locked-wrap.is-gated {
  min-height: 440px;
}

.locked-rows {
  filter: blur(5px);
  user-select: none;
  pointer-events: none;
  transition: filter 280ms var(--ease-out);
}

.locked-rows.is-unlocked {
  filter: none;
  user-select: auto;
  pointer-events: auto;
}

.unlock-gate {
  position: absolute;
  inset: 0;
  display: flex;
  /* Anchored near the top of the blurred rows rather than centred: with 7
     locked competitors the blurred area is tall, and a centred card sat too
     far down the page. */
  align-items: flex-start;
  justify-content: center;
  padding: 32px 24px 24px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.94) 55%);
}

.unlock-card {
  background: #fff;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-16);
  box-shadow: var(--shadow-large);
  padding: 24px;
  max-width: 480px;
  width: 100%;
}

.unlock-copy h3 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.4;
  font-weight: 600;
}

.unlock-copy p {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--color-text-secondary);
}

.unlock-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.unlock-form input[type="email"] {
  flex: 1;
  min-width: 180px;
  height: 40px;
  font-size: 14px;
}

/* Empty and invisible for most visitors; only takes space when Cloudflare
   shows its check. */
.unlock-copy .cf-turnstile:not(:empty) {
  margin-top: 8px;
}

.unlock-legal {
  margin: 8px 0 0 !important;
  font-size: 10px !important;
  line-height: 1.4 !important;
  color: var(--color-text-subtle) !important;
}

.unlock-legal a {
  color: var(--color-brand);
  text-decoration: underline;
}

.loading-state {
  margin-top: 40px;
  padding: 56px 24px;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-12);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 40px;
  height: 40px;
  margin-bottom: 20px;
  border-radius: 999px;
  border: 4px solid var(--color-brand-subtle);
  border-top-color: var(--color-brand);
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
  }
}

#loading-text {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-emphasis);
}

.loading-step {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--color-text-subtle);
}

@media (max-width: 640px) {
  .tool-fields {
    grid-template-columns: 1fr;
  }

  .table-row,
  .row {
    grid-template-columns: 1.6fr 1fr;
  }

  /* Phones keep the competitor and the local-language column - the core
     Weglot point - and drop the visits and searches columns. */
  .col-visits,
  .col-searches,
  .row-visits,
  .row-searches {
    display: none;
  }
}
