/* ==========================================================================
   Himalayan Trails — reusable UI components
   ========================================================================== */

/* ---- Buttons -------------------------------------------------------------
   One shape, three weights. Minimum 44px tall so every button is a valid
   touch target without a separate mobile rule. */

.ht-btn {
  --btn-bg: var(--ht-accent);
  --btn-fg: var(--ht-accent-contrast);
  --btn-border: transparent;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ht-space-2);
  min-height: 2.875rem;
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--btn-border);
  border-radius: var(--ht-radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--ht-text-base);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-align: center;
  cursor: pointer;
  transition:
    background-color var(--ht-duration-fast) var(--ht-ease),
    border-color var(--ht-duration-fast) var(--ht-ease),
    color var(--ht-duration-fast) var(--ht-ease),
    transform var(--ht-duration-fast) var(--ht-ease);
}

.ht-btn:hover {
  --btn-bg: var(--ht-accent-hover);
}

.ht-btn:active {
  transform: translateY(1px);
}

.ht-btn[disabled],
.ht-btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.ht-btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ht-text);
  --btn-border: var(--ht-border);
}

.ht-btn--ghost:hover {
  --btn-bg: var(--ht-sand);
  --btn-border: var(--ht-stone-400);
}

.ht-btn--on-dark {
  --btn-bg: transparent;
  --btn-fg: var(--ht-text-inverse);
  --btn-border: var(--ht-border-inverse);
}

.ht-btn--on-dark:hover {
  --btn-bg: rgb(255 255 255 / 0.1);
  --btn-border: rgb(255 255 255 / 0.3);
}

.ht-btn--pine {
  --btn-bg: var(--ht-pine-800);
  --btn-fg: var(--ht-text-inverse);
}

.ht-btn--pine:hover {
  --btn-bg: var(--ht-pine-700);
}

.ht-btn--sm {
  min-height: 2.375rem;
  padding: 0.5rem 1rem;
  font-size: var(--ht-text-sm);
}

.ht-btn--block {
  width: 100%;
}

/* Text link with a rule that grows on hover — used instead of a third button. */
.ht-link {
  display: inline-flex;
  align-items: center;
  gap: var(--ht-space-2);
  font-weight: 600;
  font-size: var(--ht-text-base);
  color: var(--ht-accent);
  padding-block: 0.35rem;
  border-bottom: 1px solid currentColor;
  transition: gap var(--ht-duration-fast) var(--ht-ease), color var(--ht-duration-fast) var(--ht-ease);
}

.ht-link:hover {
  gap: var(--ht-space-3);
  color: var(--ht-accent-hover);
}

.ht-link--on-dark {
  color: var(--ht-clay-400);
}

.ht-link__arrow {
  width: 1em;
  height: 1em;
  flex: none;
}

/* ---- Chips & badges ------------------------------------------------------ */

.ht-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: var(--ht-radius-pill);
  background: var(--ht-sand);
  color: var(--ht-text-soft);
  font-size: var(--ht-text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ht-chip--overlay {
  background: rgb(11 22 17 / 0.72);
  color: var(--ht-text-inverse);
  backdrop-filter: blur(6px);
}

.ht-chip--ok {
  background: var(--ht-success-soft);
  color: var(--ht-success);
}

.ht-chip--warn {
  background: var(--ht-warning-soft);
  color: var(--ht-warning);
}

.ht-chip--out {
  background: var(--ht-danger-soft);
  color: var(--ht-danger);
}

/* ---- Media ---------------------------------------------------------------
   Every framed image declares its ratio so nothing shifts as photos load. */

.ht-media {
  position: relative;
  overflow: hidden;
  background: var(--ht-stone-200);
}

.ht-media > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ht-media--4x3 { aspect-ratio: 4 / 3; }
.ht-media--3x2 { aspect-ratio: 3 / 2; }
.ht-media--16x9 { aspect-ratio: 16 / 9; }
.ht-media--1x1 { aspect-ratio: 1 / 1; }
.ht-media--portrait { aspect-ratio: 4 / 5; }

.ht-media--zoom > img {
  transition: transform var(--ht-duration-slow) var(--ht-ease-out);
}

/* ---- Trek card ----------------------------------------------------------- */

.ht-trek-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--ht-surface-card);
  border: 1px solid var(--ht-border-soft);
  border-radius: var(--ht-radius-lg);
  overflow: hidden;
  transition:
    border-color var(--ht-duration-base) var(--ht-ease),
    box-shadow var(--ht-duration-base) var(--ht-ease),
    transform var(--ht-duration-base) var(--ht-ease);
}

.ht-trek-card:hover,
.ht-trek-card:focus-within {
  border-color: var(--ht-stone-400);
  box-shadow: var(--ht-shadow-md);
  transform: translateY(-3px);
}

.ht-trek-card:hover .ht-media--zoom > img {
  transform: scale(1.045);
}

.ht-trek-card__media {
  position: relative;
}

.ht-trek-card__tags {
  position: absolute;
  inset-inline: var(--ht-space-4);
  top: var(--ht-space-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--ht-space-2);
}

.ht-trek-card__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: var(--ht-space-3);
  padding: var(--ht-space-6);
}

.ht-trek-card__title {
  font-family: var(--ht-font-display);
  font-size: var(--ht-display-4);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: var(--ht-tracking-tight);
}

/* The whole card is clickable, but only the title is a real link — so the
   accessibility tree stays clean and text is still selectable. */
.ht-trek-card__title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.ht-trek-card__summary {
  color: var(--ht-text-soft);
  font-size: var(--ht-text-base);
  line-height: var(--ht-leading-normal);
  /* Keeps every card in a row the same height without a JS equaliser. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ht-trek-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ht-space-2) var(--ht-space-4);
  padding-block: var(--ht-space-1);
  color: var(--ht-text-muted);
  font-size: var(--ht-text-sm);
}

.ht-trek-card__meta li {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.ht-trek-card__meta svg {
  width: 1rem;
  height: 1rem;
  flex: none;
  color: var(--ht-pine-500);
}

.ht-trek-card__footer {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--ht-space-3);
  margin-top: auto;
  padding-top: var(--ht-space-4);
  border-top: 1px solid var(--ht-border-soft);
}

.ht-price {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.ht-price__amount {
  font-family: var(--ht-font-display);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: var(--ht-tracking-tight);
}

.ht-price__note {
  font-size: var(--ht-text-xs);
  color: var(--ht-text-muted);
}

.ht-trek-card__departure {
  text-align: right;
  font-size: var(--ht-text-sm);
  color: var(--ht-text-soft);
}

.ht-trek-card__departure strong {
  display: block;
  font-weight: 600;
  color: var(--ht-text);
}

/* ---- Grids --------------------------------------------------------------- */

.ht-grid {
  display: grid;
  gap: var(--ht-space-6);
}

/* auto-fit with a floor means a 2-up row never leaves an orphan stretched
   across the full width, at any breakpoint. */
.ht-grid--treks {
  grid-template-columns: 1fr;
  gap: var(--ht-space-8) var(--ht-space-6);
}

@media (min-width: 44rem) {
  .ht-grid--treks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 68rem) {
  .ht-grid--treks {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/*
 * Fixed column counts above their breakpoints rather than auto-fit. auto-fit
 * decides the count from the available width, which leaves a half-empty last
 * row whenever the item count is not a multiple of what it chose — six rental
 * items became 4 + 2 with two dead cells. These sections always hold a multiple
 * of three or four, so the count is stated explicitly.
 */
.ht-grid--3 {
  grid-template-columns: 1fr;
}

@media (min-width: 40rem) {
  .ht-grid--3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 62rem) {
  .ht-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.ht-grid--4 {
  grid-template-columns: 1fr;
}

@media (min-width: 34rem) {
  .ht-grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 62rem) {
  .ht-grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ---- Forms --------------------------------------------------------------- */

.ht-field {
  display: flex;
  flex-direction: column;
  gap: var(--ht-space-2);
  min-width: 0;
}

.ht-field__label {
  font-size: var(--ht-text-sm);
  font-weight: 600;
  color: var(--ht-text-soft);
}

.ht-field__label .ht-req {
  color: var(--ht-danger);
}

.ht-input,
.ht-select,
.ht-textarea {
  width: 100%;
  min-height: 2.875rem;
  padding: 0.6875rem 0.875rem;
  border: 1px solid var(--ht-border);
  border-radius: var(--ht-radius-sm);
  background: var(--ht-white);
  color: var(--ht-text);
  font-size: var(--ht-text-base);
  transition: border-color var(--ht-duration-fast) var(--ht-ease), box-shadow var(--ht-duration-fast) var(--ht-ease);
}

.ht-textarea {
  min-height: 7rem;
  resize: vertical;
}

.ht-select {
  appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%236b7770' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 7.5 10 12.5 15 7.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.125rem;
}

.ht-input:focus,
.ht-select:focus,
.ht-textarea:focus {
  outline: none;
  border-color: var(--ht-accent);
  box-shadow: 0 0 0 3px rgb(193 118 47 / 0.18);
}

.ht-input[aria-invalid="true"],
.ht-select[aria-invalid="true"],
.ht-textarea[aria-invalid="true"] {
  border-color: var(--ht-danger);
}

.ht-field__error {
  font-size: var(--ht-text-sm);
  color: var(--ht-danger);
}

.ht-field__error:empty {
  display: none;
}

.ht-form-status {
  padding: var(--ht-space-4) var(--ht-space-5);
  border-radius: var(--ht-radius-md);
  font-size: var(--ht-text-base);
}

.ht-form-status[data-state="success"] {
  background: var(--ht-success-soft);
  color: var(--ht-success);
}

.ht-form-status[data-state="error"] {
  background: var(--ht-danger-soft);
  color: var(--ht-danger);
}

.ht-form-status:empty {
  display: none;
}

/* Button busy state — the label is swapped for a spinner in place, so the
   button never changes width mid-submit. */
.ht-btn[data-busy="true"] {
  position: relative;
  color: transparent;
  pointer-events: none;
}

.ht-btn[data-busy="true"]::after {
  content: "";
  position: absolute;
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid currentColor;
  border-top-color: var(--btn-fg);
  border-radius: 50%;
  color: rgb(255 255 255 / 0.4);
  animation: ht-spin 700ms linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .ht-btn[data-busy="true"]::after {
    animation-duration: 2s;
  }
}

/* ---- Accordion ----------------------------------------------------------- */

.ht-accordion {
  border-top: 1px solid var(--ht-border);
}

.ht-accordion__item {
  border-bottom: 1px solid var(--ht-border);
}

.ht-accordion__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ht-space-4);
  width: 100%;
  padding: var(--ht-space-5) 0;
  text-align: left;
  font-size: var(--ht-text-lg);
  font-weight: 600;
  color: var(--ht-text);
  transition: color var(--ht-duration-fast) var(--ht-ease);
}

.ht-accordion__trigger:hover {
  color: var(--ht-accent);
}

.ht-accordion__icon {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--ht-text-muted);
  transition: transform var(--ht-duration-base) var(--ht-ease);
}

.ht-accordion__trigger[aria-expanded="true"] .ht-accordion__icon {
  transform: rotate(180deg);
}

.ht-accordion__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--ht-duration-base) var(--ht-ease);
}

.ht-accordion__panel[data-open="true"] {
  grid-template-rows: 1fr;
}

.ht-accordion__panel > div {
  overflow: hidden;
}

.ht-accordion__panel p {
  padding-bottom: var(--ht-space-5);
  max-width: 62ch;
  color: var(--ht-text-soft);
  line-height: var(--ht-leading-relaxed);
}

/* FAQ blocks read better on a prose measure than the full content width. */
.ht-accordion--narrow {
  max-width: var(--ht-shell-narrow);
  margin-inline: auto;
}

/* Same audit: the arrow links sat at 35px on a phone. */
@media (max-width: 47.9375rem) {
  .ht-link {
    padding-block: 0.625rem;
  }
}

/* The compact button variant exists to sit inside dense desktop rows; on a phone
   it still has to be a full-size touch target. */
@media (max-width: 47.9375rem) {
  .ht-btn--sm {
    min-height: 2.75rem;
    padding-inline: 1.125rem;
  }
}
