/* ==========================================================================
   CYBERPUNK NEON-DIGITAL DESIGN SYSTEM STYLESHEET
   Project: LCDK CTF Portal
   Colors (Dark Default): Base #050508, Primary Accent #B026FF (Neon Violet), Secondary Accent #F3F315 (Cyber Yellow)
   ========================================================================== */

/* --- 1. LOCAL & THAI FONT DECLARATION --- */
@font-face {
  font-family: '2006_iannnnnISO';
  src: url('../fonts/2006iannnnnISO.woff2') format('woff2'),
       url('../fonts/2006iannnnnISO.woff') format('woff'),
       url('../fonts/2006_iannnnnISO.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* --- 2. ROOT THEME VARIABLES --- */
:root {
  /* Dark Cyberpunk Theme Defaults */
  --color-bg-base: #050508;
  --color-bg-surface: rgba(18, 18, 28, 0.75);
  --color-bg-card: rgba(26, 22, 38, 0.6);
  --color-accent-violet: #B026FF;
  --color-accent-yellow: #F3F315;
  --color-accent-cyan: #00F0FF;
  --color-accent-green: #00FF66;
  --color-accent-red: #FF2A6D;
  --color-text-primary: #E2E8F0;
  --color-text-muted: #94A3B8;
  --color-border-subtle: rgba(176, 38, 255, 0.25);
  --color-grid-line: rgba(176, 38, 255, 0.12);

  /* Fonts */
  --font-display: 'Orbitron', '2006_iannnnnISO', sans-serif;
  --font-body: 'Fira Code', monospace;
  --font-thai-header: '2006_iannnnnISO', 'Orbitron', sans-serif;
}

html.light {
  /* Light Neon Digital Override */
  --color-bg-base: #F0F2F8;
  --color-bg-surface: rgba(255, 255, 255, 0.85);
  --color-bg-card: rgba(240, 243, 255, 0.9);
  --color-accent-violet: #7E00CF;
  --color-accent-yellow: #D6A800;
  --color-accent-cyan: #0088AA;
  --color-accent-green: #00993E;
  --color-accent-red: #D1104D;
  --color-text-primary: #1E293B;
  --color-text-muted: #64748B;
  --color-border-subtle: rgba(126, 0, 207, 0.3);
  --color-grid-line: rgba(126, 0, 207, 0.07);
}

/* --- 3. BASE RESETS & DYNAMIC VIEWPORT STRUCTURE --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--color-bg-base);
  color: var(--color-text-primary);
  font-family: var(--font-body);
  overflow-x: hidden;
  transition: background-color 0.4s ease, color 0.4s ease;
}

/* Dynamic Viewport Height requirement (100dvh structure) */
.dvh-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* Fallback for legacy browsers */
  min-height: 100dvh; /* Modern mobile dynamic address bar proof */
  position: relative;
  z-index: 1;
}

/* --- 4. TYPOGRAPHY & i18N CLASSES --- */
.font-display {
  font-family: var(--font-display);
}
.font-body {
  font-family: var(--font-body);
}

/* When Thai language is active, override headings with local 2006_iannnnnISO Thai font */
html[lang="th"] .header-text,
.lang-th .header-text {
  font-family: var(--font-thai-header);
  letter-spacing: 0.05em;
  line-height: 1.25;
}

html[lang="en"] .header-text,
.lang-en .header-text {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
}

/* --- 5. THE CYBER GRID (TRANSPARENT VIOLET PANNING) --- */
.cyber-grid-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background-color: var(--color-bg-base);
}

.cyber-grid {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background-image: 
    linear-gradient(to right, var(--color-grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--color-grid-line) 1px, transparent 1px);
  background-size: 40px 40px;
  transform: perspective(600px) rotateX(25deg);
  animation: pan-grid 20s linear infinite;
  opacity: 0.85;
}

@keyframes pan-grid {
  0% {
    transform: perspective(600px) rotateX(25deg) translateY(0);
  }
  100% {
    transform: perspective(600px) rotateX(25deg) translateY(40px);
  }
}

/* --- 6. CUSTOM TOAST & MODAL NOTIFICATION STYLES --- */
#custom-notifier-mount {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
  width: calc(100% - 48px);
  pointer-events: none;
}

.custom-toast {
  pointer-events: auto;
  padding: 16px 20px;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  display: flex;
  items-center;
  justify-content: space-between;
  gap: 16px;
  animation: toast-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  background-color: var(--color-bg-card);
  border: 2px solid var(--color-accent-cyan);
  color: var(--color-text-primary);
  backdrop-filter: blur(12px);
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Base font scaling for improved clarity */
html {
  font-size: 16px;
}

body {
  line-height: 1.6;
}

/* --- 7. NEON GLOW EFFECTS (TEXT & BOX SHADOWS) --- */
.neon-glow-violet {
  color: #fff;
  text-shadow: 
    0 0 5px var(--color-accent-violet),
    0 0 15px var(--color-accent-violet),
    0 0 30px var(--color-accent-violet);
}

.neon-glow-yellow {
  color: var(--color-accent-yellow);
  text-shadow: 
    0 0 5px var(--color-accent-yellow),
    0 0 15px var(--color-accent-yellow);
}

.neon-glow-cyan {
  color: var(--color-accent-cyan);
  text-shadow: 
    0 0 5px var(--color-accent-cyan),
    0 0 15px var(--color-accent-cyan);
}

.neon-box-violet {
  border: 1px solid var(--color-accent-violet);
  box-shadow: 
    0 0 10px rgba(176, 38, 255, 0.4),
    inset 0 0 10px rgba(176, 38, 255, 0.2);
}

.neon-box-yellow {
  border: 1px solid var(--color-accent-yellow);
  box-shadow: 
    0 0 10px rgba(243, 243, 21, 0.4),
    inset 0 0 10px rgba(243, 243, 21, 0.2);
}

/* --- 8. GLITCH ANIMATION KEYFRAMES --- */
.animate-glitch {
  position: relative;
  display: inline-block;
  animation: glitch-skew 4s infinite linear alternate-reverse;
}

.animate-glitch::before,
.animate-glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  background: var(--color-bg-base);
}

.animate-glitch::before {
  left: -2px;
  text-shadow: -2px 0 var(--color-accent-cyan);
  animation: glitch-clip-1 3s infinite linear alternate-reverse;
}

.animate-glitch::after {
  left: 2px;
  text-shadow: 2px 0 var(--color-accent-red);
  animation: glitch-clip-2 2.5s infinite linear alternate-reverse;
}

@keyframes glitch-skew {
  0% { transform: skew(0deg); }
  90% { transform: skew(0deg); }
  92% { transform: skew(-3deg); }
  94% { transform: skew(3deg); }
  96% { transform: skew(0deg); }
  100% { transform: skew(0deg); }
}

@keyframes glitch-clip-1 {
  0% { clip-path: inset(20% 0 70% 0); }
  20% { clip-path: inset(60% 0 10% 0); }
  40% { clip-path: inset(40% 0 50% 0); }
  60% { clip-path: inset(80% 0 5% 0); }
  80% { clip-path: inset(10% 0 85% 0); }
  100% { clip-path: inset(30% 0 50% 0); }
}

@keyframes glitch-clip-2 {
  0% { clip-path: inset(70% 0 20% 0); }
  20% { clip-path: inset(10% 0 60% 0); }
  40% { clip-path: inset(50% 0 35% 0); }
  60% { clip-path: inset(15% 0 80% 0); }
  80% { clip-path: inset(85% 0 10% 0); }
  100% { clip-path: inset(40% 0 30% 0); }
}

/* --- 9. ANGULAR CYBER BORDERS USING PSEUDO-ELEMENTS --- */
.cyber-border {
  position: relative;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-subtle);
  padding: 1.5rem;
  backdrop-filter: blur(8px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cyber-border::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: 24px;
  height: 24px;
  border-top: 3px solid var(--color-accent-yellow);
  border-left: 3px solid var(--color-accent-yellow);
  pointer-events: none;
  transition: width 0.3s ease, height 0.3s ease, border-color 0.3s ease;
}

.cyber-border::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 24px;
  height: 24px;
  border-bottom: 3px solid var(--color-accent-yellow);
  border-right: 3px solid var(--color-accent-yellow);
  pointer-events: none;
  transition: width 0.3s ease, height 0.3s ease, border-color 0.3s ease;
}

.cyber-border:hover::before,
.cyber-border:hover::after {
  width: 36px;
  height: 36px;
  border-color: var(--color-accent-violet);
}

.cyber-border:hover {
  border-color: var(--color-accent-violet);
  box-shadow: 0 0 20px rgba(176, 38, 255, 0.25);
  transform: translateY(-2px);
}

/* Variant: Cyber Border Violet (Primary) */
.cyber-border-violet::before,
.cyber-border-violet::after {
  border-color: var(--color-accent-violet);
}
.cyber-border-violet:hover::before,
.cyber-border-violet:hover::after {
  border-color: var(--color-accent-yellow);
}

/* --- 10. MODERN INTERACTION & VIEW TRANSITIONS --- */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.35s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

::view-transition-new(root) {
  animation-name: cyber-fade-in;
}

::view-transition-old(root) {
  animation-name: cyber-fade-out;
}

@keyframes cyber-fade-in {
  from { opacity: 0; transform: scale(0.98); filter: blur(4px); }
  to   { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes cyber-fade-out {
  from { opacity: 1; transform: scale(1); filter: blur(0); }
  to   { opacity: 0; transform: scale(1.02); filter: blur(4px); }
}

/* Smooth entry and exit for dialogs, cards, and tooltips (@starting-style) */
.animate-entry {
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 1;
  transform: translateY(0);
}

@starting-style {
  .animate-entry {
    opacity: 0;
    transform: translateY(12px);
  }
}

/* Custom Cyberpunk Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--color-border-subtle);
  border-radius: 0px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-accent-violet);
  box-shadow: 0 0 8px var(--color-accent-violet);
}

/* Glassmorphism & Utilities */
.cyber-glass {
  background: var(--color-bg-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
