*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #121212;
  --text: #0aff0a;
  --accent: #ff00ff;
}
[data-theme="light"] {
  --bg: #f0f0f0;
  --text: #e0dede;
  --accent: #0077ff;
}
[data-theme="light"] .typing {
  color: #3d4957
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Fira Code', monospace;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s, color 0.3s;
}

/* Preloader */
#preloader {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 300;
  transition: opacity 0.5s ease;
}

#preloader.hide {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(10, 255, 10, 0.2);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#preloader p {
  margin-top: 1rem;
  font-family: 'Fira Code', monospace;
  color: var(--text);
}

#preloader .bar {
  display: inline-block;
  width: 0;
  height: 4px;
  background: var(--accent);
  vertical-align: middle;
  animation: loadBar 2s ease-out forwards;
}

@keyframes loadBar {
  to { width: 100px; }
}

/* Header Dynamic */
#main-header {
  box-sizing: border-box;
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.6);
  transition: padding 0.3s, background 0.3s, backdrop-filter 0.3s;
  z-index: 100;
}

#main-header.scrolled {
  padding: 0.5rem 1rem;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(10px);
}

/* Nav links */
.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-links a {
  color: var(--text);
  position: relative;
  font-size: 0.9rem;
  transition: color 0.2s;
}
.nav-links a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -4px;
  left: 0;
  background: var(--accent);
  transition: width 0.3s;
}
.nav-links a:hover {
  color: var(--accent);
}
.nav-links a:hover::after {
  width: 100%;
}

/* Hamburger (mobile) */
#nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
}
#nav-toggle span {
  display: block;
  width: 25px;
  height: 3px;
  background: var(--text);
  transition: transform 0.3s, opacity 0.3s;
}
#nav-toggle.active span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}
#nav-toggle.active span:nth-child(2) {
  opacity: 0;
}
#nav-toggle.active span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}


/* Mobile view */
@media (max-width: 768px) {
  .nav-links {
    position: fixed;
    top: 0; right: -100%;
    height: 100vh;
    width: 200px;
    background: rgba(0,0,0,0.9);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    transition: right 0.3s;
  }
  .nav-links.open {
    right: 0;
  }
  #nav-toggle {
    display: flex;
  }
}

/* Header */
.logo svg { fill: var(--text); }
nav {
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: center;
}
nav a {
  color: var(--text);
  position: relative;
}
nav a::after {
  content: '';
  position: absolute;
  width: 0;
  height: 2px;
  bottom: -4px;
  left: 0;
  background: var(--accent);
  transition: width 0.3s;
}
nav a:hover::after {
  width: 100%;
}

/* Hero */
#hero {
  position: relative;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  margin-top: 4rem;
}
#particle-bg { position: absolute; width: 100%; height: 100%; top: 0; left: 0; }
.typing { font-size: 2.5rem; z-index: 1; }
.typing.glitch { animation: glitchAnim 1s; }
@keyframes glitchAnim {
  0% { text-shadow: 2px 0 var(--accent); }
  20% { text-shadow: -2px 0 var(--text); }
  40% { text-shadow: 2px 2px var(--accent); }
  60% { text-shadow: -2px -2px var(--text); }
  80% { text-shadow: 2px -2px var(--accent); }
  100% { text-shadow: 0 0 var(--text); }
}

/* Projects */
#projects { padding: 6rem 2rem 2rem; }
#projects h2 { text-align: center; margin-bottom: 2rem; color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; }
.card { background: rgba(0,0,0,0.6); border: 1px solid var(--accent); border-radius: 8px; overflow: hidden; transition: transform 0.3s; }
.card:hover { transform: translateY(-5px); }
.card img { width: 100%; display: block; }
.card-info { padding: 1rem; }
.card-info h3 { margin: 0; color: var(--accent); }
.card-info p { margin: 0.5rem 0 0; font-size: 0.9rem; }

/* Contact */
#contact { padding: 4rem 2rem; background: rgba(0,0,0,0.7); }
#contact h2 { text-align: center; color: var(--accent); margin-bottom: 1.5rem; }
#contact form { display: flex; flex-direction: column; max-width: 500px; margin: 0 auto; }
#contact input, #contact textarea, #contact button { padding: 0.75rem; margin-bottom: 1rem; border: none; border-radius: 4px; font-family: 'Fira Code', monospace; }
#contact input, #contact textarea { background: rgba(255,255,255,0.1); color: var(--text); }
#contact textarea { resize: vertical; }
#contact button { background: var(--accent); color: #fff; cursor: pointer; transition: opacity 0.3s; }
#contact button:hover { opacity: 0.8; }

/* Footer */
footer { padding: 2rem; margin-top: 2rem; text-align: center; }
.terminal { background: rgba(0,0,0,0.7); padding: 1rem; font-family: 'Courier Prime', monospace; }
.terminal p { margin: 0; color: var(--accent); }

/* Theme Switcher Slider */
.theme-switcher .icon {
  font-size: 1.2rem;
  transition: opacity 0.3s, transform 0.3s;
  opacity: 0.5;
}

/* Highlight active icon */
[data-theme="dark"] .theme-switcher .moon {
  opacity: 1;
  transform: scale(1.2);
}
[data-theme="light"] .theme-switcher .sun {
  opacity: 1;
  transform: scale(1.2);
}

/* Switch styling */
.theme-switcher {
  position: fixed;
  bottom: 5px;
  right: 1rem;
  left: auto;
  transform: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  z-index: 200;
  background: rgba(0,0,0,0.6);
  padding: 0.25rem 0.75rem;
  border-radius: 30px;
  backdrop-filter: blur(5px);
  transition: background 0.3s;
}

.theme-switcher .icon {
  font-size: 1.2rem;
  transition: opacity 0.3s, transform 0.3s;
  opacity: 0.5;
}

/* Highlight ikon sesuai tema */
[data-theme="dark"] .theme-switcher .moon {
  opacity: 1;
  transform: scale(1.2);
}
[data-theme="light"] .theme-switcher .sun {
  opacity: 1;
  transform: scale(1.2);
}

/* Styling slider switch */
.theme-switcher .switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}
.theme-switcher .switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.theme-switcher .slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0;
  right: 0; bottom: 0;
  background: var(--text);
  transition: 0.3s;
  border-radius: 24px;
}
.theme-switcher .slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background: var(--accent);
  transition: 0.3s;
  border-radius: 50%;
}
.theme-switcher input:checked + .slider {
  background: var(--text);
}
.theme-switcher input:checked + .slider:before {
  transform: translateX(26px);
}

/* Responsive */
@media (max-width: 600px) {
  header { flex-direction: column; }
  .typing { font-size: 2rem; }
}

/* Popup Styles */
.popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  justify-content: center;
  align-items: center;
  z-index: 200;
}
.popup-content {
  background: var(--bg);
  color: var(--text);
  padding: 2rem;
  border-radius: 8px;
  text-align: center;
}
.popup-content button {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background: var(--accent);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.popup-content button:hover {
  opacity: 0.8;
}
@media (max-width: 600px) {
  header { flex-direction: column; }
  .typing { font-size: 2rem; }
}

/* Reveal Animation */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease-out, transform 0.8s ease-out;
  will-change: opacity, transform;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
  padding-bottom: 42px;
}

/* Interactive Terminal */
#interactive-terminal {
  padding: 1rem;
  background: rgba(0,0,0,0.8);
  margin: 2rem auto;
  max-width: 800px;
  border: 1px solid var(--accent);
  border-radius: 8px;
}

.terminal-widget {
  font-family: 'Courier Prime', monospace;
  color: var(--text);
}
.terminal-output h1,
.terminal-output h2,
.terminal-output h3 {
  font-size: 1.2rem;
  color: var(--accent);
  margin: 0.5em 0;
}

.terminal-output p {
  margin: 0.4em 0;
}

.terminal-output strong {
  font-weight: bold;
  color: var(--accent);
}

.terminal-output em {
  font-style: italic;
  opacity: 0.8;
}

.terminal-output code {
  font-family: 'Fira Code', monospace;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.95em;
  color: var(--accent);
}

.terminal-output pre {
  white-space: pre;
  font-family: 'Fira Code', monospace;
  background: rgba(0,0,0,0.2);
  padding: 0.5rem;
  border-radius: 5px;
  margin: 0.5rem 0;
}

.terminal-output pre code {
  display: block;
  background: rgba(0, 0, 0, 0.4);
  padding: 1em;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0.5em 0;
}

.terminal-output ul,
.terminal-output ol {
  padding-left: 1.5rem;
  margin: 0.5em 0;
}

.terminal-output a {
  color: var(--accent);
  text-decoration: underline;
}

.terminal-output {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 0.5rem;
}

.terminal-output .thinking {
  font-style: italic;
  opacity: 0.7;
}

.terminal-input-line {
  display: flex;
  align-items: center;
}

.prompt {
  margin-right: 0.5rem;
  color: var(--accent);
}

#terminal-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

#terminal-input::placeholder {
  color: rgba(10,255,10,0.5);
}

/* Neon Flicker Animation */
@keyframes neon-flicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
    text-shadow:
      0 0 2px var(--accent),
      0 0 8px var(--accent),
      0 0 16px var(--accent),
      0 0 32px rgba(255,0,255,0.2);
  }
  20%, 24%, 55% {
    text-shadow: none;
  }
}

/* Lantern Glow Around Element */
@keyframes lantern-glow {
  0%, 100% {
    box-shadow: 0 0 15px rgba(255,0,255,0.5), 0 0 30px rgba(255,0,255,0.3);
  }
  50% {
    box-shadow: 0 0 5px rgba(255,0,255,0.2), 0 0 10px rgba(255,0,255,0.1);
  }
}

/* Neon flicker untuk teks */
.neon-flicker {
  color: var(--accent);
  animation: neon-flicker 2s infinite;
}

/* Efek lantern (glow) untuk container/tombol */
.lantern {
  position: relative;
  animation: lantern-glow 3s ease-in-out infinite;
  border-radius: 4px;
  padding: 0.5rem 1rem;
  background: rgba(0,0,0,0.7);
  border: 1px solid var(--accent);
}

/* Hanya animasi kalau sudah visible */
.neon-flicker, .lantern {
  opacity: 0.6;
  transition: opacity 0.3s;
}
.reveal.visible .neon-flicker,
.reveal.visible .lantern {
  opacity: 1;
}

/* Copy button */
.copy-button {
  background: #222;
  color: #0ff;
  border: 1px solid #0ff3;
  padding: 4px 8px;
  margin: 6px 0 12px;
  font-family: inherit;
  font-size: 0.85em;
  cursor: pointer;
  border-radius: 4px;
}
.copy-button:hover {
  background: #0ff3;
  color: #000;
}
