// site/pratique.jsx — Dress code, FAQ (accordion), Témoins, Footer

// ─── Dress code ───────────────────────────────────────────────────
function DressCodeSection() {
  return (
    <Section id="section-dress-code" bg={T.white} washHue={180} washOpacity={0.26} paddingTop={100} paddingBottom={100}>
      <SectionHeader
        eyebrow="Tenue"
        title="Venez comme vous êtes"
        subtitle="Aucun code couleur, aucune règle vestimentaire. Une seule mise en garde, pour le confort de chacun·e."
      />

      <div style={{ display: "grid", gap: 16, gridTemplateColumns: "repeat(auto-fit, minmax(260px, 1fr))" }}>
        <Reveal delay={0}>
          <Card accent={T.or}>
            <div className="eyebrow-small">L'unique conseil</div>
            <div style={{ fontFamily: T.bold, fontWeight: 700, fontSize: 22, marginTop: 8, color: T.ink, lineHeight: 1.15 }}>
              Attention à la pelouse
            </div>
            <div style={{ marginTop: 10, fontFamily: T.sans, fontSize: 14.5, color: T.inkSoft, lineHeight: 1.55 }}>
              La cérémonie laïque et le vin d'honneur se passent sur l'herbe. Les talons aiguilles s'y plantent. Pour le reste, faites-vous plaisir.
            </div>
          </Card>
        </Reveal>
        <Reveal delay={0.1}>
          <Card accent={T.rouge}>
            <div className="eyebrow-small">Pour la soirée</div>
            <div style={{ fontFamily: T.bold, fontWeight: 700, fontSize: 22, marginTop: 8, color: T.ink, lineHeight: 1.15 }}>
              Une petite laine
            </div>
            <div style={{ marginTop: 10, fontFamily: T.sans, fontSize: 14.5, color: T.inkSoft, lineHeight: 1.55 }}>
              La cour intérieure du Château fraîchit après minuit. Un châle, un cardigan, une veste — de quoi danser jusqu'au bout sans grelotter.
            </div>
          </Card>
        </Reveal>
      </div>
    </Section>
  );
}

// ─── FAQ ──────────────────────────────────────────────────────────
// Layout : titre éditorial XL italique à gauche + accordéon à droite.
// Ouverture/fermeture en grid-template-rows pour une hauteur animée fluide.
function FaqSection() {
  const [open, setOpen] = React.useState(0);
  const [headerRef, headerSeen] = useInView();
  return (
    <Section id="section-faq" bg={T.white} washHue={200} washOpacity={0.24} paddingTop={100} paddingBottom={100}>
      <div className="faq-grid" style={{ display: "grid", gridTemplateColumns: "1fr", gap: 36, alignItems: "start" }}>
        {/* Col gauche — titre éditorial */}
        <div ref={headerRef} className="faq-side" style={{ display: "flex", flexDirection: "column" }}>
          <span style={{
            fontFamily: T.mono, fontSize: 11, letterSpacing: 4, textTransform: "uppercase", color: T.orDeep,
            opacity: headerSeen ? 1 : 0, transform: headerSeen ? "translateY(0)" : "translateY(16px)",
            transition: "opacity .55s cubic-bezier(.2,.7,.3,1), transform .55s cubic-bezier(.2,.7,.3,1)",
          }}>F.A.Q.</span>
          <div className="faq-title" style={{
            fontFamily: T.italic, fontStyle: "italic",
            fontSize: "clamp(56px, 9vw, 96px)", color: T.ink,
            letterSpacing: "-2px", lineHeight: 0.92, marginTop: 18,
            opacity: headerSeen ? 1 : 0, transform: headerSeen ? "translateY(0)" : "translateY(16px)",
            transition: "opacity .65s cubic-bezier(.2,.7,.3,1) .1s, transform .65s cubic-bezier(.2,.7,.3,1) .1s",
          }}>
            Tout ce<br/>qu'on n'a<br/>pas&nbsp;dit
          </div>
          <div style={{
            marginTop: 22, fontFamily: T.italic, fontStyle: "italic", fontSize: 16,
            color: T.inkSoft, lineHeight: 1.55, maxWidth: 320,
            opacity: headerSeen ? 1 : 0, transform: headerSeen ? "translateY(0)" : "translateY(16px)",
            transition: "opacity .55s cubic-bezier(.2,.7,.3,1) .2s, transform .55s cubic-bezier(.2,.7,.3,1) .2s",
          }}>
            Si votre question n'apparaît pas ci-contre, écrivez-nous via le RSVP ou demandez à un témoin.
          </div>
          <AppLinkFaqCard />
          <div style={{
            marginTop: 26, display: "flex", alignItems: "center", gap: 12,
            opacity: headerSeen ? 1 : 0,
            transition: "opacity .55s cubic-bezier(.2,.7,.3,1) .35s",
          }}>
            <div style={{
              height: 2, background: T.or,
              width: headerSeen ? 64 : 0,
              transition: "width 1s cubic-bezier(.4,0,.2,1) .4s",
            }} />
            <span style={{ fontFamily: T.mono, fontSize: 10, color: T.orDeep, letterSpacing: 2.5, textTransform: "uppercase" }}>
              {String(DATA.faq.length).padStart(2, "0")} questions
            </span>
          </div>
        </div>

        {/* Col droite — accordéon */}
        <div className="faq-list">
          {DATA.faq.map((item, i) => (
            <Reveal key={i} delay={Math.min(0.05 + i * 0.04, 0.32)}>
              <FaqItem item={item} idx={i} open={open === i} onToggle={() => setOpen(open === i ? null : i)} />
            </Reveal>
          ))}
        </div>
      </div>

      <style>{`
        @media (min-width: 880px) {
          .faq-grid { grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.2fr) !important; gap: 56px !important; }
          .faq-side { position: sticky; top: 80px; }
        }
      `}</style>
    </Section>
  );
}

// Item d'accordéon individuel — hauteur animée via grid-template-rows.
function FaqItem({ item, idx, open, onToggle }) {
  return (
    <div style={{ borderBottom: `1px solid ${T.rule}` }}>
      <button onClick={onToggle} style={{
        width: "100%", textAlign: "left", padding: "18px 0",
        background: "transparent", border: "none", cursor: "pointer",
        display: "flex", justifyContent: "space-between", alignItems: "center", gap: 16,
        fontFamily: T.bold, fontWeight: 600, fontSize: 17, color: T.ink,
      }}>
        <span style={{ display: "flex", alignItems: "baseline", gap: 14 }}>
          <span style={{ fontFamily: T.mono, fontSize: 11, color: T.or, letterSpacing: 1 }}>
            {String(idx + 1).padStart(2, "0")}
          </span>
          <span>{item.q}</span>
        </span>
        <span style={{
          color: T.or, fontSize: 22, fontFamily: T.bold,
          transform: open ? "rotate(45deg)" : "rotate(0deg)",
          transition: "transform .3s cubic-bezier(.2,.7,.3,1)",
          lineHeight: 1, flexShrink: 0,
        }}>+</span>
      </button>
      <div style={{
        display: "grid",
        gridTemplateRows: open ? "1fr" : "0fr",
        transition: "grid-template-rows .4s cubic-bezier(.2,.7,.3,1), opacity .3s ease",
        opacity: open ? 1 : 0.4,
      }}>
        <div style={{ overflow: "hidden" }}>
          <div style={{
            paddingBottom: 18, paddingLeft: 32,
            fontFamily: T.italic, fontStyle: "italic", fontSize: 15.5,
            color: T.inkSoft, lineHeight: 1.6, maxWidth: 640,
          }}>
            {item.a}
          </div>
        </div>
      </div>
    </div>
  );
}

// ─── Témoins ──────────────────────────────────────────────────────
function TemoinsSection() {
  return (
    <Section id="section-temoins" bg={T.white} washHue={150} washOpacity={0.28} paddingTop={100} paddingBottom={100}>
      <SectionHeader
        eyebrow="L'équipe rapprochée"
        title="Vos témoins"
        subtitle="Une question le jour J, un détail logistique, un cadeau à orchestrer en douce — appelez-les avant nous."
      />

      <div style={{ display: "grid", gap: 16, gridTemplateColumns: "repeat(auto-fit, minmax(260px, 1fr))" }}>
        {DATA.temoins.map((t, i) => (
          <Reveal key={i} delay={Math.min(i * 0.08, 0.32)}>
            <Card accent={i < 2 ? T.rouge : T.or}>
              <div className="eyebrow-small" style={{ color: i < 2 ? T.rouge : T.orDeep }}>
                {t.side}
              </div>
              <div style={{ fontFamily: T.bold, fontWeight: 700, fontSize: 22, marginTop: 8, color: T.ink }}>
                {t.name}
              </div>
              <div style={{ fontFamily: T.italic, fontStyle: "italic", fontSize: 14, color: T.inkSoft, marginTop: 4 }}>
                {t.role}
              </div>
              <div style={{
                marginTop: 14, paddingTop: 14, borderTop: `1px dashed ${T.rule}`,
                fontFamily: T.mono, fontSize: 11, color: T.inkSoft, letterSpacing: 0.5,
                display: "flex", flexDirection: "column", gap: 4,
              }}>
                <a href={`mailto:${t.email}`} style={{ color: T.ink, textDecoration: "none" }}>✉ {t.email}</a>
                <a href={`tel:${t.phone.replace(/\s/g, "")}`} style={{ color: T.ink, textDecoration: "none" }}>☎ {t.phone}</a>
              </div>
            </Card>
          </Reveal>
        ))}
      </div>
    </Section>
  );
}

// ─── Footer ───────────────────────────────────────────────────────
function FooterSection() {
  return (
    <footer style={{ background: T.ink, color: T.white, padding: "60px 0 40px" }}>
      <div className="wrap">
        <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 18, textAlign: "center" }}>
          <div className="display-bold" style={{ fontSize: 44, color: T.white, letterSpacing: -1, textTransform: "uppercase" }}>
            Enora <GoldAmpersand size={36} /> Antoine
          </div>
          <div style={{ fontFamily: T.italic, fontStyle: "italic", fontSize: 18, color: "rgba(255,255,255,0.7)" }}>
            21 / 08 / 2027 · Château Sentout · Tabanac
          </div>
          <div style={{
            marginTop: 14, fontFamily: T.mono, fontSize: 9, letterSpacing: 3, color: "rgba(255,255,255,0.4)", textTransform: "uppercase",
          }}>
            #{DATA.hashtag} · Site fait avec amour pour vous
          </div>
        </div>
      </div>
    </footer>
  );
}

Object.assign(window, { DressCodeSection, FaqSection, FooterSection, TemoinsSection });
