/* ════════════════════════════════════════════════
   EXTRAS — Film Grain · Intro Screen · Command Palette
   Add to index.html <head>:
     <link rel="stylesheet" href="css/extras.css" />
════════════════════════════════════════════════ */

/* ────────────────────────────────────────────────
   1. FILM GRAIN
   Animated SVG-noise overlay — zero JS cost,
   pure CSS composition on the GPU.
   ──────────────────────────────────────────────── */
#grain {
  position: fixed;
  inset: -120px;           /* overshoot edges so translate never reveals bg */
  z-index: 998;
  pointer-events: none;
  opacity: 0.042;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  animation: grain-anim 0.38s steps(4) infinite;
  will-change: transform;
}

@keyframes grain-anim {
  0%   { transform: translate(0px,   0px);  }
  25%  { transform: translate(-22px, 14px); }
  50%  { transform: translate(18px, -10px); }
  75%  { transform: translate(-14px,-20px); }
  100% { transform: translate(10px,   8px); }
}

html.light-mode #grain {
  opacity: 0.025;
  mix-blend-mode: multiply;
}

/* ────────────────────────────────────────────────
   2. INTRO SCREEN
   ──────────────────────────────────────────────── */

/* Hide instantly on repeat visits (class set by inline <script> in <head>) */
.intro-seen #intro-overlay { display: none; }

#intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #07070A;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Slide-up curtain exit */
#intro-overlay.exit {
  transform: translateY(-100%);
  transition: transform 0.7s cubic-bezier(0.76, 0, 0.24, 1);
}

/* ── Inner content ── */
.intro-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.intro-site-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(124, 58, 237, 0.5);
  margin-bottom: 1.2rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.intro-site-label.show { opacity: 1; transform: translateY(0); }

.intro-name {
  font-size: clamp(2.8rem, 9vw, 5.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: #F5F7FA;
  margin-bottom: 2.5rem;
  min-height: 1.15em;       /* prevent layout jump during typing */
  white-space: nowrap;
}

/* Blinking cursor after the name */
.intro-name::after {
  content: '_';
  color: #7c3aed;
  animation: cursor-blink 0.75s step-end infinite;
}
.intro-name.done::after { display: none; }   /* remove when exiting */

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Progress bar */
.intro-bar-wrap {
  width: 200px;
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 1px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.intro-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7c3aed, #06b6d4);
  box-shadow: 0 0 10px rgba(124, 58, 237, 0.8);
  transition: width 0.06s linear;
}

.intro-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(139, 147, 163, 0.45);
  min-height: 1.2em;
  transition: opacity 0.25s ease;
}

/* Skip button */
#intro-skip {
  position: absolute;
  bottom: 2rem;
  right: 2.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(139, 147, 163, 0.28);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  opacity: 0;
  transition: opacity 0.4s ease, color 0.2s;
}
#intro-skip.show    { opacity: 1; }
#intro-skip:hover   { color: rgba(139, 147, 163, 0.7); }

/* ────────────────────────────────────────────────
   3. COMMAND PALETTE
   ──────────────────────────────────────────────── */
#cp-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(7, 7, 10, 0.6);
  backdrop-filter: blur(12px) saturate(120%);
  -webkit-backdrop-filter: blur(12px) saturate(120%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 13vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}
#cp-overlay.open {
  opacity: 1;
  pointer-events: all;
}

#cp-panel {
  width: 100%;
  max-width: 560px;
  margin: 0 1rem;
  background: rgba(10, 10, 16, 0.98);
  border: 1px solid rgba(124, 58, 237, 0.22);
  border-radius: 14px;
  box-shadow:
    0 0 0 1px rgba(124, 58, 237, 0.07),
    0 8px 32px rgba(0, 0, 0, 0.55),
    0 32px 80px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  transform: scale(0.96) translateY(-10px);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
#cp-overlay.open #cp-panel {
  transform: scale(1) translateY(0);
}

/* Search row */
#cp-search-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}
#cp-search-icon {
  color: rgba(139, 147, 163, 0.45);
  font-size: 0.82rem;
  flex-shrink: 0;
}
#cp-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: #F5F7FA;
  font-size: 0.92rem;
  font-family: inherit;
  caret-color: #7c3aed;
}
#cp-input::placeholder { color: rgba(139, 147, 163, 0.32); }
#cp-esc-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.58rem;
  color: rgba(139, 147, 163, 0.38);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  flex-shrink: 0;
  cursor: default;
}

/* Results list */
#cp-list {
  max-height: 340px;
  overflow-y: auto;
  padding: 0.3rem 0;
}
#cp-list::-webkit-scrollbar { width: 2px; }
#cp-list::-webkit-scrollbar-thumb {
  background: rgba(124, 58, 237, 0.25);
  border-radius: 1px;
}

.cp-group-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.56rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(139, 147, 163, 0.3);
  padding: 0.65rem 1rem 0.2rem;
  user-select: none;
}

.cp-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: background 0.07s;
  border-left: 2px solid transparent;
}
.cp-item:hover   { background: rgba(124, 58, 237, 0.07); }
.cp-item.active  {
  background: rgba(124, 58, 237, 0.11);
  border-left-color: rgba(124, 58, 237, 0.6);
}
.cp-item.active .cp-item-label { color: #F5F7FA; }

.cp-item-icon  { font-size: 0.8rem; flex-shrink: 0; opacity: 0.75; }
.cp-item-label { font-size: 0.84rem; color: #C6CDD8; line-height: 1; }
.cp-item-label mark { background: none; color: #a78bfa; font-weight: 600; }

.cp-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(139, 147, 163, 0.28);
}

/* Footer hints */
#cp-footer {
  display: flex;
  gap: 1.25rem;
  padding: 0.55rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(0, 0, 0, 0.22);
}
#cp-footer span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.6rem;
  color: rgba(139, 147, 163, 0.3);
}
#cp-footer kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.56rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 3px;
  padding: 0.1rem 0.3rem;
  color: rgba(139, 147, 163, 0.4);
}

/* ⌘K button in navbar */
#paletteBtn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.04em;
  color: var(--t1); 
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--t1); 
  border-radius: 5px;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  white-space: nowrap;
}
#paletteBtn:hover {
  color: rgba(139, 147, 163, 0.85);
  border-color: rgba(124, 58, 237, 0.3);
  background: rgba(124, 58, 237, 0.06);
}
@media (max-width: 420px) { #paletteBtn { display: none; } }

html.light-mode #paletteBtn {
  border-color: rgba(15, 23, 42, 0.11);
  background: rgba(255, 255, 255, 0.6);
  color: rgba(71, 85, 105, 0.6);
}
html.light-mode #paletteBtn:hover {
  border-color: rgba(79, 70, 229, 0.28);
  background: rgba(79, 70, 229, 0.05);
  color: rgba(71, 85, 105, 1);
}
