@page "/Error"
@using System.Diagnostics
@inject NavigationManager Navigation

<PageTitle>System Exception | Midrand Books</PageTitle>

<div class="artistic-error-container">
    <div class="container h-100">
        <div class="row align-items-center justify-content-center min-vh-70 py-5">

            <div class="col-12 col-md-5 d-flex justify-content-center mb-5 mb-md-0">
                <svg viewBox="0 0 400 400" width="300" height="300" fill="none" stroke="#1A1A1A" stroke-width="1.5">
                    <rect x="100" y="100" width="200" height="200" transform="rotate(45 200 200)" opacity="0.2" />
                    <line x1="150" y1="150" x2="250" y2="250" />
                    <line x1="250" y1="150" x2="150" y2="250" />
                    <circle cx="200" cy="200" r="80" stroke-dasharray="10 10" />
                </svg>
            </div>

            <div class="col-12 col-md-6 offset-md-1">
                <div class="meta-tag font-monospace text-uppercase text-danger mb-3">System Exception // Critical Halt</div>

                <h1 class="display-4 text-dark mb-4 editorial-headline">An unexpected<br />interruption.</h1>

                <p class="text-muted mb-5 body-manifesto-text">
                    We are experiencing a technical disruption in our processing stream. Our team has been notified of this structural anomaly.
                </p>

                @if (ShowRequestId)
                {
                    <p class="font-monospace text-muted small mb-4">
                        Ref: <code>@RequestId</code>
                    </p>
                }

                <button class="btn btn-outline-dark rounded-pill px-5 py-3" @onclick='() => Navigation.NavigateTo("/")'>Return to Library</button>
            </div>
        </div>
    </div>
</div>

@code {
    [CascadingParameter] private HttpContext? HttpContext { get; set; }
    private string? RequestId { get; set; }
    private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

    protected override void OnInitialized() =>
        RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
}