/* =================================================================
   page404.css — 404 Error Page (redesigned v2)
   All UI colors derived from --hrms-* tokens in hrms-theme.css.
   Chromatic-aberration glitch channels defined once as --p4-glitch-*
   variables at the top of the scoped block — the only non-token
   color values in this file.
   ================================================================= */

/* ── Scoped token aliases ────────────────────────────────────── */
body.page-404-body {
  --p4-red:         var(--hrms-red, #da0000);
  --p4-red-strong:  color-mix(in srgb, var(--p4-red) 78%, #000);
  --p4-red-muted:   color-mix(in srgb, var(--p4-red) 14%, transparent);
  --p4-red-soft:    color-mix(in srgb, var(--p4-red) 20%, transparent);
  --p4-red-fg:      #ffffff;

  /* Glitch chromatic-aberration channels — only hardcoded values in file */
  --p4-glitch-hi:   color-mix(in srgb, var(--p4-red) 68%, #fff); /* lighter red */
  --p4-glitch-lo:   color-mix(in srgb, #4fc3f7 52%, transparent); /* faint blue  */
}

/* ── Base reset ─────────────────────────────────────────────── */
body.page-404-body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--hrms-bg);
  color: var(--hrms-text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

/* ── Full-screen scene ──────────────────────────────────────── */
.p4-scene {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* ── Background ─────────────────────────────────────────────── */
.p4-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* Grid: thin lines, very low opacity — light vs dark */
.p4-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
}

html.hrms-dark .p4-grid {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
}

/* Glow is subtle in light mode, richer in dark mode */
html.hrms-dark .p4-glow {
  --p4-red-glow: color-mix(in srgb, var(--p4-red) 36%, transparent);
}

/* ── Centered column ────────────────────────────────────────── */
.p4-col {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 30rem;
  padding: 2rem 1.25rem 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* ── Logo badge ─────────────────────────────────────────────── */
.p4-logo-badge {
  background: var(--p4-red);
  border-radius: var(--hrms-radius);
  padding: 0.6rem 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 4px 16px var(--p4-red-soft),
    0 8px 32px var(--p4-red-muted);
  margin-bottom: 1.5rem;
}

.p4-logo-img {
  display: block;
  height: 36px;
  width: auto;
}

/* ── Glitch 404 ─────────────────────────────────────────────── */
.p4-glitch {
  display: inline-block;
  font-size: 9rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1;
  color: var(--hrms-text);
  position: relative;
  margin-bottom: 1.5rem;
  animation: p4-flicker 4s infinite;
  user-select: none;
}

/* Both pseudo-elements clone the text via data-text */
.p4-glitch::before,
.p4-glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  font: inherit;
  letter-spacing: inherit;
  /* Hidden by default — clip-path collapses them */
}

/* ::before — lighter red channel, shifts left */
.p4-glitch::before {
  color: var(--p4-glitch-hi);
  clip-path: inset(0 0 100% 0); /* hidden until animation */
  animation: p4-glitch-a 4s infinite;
}

/* ::after — faint blue channel, shifts right */
.p4-glitch::after {
  color: var(--p4-glitch-lo);
  clip-path: inset(100% 0 0 0); /* hidden until animation */
  animation: p4-glitch-b 4s infinite;
  animation-delay: 0.15s; /* slight offset for chromatic separation */
}

/* Whole-element subtle flicker synced to glitch burst */
@keyframes p4-flicker {
  0%, 83%, 100% { opacity: 1; }
  84%           { opacity: 0.93; }
  86%           { opacity: 1;    }
  90%           { opacity: 0.96; }
  91%           { opacity: 1;    }
}

/* Red (lighter) channel — clips horizontal strips, shifts left */
@keyframes p4-glitch-a {
  0%,  83%, 100% { clip-path: inset(0 0 100% 0); transform: translate(0); }
  84%            { clip-path: inset( 5% 0 58% 0); transform: translate(-6px,  0   ); }
  86%            { clip-path: inset(40% 0 18% 0); transform: translate( 6px,  1px ); }
  88%            { clip-path: inset(15% 0 52% 0); transform: translate(-5px, -1px ); }
  90%            { clip-path: inset(68% 0  8% 0); transform: translate( 5px,  0   ); }
  92%            { clip-path: inset(28% 0 36% 0); transform: translate(-6px,  1px ); }
  94%            { clip-path: inset(50% 0 20% 0); transform: translate( 4px, -1px ); }
  96%            { clip-path: inset(0 0 100% 0);  transform: translate(0);           }
}

/* Blue (faint) channel — clips opposite strips, shifts right */
@keyframes p4-glitch-b {
  0%,  79%, 100% { clip-path: inset(100% 0 0 0);  transform: translate(0); }
  80%            { clip-path: inset(52% 0  0%  0); transform: translate( 6px, -1px); }
  82%            { clip-path: inset(28% 0 30%  0); transform: translate(-6px,  1px); }
  84%            { clip-path: inset(72% 0  5%  0); transform: translate( 5px,  0  ); }
  86%            { clip-path: inset(15% 0 48%  0); transform: translate(-5px, -1px); }
  88%            { clip-path: inset(62% 0 12%  0); transform: translate( 6px,  1px); }
  90%            { clip-path: inset( 8% 0 62%  0); transform: translate(-4px,  0  ); }
  92%            { clip-path: inset(100% 0 0 0);   transform: translate(0);          }
}

/* ── Frosted glass card ──────────────────────────────────────── */
.p4-card {
  width: 100%;
  background: color-mix(in srgb, var(--hrms-card) 82%, transparent);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid color-mix(in srgb, var(--hrms-border) 55%, transparent);
  border-radius: var(--hrms-radius-lg, 18px);
  padding: 2rem 2rem 1.875rem;
  text-align: center;
  box-shadow:
    0 4px 6px rgba(0, 0, 0, 0.04),
    0 10px 24px rgba(0, 0, 0, 0.08),
    0 24px 48px rgba(0, 0, 0, 0.06);
}

html.hrms-dark .p4-card {
  background: color-mix(in srgb, var(--hrms-card-alt) 72%, transparent);
  border-color: color-mix(in srgb, #fff 10%, transparent);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.20),
    0 10px 28px rgba(0, 0, 0, 0.30),
    0 28px 56px rgba(0, 0, 0, 0.38);
}

/* ── Card content ───────────────────────────────────────────── */
.p4-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--hrms-text);
  margin: 0 0 0.625rem;
  line-height: 1.2;
}

.p4-desc {
  font-size: 0.875rem;
  color: var(--hrms-muted);
  line-height: 1.65;
  margin: 0 0 1.75rem;
  max-width: 22rem;
  margin-left: auto;
  margin-right: auto;
}

/* ── Action buttons ─────────────────────────────────────────── */
.p4-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Base button */
.p4-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  height: 42px;
  padding: 0 1.5rem;
  border-radius: var(--hrms-radius-sm);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.p4-btn i {
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* Primary — solid red fill */
.p4-btn-primary {
  background: var(--hrms-primary);
  color: var(--p4-red-fg);
  border: none;
  box-shadow: 0 2px 10px var(--p4-red-soft);
}

.p4-btn-primary:hover {
  background: var(--hrms-primary);
  color: var(--p4-red-fg);
  text-decoration: none;
}

.p4-btn-primary:active {
  transform: scale(0.98);
}

/* Ghost — transparent with border */
.p4-btn-ghost {
  background: transparent;
  color: var(--hrms-text);
  border: 1px solid var(--hrms-border);
}

.p4-btn-ghost:hover {
  background: var(--hrms-hover);
}

.p4-btn-ghost:active {
  transform: scale(0.98);
}

/* ── Footer text ────────────────────────────────────────────── */
.p4-footer {
  font-size: 0.72rem;
  color: var(--hrms-subtle);
  text-align: center;
  margin: 1.25rem 0 0;
  letter-spacing: 0.01em;
}

/* ── Theme toggle ───────────────────────────────────────────── */
.p4-theme-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 999;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--hrms-border);
  background: var(--hrms-card);
  color: var(--hrms-text);
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--hrms-shadow);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

html.hrms-dark .p4-theme-btn {
  background: var(--hrms-card-alt);
  border-color: var(--hrms-border);
}

.p4-theme-btn:hover {
  border-color: var(--p4-red);
  box-shadow: 0 0 0 3px var(--p4-red-muted);
}

.p4-theme-btn .p4-icon-light { display: none; }
.p4-theme-btn .p4-icon-dark  { display: block; }

html.hrms-dark .p4-theme-btn .p4-icon-light { display: block; }
html.hrms-dark .p4-theme-btn .p4-icon-dark  { display: none; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  body.page-404-body { overflow: auto; }

  .p4-scene { min-height: 100svh; align-items: flex-start; padding-top: 3rem; }

  .p4-col { padding: 1.5rem 1rem 2.5rem; }

  .p4-glitch { font-size: 6.5rem; }

  .p4-card { padding: 1.5rem 1.25rem 1.375rem; }

  .p4-actions { flex-direction: column; }

  .p4-btn { width: 100%; }
}

@media (min-height: 600px) and (min-width: 576px) {
  body.page-404-body { overflow: hidden; }
  .p4-scene { min-height: 100vh; }
}
