.preloader {
  display: none !important;
}

:root {
  --wtf-bg: #130d0e;
  --wtf-text: #ffffff;
  --wtf-primary: #d1b986; /* accent color (matches TheFork's button color) */
  --wtf-primary-hover: #b8ab8e; /* accent color on hover (TheFork) */
}

.widget-tf {
  position: fixed;
  right: 2rem;
  bottom: 2rem;
  width: 385px;
  z-index: 2147483647;
  max-height: calc(100% - 4rem);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 4px;
  box-shadow: rgba(255, 255, 255, 0.12) 0 0 0 1px inset;
  font-weight: 400;
  font-family: "Poppins", sans-serif;
  text-rendering: geometricPrecision;
  /* visibility flips only after the slide-out animation finishes */
  transition:
    transform 0.2s ease-in-out,
    visibility 0s 0.2s;
  background-color: var(--wtf-bg);
  color: var(--wtf-text);
  overflow: hidden;
  /* Off-screen by default (below the viewport) and unreachable by Tab/screen readers */
  transform: translateY(calc(100% + 4rem));
  visibility: hidden;
  pointer-events: none;
}

/* Force Poppins on form fields too (input/button don't inherit font automatically) */
.widget-tf * {
  font-family: inherit;
}

/* No browser outline on mouse clicks; keyboard focus gets its own ring below */
.widget-tf :focus,
#widget-tf-launcher:focus {
  outline: none;
  box-shadow: none;
}

/* Visible focus ring for keyboard navigation */
.widget-tf :focus-visible,
#widget-tf-launcher:focus-visible {
  outline: 2px solid var(--wtf-primary);
  outline-offset: 2px;
}

/* The search field already has its own focus indicator (gold border color) */
#widget-tf-search:focus-visible {
  outline: none;
}

/* List items: inset ring, otherwise the scrolling list clips it */
.widget-tf .widget-tf-select:focus-visible {
  outline-offset: -2px;
}

.widget-tf.is-open {
  transform: translateY(0);
  visibility: visible;
  transition:
    transform 0.2s ease-in-out,
    visibility 0s;
  pointer-events: auto;
}

/* Header: title left, close button right */
#widget-tf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

#widget-tf-heading {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

#widget-tf-logo {
  width: 1.4rem;
  height: 1.4rem;
  flex-shrink: 0;
  color: var(--wtf-text);
}

#widget-tf-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--wtf-text);
  letter-spacing: 0.01em;
}

/* Close button using FontAwesome xmark (thin) as inline SVG */
#widget-tf-close {
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--wtf-text);
  padding: 0;
  line-height: 0;
  flex-shrink: 0;
  transition: color 200ms;
}

#widget-tf-close:hover,
#widget-tf-close:focus {
  color: var(--wtf-primary);
}

#widget-tf-close svg {
  width: 1rem;
  height: 1rem;
  display: block;
}

/* Content: search field + locate + list */
#widget-tf-main {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1;
  min-height: 0;
}

#widget-tf-search-label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

#widget-tf-search {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.85rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--wtf-text);
  font-size: 0.95rem;
}

#widget-tf-search::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

#widget-tf-search:focus {
  border-color: var(--wtf-primary);
  outline: none;
}

/* iOS auto-zooms on focus for inputs < 16px; keep at least 16px on mobile. */
@media (max-width: 768px) {
  #widget-tf-search {
    font-size: 16px;
  }
}

/* "My location": secondary button with icon */
#widget-tf-locate {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  align-self: flex-start;
  padding: 0.5rem 0.85rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: var(--wtf-primary);
  cursor: pointer;
  font-size: 0.85rem;
}

#widget-tf-locate svg {
  width: 0.85rem;
  height: 0.85rem;
}

#widget-tf-locate:hover,
#widget-tf-locate:focus {
  border-color: var(--wtf-primary);
  background: rgba(209, 185, 134, 0.1);
  outline: none;
}

#widget-tf-status {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
}

/* Restaurant list (the only scrolling element) */
#widget-tf-list {
  /* One item ≈ 2.635rem (1.4rem padding + ~1.235rem line height); 7 full items + half 8th + 7px borders */
  --wtf-item-h: 2.635rem;
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-height: calc(var(--wtf-item-h) * 6.75 + 7px);
  overflow-y: auto;
}

/* Show fewer items on mobile so the widget doesn't fill nearly the whole viewport */
@media (max-width: 768px) {
  #widget-tf-list {
    max-height: calc(var(--wtf-item-h) * 4.75 + 7px);
  }
}

/* Bottom fade to signal the list scrolls further.
   Only active while items remain below the visible edge (see main.js). */
#widget-tf-list.is-fade-bottom {
  -webkit-mask-image: linear-gradient(
    to bottom,
    #000 calc(100% - 2.5rem),
    transparent
  );
  mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5rem), transparent);
}

#widget-tf-list li + li {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#widget-tf-list::-webkit-scrollbar {
  width: 6px;
}

#widget-tf-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.widget-tf-select {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 4px;
  padding: 0.7rem 0.75rem;
  color: var(--wtf-text);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.3;
  transition: background-color 200ms;
}

.widget-tf-select:hover,
.widget-tf-select:focus {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.widget-tf-select .distance {
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Iframe view */
#widget-tf-frame-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#widget-tf-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  align-self: flex-start;
  padding: 0.4rem 0;
  border: 0;
  background: transparent;
  color: var(--wtf-primary);
  cursor: pointer;
  font-size: 0.9rem;
}

#widget-tf-back svg {
  width: 0.85rem;
  height: 0.85rem;
}

#widget-tf-back:hover,
#widget-tf-back:focus {
  text-decoration: underline;
  outline: none;
}

#widget-tf-frame-inner {
  position: relative;
}

#widget-tf-frame {
  width: 100%;
  height: min(600px, 65vh);
  border: 0;
  border-radius: 4px;
  display: block;
  background: var(--wtf-bg);
  opacity: 1;
  transition: opacity 250ms ease;
}

/* While loading: hide the iframe and show the spinner (loading flash blends into the dark widget) */
#widget-tf-frame-inner.is-loading #widget-tf-frame {
  opacity: 0;
}

#widget-tf-spinner {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--wtf-bg);
  border-radius: 4px;
}

#widget-tf-frame-inner.is-loading #widget-tf-spinner {
  display: flex;
}

#widget-tf-spinner::before {
  content: "";
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--wtf-primary);
  animation: widget-tf-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  #widget-tf-spinner::before {
    animation-duration: 2s;
  }
  #widget-tf-frame {
    transition: none;
  }
}

/* Floating CTA in TheFork style (full-width omitted: this is a fixed button) */
#widget-tf-launcher {
  position: fixed;
  right: 2rem;
  bottom: 2rem;
  z-index: 2147483646;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  padding: 0.75rem 1.5rem;
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.375;
  text-rendering: geometricPrecision;
  border-radius: 4px;
  background-color: var(--wtf-primary);
  color: #000;
  box-shadow: transparent 0 0 0 1px inset;
  transition:
    background-color 250ms,
    box-shadow 250ms,
    color 250ms;
}

#widget-tf-launcher svg {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

#widget-tf-launcher:hover,
#widget-tf-launcher:focus {
  background-color: var(--wtf-primary-hover);
  color: #000;
  text-decoration: underline transparent;
  outline: none;
}

/* Mobile: prevent overflow on narrow screens */
@media (max-width: 480px) {
  .widget-tf {
    right: 1rem;
    bottom: 1rem;
    width: calc(100vw - 2rem);
    max-height: calc(100% - 2rem);
  }

  #widget-tf-launcher {
    right: 1rem;
    bottom: 1rem;
  }
}
