/* ==========================================================================
   ToolsVale — Components
   Every repeated block from the approved designs, written once.
   Naming: .tv-{block}__{element}--{modifier}
   ========================================================================== */

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.tv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--tv-space-2);
  height: 42px;
  padding-inline: var(--tv-space-6);
  border: 1px solid transparent;
  border-radius: var(--tv-radius-sm);
  font-size: var(--tv-fs-base);
  font-weight: var(--tv-fw-medium);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--tv-transition);
}

.tv-btn:disabled,
.tv-btn[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
}

/* Primary — the one filled action per view */
.tv-btn--primary {
  background: var(--tv-primary);
  color: var(--tv-text-invert);
  border-color: var(--tv-primary);
}

.tv-btn--primary:hover {
  background: var(--tv-primary-hover);
  border-color: var(--tv-primary-hover);
  color: var(--tv-text-invert);
}

/* Secondary — surface with a hairline. The default button. */
.tv-btn--secondary {
  background: var(--tv-surface);
  color: var(--tv-text);
  border-color: var(--tv-border-strong);
}

.tv-btn--secondary:hover {
  border-color: var(--tv-primary);
  color: var(--tv-primary);
}

/* Ghost — text with a gold underline on hover */
.tv-btn--ghost {
  background: transparent;
  color: var(--tv-text);
  padding-inline: var(--tv-space-2);
  border-radius: 0;
  border-bottom: 1px solid transparent;
}

.tv-btn--ghost:hover {
  color: var(--tv-primary);
  border-bottom-color: var(--tv-gold);
}

.tv-btn--sm { height: 34px; padding-inline: var(--tv-space-4); font-size: var(--tv-fs-small); }
.tv-btn--lg { height: 50px; padding-inline: var(--tv-space-8); }
.tv-btn--block { width: 100%; }

/* On dark bands */
.tv-section--invert .tv-btn--secondary {
  background: transparent;
  color: var(--tv-text-invert);
  border-color: rgba(255, 255, 255, .24);
}

.tv-section--invert .tv-btn--secondary:hover {
  border-color: var(--tv-gold);
  color: var(--tv-text-invert);
}

/*
   Text link with a trailing arrow that steps forward on hover.
   Used for "Open →", "Browse all →", "Read more →".
*/
.tv-link-arrow {
  display: inline-flex;
  align-items: center;
  gap: var(--tv-space-2);
  font-size: var(--tv-fs-base);
  font-weight: var(--tv-fw-medium);
  color: var(--tv-primary);
}

.tv-link-arrow__icon { transition: transform var(--tv-dur) var(--tv-ease); }
.tv-link-arrow:hover .tv-link-arrow__icon { transform: translateX(3px); }


/* ==========================================================================
   CHIPS, BADGES, TAGS
   ========================================================================== */

/* Mono format chip — "pdf → docx" */
.tv-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--tv-space-1);
  font-family: var(--tv-font-mono);
  font-size: var(--tv-fs-micro);
  letter-spacing: var(--tv-ls-mono);
  text-transform: lowercase;
  color: var(--tv-text-muted);
  background: var(--tv-surface-sunken);
  border: 1px solid var(--tv-border);
  border-radius: var(--tv-radius-xs);
  padding: 2px 6px;
  white-space: nowrap;
}

.tv-chip--bare { background: none; border: 0; padding: 0; }

/* Uppercase status badge */
.tv-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--tv-space-1);
  font-size: var(--tv-fs-micro);
  font-weight: var(--tv-fw-semibold);
  letter-spacing: var(--tv-ls-eyebrow);
  text-transform: uppercase;
  border-radius: var(--tv-radius-xs);
  padding: 3px 8px;
  white-space: nowrap;
}

.tv-badge--new {
  color: var(--tv-primary);
  background: var(--tv-violet-100);
}

/* Gold is reserved for this one badge type. */
.tv-badge--pro {
  color: var(--tv-gold-ink);
  background: var(--tv-gold-soft);
  border: 1px solid var(--tv-gold);
}

.tv-badge--status {
  color: var(--tv-text-muted);
  background: var(--tv-surface-sunken);
  border: 1px solid var(--tv-border);
}

/* Processing-mode label — appears on every tool card and tool page */
.tv-mode {
  display: inline-flex;
  align-items: center;
  gap: var(--tv-space-2);
  font-family: var(--tv-font-mono);
  font-size: var(--tv-fs-micro);
  letter-spacing: var(--tv-ls-mono);
  color: var(--tv-text-muted);
}

.tv-mode__dot {
  width: 5px;
  height: 5px;
  border-radius: var(--tv-radius-pill);
  flex: none;
  background: var(--tv-success);
}

.tv-mode--server .tv-mode__dot { background: var(--tv-warning); }

/* Pill filter button */
.tv-pill {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding-inline: var(--tv-space-4);
  border: 1px solid var(--tv-border-strong);
  border-radius: var(--tv-radius-pill);
  background: var(--tv-surface);
  font-size: var(--tv-fs-small);
  font-weight: var(--tv-fw-medium);
  color: var(--tv-text-soft);
  cursor: pointer;
  transition: var(--tv-transition);
}

.tv-pill:hover { border-color: var(--tv-primary); color: var(--tv-primary); }

.tv-pill[aria-pressed="true"] {
  background: var(--tv-violet-950);
  border-color: var(--tv-violet-950);
  color: var(--tv-text-invert);
}

/* Keyboard hint */
.tv-kbd {
  font-family: var(--tv-font-mono);
  font-size: var(--tv-fs-eyebrow);
  color: var(--tv-text-muted);
  border: 1px solid var(--tv-border);
  border-radius: var(--tv-radius-xs);
  padding: 2px 6px;
  background: var(--tv-surface);
}


/* ==========================================================================
   SITE HEADER
   ========================================================================== */

.tv-site-header {
  position: sticky;
  top: 0;
  z-index: var(--tv-z-sticky);
  background: rgba(250, 249, 252, .88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--tv-border);
}

.tv-site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--tv-space-8);
  height: var(--tv-header-h);
  max-width: var(--tv-container);
  margin-inline: auto;
  padding-inline: var(--tv-gutter);
}

.tv-brand { display: flex; align-items: center; flex: none; }

.tv-brand__logo {
  height: 48px;
  width: auto;
  /* Logo ships on white; multiply drops the box on our tinted canvas. */
  mix-blend-mode: multiply;
}

.tv-nav {
  display: flex;
  align-items: center;
  gap: var(--tv-space-8);
  font-size: var(--tv-fs-base);
  font-weight: var(--tv-fw-medium);
  white-space: nowrap;
}

.tv-nav__link {
  color: var(--tv-text-soft);
  padding-block: var(--tv-space-2);
  border-bottom: 2px solid transparent;
  transition: var(--tv-transition);
}

.tv-nav__link:hover { color: var(--tv-primary-hover); }

/* Gold underline marks the current section — the accent's main job. */
.tv-nav__link[aria-current="page"],
.tv-nav__link.is-active {
  color: var(--tv-text);
  border-bottom-color: var(--tv-gold);
}

.tv-site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--tv-space-5);
  margin-left: auto;
  min-width: 0;
}

/* Search trigger that opens the command palette */
.tv-search-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tv-space-4);
  flex: 1 1 auto;
  min-width: 150px;
  max-width: 280px;
  height: 42px;
  padding: 0 var(--tv-space-3) 0 var(--tv-space-4);
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  border-radius: var(--tv-radius-sm);
  color: var(--tv-text-muted);
  font-size: var(--tv-fs-base);
  overflow: hidden;
  transition: var(--tv-transition);
}

.tv-search-trigger:hover { border-color: var(--tv-border-strong); }

.tv-search-trigger__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mobile menu toggle */
.tv-burger {
  display: none;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--tv-border-strong);
  border-radius: var(--tv-radius-sm);
  background: var(--tv-surface);
  flex: none;
}

.tv-burger__bar {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--tv-text);
  border-radius: 2px;
  transition: var(--tv-transition);
}

.tv-burger__bar + .tv-burger__bar { margin-top: 4px; }

@media (max-width: 900px) {
  .tv-burger { display: inline-flex; }
  .tv-brand__logo { height: 36px; }
  .tv-site-header__inner { gap: var(--tv-space-4); }

  .tv-nav {
    position: fixed;
    inset: var(--tv-header-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--tv-surface);
    border-bottom: 1px solid var(--tv-border);
    box-shadow: var(--tv-shadow);
    padding: var(--tv-space-2) var(--tv-gutter) var(--tv-space-5);
    max-height: calc(100vh - var(--tv-header-h));
    overflow-y: auto;
    display: none;
  }

  .tv-nav.is-open { display: flex; }

  .tv-nav__link {
    padding-block: var(--tv-space-4);
    border-bottom: 1px solid var(--tv-border);
  }

  .tv-nav__link[aria-current="page"],
  .tv-nav__link.is-active {
    border-bottom-color: var(--tv-gold);
  }

  .tv-search-trigger__label { display: none; }
  .tv-search-trigger { min-width: 42px; max-width: 42px; justify-content: center; padding: 0; }
}


/* ==========================================================================
   COMMAND PALETTE (⌘K)
   ========================================================================== */

.tv-palette {
  position: fixed;
  inset: 0;
  z-index: var(--tv-z-modal);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh var(--tv-space-5) var(--tv-space-5);
  background: rgba(23, 19, 31, .38);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.tv-palette.is-open { display: flex; }

.tv-palette__dialog {
  width: 100%;
  max-width: 560px;
  background: var(--tv-surface);
  border: 1px solid var(--tv-border-strong);
  border-radius: var(--tv-radius);
  box-shadow: var(--tv-shadow-lg);
  overflow: hidden;
}

.tv-palette__field {
  display: flex;
  align-items: center;
  gap: var(--tv-space-3);
  padding: var(--tv-space-4) var(--tv-space-5);
  border-bottom: 1px solid var(--tv-border);
}

.tv-palette__input {
  flex: 1;
  border: 0;
  outline: 0;
  background: none;
  font-size: var(--tv-fs-body);
  color: var(--tv-text);
  min-width: 0;
}

.tv-palette__input::placeholder { color: var(--tv-text-muted); }

.tv-palette__results {
  max-height: 340px;
  overflow-y: auto;
  padding: var(--tv-space-2);
}

.tv-palette__item {
  display: flex;
  align-items: center;
  gap: var(--tv-space-3);
  width: 100%;
  padding: var(--tv-space-3) var(--tv-space-4);
  border-radius: var(--tv-radius-sm);
  text-align: left;
  color: var(--tv-text);
  transition: background var(--tv-dur-fast) var(--tv-ease);
}

.tv-palette__item:hover,
.tv-palette__item.is-active { background: var(--tv-surface-sunken); }

.tv-palette__item-name { font-weight: var(--tv-fw-medium); }
.tv-palette__item-meta { margin-left: auto; }

.tv-palette__empty {
  padding: var(--tv-space-8) var(--tv-space-5);
  text-align: center;
  color: var(--tv-text-muted);
  font-size: var(--tv-fs-small);
}


/* ==========================================================================
   CARDS
   ========================================================================== */

.tv-card {
  display: flex;
  flex-direction: column;
  gap: var(--tv-space-3);
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  border-radius: var(--tv-radius);
  padding: var(--tv-space-6);
  transition: var(--tv-transition);
}

.tv-card--flat  { background: var(--tv-surface-raised); }
.tv-card--sunken { background: var(--tv-surface-sunken); border-color: transparent; }

/* Tool card — the most repeated object on the site */
.tv-tool-card { position: relative; }

.tv-tool-card:hover {
  border-color: var(--tv-border-strong);
  transform: translateY(-2px);
  box-shadow: var(--tv-shadow-sm);
}

.tv-tool-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tv-space-3);
}

.tv-tool-card__title {
  font-family: var(--tv-font-display);
  font-size: var(--tv-fs-h6);
  font-weight: var(--tv-fw-semibold);
  letter-spacing: var(--tv-ls-tight);
  color: var(--tv-text);
}

.tv-tool-card__desc {
  font-size: var(--tv-fs-small);
  line-height: var(--tv-lh-snug);
  color: var(--tv-text-soft);
  flex: 1;
}

.tv-tool-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tv-space-3);
  padding-top: var(--tv-space-3);
  border-top: 1px solid var(--tv-border);
}

/* Whole card clickable without nesting interactive elements */
.tv-tool-card__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}


/* ==========================================================================
   FORMS
   ========================================================================== */

.tv-field { display: flex; flex-direction: column; gap: var(--tv-space-2); }

.tv-label {
  font-size: var(--tv-fs-small);
  font-weight: var(--tv-fw-medium);
  color: var(--tv-text);
}

.tv-hint {
  font-size: var(--tv-fs-small);
  color: var(--tv-text-muted);
}

.tv-input,
.tv-textarea,
.tv-select {
  width: 100%;
  min-height: 42px;
  padding: var(--tv-space-3) var(--tv-space-4);
  background: var(--tv-surface);
  border: 1px solid var(--tv-border-strong);
  border-radius: var(--tv-radius-sm);
  font-size: var(--tv-fs-base);
  color: var(--tv-text);
  transition: var(--tv-transition);
}

.tv-input::placeholder,
.tv-textarea::placeholder { color: var(--tv-text-muted); }

.tv-input:focus,
.tv-textarea:focus,
.tv-select:focus {
  outline: none;
  border-color: var(--tv-primary);
  box-shadow: var(--tv-focus-ring);
}

.tv-textarea { min-height: 110px; resize: vertical; line-height: var(--tv-lh-snug); }

/* Inline input + button, used by the join and request forms */
.tv-inline-form {
  display: flex;
  align-items: stretch;
  gap: var(--tv-space-2);
}

.tv-inline-form .tv-input { flex: 1; min-width: 0; }

@media (max-width: 480px) {
  .tv-inline-form { flex-direction: column; }
}

.tv-form-note {
  font-family: var(--tv-font-mono);
  font-size: var(--tv-fs-micro);
  letter-spacing: var(--tv-ls-mono);
  color: var(--tv-text-muted);
  margin-top: var(--tv-space-3);
}

/*
   Contact Form 7 overrides.
   CF7 wraps every control in <span class="wpcf7-form-control-wrap">, which
   breaks flex layouts unless it is made transparent to the layout.
*/
.wpcf7-form-control-wrap { display: block; width: 100%; }
.tv-inline-form .wpcf7-form-control-wrap { flex: 1; min-width: 0; }

.wpcf7-not-valid-tip {
  font-size: var(--tv-fs-small);
  color: var(--tv-danger);
  margin-top: var(--tv-space-2);
}

.wpcf7-response-output {
  margin: var(--tv-space-4) 0 0 !important;
  padding: var(--tv-space-3) var(--tv-space-4) !important;
  border: 1px solid var(--tv-border-strong) !important;
  border-radius: var(--tv-radius-sm);
  font-size: var(--tv-fs-small);
}

.wpcf7 form.invalid .wpcf7-response-output,
.wpcf7 form.unaccepted .wpcf7-response-output { border-color: var(--tv-danger) !important; color: var(--tv-danger); }

.wpcf7 form.sent .wpcf7-response-output { border-color: var(--tv-success) !important; color: var(--tv-success); }

.wpcf7-spinner { display: none; }
