---
import { site } from "../data/site";
import { socials } from "../data/socials";
import { buildInfo } from "../lib/build-info";
const year = 2026; // build-stamped; bump via the build, not a runtime Date()
const linkedinHref = socials.find((s) => s.label === "LinkedIn")?.href;
const emailHref = socials.find((s) => s.label === "Email")?.href;
---

<!-- One terminal session = the whole footer. Every value baked at build time, zero runtime calls. -->
<footer class="footer">
  <div class="container">
    <div class="term mono" data-reveal>
      <div class="term__bar">
        <span class="term__chrome" aria-hidden="true">
          <span class="term__led"></span><span class="term__led"></span><span class="term__led term__led--lit"></span>
        </span>
        <span class="term__title">jonny@bztmon:~ · session receipt</span>
        <span class="term__health"><span class="term__ok">✓</span> Synced · Healthy</span>
      </div>

      <div class="term__body">
        <p class="term__line"><span class="term__prompt">$</span> whoami</p>
        <p class="term__out">
          <span class="term__name">{site.name}</span>
          <span class="term__sep"> - </span> {site.role}
        </p>

        <p class="term__line"><span class="term__prompt">$</span> traceroute www.bztmon.com</p>
        <p class="term__out">
          served from a homelab Kubernetes cluster, over an encrypted tunnel
        </p>

        <p class="term__line"><span class="term__prompt">$</span> git log -1 --format=receipt</p>
        <p class="term__out">
          HEAD <span class="term__val">{buildInfo.sha}</span>
          <span class="term__sep">·</span> built <span class="term__val">{buildInfo.builtAt}</span>
          <span class="term__sep">·</span> reconciled by <span class="term__val">ArgoCD</span>
        </p>

        <p class="term__line"><span class="term__prompt">$</span> contact --priority low-ms</p>
        <p class="term__out">
          ping me on{" "}
          <a href={linkedinHref} rel="noopener noreferrer" target="_blank">LinkedIn</a>{" "}
          or <a href={emailHref}>email</a> - everything else is best-effort delivery.
        </p>

        <p class="term__line" aria-hidden="true">
          <span class="term__prompt">$</span> <span class="term__cursor"></span>
        </p>
      </div>

      <div class="term__statusbar">
        <span>© {year} {site.name}</span>
        <span class="term__sdot" aria-hidden="true">·</span>
        <a
          href={site.license.url}
          rel="license noopener noreferrer"
          target="_blank"
          title={site.license.label}
        >
          {site.license.name}
        </a>
        <span class="term__sdot" aria-hidden="true">·</span>
        <span>built with Astro, shipped via GitOps</span>
        <span class="term__spring" aria-hidden="true"></span>
        <span class="term__socials">
          {
            socials.map((s) => (
              <a
                href={s.href}
                rel={s.external ? "noopener noreferrer" : undefined}
                aria-label={s.label}
                title={s.label}
              >
                <svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true">
                  <path d={s.icon} fill="currentColor" />
                </svg>
              </a>
            ))
          }
        </span>
      </div>
    </div>
  </div>
</footer>

<style>
  .footer {
    padding-block: var(--space-7) var(--space-6);
    margin-top: var(--space-8);
  }

  /* ── the terminal panel ─────────────────────────────────────────────── */
  .term {
    position: relative;
    border: 1px solid var(--border-accent);
    border-radius: var(--radius);
    background: var(--panel);
    backdrop-filter: var(--panel-blur);
    -webkit-backdrop-filter: var(--panel-blur);
    overflow: hidden;
    font-size: 12.5px;
    letter-spacing: 0.03em;
    box-shadow: 0 0 24px -14px var(--accent-glow);
  }
  /* faint CRT scanlines across the whole session (static - not motion) */
  .term::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
      to bottom,
      transparent 0 2px,
      color-mix(in srgb, var(--text) 3%, transparent) 2px 3px
    );
  }

  /* ── title bar ──────────────────────────────────────────────────────── */
  .term__bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-faint);
    font-size: 11px;
  }
  .term__chrome {
    display: inline-flex;
    gap: 5px;
  }
  .term__led {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--border-strong);
  }
  .term__led--lit {
    background: var(--accent);
    box-shadow: 0 0 6px var(--accent-glow);
  }
  .term__title {
    letter-spacing: 0.08em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .term__health {
    margin-left: auto;
    white-space: nowrap;
    color: var(--text-dim);
  }
  .term__ok {
    color: var(--accent);
  }

  /* ── session body ───────────────────────────────────────────────────── */
  .term__body {
    padding: 14px 16px 10px;
    display: grid;
    gap: 2px;
  }
  .term__line {
    color: var(--text-dim);
  }
  .term__line + .term__out {
    margin-bottom: 0.55rem;
  }
  .term__prompt {
    color: var(--accent);
    margin-right: 0.45rem;
  }
  .term__out {
    color: var(--text-faint);
    padding-left: 1.05rem;
    max-width: 72ch;
  }
  .term__name {
    color: var(--text);
    font-weight: 600;
  }
  .term__sep {
    opacity: 0.5;
    margin-inline: 0.15rem;
  }
  .term__val {
    color: var(--accent-2);
  }
  .term__out a {
    color: var(--text-dim);
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .term__out a:hover {
    color: var(--accent);
  }

  /* blinking block cursor on the empty prompt */
  .term__cursor {
    display: inline-block;
    width: 0.62em;
    height: 1.05em;
    vertical-align: text-bottom;
    background: var(--accent);
    animation: term-blink 1.1s steps(2, start) infinite;
  }
  @keyframes term-blink {
    to {
      visibility: hidden;
    }
  }
  @media (prefers-reduced-motion: reduce) {
    .term__cursor {
      animation: none;
    }
  }

  /* ── status bar (tmux-style) ────────────────────────────────────────── */
  .term__statusbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 8px 14px;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--panel) 60%, transparent);
    color: var(--text-faint);
    font-size: 0.72rem;
  }
  .term__sdot {
    opacity: 0.5;
  }
  .term__statusbar a {
    color: var(--text-dim);
    text-decoration: underline;
    text-underline-offset: 2px;
  }
  .term__statusbar a:hover {
    color: var(--accent);
  }
  .term__spring {
    flex: 1;
  }
  .term__socials {
    display: inline-flex;
    gap: var(--space-3);
  }
  .term__socials a {
    color: var(--text-dim);
    text-decoration: none;
  }
  .term__socials a:hover {
    color: var(--accent);
  }

  @media (max-width: 560px) {
    .term__health {
      display: none;
    }
    .term__spring {
      flex-basis: 100%;
    }
  }
</style>
