/* TFM Search — "Laterne" (php/tfm-search.php, js/tfm-search.js).
   1. Header search overlay: Blocksy's #search-modal, marked .tfm-so by JS.
   2. Result rows (.tfm-sr), shared by overlay and results page.
   3. Results page: body.tfm-search-page, Elementor template "Search Results"
      with [tfm_search_results].
   Mock: docs/mocks/search-laterne-mock.html. Docs: docs/immersion.md section 6.
   The search belongs to no area: it takes the Village gold. */

#search-modal,
.tfm-search-page {
  --tfm-so-gold: #d4a843; --tfm-so-gold-soft: #e8c97a; --tfm-so-rgb: 212, 168, 67;
  --tfm-c-village: #d4a843; --tfm-c-academy: #5ab87a; --tfm-c-square: #40d9b0; --tfm-c-training: #cc3355;
  --tfm-c-none: var(--muted, #b6afc7);
}

/* ── 1. Overlay ── */
#search-modal.tfm-so { background: rgba(8, 5, 14, .94) !important; backdrop-filter: blur(6px); overflow-x: hidden; }
/* the lantern's light from above */
#search-modal.tfm-so::before {
  content: ""; position: absolute; left: 50%; top: -260px; width: 900px; height: 700px; margin-left: -450px; pointer-events: none; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, rgba(255, 196, 110, .16), rgba(var(--tfm-so-rgb), .05) 40%, transparent 68%);
  opacity: .55; transition: opacity .6s ease;
}
#search-modal.tfm-so.tfm-so--lit::before { opacity: 1; }
#search-modal.tfm-so .ct-panel-content { position: relative; justify-content: flex-start !important; align-items: center; padding-top: 12vh; overflow-y: auto; }
#search-modal.tfm-so .ct-panel-content > * { width: min(620px, calc(100vw - 36px)); max-width: none; }
#search-modal.tfm-so .ct-toggle-close { border: 1px solid rgba(255, 255, 255, .18) !important; border-radius: 50% !important; color: var(--muted, #b6afc7) !important; }
#search-modal.tfm-so .ct-toggle-close:hover { border-color: var(--tfm-so-gold) !important; color: var(--ink, #f6f1ea) !important; }
#search-modal.tfm-so .ct-toggle-close svg { fill: currentColor !important; }

.tfm-so-head { text-align: center; }
.tfm-so-lantern { position: relative; width: 34px; height: 58px; margin: 0 auto 14px; }
.tfm-so-lantern i { position: absolute; display: block; }
.tfm-so-lantern__hook { left: 50%; top: 0; width: 1px; height: 12px; background: rgba(var(--tfm-so-rgb), .6); }
.tfm-so-lantern__cap { left: 7px; top: 12px; width: 20px; height: 6px; border-radius: 6px 6px 0 0; background: #6a5326; }
.tfm-so-lantern__glass {
  left: 5px; top: 18px; width: 24px; height: 30px; border-radius: 6px; border: 1px solid rgba(var(--tfm-so-rgb), .7);
  background: radial-gradient(circle at 50% 60%, rgba(255, 230, 170, .9), rgba(255, 180, 90, .35) 45%, rgba(40, 25, 10, .6) 75%);
  box-shadow: 0 0 22px 4px rgba(255, 190, 100, .25); filter: brightness(.75); transition: box-shadow .5s ease, filter .5s ease;
}
.tfm-so-lantern__base { left: 8px; top: 48px; width: 18px; height: 4px; border-radius: 0 0 4px 4px; background: #6a5326; }
.tfm-so--lit .tfm-so-lantern__glass { filter: brightness(1.1); box-shadow: 0 0 40px 10px rgba(255, 190, 100, .4); animation: tfmSoFlicker 3.4s ease-in-out infinite; }
.tfm-so--loading .tfm-so-lantern__glass { animation: tfmSoPulse 1s ease-in-out infinite; }
@keyframes tfmSoFlicker { 0%, 100% { opacity: 1; } 40% { opacity: .9; } 60% { opacity: .97; } }
@keyframes tfmSoPulse { 50% { filter: brightness(1.3); box-shadow: 0 0 50px 14px rgba(255, 190, 100, .45); } }

.tfm-so-ask {
  margin: 0 0 22px !important; font-family: "Cormorant Garamond", Georgia, serif; font-style: italic; font-weight: 400;
  font-size: clamp(1.9rem, 5vw, 2.6rem); line-height: 1.1; color: var(--ink, #f6f1ea); text-shadow: 0 0 24px rgba(255, 190, 100, .2);
}

/* the field: a dashed line instead of Blocksy's box */
#search-modal.tfm-so .ct-search-form { --theme-form-field-border-width: 0; }
#search-modal.tfm-so .ct-search-form-inner {
  display: flex !important; align-items: center; gap: 12px; background: transparent !important; border: 0 !important; border-radius: 0 !important;
  border-bottom: 1px dashed rgba(var(--tfm-so-rgb), .55) !important; box-shadow: none !important; padding: 6px 2px; transition: border-color .3s, box-shadow .3s;
}
#search-modal.tfm-so .ct-search-form-inner::before, #search-modal.tfm-so .ct-search-form-inner::after { display: none !important; }
#search-modal.tfm-so .ct-search-form-inner:focus-within { border-bottom-color: var(--tfm-so-gold) !important; box-shadow: 0 10px 18px -14px rgba(255, 190, 100, .9) !important; }
#search-modal.tfm-so input.modal-field {
  flex: 1; min-width: 0; height: auto !important; padding: 6px 0 !important; background: transparent !important; border: 0 !important; outline: 0 !important; box-shadow: none !important;
  font-family: "Cormorant Garamond", Georgia, serif !important; font-style: italic !important; font-size: 1.5rem !important; color: var(--ink, #f6f1ea) !important; text-align: left !important;
}
#search-modal.tfm-so input.modal-field::placeholder { color: rgba(182, 175, 199, .5) !important; }
#search-modal.tfm-so .ct-search-form button[type="submit"] {
  position: static !important; width: auto !important; height: auto !important; min-width: 0 !important; padding: 4px 6px !important; inset: auto !important;
  background: transparent !important; border: 0 !important; box-shadow: none !important; color: var(--tfm-so-gold-soft) !important; transform: none !important;
}
#search-modal.tfm-so .ct-search-form button[type="submit"] .ct-icon { display: none !important; }
/* Blocksy keeps its own ::before on this button hidden (display none, opacity 0) */
#search-modal.tfm-so .ct-search-form button[type="submit"]::before {
  content: "✦" !important; display: block !important; position: static !important; opacity: 1 !important; inset: auto !important;
  width: auto !important; height: auto !important; background: none !important; border: 0 !important; font-size: 1.3rem; line-height: 1; color: inherit;
}
#search-modal.tfm-so .ct-search-form button[type="submit"] .ct-ajax-loader { display: none !important; }
/* Blocksy's own live results: switched off by JS, hidden here in case they still come */
#search-modal.tfm-so .ct-search-results { display: none !important; }

.tfm-so-hint {
  margin: 10px 0 0 !important; text-align: center; font-family: Jost, sans-serif; font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(182, 175, 199, .6);
}
.tfm-so-out { padding-bottom: 60px; }
@media (max-width: 767px), (hover: none) {
  .tfm-so-hint { display: none !important; }
  #search-modal.tfm-so .ct-panel-content { padding-top: 8vh; }
}

/* ── 2. Result rows ── */
.tfm-sr-list { list-style: none !important; margin: 22px 0 0 !important; padding: 0 !important; }
.tfm-sr { --c: var(--tfm-c-none); margin: 0 !important; padding: 0 !important; opacity: 0; transform: translateY(6px); animation: tfmSrIn .45s ease forwards; }
.tfm-sr + .tfm-sr { margin-top: 2px !important; }
@keyframes tfmSrIn { to { opacity: 1; transform: none; } }
.tfm-sr[data-area="village"] { --c: var(--tfm-c-village); }
.tfm-sr[data-area="academy"] { --c: var(--tfm-c-academy); }
.tfm-sr[data-area="square"] { --c: var(--tfm-c-square); }
.tfm-sr[data-area="training"] { --c: var(--tfm-c-training); }
.tfm-sr__link {
  display: flex !important; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 10px; text-decoration: none !important; color: inherit !important;
  transition: background .25s ease;
}
.tfm-sr__dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--c); box-shadow: 0 0 10px var(--c); }
.tfm-sr[data-area="none"] .tfm-sr__dot { background: transparent; border: 1px solid var(--c); box-shadow: none; }
.tfm-sr__text { min-width: 0; }
.tfm-sr__title { display: block; font-family: "Cormorant Garamond", Georgia, serif; font-size: 1.3rem; line-height: 1.2; color: var(--ink, #f6f1ea); }
.tfm-sr__title mark { background: none; color: inherit; padding: 0; border-bottom: 1px solid rgba(var(--tfm-so-rgb), .6); }
.tfm-sr__meta { display: block; margin-top: 2px; font-family: Jost, sans-serif; font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted, #b6afc7); }
.tfm-sr__meta em { font-style: normal; color: var(--c); opacity: .9; }
.tfm-sr__excerpt { display: block; margin-top: 4px; font-family: "Cormorant Garamond", Georgia, serif; font-style: italic; font-size: 1rem; line-height: 1.4; color: var(--muted, #b6afc7); }
.tfm-sr__resid {
  flex: none; margin-left: 8px; padding: 0 8px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 999px;
  font-family: Jost, sans-serif; font-size: .62rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted, #b6afc7);
}
.tfm-sr__go { margin-left: auto; padding-left: 8px; color: var(--c); opacity: 0; transform: translateX(-6px); transition: .25s ease; }
.tfm-sr__link:hover, .tfm-sr__link:focus-visible, .tfm-sr.is-active .tfm-sr__link { background: linear-gradient(90deg, color-mix(in srgb, var(--c) 16%, transparent), transparent 80%); outline: none; }
.tfm-sr__link:hover .tfm-sr__go, .tfm-sr__link:focus-visible .tfm-sr__go, .tfm-sr.is-active .tfm-sr__go { opacity: 1; transform: none; }

.tfm-sr-resid {
  margin: 18px 0 0 !important; padding: 12px 16px; text-align: center; border: 1px dashed rgba(var(--tfm-so-rgb), .35); border-radius: 12px;
  font-family: "Cormorant Garamond", Georgia, serif; font-style: italic; font-size: 1.1rem; color: var(--muted, #b6afc7);
}
.tfm-sr-resid a, .tfm-sr-more a {
  font-family: Jost, sans-serif; font-style: normal; font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; text-decoration: none !important;
  color: var(--tfm-so-gold-soft) !important; border-bottom: 1px solid rgba(var(--tfm-so-rgb), .4);
}
.tfm-sr-resid a { margin-left: 6px; }
.tfm-sr-more { margin: 18px 0 0 !important; text-align: center; }

.tfm-sr-empty { margin: 26px 0 0; text-align: center; }
.tfm-sr-empty p { margin: 0 0 14px !important; font-family: "Cormorant Garamond", Georgia, serif; font-style: italic; font-size: 1.25rem; color: var(--muted, #b6afc7); }
.tfm-sr-ways { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.tfm-sr-ways a {
  --c: var(--tfm-c-none); padding: 5px 14px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--c) 50%, transparent);
  font-family: Jost, sans-serif; font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; text-decoration: none !important; color: var(--ink, #f6f1ea) !important;
  transition: background .25s ease;
}
.tfm-sr-ways a[data-area="village"] { --c: var(--tfm-c-village); }
.tfm-sr-ways a[data-area="academy"] { --c: var(--tfm-c-academy); }
.tfm-sr-ways a[data-area="square"] { --c: var(--tfm-c-square); }
.tfm-sr-ways a[data-area="training"] { --c: var(--tfm-c-training); }
.tfm-sr-ways a:hover { background: color-mix(in srgb, var(--c) 18%, transparent); }

/* ── 3. Results page ── */
.tfm-search-page .tfm-search-hero { position: relative; isolation: isolate; text-align: center; }
.tfm-search-page .tfm-search-hero::after { content: none; }
.tfm-search-kicker, .tfm-search-kicker * {
  font-family: Jost, sans-serif !important; font-size: .66rem !important; letter-spacing: .3em !important; text-transform: uppercase !important;
  color: var(--tfm-so-gold-soft) !important; opacity: .85;
}
.tfm-search-kicker p { margin: 0; }
.tfm-search-term .elementor-heading-title {
  font-family: "Cormorant Garamond", Georgia, serif !important; font-style: italic !important; font-weight: 400 !important;
  font-size: clamp(2.2rem, 7vw, 3.4rem) !important; line-height: 1.05 !important; color: var(--ink, #f6f1ea) !important;
}
.tfm-search-term .elementor-heading-title::before { content: "“"; }
.tfm-search-term .elementor-heading-title::after { content: "”"; }
.tfm-search-results { position: relative; }
/* the lantern's light, behind the head of the page */
.tfm-search-results::before {
  content: ""; position: absolute; z-index: -1; left: 50%; top: -340px; width: 900px; height: 600px; margin-left: -450px; pointer-events: none; border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, rgba(255, 196, 110, .12), transparent 65%);
}
.tfm-sr-page { position: relative; }
.tfm-sr-count { margin: 0 !important; text-align: center; font-family: "Cormorant Garamond", Georgia, serif; font-style: italic; font-size: 1.1rem; color: var(--muted, #b6afc7); }
.tfm-sr-field {
  display: flex; align-items: center; gap: 12px; max-width: 520px; margin: 18px auto 0; padding: 6px 2px;
  border-bottom: 1px dashed rgba(var(--tfm-so-rgb), .55); transition: border-color .3s, box-shadow .3s;
}
.tfm-sr-field:focus-within { border-bottom-color: var(--tfm-so-gold); box-shadow: 0 10px 18px -14px rgba(255, 190, 100, .9); }
.tfm-sr-field input[type="search"] {
  flex: 1; min-width: 0; height: auto !important; padding: 6px 0 !important; background: transparent !important; border: 0 !important; outline: 0 !important; box-shadow: none !important;
  font-family: "Cormorant Garamond", Georgia, serif !important; font-style: italic !important; font-size: 1.2rem !important; color: var(--ink, #f6f1ea) !important;
}
.tfm-sr-field input[type="search"]::placeholder { color: rgba(182, 175, 199, .5) !important; }
.tfm-sr-field button {
  min-width: 0 !important; padding: 4px 6px !important; background: transparent !important; border: 0 !important; box-shadow: none !important;
  color: var(--tfm-so-gold-soft) !important; font-size: 1.3rem !important; line-height: 1 !important; cursor: pointer;
}
.tfm-sr-page .tfm-sr-list { margin-top: 26px !important; padding-top: 10px !important; border-top: 1px solid rgba(var(--tfm-so-rgb), .14); }
.tfm-sr-page .tfm-sr__link { padding: 16px 14px; }
.tfm-sr-pager { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; margin-top: 26px; }
.tfm-sr-pager .page-numbers {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 1px solid transparent; text-decoration: none !important;
  font-family: "Cormorant Garamond", Georgia, serif; font-size: 1.1rem; color: var(--muted, #b6afc7) !important;
}
.tfm-sr-pager .page-numbers.current { color: var(--ink, #f6f1ea) !important; border-color: rgba(var(--tfm-so-rgb), .6); background: rgba(var(--tfm-so-rgb), .12); }
.tfm-sr-pager a.page-numbers:hover { border-color: rgba(var(--tfm-so-rgb), .4); }
@media (max-width: 767px) {
  .tfm-sr-page .tfm-sr__excerpt { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tfm-sr { animation: none; opacity: 1; transform: none; }
  .tfm-so--lit .tfm-so-lantern__glass, .tfm-so--loading .tfm-so-lantern__glass { animation: none; }
}
