/* ============================================================
   TaleFin Shared Components
   Header / nav, footer, and contact panel.
   Loads after tokens.css + base.css.
   ============================================================ */

/* ---------------------------------------------------------- */
/* HEADER + NAV                                                */
/* ---------------------------------------------------------- */
.tf-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(150%) blur(8px);
  border-bottom: 1px solid var(--tf-line);
}
.tf-header__bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--tf-space-6);
  height: 72px;
}
.tf-header__brand { display: inline-flex; align-items: center; flex: 0 0 auto; }
.tf-header__brand img { height: 30px; width: auto; }

.tf-nav { display: flex; align-items: center; gap: var(--tf-space-2); }
.tf-nav__list { display: flex; align-items: center; gap: var(--tf-space-1);
  list-style: none; margin: 0; padding: 0; }
.tf-nav__item { position: relative; }
.tf-nav__link {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-family: var(--tf-font-body); font-size: 0.95rem; color: var(--tf-ink);
  padding: 0.6rem 0.8rem; border-radius: var(--tf-radius-sm);
  text-decoration: none; white-space: nowrap; cursor: pointer; background: none; border: 0;
}
.tf-nav__link:hover, .tf-nav__item:hover > .tf-nav__link { background: var(--tf-plum-050); color: var(--tf-plum); text-decoration: none; }
.tf-nav__link[aria-current="page"] { color: var(--tf-plum); font-weight: 500; }
.tf-nav__caret { width: 10px; height: 10px; transition: transform var(--tf-dur-fast) var(--tf-ease); }
.tf-nav__item:hover .tf-nav__caret, .tf-nav__item:focus-within .tf-nav__caret { transform: rotate(180deg); }

/* Dropdowns */
.tf-nav__menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 250px; z-index: 10;
  background: #fff; border: 1px solid var(--tf-line); border-radius: var(--tf-radius);
  box-shadow: var(--tf-shadow); padding: var(--tf-space-2);
  list-style: none; margin: 0; opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: opacity var(--tf-dur-fast) var(--tf-ease), transform var(--tf-dur-fast) var(--tf-ease), visibility var(--tf-dur-fast);
}
.tf-nav__item:hover > .tf-nav__menu, .tf-nav__item:focus-within > .tf-nav__menu { opacity: 1; visibility: visible; transform: none; }
.tf-nav__menu a { display: block; padding: 0.6rem 0.8rem; border-radius: var(--tf-radius-sm);
  color: var(--tf-body); font-size: 0.92rem; text-decoration: none; }
.tf-nav__menu a:hover { background: var(--tf-plum-050); color: var(--tf-plum); }

.tf-header__cta { display: flex; align-items: center; gap: var(--tf-space-3); flex: 0 0 auto; }

/* Hamburger */
.tf-burger { display: none; flex-direction: column; gap: 5px; width: 44px; height: 44px;
  align-items: center; justify-content: center; background: none; border: 0; cursor: pointer; border-radius: var(--tf-radius-sm); }
.tf-burger span { width: 24px; height: 2px; background: var(--tf-ink); transition: transform var(--tf-dur) var(--tf-ease), opacity var(--tf-dur); }
.tf-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.tf-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.tf-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Mobile nav ---- */
@media (max-width: 1024px) {
  /* Solid header on mobile. A backdrop-filter both (a) makes the sticky header
     flicker/vanish on iOS Safari and (b) becomes the containing block for the
     fixed nav panel, collapsing it. Use an opaque background here instead. */
  .tf-header { background: var(--tf-surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .tf-burger { display: flex; }
  .tf-nav {
    position: fixed; inset: 72px 0 0 0; background: #fff;
    flex-direction: column; align-items: stretch; gap: 0;
    padding: var(--tf-space-4) var(--tf-gutter) var(--tf-space-16);
    overflow-y: auto; transform: translateX(100%);
    transition: transform var(--tf-dur) var(--tf-ease);
    border-top: 1px solid var(--tf-line);
  }
  .tf-nav.is-open { transform: none; }
  .tf-nav__list { flex-direction: column; align-items: stretch; gap: 0; width: 100%; }
  .tf-nav__item { border-bottom: 1px solid var(--tf-line); }
  .tf-nav__link { width: 100%; justify-content: space-between; padding: 0.9rem 0.4rem; font-size: 1.05rem; }
  .tf-nav__menu {
    position: static; opacity: 1; visibility: visible; transform: none; box-shadow: none;
    border: 0; border-radius: 0; padding: 0 0 var(--tf-space-3) var(--tf-space-4);
    max-height: 0; overflow: hidden; transition: max-height var(--tf-dur) var(--tf-ease);
  }
  .tf-nav__item.is-expanded > .tf-nav__menu { max-height: 600px; }
  .tf-header__cta .tf-btn { margin-top: var(--tf-space-4); }
}
body.tf-nav-lock { overflow: hidden; }

/* ---------------------------------------------------------- */
/* CONTACT PANEL                                               */
/* ---------------------------------------------------------- */
.tf-contact { background: var(--tf-plum); color: #fff; }
.tf-contact__grid { display: grid; gap: var(--tf-space-12); align-items: start; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 880px) { .tf-contact__grid { grid-template-columns: 0.85fr 1.15fr; } }
.tf-contact h2 { color: #fff; }
.tf-contact__intro { color: rgba(255,255,255,0.85); }
.tf-contact__details { list-style: none; padding: 0; margin: var(--tf-space-8) 0 0; }
.tf-contact__details li { display: flex; align-items: center; gap: var(--tf-space-3); margin-bottom: var(--tf-space-4); }
.tf-contact__details a { color: #fff; text-decoration: none; }
.tf-contact__details a:hover { text-decoration: underline; color: var(--tf-green); }
.tf-contact__icon { width: 22px; height: 22px; flex: 0 0 auto; color: var(--tf-green); }

.tf-form { background: #fff; border-radius: var(--tf-radius-lg); padding: clamp(1.5rem, 3vw, 2.5rem); box-shadow: var(--tf-shadow-lg); }
.tf-field { margin-bottom: var(--tf-space-4); }
.tf-field label { display: block; font-size: var(--tf-fs-small); color: var(--tf-ink); margin-bottom: 0.35rem; }
.tf-field .req { color: var(--tf-peach); }
.tf-field input, .tf-field textarea {
  width: 100%; font-family: var(--tf-font-body); font-size: 1rem; color: var(--tf-ink);
  padding: 0.8rem 0.9rem; border: 1.5px solid var(--tf-line); border-radius: var(--tf-radius-sm);
  background: #fff; transition: border-color var(--tf-dur-fast) var(--tf-ease);
}
.tf-field input:focus, .tf-field textarea:focus { outline: none; border-color: var(--tf-blue); }
.tf-field textarea { min-height: 120px; resize: vertical; }
.tf-field--invalid input, .tf-field--invalid textarea { border-color: var(--tf-error); }
.tf-field__error { display: none; color: var(--tf-error); font-size: var(--tf-fs-small); margin-top: 0.3rem; }
.tf-field--invalid .tf-field__error { display: block; }
.tf-form__row { display: grid; gap: var(--tf-space-4); }
@media (min-width: 560px) { .tf-form__row { grid-template-columns: 1fr 1fr; } }
.tf-form__hint { font-size: var(--tf-fs-small); color: var(--tf-muted); margin: -0.25rem 0 var(--tf-space-4); }
.tf-form__recaptcha { margin: var(--tf-space-4) 0; }
/* reCAPTCHA renders a fixed 302px-wide iframe that otherwise pushes the whole
   form wider than a narrow phone. Clip the container (so it can never force the
   page wider than the device) and scale the widget down so it stays usable. */
@media (max-width: 480px) {
  .tf-form { padding: 1.4rem; }
  .tf-form__recaptcha { overflow: hidden; height: 66px; }
  .tf-form__recaptcha .g-recaptcha { transform: scale(0.85); transform-origin: left top; }
}
@media (max-width: 360px) {
  .tf-form__recaptcha { height: 60px; }
  .tf-form__recaptcha .g-recaptcha { transform: scale(0.78); }
}
.tf-form__status { margin-top: var(--tf-space-4); font-size: var(--tf-fs-small); border-radius: var(--tf-radius-sm); padding: 0.75rem 1rem; display: none; }
.tf-form__status.is-success { display: block; background: #e8f6f1; color: var(--tf-success); }
.tf-form__status.is-error { display: block; background: #fbeae8; color: var(--tf-error); }
.tf-form button[type="submit"] { width: 100%; justify-content: center; }
.tf-form button[disabled] { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ---------------------------------------------------------- */
/* FOOTER                                                      */
/* ---------------------------------------------------------- */
.tf-footer { background: var(--tf-plum-900); color: rgba(255,255,255,0.78); padding-block: var(--tf-space-24) var(--tf-space-12); }
.tf-footer a { color: rgba(255,255,255,0.78); text-decoration: none; }
.tf-footer a:hover { color: #fff; text-decoration: underline; }
/* Roomier tap targets for the dense footer link lists on mobile (Lighthouse SEO) */
@media (max-width: 768px) { .tf-footer li a { display: inline-block; padding-block: 6px; } }
.tf-footer__top { display: grid; gap: var(--tf-space-12); }
@media (min-width: 880px) { .tf-footer__top { grid-template-columns: 1.2fr 2fr; } }
.tf-footer__brand img { height: 34px; width: auto; margin-bottom: var(--tf-space-6); }
.tf-footer__tagline { max-width: 32ch; color: rgba(255,255,255,0.7); }

.tf-footer__badges { display: flex; flex-wrap: wrap; gap: var(--tf-space-3); margin-top: var(--tf-space-8); }
.tf-badge {
  display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.8rem;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.14);
  border-radius: var(--tf-radius-sm); font-size: 0.78rem; line-height: 1.15; color: #fff;
}
.tf-badge b { display: block; font-family: var(--tf-font-head); font-weight: 500; font-size: 0.8rem; }
.tf-badge span { color: rgba(255,255,255,0.6); }

.tf-sitemap { display: grid; grid-template-columns: repeat(2,1fr); gap: var(--tf-space-8); }
@media (min-width: 620px) { .tf-sitemap { grid-template-columns: repeat(4,1fr); } }
.tf-sitemap h4 { font-family: var(--tf-font-head); font-weight: 500; color: #fff; font-size: 0.95rem; margin-bottom: var(--tf-space-3); }
.tf-sitemap ul { list-style: none; padding: 0; margin: 0; }
.tf-sitemap li { margin-bottom: var(--tf-space-2); }
.tf-sitemap a { font-size: 0.88rem; }

.tf-footer__bottom { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--tf-space-4); margin-top: 0; padding-top: var(--tf-space-8);
  border-top: 1px solid rgba(255,255,255,0.14); font-size: var(--tf-fs-small); }
.tf-social { display: flex; gap: var(--tf-space-3); }
.tf-social a { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center;
  border-radius: 50%; background: rgba(255,255,255,0.08); }
.tf-social a:hover { background: var(--tf-plum); }
.tf-social svg { width: 21px; height: 21px; color: #fff; }
.tf-footer__end { display: flex; align-items: center; gap: var(--tf-space-8); flex-wrap: wrap; }
.tf-member { height: 40px; width: auto; display: block; }

/* ============================================================
   Animation layer (Phase 7)
   ============================================================ */

/* Header gains a shadow once the page is scrolled */
.tf-header { transition: box-shadow var(--tf-dur) var(--tf-ease), background var(--tf-dur) var(--tf-ease); }
.tf-header.is-scrolled { box-shadow: 0 6px 24px rgba(74,26,63,0.10); }

/* Animated underline on nav links */
.tf-nav__link { position: relative; }
.tf-nav__link::after {
  content: ""; position: absolute; left: 0.8rem; right: 0.8rem; bottom: 0.35rem; height: 2px;
  background: var(--tf-plum); border-radius: 2px; transform: scaleX(0); transform-origin: left;
  transition: transform var(--tf-dur) var(--tf-ease);
}
.tf-nav__item:hover > .tf-nav__link::after,
.tf-nav__link[aria-current="page"]::after { transform: scaleX(1); }
@media (max-width: 1024px) { .tf-nav__link::after { display: none; } }

/* Button shine sweep on hover */
.tf-btn { position: relative; overflow: hidden; }
.tf-btn::after {
  content: ""; position: absolute; top: 0; left: -150%; width: 55%; height: 100%;
  transform: skewX(-20deg); background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
  transition: left 0.6s var(--tf-ease); pointer-events: none;
}
.tf-btn:hover::after { left: 160%; }

/* "Trusted by" logo marquee */
.tf-marquee { overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
.tf-marquee__track { display: flex; gap: var(--tf-space-8); width: max-content; align-items: center;
  animation: tfMarquee 30s linear infinite; }
.tf-marquee:hover .tf-marquee__track { animation-play-state: paused; }
@keyframes tfMarquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

@media (prefers-reduced-motion: reduce) {
  .tf-btn::after { display: none; }
  .tf-marquee__track { animation: none; flex-wrap: wrap; justify-content: center; width: auto; }
  .tf-marquee { -webkit-mask-image: none; mask-image: none; }
}

/* Accreditation badge chips (footer) — white tiles so marks read on any background */
.tf-footer__badges { display: flex; flex-wrap: wrap; gap: var(--tf-space-3); margin-top: var(--tf-space-8); }
.tf-badgelogo { display: inline-flex; align-items: center; justify-content: center;
  background: #fff; border-radius: 10px; padding: 8px 12px; height: 60px; box-shadow: var(--tf-shadow-sm); }
.tf-badgelogo img { height: 100%; max-height: 44px; width: auto; max-width: 132px; object-fit: contain; display: block; }

/* Footer badge alignment fix — uniform white tiles, larger for legibility */
.tf-footer__badges { display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-top: var(--tf-space-8); padding-top: var(--tf-space-8); padding-bottom: var(--tf-space-8); border-top: 1px solid rgba(255,255,255,0.14); }
.tf-badgelogo { width: 150px; height: 84px; background: #fff; border-radius: 12px; padding: 10px;
  display: flex; align-items: center; justify-content: center; box-shadow: var(--tf-shadow-sm); }
.tf-badgelogo img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block; }

/* Larger footer badge tiles */
.tf-badgelogo { width: 168px; height: 96px; }

/* Landscape footer badge tiles (suit CDR-style lockups) */
.tf-badgelogo { width: 232px; height: 88px; }

/* Footer badge tiles — sized for readable descriptor text */
.tf-badgelogo { width: 264px; height: 92px; padding: 10px 14px; }

/* Footer badge images must not inherit the brand-logo bottom margin */
.tf-footer__brand .tf-badgelogo img { margin-bottom: 0; }

/* ---- Flip cards: legacy-bureau problem -> TaleFin fix (signature interaction) ---- */
.tf-flip { perspective: 1200px; cursor: pointer; outline: none; }
.tf-flip__inner { position: relative; width: 100%; height: 100%; min-height: inherit;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1); transform-style: preserve-3d; }
.tf-flip.is-flipped .tf-flip__inner { transform: rotateY(180deg); }
/* Hover-to-flip only on hover-capable pointers (desktop). On touch this would
   stick after the first tap and stop the card flipping back. */
@media (hover: hover) {
  .tf-flip:hover .tf-flip__inner { transform: rotateY(180deg); }
}
.tf-flip:focus-visible { box-shadow: 0 0 0 3px var(--tf-focus-ring); border-radius: var(--tf-radius); }
.tf-flip__face { position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden;
  display: flex; flex-direction: column; }
.tf-flip__face--back { transform: rotateY(180deg); }

/* Home trust-panel problem cards rendered as flip cards */
.hm-card.hm-card--flip { background: transparent; border: 0; padding: 0; min-height: 248px; }
.hm-card--flip .tf-flip__face { background: #fff; border: 1px solid var(--tf-line);
  border-radius: var(--tf-radius); padding: var(--tf-space-8); }
.hm-card--flip .tf-flip__face--back { background: var(--tf-plum); border-color: var(--tf-plum); justify-content: center; }
.hm-card--flip .tf-flip__face--back h3 { color: #fff; }
.hm-card--flip .tf-flip__face--back p { color: rgba(255,255,255,0.9); }
.hm-card--flip .ico { flex-shrink: 0; }
.hm-card--flip .tf-flip__face h3 { font-size: 1.2rem; line-height: 1.2; }
.hm-fix__tag { font-size: var(--tf-fs-eyebrow); font-weight: 500; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--tf-green); margin-bottom: var(--tf-space-2);
  display: inline-flex; align-items: center; gap: 0.4rem; }
.hm-flip__hint { display: block; max-width: none; text-align: center; margin-top: var(--tf-space-8);
  font-size: var(--tf-fs-small); color: var(--tf-muted); }

@media (prefers-reduced-motion: reduce) {
  .tf-flip__inner { transition: none; }
}
