/*!
 * © 2026 Paulo Oliveira · All Rights Reserved
 * Fingerprint: pf-paulo-2026-r3-d4c602ab
 */
/* global React, PROFILE, EXPERIENCE, SKILLS, CERTS, EDUCATION, TRAITS,
   Pill, TypeLine, CopyBtn, SectionHead, Brackets, SideRail, TopBar, Marquee */
const { useState: useStateS, useEffect: useEffectS } = React;

// ───────── Microsoft Cert Badge Rotator (3 certs, auto + manual) ─────────
const HERO_CERTS = [
  {
    label: "Azure Solutions Architect",
    sub: "✓ Expert · Verify ↗",
    url: "https://learn.microsoft.com/api/credentials/share/en-us/goncalves/7CDD13E96A0B7115?sharingId=ABCF060CC0240657",
    ribbon: "EXPERT",
  },
  {
    label: "DevOps Engineer Expert",
    sub: "✓ Expert · Verify ↗",
    url: "https://learn.microsoft.com/api/credentials/share/en-us/goncalves/D6BB088068EF1599?sharingId=ABCF060CC0240657",
    ribbon: "EXPERT",
  },
  {
    label: "Azure Security Engineer",
    sub: "✓ Associate · Verify ↗",
    url: "https://learn.microsoft.com/en-us/users/goncalves/credentials/certification/azure-security-engineer?tab=credentials-tab",
    ribbon: "ASSOC",
  },
];

function CertBadge() {
  const [i, setI] = React.useState(0);
  const [paused, setPaused] = React.useState(false);
  const total = HERO_CERTS.length;

  React.useEffect(() => {
    if (paused) return;
    const id = setInterval(() => setI((x) => (x + 1) % total), 5000);
    return () => clearInterval(id);
  }, [paused, total]);

  const c = HERO_CERTS[i];
  const go = (delta) => setI((x) => (x + delta + total) % total);

  return (
    <div
      style={{ display: "flex", flexDirection: "column", alignItems: "stretch", width: "100%", maxWidth: 364, gap: 8 }}
      onMouseEnter={() => setPaused(true)}
      onMouseLeave={() => setPaused(false)}
    >
      <a
        href={c.url}
        target="_blank"
        rel="noopener noreferrer"
        key={i}
        style={{
          display: "flex", alignItems: "center", gap: 16,
          padding: "13px 18px",
          border: "1px solid var(--line-strong)",
          borderRadius: 10,
          background: "color-mix(in oklab, var(--accent) 6%, var(--bg-1))",
          textDecoration: "none", color: "inherit",
          animation: "certFadeIn .45s ease",
        }}
      >
        <svg width="57" height="57" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg" style={{ flexShrink: 0 }}>
          <defs>
            <linearGradient id={"badgeGrad" + i} x1="0" y1="0" x2="1" y2="1">
              <stop offset="0%" stopColor="var(--accent-soft)" />
              <stop offset="100%" stopColor="var(--accent-deep)" />
            </linearGradient>
          </defs>
          <path d="M32 2 L58 17 L58 47 L32 62 L6 47 L6 17 Z" fill={"url(#badgeGrad" + i + ")"} stroke="var(--accent)" strokeWidth="1.5" />
          <path d="M32 2 L58 17 L58 47 L32 62 L6 47 L6 17 Z" fill="rgba(0,0,0,0.35)" />
          <g transform="translate(20, 18)">
            <rect x="0"  y="0"  width="10" height="10" fill="#f25022"/>
            <rect x="12" y="0"  width="10" height="10" fill="#7fba00"/>
            <rect x="0"  y="12" width="10" height="10" fill="#00a4ef"/>
            <rect x="12" y="12" width="10" height="10" fill="#ffb900"/>
          </g>
          <text x="32" y="52" textAnchor="middle" fontSize="7" fontWeight="700" fill="var(--accent)" fontFamily="JetBrains Mono, monospace" letterSpacing="1.2">{c.ribbon}</text>
        </svg>
        <div style={{ minWidth: 0, flex: 1 }}>
          <div className="ink-dim" style={{ fontSize: 12, letterSpacing: "0.18em", textTransform: "uppercase" }}>Microsoft Certified</div>
          <div className="display" style={{ fontSize: 17, fontWeight: 600, lineHeight: 1.25, marginTop: 3 }}>
            {c.label}
          </div>
          <div style={{ fontSize: 13, color: "var(--accent)", letterSpacing: "0.2em", marginTop: 4, textTransform: "uppercase" }}>
            {c.sub}
          </div>
        </div>
      </a>

      {/* discreet manual prev/next */}
      <div style={{
        display: "flex", alignItems: "center", justifyContent: "space-between",
        padding: "0 4px",
      }}>
        <button
          onClick={(e) => { e.preventDefault(); go(-1); }}
          aria-label="Previous certification"
          style={{
            background: "transparent", border: "none", padding: "5px 10px",
            color: "var(--ink-dim)", cursor: "pointer", fontSize: 14,
            fontFamily: "JetBrains Mono, monospace", letterSpacing: "0.16em",
          }}
          onMouseEnter={(e) => e.currentTarget.style.color = "var(--accent)"}
          onMouseLeave={(e) => e.currentTarget.style.color = "var(--ink-dim)"}
        >‹ prev</button>

        <div style={{ display: "flex", gap: 5 }}>
          {HERO_CERTS.map((_, j) => (
            <button
              key={j}
              onClick={(e) => { e.preventDefault(); setI(j); }}
              aria-label={"Cert " + (j + 1)}
              style={{
                width: j === i ? 21 : 7, height: 7,
                borderRadius: 4, border: "none",
                background: j === i ? "var(--accent)" : "var(--line-strong)",
                cursor: "pointer", padding: 0,
                transition: "all .25s",
              }}
            ></button>
          ))}
        </div>

        <button
          onClick={(e) => { e.preventDefault(); go(1); }}
          aria-label="Next certification"
          style={{
            background: "transparent", border: "none", padding: "5px 10px",
            color: "var(--ink-dim)", cursor: "pointer", fontSize: 14,
            fontFamily: "JetBrains Mono, monospace", letterSpacing: "0.16em",
          }}
          onMouseEnter={(e) => e.currentTarget.style.color = "var(--accent)"}
          onMouseLeave={(e) => e.currentTarget.style.color = "var(--ink-dim)"}
        >next ›</button>
      </div>

      <style>{`
        @keyframes certFadeIn {
          from { opacity: 0; transform: translateY(4px); }
          to { opacity: 1; transform: translateY(0); }
        }
      `}</style>
    </div>
  );
}

// ───────── Hero ─────────
function Hero() {
  return (
    <section
      id="home"
      style={{
        position: "relative",
        padding: "60px 28px 80px",
        maxWidth: 1280,
        margin: "0 auto",
      }}
    >
      <div style={{ display: "flex", justifyContent: "space-between", alignItems: "flex-start", gap: 24, flexWrap: "wrap", marginBottom: 28 }}>
        <Pill>{PROFILE.status}</Pill>
        <div style={{ fontSize: 11, color: "var(--ink-dim)", letterSpacing: "0.18em", textTransform: "uppercase", textAlign: "right", lineHeight: 1.7 }}>
          <div>SCROLL TO NAVIGATE</div>
          <div style={{ color: "var(--accent)", fontSize: 16, marginTop: 4 }}>↓</div>
        </div>
      </div>

      <div className="hero-main-grid">
        <div>
          <div className="hero-name">
            <div>PAULO</div>
            <div style={{ color: "var(--accent)" }}>OLIVEIRA<span className="cursor">_</span></div>
          </div>
        </div>

        <div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: 18, width: 364, maxWidth: "100%" }}>
          <div className="portrait" style={{ flexShrink: 0 }}>
            <div style={{ position: "absolute", inset: 8, borderRadius: "50%", overflow: "hidden", zIndex: 1 }}>
              <img src="/assets/paulo.png" alt="Paulo Oliveira" />
            </div>
            <div className="scope"></div>
          </div>
          <CertBadge />
        </div>
      </div>

      <div className="hero-cta-grid">
        <div>
          <div className="label" style={{ marginBottom: 12 }}>// PROFILE</div>
          <div style={{ fontSize: 18, lineHeight: 1.55, color: "var(--ink)", maxWidth: 720 }}>
            <span style={{ color: "var(--accent)" }}>{">"}</span> {PROFILE.role} —
            <span className="ink-mute"> 9+ years</span> across Microsoft 365, Azure identity & security,
            Intune endpoint management, and enterprise IT infrastructure. Currently based in <span className="accent">Vancouver, BC</span>.
          </div>
        </div>
        <div style={{ display: "flex", gap: 12, flexWrap: "wrap" }}>
          <a className="btn primary" href={"mailto:" + PROFILE.email}>↗ Contact me</a>
          <a className="btn" href={PROFILE.linkedinUrl} target="_blank" rel="noopener">LinkedIn</a>
        </div>
      </div>
    </section>
  );
}

// ───────── Contact Directory side-card ─────────
function ContactDirectory() {
  const items = [
    { label: "Current Location", value: PROFILE.location, status: "Active", copy: false },
    { label: "Email", value: PROFILE.email, copy: true },
    { label: "LinkedIn", value: PROFILE.linkedin, copy: true, href: PROFILE.linkedinUrl },
  ];
  return (
    <Brackets style={{ padding: 28 }}>
      <div className="panel" style={{ padding: 28 }}>
        <div style={{ display: "flex", alignItems: "baseline", justifyContent: "space-between", marginBottom: 24 }}>
          <div>
            <div className="label" style={{ marginBottom: 6 }}>// SYSTEM / COMMUNICATIONS</div>
            <h3 className="display" style={{ margin: 0, fontSize: 24, fontWeight: 600 }}>Contact Directory</h3>
          </div>
          <span style={{ color: "var(--accent)", fontSize: 11, letterSpacing: "0.18em" }}>● ONLINE</span>
        </div>
        <div style={{ display: "grid", gap: 18 }}>
          {items.map((it, i) => (
            <div
              key={i}
              className="contact-row"
              style={{
                display: "grid",
                gridTemplateColumns: "1fr auto",
                gap: 12,
                padding: "12px 0",
                borderBottom: i < items.length - 1 ? "1px dashed var(--line)" : "none",
                alignItems: "center",
              }}
            >
              <div>
                <div className="label" style={{ marginBottom: 4 }}>{it.label}</div>
                <div style={{ fontSize: 14, color: "var(--ink)" }}>
                  {it.href ? (
                    <a href={it.href} target="_blank" rel="noopener" style={{ color: "var(--ink)" }}>
                      {it.value}
                    </a>
                  ) : (
                    it.value
                  )}
                  {it.status && (
                    <span style={{ marginLeft: 10, fontSize: 10, color: "var(--accent)", letterSpacing: "0.18em" }}>● {it.status}</span>
                  )}
                </div>
              </div>
              {it.copy && <CopyBtn text={it.value} />}
            </div>
          ))}
        </div>
        <div style={{ marginTop: 20, display: "flex", justifyContent: "space-between", fontSize: 10, color: "var(--ink-dim)", letterSpacing: "0.18em", textTransform: "uppercase" }}>
          <span>Connection: Secure</span>
          <span>ID: 2026-SYS</span>
        </div>
      </div>
    </Brackets>
  );
}

// ───────── Summary section ─────────
function Summary() {
  return (
    <section id="summary" style={{ padding: "80px 28px", maxWidth: 1280, margin: "0 auto" }}>
      <SectionHead cmd="$ cat ~/summary.md" title="Summary" meta="// 01" />
      <div className="summary-grid">
        <div className="term">
          <div className="term-bar">
            <div className="lights"><span></span><span></span><span></span></div>
            <span>paulo@azure-cloud:~/summary</span>
            <span className="meta-zsh">— zsh —</span>
          </div>
          <div style={{ padding: "22px 26px" }}>
            <div style={{ color: "var(--accent)", fontSize: 13, marginBottom: 14 }}>$ whoami --verbose</div>
            <p style={{ margin: 0, fontSize: 16, lineHeight: 1.7, color: "var(--ink)" }}>
              {PROFILE.summary}
            </p>
            <div style={{ marginTop: 22, color: "var(--accent)", fontSize: 13 }}>$ ls ~/traits<span className="cursor">_</span></div>
            <div style={{ display: "flex", flexWrap: "wrap", gap: 8, marginTop: 12 }}>
              {TRAITS.map((t) => <span key={t} className="chip">{t}</span>)}
            </div>
          </div>
        </div>

        <div className="summary-metrics">
          {PROFILE.metrics.map((m) => (
            <div className="metric" key={m.l}>
              <div className="v">{m.v}</div>
              <div className="l">{m.l}</div>
            </div>
          ))}
        </div>
      </div>
    </section>
  );
}

// ───────── Experience timeline ─────────
function Experience() {
  const itemsRef = React.useRef([]);

  React.useEffect(() => {
    const reduce = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
    if (reduce) {
      itemsRef.current.forEach((el) => el && el.classList.add("is-visible"));
      return;
    }
    const io = new IntersectionObserver(
      (entries) => {
        entries.forEach((entry) => {
          if (entry.isIntersecting) {
            entry.target.classList.add("is-visible");
          } else if (entry.boundingClientRect.top > 0) {
            // user scrolled back up past it — dim again so the reveal replays
            entry.target.classList.remove("is-visible");
          }
        });
      },
      { threshold: 0.28, rootMargin: "0px 0px -8% 0px" }
    );
    itemsRef.current.forEach((el) => el && io.observe(el));
    return () => io.disconnect();
  }, []);

  const renderChip = (s) => {
    const url = (window.TECH_DOCS || {})[s];
    if (url) {
      return (
        <a
          key={s}
          href={url}
          target="_blank"
          rel="noopener noreferrer"
          className="chip-link"
          title={"Open official documentation for " + s}
        >
          <span className="chip">{s}</span>
        </a>
      );
    }
    return <span key={s} className="chip">{s}</span>;
  };

  return (
    <div className="experience-wrap">
      <section id="experience" style={{ padding: "80px 28px", maxWidth: 1280, margin: "0 auto", position: "relative", zIndex: 1 }}>
        <SectionHead cmd="$ git log --career" title="Work Experience" meta="// 04" />
        <div className="timeline">
          {EXPERIENCE.map((job, i) => (
            <div className="timeline-item" key={i} ref={(el) => (itemsRef.current[i] = el)}>
              <Brackets style={{ padding: 0 }}>
                <div className="panel" style={{ padding: "26px 28px" }}>
                  <div style={{ display: "flex", justifyContent: "space-between", alignItems: "flex-start", flexWrap: "wrap", gap: 12 }}>
                    <div>
                      <div style={{ display: "flex", alignItems: "center", gap: 10, flexWrap: "wrap" }}>
                        <h3 className="display" style={{ margin: 0, fontSize: 24, fontWeight: 600 }}>
                          {job.companyUrl ? (
                            <a
                              href={job.companyUrl}
                              target="_blank"
                              rel="noopener noreferrer"
                              className="company-link"
                              title={"Visit " + job.company}
                            >
                              {job.company}
                            </a>
                          ) : (
                            job.company
                          )}
                        </h3>
                        {job.partner && (
                          <span className="ink-mute" style={{ fontSize: 13 }}>— {job.partner}</span>
                        )}
                        {job.current && (
                          <span style={{ fontSize: 9.5, color: "var(--accent)", letterSpacing: "0.18em", border: "1px solid var(--pill-border)", background: "var(--pill-bg)", padding: "2px 8px", borderRadius: 4, textTransform: "uppercase" }}>● Active</span>
                        )}
                      </div>
                      <div style={{ marginTop: 6, color: "var(--accent-soft)", fontSize: 14 }}>{job.role}</div>
                      <div className="ink-dim" style={{ fontSize: 12, marginTop: 4, letterSpacing: "0.06em" }}>
                        {job.location}
                      </div>
                    </div>
                    <div style={{ textAlign: "right" }}>
                      <div className="label">Period</div>
                      <div style={{ fontSize: 13, color: "var(--ink)", marginTop: 4 }}>{job.period}</div>
                    </div>
                  </div>

                  <ul style={{ margin: "20px 0 0", padding: 0, listStyle: "none", display: "grid", gap: 10 }}>
                    {job.bullets.map((b, j) => (
                      <li key={j} style={{ display: "grid", gridTemplateColumns: "auto 1fr", gap: 12, fontSize: 14, lineHeight: 1.55 }}>
                        <span style={{ color: "var(--accent)", marginTop: 2 }}>▹</span>
                        <span>{b}</span>
                      </li>
                    ))}
                  </ul>

                  <div style={{ display: "flex", flexWrap: "wrap", gap: 8, marginTop: 18, paddingTop: 18, borderTop: "1px dashed var(--line)" }}>
                    {job.stack.map(renderChip)}
                  </div>
                </div>
              </Brackets>
            </div>
          ))}
        </div>
      </section>
    </div>
  );
}

// ───────── Skills grid ─────────
function Skills() {
  return (
    <section id="skills" style={{ padding: "60px 28px", maxWidth: 1280, margin: "0 auto" }}>
      <SectionHead cmd="$ skill --list" title="Skills" meta="// 05" />
      <div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(280px, 1fr))", gap: 18 }}>
        {SKILLS.map((g, i) => (
          <div
            key={i}
            className="panel skill-card"
            style={{ padding: 22, position: "relative", overflow: "hidden", transition: "all .3s ease" }}
          >
            <div className="skill-glow"></div>
            <div style={{ position: "relative", zIndex: 1 }}>
              <div style={{ display: "flex", alignItems: "center", gap: 8, marginBottom: 16 }}>
                <span style={{ color: "var(--accent)" }}>›</span>
                <h4 className="display" style={{ margin: 0, fontSize: 16, fontWeight: 600, letterSpacing: 0 }}>{g.title}</h4>
                <span className="ink-dim" style={{ fontSize: 10, letterSpacing: "0.18em", marginLeft: "auto" }}>
                  {String(g.items.length).padStart(2, "0")}
                </span>
              </div>
              <div style={{ display: "flex", flexWrap: "wrap", gap: 6 }}>
                {g.items.map((it) => <span key={it} className="chip">{it}</span>)}
              </div>
            </div>
          </div>
        ))}
      </div>
      <style>{`
        .skill-card .skill-glow {
          position: absolute; inset: 0;
          background: radial-gradient(circle at var(--mx,50%) var(--my,50%),
            color-mix(in oklab, var(--accent) 28%, transparent) 0%,
            transparent 55%);
          opacity: 0;
          transition: opacity .35s ease;
          pointer-events: none;
        }
        .skill-card:hover {
          border-color: var(--accent) !important;
          box-shadow: 0 0 0 1px color-mix(in oklab, var(--accent) 30%, transparent),
                      0 12px 40px -8px color-mix(in oklab, var(--accent) 35%, transparent);
        }
        .skill-card:hover .skill-glow { opacity: 1; }
      `}</style>
    </section>
  );
}

// Track mouse for skill-card glow position
if (typeof window !== "undefined" && !window.__skillGlowBound) {
  window.__skillGlowBound = true;
  document.addEventListener("mousemove", (e) => {
    const card = e.target.closest && e.target.closest(".skill-card");
    if (!card) return;
    const r = card.getBoundingClientRect();
    card.style.setProperty("--mx", ((e.clientX - r.left) / r.width * 100) + "%");
    card.style.setProperty("--my", ((e.clientY - r.top) / r.height * 100) + "%");
  });
}

// ───────── Certifications (infinite auto-rotating carousel, 2s) ─────────
function Certifications() {
  const trackRef = React.useRef(null);
  const [active, setActive] = React.useState(0);
  const [paused, setPaused] = React.useState(false);
  const userScrolling = React.useRef(false);
  const scrollTimeout = React.useRef(null);

  // Programmatic scroll (instant for wrap, smooth otherwise)
  const goTo = (i, behavior = "smooth") => {
    const t = trackRef.current;
    if (!t) return;
    const idx = ((i % CERTS.length) + CERTS.length) % CERTS.length;
    userScrolling.current = false;
    t.scrollTo({ left: idx * t.clientWidth, behavior });
    setActive(idx);
  };

  const onScroll = () => {
    const t = trackRef.current;
    if (!t) return;
    userScrolling.current = true;
    clearTimeout(scrollTimeout.current);
    scrollTimeout.current = setTimeout(() => {
      const i = Math.round(t.scrollLeft / t.clientWidth);
      if (i !== active) setActive(i);
      userScrolling.current = false;
    }, 80);
  };

  // Infinite auto-advance every 2s, pause on hover/focus
  React.useEffect(() => {
    if (paused) return;
    const id = setInterval(() => {
      goTo(active + 1, "smooth");
    }, 2000);
    return () => clearInterval(id);
  }, [active, paused]);

  return (
    <section id="certs" style={{ padding: "60px 28px", maxWidth: 1280, margin: "0 auto" }}>
      <SectionHead cmd="$ certs --verify" title="Certifications" meta="// 06" />
      <p className="ink-mute" style={{ maxWidth: 720, margin: "0 0 28px", fontSize: 14, lineHeight: 1.6 }}>
        Active credentials — click any card to verify directly on the issuer's site.
      </p>

      <div
        style={{ position: "relative" }}
        onMouseEnter={() => setPaused(true)}
        onMouseLeave={() => setPaused(false)}
        onFocusCapture={() => setPaused(true)}
        onBlurCapture={() => setPaused(false)}
      >
        {/* Arrows — always enabled (infinite); hidden on touch viewports via CSS */}
        <button
          onClick={() => goTo(active - 1)}
          aria-label="Previous certification"
          className="slide-arrow prev"
        >
          ◀
        </button>
        <button
          onClick={() => goTo(active + 1)}
          aria-label="Next certification"
          className="slide-arrow next"
        >
          ▶
        </button>

        {/* Track */}
        <div
          ref={trackRef}
          onScroll={onScroll}
          style={{
            display: "flex",
            overflowX: "auto",
            scrollSnapType: "x mandatory",
            scrollBehavior: "smooth",
            padding: "0 0 8px",
            scrollbarWidth: "none",
          }}
          className="hide-scrollbar"
        >
          {CERTS.map((c, i) => (
            <div key={i} style={{ flex: "0 0 100%", scrollSnapAlign: "start", padding: "0 4px" }}>
              <a
                href={c.url}
                target="_blank"
                rel="noopener noreferrer"
                className="panel cert-card-grid"
                style={{
                  padding: "32px 36px",
                  textDecoration: "none",
                  color: "inherit",
                  position: "relative",
                  overflow: "hidden",
                }}
              >
                {/* corner ID */}
                <div className="mono" style={{
                  position: "absolute", top: 14, right: 18,
                  fontSize: 10, letterSpacing: "0.18em",
                  color: "var(--ink-dim)",
                }}>
                  {String(i + 1).padStart(2, "0")} / {String(CERTS.length).padStart(2, "0")}
                </div>

                {/* LEFT — big badge */}
                <div style={{
                  border: "1px solid var(--line)",
                  borderRadius: 8,
                  display: "flex",
                  flexDirection: "column",
                  alignItems: "center",
                  justifyContent: "center",
                  background: "linear-gradient(180deg, color-mix(in oklab, var(--accent) 6%, transparent), transparent)",
                  padding: "28px 20px",
                  position: "relative",
                  overflow: "hidden",
                  minHeight: 240,
                }}>
                  {/* Microsoft logo for MS certs */}
                  {c.issuer === "Microsoft" && (
                    <div style={{
                      display: "grid",
                      gridTemplateColumns: "1fr 1fr",
                      gap: 4,
                      width: 56, height: 56,
                      marginBottom: 18,
                    }}>
                      <div style={{ background: "#f25022" }}></div>
                      <div style={{ background: "#7fba00" }}></div>
                      <div style={{ background: "#00a4ef" }}></div>
                      <div style={{ background: "#ffb900" }}></div>
                    </div>
                  )}
                  {c.issuer === "Amazon Web Services" && (
                    <div style={{
                      width: 64, height: 56, marginBottom: 18,
                      display: "grid", placeItems: "center",
                      fontFamily: "Space Grotesk, sans-serif",
                      fontSize: 26, fontWeight: 800,
                      color: "#ff9900",
                      letterSpacing: "-0.04em",
                    }}>aws</div>
                  )}

                  <div className="display" style={{
                    fontSize: 38,
                    fontWeight: 800,
                    color: "var(--accent)",
                    letterSpacing: "-0.04em",
                    lineHeight: 0.95,
                    textAlign: "center",
                  }}>
                    {c.code}
                  </div>

                  <div className={"level " + (c.level === "Expert" ? "expert" : c.level === "Associate" ? "assoc" : "")} style={{ marginTop: 14 }}>
                    {c.level}
                  </div>

                  {/* scan dots */}
                  <div style={{
                    position: "absolute", inset: 0,
                    backgroundImage: "radial-gradient(circle, color-mix(in oklab, var(--accent) 25%, transparent) 1px, transparent 1px)",
                    backgroundSize: "14px 14px",
                    opacity: 0.12,
                    pointerEvents: "none",
                  }}></div>
                </div>

                {/* RIGHT — text */}
                <div style={{ display: "flex", flexDirection: "column", gap: 14, minWidth: 0 }}>
                  <div className="ink-dim" style={{ fontSize: 10.5, letterSpacing: "0.2em", textTransform: "uppercase", fontFamily: "JetBrains Mono, monospace" }}>
                    ▸ {c.issuer}
                  </div>
                  <h3 className="display" style={{
                    fontSize: "clamp(26px, 3vw, 36px)",
                    fontWeight: 700,
                    letterSpacing: "-0.02em",
                    lineHeight: 1.05,
                    margin: 0,
                  }}>
                    {c.title}
                  </h3>
                  <p className="ink-mute" style={{ fontSize: 14, lineHeight: 1.7, margin: "4px 0 0", maxWidth: 580 }}>
                    {c.desc}
                  </p>

                  <div style={{ display: "flex", flexWrap: "wrap", gap: 6, marginTop: 6 }}>
                    {c.skills.map((s) => (
                      <span key={s} className="mono" style={{
                        fontSize: 10.5, letterSpacing: "0.06em",
                        padding: "5px 10px",
                        border: "1px solid var(--line)",
                        borderRadius: 4,
                        color: "var(--ink-mute)",
                        background: "rgba(255,255,255,0.02)",
                      }}>
                        {s}
                      </span>
                    ))}
                  </div>

                  <div style={{
                    marginTop: "auto",
                    paddingTop: 18,
                    borderTop: "1px dashed var(--line)",
                    display: "flex",
                    justifyContent: "space-between",
                    alignItems: "center",
                    fontSize: 10.5,
                    color: "var(--ink-dim)",
                    letterSpacing: "0.16em",
                    textTransform: "uppercase",
                    fontFamily: "JetBrains Mono, monospace",
                  }}>
                    <span style={{ color: "var(--accent)" }}>✓ ACTIVE · VERIFIED</span>
                    <span style={{ color: "var(--accent)" }}>view credential ↗</span>
                  </div>
                </div>
              </a>
            </div>
          ))}
        </div>

        {/* Pagination dots */}
        <div style={{
          display: "flex", justifyContent: "center",
          gap: 8, marginTop: 22, flexWrap: "wrap",
        }}>
          {CERTS.map((c, i) => (
            <button
              key={i}
              onClick={() => goTo(i)}
              aria-label={"Go to " + c.title}
              style={{
                width: i === active ? 28 : 8,
                height: 8,
                borderRadius: 4,
                border: "none",
                background: i === active ? "var(--accent)" : "var(--line-strong)",
                cursor: "pointer",
                transition: "all .25s",
                padding: 0,
              }}
            ></button>
          ))}
        </div>

        <div className="mono" style={{
          textAlign: "center", marginTop: 12,
          fontSize: 11, letterSpacing: "0.18em",
          color: "var(--ink-dim)",
        }}>
          [ {String(active + 1).padStart(2, "0")} / {String(CERTS.length).padStart(2, "0")} ] · {CERTS[active].title.toUpperCase()}
          <span style={{ marginLeft: 12, color: paused ? "var(--ink-dim)" : "var(--accent)" }}>
            {paused ? "⏸ paused" : "▶ auto"}
          </span>
        </div>

        {/* progress bar */}
        <div className="cert-progress" style={{
          position: "relative",
          height: 2, marginTop: 10,
          background: "var(--line)",
          borderRadius: 1,
          overflow: "hidden",
          maxWidth: 200,
          marginLeft: "auto",
          marginRight: "auto",
        }}>
          <div
            key={active + "-" + paused}
            style={{
              position: "absolute", inset: 0,
              background: "var(--accent)",
              transformOrigin: "left",
              animation: paused ? "none" : "certProgress 2s linear forwards",
            }}
          ></div>
        </div>
      </div>

      <style>{`
        .hide-scrollbar::-webkit-scrollbar { display: none; }
        @keyframes certProgress {
          from { transform: scaleX(0); }
          to { transform: scaleX(1); }
        }
      `}</style>
    </section>
  );
}

// ───────── Education ─────────
function Education() {
  return (
    <section id="education" style={{ padding: "60px 28px 80px", maxWidth: 1280, margin: "0 auto" }}>
      <SectionHead cmd="$ ls ~/education" title="Education" meta="// 07" />
      <div style={{ display: "grid", gap: 16 }}>
        {EDUCATION.map((e, i) => (
          <div key={i} className="panel edu-row" style={{ padding: 22 }}>
            <div style={{ fontFamily: "Space Grotesk, sans-serif", fontSize: 28, fontWeight: 700, color: "var(--accent)", letterSpacing: "-0.02em" }}>
              {String(i + 1).padStart(2, "0")}
            </div>
            <div>
              <div className="display" style={{ fontSize: 18, fontWeight: 600 }}>{e.school}</div>
              <div className="ink-mute" style={{ fontSize: 13, marginTop: 4 }}>{e.degree} <span className="ink-dim">— {e.location}</span></div>
            </div>
            <div className="ink-dim edu-period" style={{ fontSize: 12, letterSpacing: "0.16em", textAlign: "right" }}>{e.period}</div>
          </div>
        ))}
      </div>
    </section>
  );
}

// ───────── Footer ─────────
function FooterBlock() {
  return (
    <footer>
      <div className="footer-grid" style={{ maxWidth: 1280, margin: "0 auto", padding: "0 28px" }}>
        <div>
          <div className="label" style={{ marginBottom: 8 }}>// END OF FILE</div>
          <div className="display footer-cta" style={{ fontSize: 36, fontWeight: 700, letterSpacing: "-0.02em", lineHeight: 1 }}>
            Let's build something <span className="accent">resilient</span>.
          </div>
          <div className="ink-mute" style={{ marginTop: 10, fontSize: 13 }}>
            <span className="accent">{PROFILE.prompt}</span> echo "thanks for reading"<span className="cursor">_</span>
          </div>
        </div>
        <div style={{ display: "flex", gap: 10, flexWrap: "wrap", justifyContent: "flex-end" }}>
          <a className="btn primary" href={"mailto:" + PROFILE.email}>↗ {PROFILE.email}</a>
          <a className="btn" href={PROFILE.linkedinUrl} target="_blank" rel="noopener">LinkedIn ↗</a>
        </div>
      </div>
      <div className="footer-meta" style={{ marginTop: 36, padding: "0 28px", maxWidth: 1280, margin: "36px auto 0", display: "flex", justifyContent: "space-between", fontSize: 10.5, color: "var(--ink-dim)", letterSpacing: "0.18em", textTransform: "uppercase", flexWrap: "wrap", gap: 12 }}>
        <span>© 2026 Paulo Oliveira · All Rights Reserved</span>
        <span>SYS-2026 • Vancouver, BC</span>
      </div>
      <div className="footer-meta" style={{ padding: "10px 28px 0", maxWidth: 1280, margin: "0 auto", fontSize: 9.5, color: "var(--ink-dim)", letterSpacing: "0.14em", textTransform: "uppercase", opacity: 0.7 }}>
        Unauthorized reproduction, mirroring, or derivative use of source, design, or assets is prohibited. License inquiries: {PROFILE.email}
      </div>
    </footer>
  );
}

Object.assign(window, { Hero, ContactDirectory, Summary, Experience, Skills, Certifications, Education, FooterBlock });
