/**
 * Travel Offers Plugin — Front-end styles
 *
 * Architecture: BEM (Block__Element--Modifier)
 * Blocks: top-offer-block, top-offer-grid, top-hotel-box, top-destination-box,
 *         top-price, top-stars, top-rating, top-badge, top-skeleton, top-empty-state
 *
 * Breakpoints (matching ACF device_visibility field):
 *   Mobile:  < 768 px
 *   Tablet:  768 – 1279 px
 *   Desktop: ≥ 1280 px
 *
 * Custom properties are set by RenderContext::gridColumnVars() inline
 * on .top-offer-grid so grid columns are driven entirely by PHP/ACF config.
 */

/* =============================================================================
   0. CSS Custom Properties / Design Tokens
   ============================================================================= */

:root {
  /* Colours */
  --top-color-primary:      #0073aa;
  --top-color-primary-dark: #005a87;
  --top-color-accent:       #ff6b35;
  --top-color-success:      #2e7d32;
  --top-color-excellent:      #00A54C;
  --top-color-warning:      #f57f17;
  --top-color-danger:       #c62828;
  --top-color-text:         #1a1a2e;
  --top-color-text-muted:   #637083;
  --top-color-bg:           #ffffff;
  --top-color-surface:      #f7f9fc;
  --top-color-border:       #dde3ec;
  --top-color-skeleton:     #e8edf4;
  --top-color-skeleton-shine: #f4f7fb;
  --top-color-destination: #0E97C2;

  /* Stars */
  --top-star-color:  #f5a623;

  /* Typography */
  --top-font-base: inherit;
  --top-fs-xs:   0.75rem;
  --top-fs-sm:   0.8125rem;
  --top-fs-md:   0.9375rem;
  --top-fs-lg:   1.0625rem;
  --top-fs-xl:   1.25rem;
  --top-fs-2xl:  1.5rem;
  --top-fs-3xl:  1.75rem;

  /* Spacing */
  --top-gap:    1.25rem;
  --top-gap-sm: 0.625rem;
  --top-gap-xs: 0.375rem;
  --top-radius: 0.625rem;
  --top-radius-sm: 0.375rem;

  /* Shadows */
  --top-shadow-card:  0 2px 8px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
  --top-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);

  /* Transitions */
  --top-transition: 220ms ease;

  /* Grid columns — overridden inline by PHP (RenderContext::gridColumnVars()) */
  --top-cols-desktop: 3;
  --top-cols-tablet:  2;
  --top-cols-mobile:  1;
}

/* =============================================================================
   1. Offer Block — section wrapper
   ============================================================================= */

.top-offer-block {
  container-type: inline-size;
  margin-block: calc(var(--top-gap) * 2);
  font-family: var(--top-font-base);
  max-width: 1320px;
}

/* Device visibility — controlled by PHP via CSS classes */
@media (max-width: 767px) {
  .top-offer-block--hide-mobile { display: none !important; }
}
@media (min-width: 768px) and (max-width: 1279px) {
  .top-offer-block--hide-tablet { display: none !important; }
}
@media (min-width: 1280px) {
  .top-offer-block--hide-desktop { display: none !important; }
}

/* ── Header ── */
.top-offer-block__header {
  margin-block-end: var(--top-gap);
  text-align: start;
}

.top-offer-block__headline {
  margin: 0 0 0.35em;
  font-size: var(--top-fs-2xl);
  font-weight: 700;
  line-height: 1.2;
  color: var(--top-color-text);
}

.top-offer-block__subheadline {
  margin: 0;
  font-size: var(--top-fs-md);
  color: var(--top-color-text-muted);
}

/* =============================================================================
   2. Offer Grid — responsive grid
   ============================================================================= */

.top-offer-grid {
  display: grid;
  grid-template-columns: repeat(var(--top-cols-mobile), 1fr);
  gap: var(--top-gap);
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Tablet breakpoint */
@media (min-width: 768px) {
  .top-offer-grid {
    grid-template-columns: repeat(var(--top-cols-tablet), 1fr);
  }
}

/* Desktop breakpoint */
@media (min-width: 1280px) {
  .top-offer-grid {
    grid-template-columns: repeat(var(--top-cols-desktop), 1fr);
  }
}

/* Container query variant — activates when parent supports it */
@container (min-width: 600px) {
  .top-offer-grid {
    grid-template-columns: repeat(var(--top-cols-tablet), 1fr);
  }
}
@container (min-width: 900px) {
  .top-offer-grid {
    grid-template-columns: repeat(var(--top-cols-desktop), 1fr);
  }
}

/* =============================================================================
   3. Hotel Box — hotel offer card
   ============================================================================= */

.top-hotel-box {
  display: flex;
  flex-direction: column;
  background: var(--top-color-bg);
  border: 1px solid var(--top-color-border);
  border-radius: 5px;
  box-shadow: var(--top-shadow-card);
  overflow: hidden;
  transition: box-shadow var(--top-transition), transform var(--top-transition);
  /* Ensure card height stretches to fill grid cell */
  height: 100%;
}

.top-hotel-box:hover,
.top-hotel-box:focus-within {
  box-shadow: var(--top-shadow-hover);
  transform: translateY(-2px);
}

/* ── Media ── */
.top-hotel-box__media {
  position: relative;
  flex-shrink: 0;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--top-color-skeleton);
}

.top-hotel-box__image-link {
  display: block;
  height: 100%;
}

.top-hotel-box__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--top-transition);
  display: block;
}

.top-hotel-box:hover .top-hotel-box__image {
  transform: scale(1.04);
}

/* Badges overlay */
.top-hotel-box__badges {
  position: absolute;
  inset-block-start: var(--top-gap-sm);
  inset-inline-start: var(--top-gap-sm);
  display: flex;
  flex-wrap: wrap;
  gap: var(--top-gap-xs);
  z-index: 1;
}

.top-hotel-box__caption {
  position: absolute;
  inset-block-end: 0;
  inset-inline: 0;
  margin: 0;
  padding: var(--top-gap-xs) var(--top-gap-sm);
  background: linear-gradient(transparent, rgba(0,0,0,0.55));
  color: #fff;
  font-size: var(--top-fs-xs);
  font-weight: 500;
}

/* ── Body ── */
.top-hotel-box__body {
  padding: var(--top-gap-sm) var(--top-gap-sm) 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--top-gap-xs);
  min-height: 0;
}

.top-hotel-box__stars { line-height: 1; }

.top-hotel-box__title {
  margin: 0;
  font-size: var(--top-fs-lg);
  font-weight: 600;
  line-height: 1.3;
}

.top-hotel-box__title-link {
  color: var(--top-color-text);
  text-decoration: none;
}

.top-hotel-box__title-link:hover,
.top-hotel-box__title-link:focus-visible {
  color: var(--top-color-primary);
  text-decoration: underline;
  outline-offset: 2px;
}

.top-hotel-box__location {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.3em;
  font-size: var(--top-fs-sm);
  color: var(--top-color-text-muted);
}

/* .top-hotel-box__rating — no longer used; rating badge moved to meta-row */

/* ── Footer ── */
.top-hotel-box__footer {
  padding: var(--top-gap-sm);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--top-gap-sm);
  border-block-start: 1px solid var(--top-color-border);
  margin-block-start: var(--top-gap-sm);
}

/* price-wrap & travelers styles now in section 13 */

.top-hotel-box__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.45em 0.9em;
  background: var(--top-color-primary);
  color: #fff;
  font-size: var(--top-fs-sm);
  font-weight: 600;
  border-radius: var(--top-radius-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--top-transition);
  flex-shrink: 0;
}

.top-hotel-box__cta:hover,
.top-hotel-box__cta:focus-visible {
  background: var(--top-color-primary-dark);
  color: #fff;
  outline: 2px solid var(--top-color-primary);
  outline-offset: 2px;
}

.top-hotel-box__cta-arrow { transition: transform var(--top-transition); }
.top-hotel-box__cta:hover .top-hotel-box__cta-arrow { transform: translateX(3px); }

/* =============================================================================
   4. Destination Box
   ============================================================================= */

.top-destination-box {
  display: block;
  border-radius: var(--top-radius);
  box-shadow: var(--top-shadow-card);
  overflow: hidden;
  transition: box-shadow var(--top-transition), transform var(--top-transition);
  width: 300px;
  height: 370px;
  background: var(--top-color-skeleton);
  position: relative;
}

.top-destination-box:hover,
.top-destination-box:focus-within {
  box-shadow: var(--top-shadow-hover);
  transform: translateY(-3px);
}

/* ── Full-card link ── */
.top-destination-box__link {
  display: block;
  position: relative;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

/* ── Media — fills entire card ── */
.top-destination-box__media {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--top-color-skeleton);
}

/* Gradient overlay for text readability — sits on top of image */
.top-destination-box__media::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(58,58,58,0) 66.15%, rgba(31,31,31,0.6) 82.29%, rgba(0,0,0,0.9) 100%);
  pointer-events: none;
}

.top-destination-box__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--top-transition);
  display: block;
}

.top-destination-box__link:hover .top-destination-box__image,
.top-destination-box__link:focus-visible .top-destination-box__image {
  transform: scale(1.05);
}

/* ── Footer — overlaid at bottom of card ── */
.top-destination-box__footer {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0.75rem var(--top-gap-sm);
  z-index: 1;
}

.top-destination-box__region {
  display: block;
  color: #fff;
  font-size: var(--top-fs-xl);
  font-weight: 700;
  line-height: 1.2;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-destination-box__footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--top-gap-sm);
}

.top-destination-box__trip-info {
  font-size: var(--top-fs-sm);
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.top-destination-box__price-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
  gap: 1px;
}

.top-destination-box__price-main {
  display: flex;
  align-items: baseline;
  gap: 0.25em;
  white-space: nowrap;
}

.top-destination-box__price-from {
  font-size: var(--top-fs-xs);
  color: rgba(255,255,255,0.75);
}

.top-destination-box__price-amount {
  font-size: var(--top-fs-xl);
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
}

.top-destination-box__price-pp {
  font-size: var(--top-fs-xs);
  color: rgba(255,255,255,0.75);
  white-space: nowrap;
}

/* =============================================================================
   5. Price component
   ============================================================================= */

.top-price {
  display: inline-flex;
  align-items: baseline;
  gap: 0.2em;
  font-weight: 700;
  color: var(--top-color-text);
}

.top-price__from {
  font-size: var(--top-fs-xs);
  font-weight: 400;
  color: var(--top-color-text-muted);
  align-self: center;
}

.top-price__amount { font-size: var(--top-fs-3xl); line-height: 32px; }
.top-price__currency { font-size: var(--top-fs-3xl); font-weight: 500; }

/* Discounted price pair */
.top-price--discounted {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.top-price__original {
  font-size: var(--top-fs-sm);
  font-weight: 400;
  color: var(--top-color-text-muted);
  text-decoration: line-through;
}

.top-price__amount--sale {
  font-size: var(--top-fs-xl);
  color: var(--top-color-accent);
}

/* =============================================================================
   6. Stars component
   ============================================================================= */

.top-stars {
  display: inline-flex;
  gap: 1px;
  color: black;
  font-size: 1rem;
  width: 1rem;
  line-height: 1;
}

/* =============================================================================
   7. Rating component
   ============================================================================= */

.top-rating {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: var(--top-fs-sm);
}

.top-rating__score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2em;
  padding: 0.15em 0.4em;
  border-radius: var(--top-radius-sm);
  font-weight: 700;
  font-size: var(--top-fs-md);
  color: #fff;
  line-height: 1;
}

.top-rating--excellent .top-rating__score { background: #2e7d32; }
.top-rating--good      .top-rating__score { background: #388e3c; }
.top-rating--fair      .top-rating__score { background: #f57f17; }
.top-rating--poor      .top-rating__score { background: #c62828; }

.top-rating__label {
  font-weight: 600;
  color: var(--top-color-text);
}

.top-rating__count {
  color: var(--top-color-text-muted);
  font-size: var(--top-fs-xs);
}

/* =============================================================================
   8. Badge component
   ============================================================================= */

.top-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2em 0.55em;
  border-radius: var(--top-radius-sm);
  font-size: var(--top-fs-xs);
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.top-badge--discount {
  background: var(--top-color-accent);
  color: #fff;
}

.top-badge--reco {
  background: rgba(255,255,255,0.92);
  color: var(--top-color-text);
  border: 1px solid var(--top-color-border);
}

/* =============================================================================
   9. Skeleton loader
   ============================================================================= */

@keyframes top-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

.top-skeleton {
  background: linear-gradient(
    90deg,
    var(--top-color-skeleton)        25%,
    var(--top-color-skeleton-shine)  50%,
    var(--top-color-skeleton)        75%
  );
  background-size: 800px 100%;
  animation: top-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--top-radius-sm);
  display: block;
}

/* Prevent text from appearing inside skeleton elements */
.top-skeleton * { visibility: hidden; }

.top-skeleton--image {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.top-skeleton--image-tall { aspect-ratio: 4 / 3; }

.top-skeleton--text {
  height: 1em;
  width: 100%;
}
.top-skeleton--text-lg { width: 80%; height: 1.2em; }
.top-skeleton--text-md { width: 60%; }
.top-skeleton--text-sm { width: 40%; height: 0.85em; }

.top-skeleton--badge {
  width: 3em;
  height: 1.6em;
}

.top-skeleton--button {
  height: 2.2em;
  width: 7em;
  border-radius: var(--top-radius-sm);
}

.top-skeleton--stars {
  width: 5em;
  height: 1em;
}

/* Skeleton card structure inherits hotel-box layout */
.top-hotel-box--skeleton,
.top-destination-box--skeleton {
  pointer-events: none;
}

/* =============================================================================
   10. Empty state
   ============================================================================= */

.top-empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--top-gap-sm);
  padding: calc(var(--top-gap) * 2);
  text-align: center;
  color: var(--top-color-text-muted);
  border: 2px dashed var(--top-color-border);
  border-radius: var(--top-radius);
  background: var(--top-color-surface);
}

.top-empty-state__icon { font-size: 2.5rem; line-height: 1; }

.top-empty-state__message {
  margin: 0;
  font-size: var(--top-fs-md);
  max-width: 36ch;
}

.top-empty-state__retry {
  padding: 0.45em 1.2em;
  background: var(--top-color-primary);
  color: #fff;
  border: none;
  border-radius: var(--top-radius-sm);
  font-size: var(--top-fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--top-transition);
}

.top-empty-state__retry:hover { background: var(--top-color-primary-dark); }

/* Error type — red tint */
.top-empty-state--error {
  border-color: #f5c6c6;
  background: #fff5f5;
}

/* =============================================================================
   11. Reduced motion
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
  .top-hotel-box,
  .top-destination-box,
  .top-hotel-box__image,
  .top-destination-box__image,
  .top-skeleton,
  .top-hotel-box__cta {
    transition: none;
    animation: none;
  }
}

/* =============================================================================
   12. High-contrast mode
   ============================================================================= */

@media (forced-colors: active) {
  .top-hotel-box,
  .top-destination-box {
    border: 2px solid ButtonText;
  }

  .top-hotel-box__cta {
    background: ButtonFace;
    color: ButtonText;
    border: 2px solid ButtonText;
  }

  .top-badge,
  .top-rating__score {
    border: 1px solid ButtonText;
  }
}

/* =============================================================================
   13. Hotel Box — redesigned card elements
   ============================================================================= */

/* ── Meta row: destination (left) + rating badge (right) ── */

.top-hotel-box__meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--top-gap-xs);
  min-height: 1.4em; /* prevents layout shift when one side is absent */
}

.top-hotel-box__destination {
  font-size: var(--top-fs-xs);
  color: var(--top-color-destination);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

/* ── Rating badge — X.X/6 scale ── */

.top-rating-badge {
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0.18em 0.45em;
  border-radius: 2px;
  font-size: var(--top-fs-sm);
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}

/*.top-rating-badge__denom {*/
/*  font-size: 0.72em;*/
/*  font-weight: 400;*/
/*  opacity: 0.72;*/
/*}*/

.top-rating-badge--excellent { background: var(--top-color-excellent); }
.top-rating-badge--good      { background: var(--top-color-excellent);  }
.top-rating-badge--fair      { background: var(--top-color-excellent);  }
.top-rating-badge--poor      { background: var(--top-color-excellent);  }

/* ── Info row: date | duration | board type ── */

.top-hotel-box__info-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3em;
  font-size: var(--top-fs-xs);
  color: var(--top-color-text-muted);
  margin-block-start: auto; /* pushes row to bottom of body */
}

.top-hotel-box__info-sep {
  color: var(--top-color-border);
  user-select: none;
  font-weight: 300;
}

.top-hotel-box__info-item {
  white-space: nowrap;
}

/* ── Footer: price-wrap is flex row now (price + travelers inline) ── */

.top-hotel-box__price-wrap {
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  flex-wrap: wrap;
  gap: 0.25em;
  min-width: 0;
  margin-inline-start: auto;
}

.top-hotel-box__travelers {
  font-size: var(--top-fs-xs);
  color: var(--top-color-text-muted);
  white-space: nowrap;
}

/* ── Price component adjustments inside card ── */

.top-hotel-box .top-price {
  font-size: var(--top-fs-lg);
  font-weight: 700;
  color: var(--top-color-text);
  white-space: nowrap;
}

.top-hotel-box .top-price__from {
  font-size: var(--top-fs-xs);
  font-weight: 400;
  color: var(--top-color-text-muted);
}

/* ── CTA arrow update ── */

.top-hotel-box__cta-arrow {
  transition: transform var(--top-transition);
  font-style: normal;
}

/* =============================================================================
   14. Offer Slider
   ============================================================================= */

.top-offer-slider {
  position: relative;
  overflow: hidden;
  width: 100%;
}

/* Viewport clips the scrollable track */
.top-offer-slider__viewport {
  overflow: hidden;
  width: 100%;
}

/* Track — horizontal flex strip, animated via transform */
.top-offer-slider__track {
  display: flex;
  gap: 16px;
  align-items: stretch;
  padding-bottom: 20px;
  transition: transform 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

/* ── Slide: fixed width matching destination-box ── */
.top-offer-slider__slide {
  flex: 0 0 300px;
  width: 300px;
  min-width: 0;
}

/* No hover lift inside slider */
.top-offer-slider__slide .top-destination-box:hover,
.top-offer-slider__slide .top-destination-box:focus-within,
.top-offer-slider__slide .top-hotel-box:hover,
.top-offer-slider__slide .top-hotel-box:focus-within {
  transform: none;
}

/* ── Stage (viewport + side arrows) ── */

.top-offer-slider__stage {
  position: relative;
  display: flex;
  align-items: center;
}

.top-offer-slider__stage .top-offer-slider__viewport {
  flex: 1 1 0;
  min-width: 0;
}

/* ── Controls bar (dots only) ── */

.top-offer-slider__controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: var(--top-gap-sm);
  margin-top: var(--top-gap);
}

/* ── Arrow buttons ── */

.top-offer-slider__arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--top-color-border);
  background: var(--top-color-bg);
  color: var(--top-color-text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition:
    border-color var(--top-transition),
    background var(--top-transition),
    color var(--top-transition);
}

.top-offer-slider__arrow:hover:not(:disabled) {
  border-color: var(--top-color-primary);
  color: var(--top-color-primary);
  background: var(--top-color-surface);
}

.top-offer-slider__arrow:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ── Dots container ── */

.top-offer-slider__dots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ── Individual dot ── */

.top-offer-slider__dot {
  display: block;
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--top-color-border);
  cursor: pointer;
  transition: background var(--top-transition);
  flex-shrink: 0;
}

.top-offer-slider__dot--active {
  background: var(--top-color-primary);
}

.top-offer-slider__dot:hover:not(.top-offer-slider__dot--active) {
  background: var(--top-color-text-muted);
}

/* ── Reduced motion ── */

@media (prefers-reduced-motion: reduce) {
  .top-offer-slider__track {
    transition: none;
  }
  .top-offer-slider__dot {
    transition: none;
  }
}
