/* ABOUT — editorial: quiet portrait, dropcap, hairline credentials, restrained stats */

function About({ t }) {
  const ref = React.useRef(null);
  const [p, setP] = React.useState(0);

  React.useEffect(() => {
    const onScroll = () => {
      if (!ref.current) return;
      const r = ref.current.getBoundingClientRect();
      const v = Math.max(0, Math.min(1, (window.innerHeight - r.top) / (window.innerHeight + r.height)));
      setP(v);
    };
    onScroll();
    window.addEventListener("scroll", onScroll, { passive: true });
    return () => window.removeEventListener("scroll", onScroll);
  }, []);

  return (
    <section ref={ref} className="section bg-cream about" data-screen-label="04 About" id="about">
      <div className="section-inner">
        <header className="about-head">
          <div className="sec-badge">
            <span className="num">04</span>
            <span className="bar" />
            <span>{t.aboutEyebrow}</span>
          </div>
          <div className="about-coords mono">{t.aboutCoords}</div>
        </header>

        <div className="about-grid">
          <div className="about-portrait-wrap" style={{ transform: `translateY(${-p * 30}px)` }}>
            <img src="uploads/Natalie.jpg" alt="portrait · natalia" style={{ width: "100%", aspectRatio: "3/4", objectFit: "cover", objectPosition: "center 30%", display: "block" }} />
            <div className="portrait-cap">
              <span className="mono">Plate ii</span>
              <span className="italic-serif">Natalia, Málaga, 2026</span>
            </div>
          </div>

          <div className="about-text">
            <h2 className="about-title display">
              <span>{t.aboutTitle1}</span>{" "}
              <span className="italic-serif">{t.aboutTitle2}</span>
            </h2>

            <div className="about-quote">
              <p className="display">"{t.aboutQuote}"</p>
            </div>

            <div className="about-body">
              {t.aboutPara.map((para, i) => (
                <p key={i} className="about-para">{para}</p>
              ))}
            </div>

            <div className="about-creds">
              <h4 className="creds-label mono">{t.credsLabel}</h4>
              <ul>
                {t.creds.map((c, i) => (
                  <li key={i}>
                    <span className="display creds-name">{c.name}</span>
                    <span className="dotted" />
                    <span className="italic-serif creds-loc">{c.loc}</span>
                  </li>
                ))}
              </ul>
            </div>

            <div className="about-stats">
              <div className="stat">
                <span className="stat-num display">10<span className="stat-plus">+</span></span>
                <span className="stat-label mono">{t.statYears}</span>
              </div>
              <div className="stat-divider" />
              <div className="stat">
                <span className="stat-num display italic-serif">∞</span>
                <span className="stat-label mono">{t.statHorizons}</span>
              </div>
              <div className="stat-divider" />
              <div className="stat">
                <span className="stat-num display">3</span>
                <span className="stat-label mono">{t.statHomeOven}</span>
              </div>
            </div>
          </div>
        </div>
      </div>

      <style>{`
        .about-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 32px; border-bottom: 1px solid var(--line-soft); }
        .about-coords { color: var(--muted); }

        .about-grid { display: grid; grid-template-columns: minmax(280px, 460px) 1fr; gap: clamp(40px, 8vw, 120px); padding-top: 80px; align-items: start; }
        @media (max-width: 900px) { .about-grid { grid-template-columns: 1fr; } }

        .about-portrait-wrap { position: sticky; top: 100px; transition: transform 0.05s linear; }
        .portrait-cap {
          display: flex;
          justify-content: space-between;
          margin-top: 14px;
          color: var(--muted);
          font-size: 12px;
        }
        .portrait-cap .mono { font-size: 10px; }

        .about-title { font-size: clamp(48px, 7vw, 110px); font-weight: 300; line-height: 0.95; letter-spacing: -0.03em; margin-bottom: 56px; color: var(--slate-ink); }
        .about-title .italic-serif { color: var(--slate); font-weight: 300; }

        .about-quote { padding: 36px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); margin-bottom: 56px; }
        .about-quote p { font-size: clamp(20px, 2.2vw, 32px); line-height: 1.3; color: var(--slate-ink); font-weight: 300; font-style: italic; }

        .about-body { display: flex; flex-direction: column; gap: 22px; margin-bottom: 64px; }
        .about-para { font-size: 16px; line-height: 1.75; color: var(--slate); max-width: 60ch; font-weight: 300; }
        .about-para:first-child::first-letter { font-family: var(--display); font-size: 4.6em; float: left; line-height: 0.85; padding: 0.05em 0.12em 0 0; color: var(--slate-ink); font-weight: 300; }

        .about-creds { padding: 36px 0; border-top: 1px solid var(--line-soft); margin-bottom: 56px; }
        .creds-label { font-size: 10px; color: var(--muted); margin-bottom: 24px; }
        .about-creds ul { list-style: none; display: flex; flex-direction: column; gap: 0; }
        .about-creds li { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 16px; font-size: 20px; padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
        .creds-name { color: var(--slate-ink); font-weight: 300; }
        .dotted { border-bottom: 1px dotted var(--line); transform: translateY(-4px); }
        .creds-loc { font-size: 14px; color: var(--muted); }

        .about-stats { display: flex; gap: 24px; align-items: center; padding: 32px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
        .stat { flex: 1; display: flex; flex-direction: column; gap: 8px; }
        .stat-num { font-size: clamp(40px, 5vw, 64px); color: var(--slate-ink); line-height: 1; font-weight: 300; letter-spacing: -0.02em; }
        .stat-plus { font-size: 0.5em; vertical-align: super; color: var(--muted); }
        .stat-label { font-size: 10px; color: var(--muted); }
        .stat-divider { width: 1px; height: 50px; background: var(--line); }
      `}</style>
    </section>
  );
}

window.About = About;
