"use client";

import Link from "next/link";
import Image from "next/image";
import { useEffect } from "react";

export default function Error({
  error,
  reset,
}: {
  error: Error & { digest?: string };
  reset: () => void;
}) {
  useEffect(() => {
    console.error("[app error]", error);
  }, [error]);

  return (
    <div className="relative min-h-screen flex items-center justify-center px-6 lg:px-10 overflow-hidden isolate">
      <div
        aria-hidden
        className="absolute inset-0 z-0"
        style={{
          background:
            "radial-gradient(ellipse at 50% 60%, rgba(196,184,150,0.08) 0%, rgba(10,10,10,0) 60%)",
        }}
      />
      <div
        aria-hidden
        className="animate-orb-pulse absolute left-1/2 top-1/2 z-0 w-[500px] h-[500px] sm:w-[700px] sm:h-[700px] rounded-full pointer-events-none"
        style={{
          background:
            "radial-gradient(circle, rgba(196,184,150,0.35) 0%, rgba(196,184,150,0.15) 30%, rgba(196,184,150,0) 70%)",
          filter: "blur(80px)",
        }}
      />

      <div className="relative z-10 max-w-2xl w-full text-center pt-24 pb-12">
        <Image
          src="/image/Studio/Logo Flat.png"
          alt=""
          width={120}
          height={80}
          className="mx-auto mb-10 opacity-40"
        />

        <p className="font-display text-sm tracking-[0.3em] text-accent mb-4">
          ERROR
        </p>
        <h1 className="font-display text-5xl sm:text-6xl lg:text-7xl tracking-wider leading-[0.95] mb-8">
          AVALANCHE
          <br />
          ON THE PATH.
        </h1>
        <p className="text-lg text-foreground-muted leading-relaxed max-w-xl mx-auto mb-4">
          Something went wrong on our side. Try again, or head back to base
          camp.
        </p>
        {error.digest && (
          <p className="text-xs tracking-widest text-foreground-muted mb-12 uppercase">
            Ref: {error.digest}
          </p>
        )}

        <div className="flex flex-col sm:flex-row gap-4 justify-center mt-8">
          <button
            type="button"
            onClick={reset}
            className="px-8 py-3 bg-accent text-background font-display tracking-widest text-sm hover:bg-foreground transition-colors"
          >
            TRY AGAIN
          </button>
          <Link
            href="/"
            className="px-8 py-3 border border-border text-foreground font-display tracking-widest text-sm hover:border-accent hover:text-accent transition-colors"
          >
            BACK TO BASE CAMP
          </Link>
        </div>
      </div>
    </div>
  );
}
