/* KaraHub — reusable UI components: buttons, forms, alerts, badges, pagination. */

.kh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.75em 1.5em;
  border-radius: var(--kh-r-sm);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.15s var(--kh-ease), box-shadow 0.15s var(--kh-ease);
}

.kh-btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
}

.kh-btn:active {
  transform: scale(0.97);
}

/* Amber is reserved for exactly one CTA per page — see tokens.css usage ratio.
   Since it only ever appears once, it can afford to be the loudest thing on
   the page: bigger padding, a warm glow, and a directional arrow. */
.kh-btn--cta {
  background: var(--kh-amber);
  color: var(--kh-graphite);
  font-weight: 700;
  padding: 0.85em 1.4em 0.85em 1.75em;
  border-radius: var(--kh-r-md);
  box-shadow: 0 4px 16px rgba(233, 161, 59, 0.4), var(--kh-sh-1);
}

[dir="rtl"] .kh-btn--cta {
  padding: 0.85em 1.75em 0.85em 1.4em;
}

.kh-btn--cta:hover {
  box-shadow: 0 8px 26px rgba(233, 161, 59, 0.55), var(--kh-sh-2);
  transform: translateY(-2px);
}

.kh-btn--cta:active {
  transform: scale(0.97);
}

.kh-btn--cta::after {
  content: '';
  width: 0.9em;
  height: 0.9em;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E") no-repeat center / contain;
  transition: transform 0.2s var(--kh-ease);
}

[dir="rtl"] .kh-btn--cta::after {
  transform: scaleX(-1);
}

.kh-btn--cta:hover::after {
  transform: translateX(4px);
}

[dir="rtl"] .kh-btn--cta:hover::after {
  transform: scaleX(-1) translateX(-4px);
}

/* The hero's CTA is the page's single most important action — a slow ambient
   pulse earns its keep there without turning every CTA site-wide into a
   blinking distraction. */
.kh-hero .kh-btn--cta {
  animation: kh-cta-pulse 2.6s ease-in-out infinite;
}

@keyframes kh-cta-pulse {
  0%, 100% {
    box-shadow: 0 4px 16px rgba(233, 161, 59, 0.4), var(--kh-sh-1);
  }
  50% {
    box-shadow: 0 4px 26px rgba(233, 161, 59, 0.7), var(--kh-sh-1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .kh-hero .kh-btn--cta {
    animation: none;
  }
}

/* For use on dark backgrounds (e.g. the petrol CTA band) where the page's one
   amber CTA already lives elsewhere — keeps the "amber once per page" rule intact. */
.kh-btn--outline-light {
  background: transparent;
  color: var(--kh-n0);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.kh-btn--outline-light:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--kh-n0);
}

/* Forms */

.kh-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

.kh-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.4em;
}

.kh-form__field--full {
  grid-column: 1 / -1;
}

.kh-form__field--honeypot {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.kh-form label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--kh-petrol);
}

.kh-form input,
.kh-form textarea,
.kh-form select {
  padding: 0.7em 0.9em;
  border: 1px solid var(--kh-n300);
  border-radius: var(--kh-r-sm);
  background: var(--kh-n0);
  width: 100%;
}

.kh-form input:focus,
.kh-form textarea:focus,
.kh-form select:focus {
  border-color: var(--kh-teal);
}

.kh-form button {
  grid-column: 1 / -1;
  justify-self: start;
}

@media (max-width: 600px) {
  .kh-form {
    grid-template-columns: 1fr;
  }
}

/* Alerts */

.kh-alert {
  padding: 1em 1.25em;
  border-radius: var(--kh-r-md);
  margin-bottom: 1.5rem;
}

.kh-alert ul {
  margin: 0;
  padding-inline-start: 1.2em;
}

.kh-alert--success {
  background: rgba(14, 124, 134, 0.12);
  color: var(--kh-petrol);
  border: 1px solid var(--kh-teal);
}

.kh-alert--error {
  background: rgba(192, 85, 63, 0.1);
  color: var(--kh-danger);
  border: 1px solid var(--kh-danger);
}

/* Badges */

.kh-badge {
  display: inline-block;
  background: var(--kh-petrol);
  color: var(--kh-n0);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25em 0.65em;
  border-radius: 999px;
  margin-bottom: 0.6em;
}

/* Inside a flex tag row (post cards) the badge sits inline, no own margin. */
.kh-post-card__tags .kh-badge {
  margin-bottom: 0;
}

/* Pagination */

.kh-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 2.5rem;
  font-size: 0.9rem;
}

.kh-pagination a {
  font-weight: 600;
}

/* Tables (used inside .kh-prose for content tables too) */

.kh-table-wrap {
  overflow-x: auto;
}
