/* ==========================================================
   Device Portfolio — Main Stylesheet
   ========================================================== */

/* --- RESET & VARS --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0a0f;
  --fg: #e0e0e8;
  --accent: #00ffaa;
  --accent2: #ff3366;
  --accent3: #6633ff;
  --dim: #2a2a3a;
  --mono: 'Space Mono', monospace;
  --display: 'Orbitron', sans-serif;
}

html { scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--accent) var(--bg); }

body {
  background: var(--bg); color: var(--fg);
  font-family: var(--mono); overflow-x: hidden;
  cursor: crosshair;
}

a { color: inherit; }
img { max-width: 100%; height: auto; }

/* --- LOADING SCREEN --- */
#loader {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  transition: opacity 0.8s, visibility 0.8s;
}
#loader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
#loader .bar-track {
  width: 300px; height: 3px; background: var(--dim);
  border-radius: 2px; overflow: hidden; margin-top: 24px;
}
#loader .bar-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.3s; }
#loader .label {
  font-family: var(--display); font-size: 11px;
  letter-spacing: 6px; color: var(--accent); margin-top: 12px;
  text-transform: uppercase;
}

/* --- GLITCH TITLE (shared) --- */
.glitch-title {
  font-family: var(--display); font-size: clamp(28px, 5vw, 48px);
  font-weight: 900; color: var(--fg); position: relative;
  text-transform: uppercase; letter-spacing: 4px;
}
.glitch-title::before, .glitch-title::after {
  content: attr(data-text); position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; overflow: hidden;
}
.glitch-title::before {
  color: var(--accent2); clip-path: inset(0 0 60% 0);
  animation: glitch1 2.5s infinite linear alternate-reverse;
}
.glitch-title::after {
  color: var(--accent); clip-path: inset(40% 0 0 0);
  animation: glitch2 2.5s infinite linear alternate-reverse;
}
@keyframes glitch1 {
  0% { transform: translate(0); } 20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -1px); } 60% { transform: translate(-1px, 3px); }
  80% { transform: translate(2px, -2px); } 100% { transform: translate(0); }
}
@keyframes glitch2 {
  0% { transform: translate(0); } 20% { transform: translate(2px, -3px); }
  40% { transform: translate(-2px, 1px); } 60% { transform: translate(3px, -2px); }
  80% { transform: translate(-3px, 3px); } 100% { transform: translate(0); }
}

/* --- WEBGL CANVAS --- */
#webgl-bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

/* --- OVERLAYS --- */
#scanlines {
  position: fixed; inset: 0; z-index: 50; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px);
}
#noise {
  position: fixed; inset: -50%; z-index: 49; pointer-events: none; opacity: 0.035;
  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");
  animation: noiseAnim 0.5s steps(8) infinite;
}
@keyframes noiseAnim {
  0% { transform: translate(0,0); } 25% { transform: translate(-5%,5%); }
  50% { transform: translate(5%,-5%); } 75% { transform: translate(-5%,-5%); }
  100% { transform: translate(5%,5%); }
}
#cursor-glow {
  position: fixed; width: 400px; height: 400px;
  border-radius: 50%; pointer-events: none; z-index: 2;
  background: radial-gradient(circle, rgba(0,255,170,0.04) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  transition: left 0.15s ease-out, top 0.15s ease-out;
}
.glitch-flash {
  position: fixed; inset: 0; z-index: 48;
  pointer-events: none; opacity: 0;
  background: var(--accent); mix-blend-mode: overlay;
}

/* --- NAVIGATION --- */
.device-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 20px 40px;
  display: flex; justify-content: space-between; align-items: center;
  mix-blend-mode: difference;
}
.device-nav .logo {
  font-family: var(--display); font-size: 14px; font-weight: 700;
  letter-spacing: 6px; text-transform: uppercase; color: var(--fg);
}
.device-nav .logo a { text-decoration: none; color: inherit; }
.device-nav .logo .custom-logo { height: 30px; width: auto; }
.device-nav .nav-links { display: flex; gap: 28px; }
.device-nav .nav-links a {
  font-size: 11px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--fg); text-decoration: none; transition: color 0.3s;
}
.device-nav .nav-links a:hover { color: var(--accent); }

/* Mobile toggle */
.nav-toggle {
  display: none; background: none; border: none; cursor: pointer;
  flex-direction: column; gap: 5px; padding: 4px;
}
.nav-toggle span {
  display: block; width: 24px; height: 2px; background: var(--fg);
  transition: all 0.3s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* --- SECTIONS --- */
.device-section {
  position: relative; z-index: 1;
  min-height: 100vh; padding: 120px 60px;
  display: flex; flex-direction: column; justify-content: center;
}

/* --- HERO --- */
#hero { align-items: center; text-align: center; }
#hero h1 {
  font-family: var(--display); font-size: clamp(40px, 8vw, 100px);
  font-weight: 900; line-height: 1.05;
  text-transform: uppercase; letter-spacing: 2px;
  background: linear-gradient(135deg, var(--fg) 0%, var(--accent) 50%, var(--accent2) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  opacity: 0; transform: translateY(40px);
}
#hero .subtitle {
  font-size: 13px; letter-spacing: 8px; text-transform: uppercase;
  color: var(--accent); margin-top: 20px;
  opacity: 0; transform: translateY(20px);
}
#hero .scroll-hint {
  position: absolute; bottom: 40px; left: 50%; transform: translateX(-50%);
  font-size: 10px; letter-spacing: 4px; text-transform: uppercase;
  color: var(--dim); animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

/* --- SOUND PAD --- */
#sound-section { align-items: center; }
#sound-section h2 {
  font-family: var(--display); font-size: 12px;
  letter-spacing: 8px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 40px;
}
.sound-pad {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; max-width: 520px; width: 100%;
}
.pad-btn {
  aspect-ratio: 1; border: 1px solid var(--dim);
  background: rgba(255,255,255,0.02);
  border-radius: 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 2px; text-transform: uppercase;
  color: var(--dim); transition: all 0.15s;
  position: relative; overflow: hidden; user-select: none;
}
.pad-btn::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at center, currentColor, transparent 70%);
  opacity: 0; transition: opacity 0.3s;
}
.pad-btn:hover { border-color: var(--accent); color: var(--accent); }
.pad-btn.active {
  border-color: var(--accent); color: var(--accent);
  background: rgba(0,255,170,0.05);
  box-shadow: 0 0 30px rgba(0,255,170,0.15), inset 0 0 30px rgba(0,255,170,0.05);
}
.pad-btn.active::after { opacity: 0.1; }
.pad-key { font-family: var(--display); font-size: 18px; font-weight: 700; }
.pad-label { font-size: 8px; opacity: 0.6; }
.sound-info {
  margin-top: 24px; font-size: 10px; color: var(--dim);
  letter-spacing: 3px; text-transform: uppercase;
}

/* --- VISUALIZER --- */
#visualizer {
  width: 100%; max-width: 520px; height: 60px;
  margin-top: 20px; display: flex; align-items: flex-end; gap: 2px;
}
#visualizer .vbar {
  flex: 1; background: var(--accent); min-height: 2px;
  border-radius: 1px 1px 0 0; transition: height 0.05s; opacity: 0.7;
}

/* --- PROJECTS --- */
#projects h2 {
  font-family: var(--display); font-size: 12px;
  letter-spacing: 8px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 60px;
}
.project-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px; max-width: 1100px; width: 100%;
}
.project-card {
  border: 1px solid var(--dim); border-radius: 12px;
  padding: 32px; background: rgba(255,255,255,0.01);
  transition: all 0.4s; position: relative; overflow: hidden;
  opacity: 0; transform: translateY(40px);
}
.project-card::before {
  content: ''; position: absolute; top: 0; left: 0;
  width: 100%; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--accent3));
  opacity: 0; transition: opacity 0.4s;
}
.project-card:hover {
  border-color: var(--accent); transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,255,170,0.08);
}
.project-card:hover::before { opacity: 1; }
.project-card .p-number {
  font-family: var(--display); font-size: 36px; font-weight: 900;
  color: var(--dim); line-height: 1; margin-bottom: 16px;
}
.project-card h3 {
  font-family: var(--display); font-size: 16px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 2px; margin-bottom: 12px;
}
.project-card h3 a { text-decoration: none; color: inherit; }
.project-card p { font-size: 13px; line-height: 1.7; color: rgba(224,224,232,0.6); }
.project-card .tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.project-card .tag {
  font-size: 9px; letter-spacing: 2px; text-transform: uppercase;
  padding: 4px 10px; border: 1px solid var(--dim); border-radius: 20px; color: var(--dim);
}
.project-card:hover .tag { border-color: var(--accent); color: var(--accent); }
.project-link {
  display: inline-block; margin-top: 16px; font-size: 11px;
  letter-spacing: 2px; text-transform: uppercase; text-decoration: none;
  color: var(--accent); transition: opacity 0.3s;
}
.project-link:hover { opacity: 0.7; }

/* --- ABOUT --- */
#about { max-width: 800px; margin: 0 auto; }
#about h2 {
  font-family: var(--display); font-size: 12px;
  letter-spacing: 8px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 40px;
}
.about-text { font-size: 15px; line-height: 2; color: rgba(224,224,232,0.7); }
.about-text span { color: var(--accent); font-weight: 700; }
.stats-row { display: flex; gap: 60px; margin-top: 60px; flex-wrap: wrap; }
.stat { text-align: center; }
.stat .num { font-family: var(--display); font-size: 36px; font-weight: 900; color: var(--fg); }
.stat .lbl { font-size: 9px; letter-spacing: 4px; text-transform: uppercase; color: var(--dim); margin-top: 8px; }

/* --- CONTACT --- */
#contact { align-items: center; text-align: center; }
#contact h2 {
  font-family: var(--display); font-size: clamp(24px, 4vw, 48px);
  font-weight: 900; text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
#contact .contact-sub { font-size: 13px; color: var(--dim); margin-top: 16px; letter-spacing: 3px; }
.contact-links { display: flex; gap: 24px; margin-top: 40px; flex-wrap: wrap; justify-content: center; }
.contact-link {
  font-size: 11px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--fg); text-decoration: none;
  padding: 12px 28px; border: 1px solid var(--dim);
  border-radius: 30px; transition: all 0.3s; display: inline-block;
}
.contact-link:hover {
  border-color: var(--accent); color: var(--accent);
  box-shadow: 0 0 20px rgba(0,255,170,0.15);
}

/* --- SINGLE POST/PROJECT --- */
.device-single { max-width: 800px; margin: 0 auto; }
.single-meta {
  display: flex; align-items: center; gap: 16px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.single-date {
  font-family: var(--display); font-size: 11px;
  letter-spacing: 4px; color: var(--accent); text-transform: uppercase;
}
.single-title {
  font-family: var(--display); font-size: clamp(24px, 4vw, 48px);
  font-weight: 900; text-transform: uppercase; letter-spacing: 2px;
  margin-bottom: 40px;
}
.single-hero-img { margin-bottom: 40px; border-radius: 12px; overflow: hidden; }
.single-hero-img img { width: 100%; display: block; }
.single-content { font-size: 15px; line-height: 2; color: rgba(224,224,232,0.8); }
.single-content h2, .single-content h3 {
  font-family: var(--display); text-transform: uppercase;
  letter-spacing: 2px; margin-top: 48px; margin-bottom: 16px;
}
.single-content a { color: var(--accent); }
.single-content img { border-radius: 8px; margin: 24px 0; }
.single-content code {
  background: rgba(255,255,255,0.05); padding: 2px 8px;
  border-radius: 4px; font-size: 14px;
}
.single-content pre {
  background: rgba(255,255,255,0.03); padding: 20px;
  border-radius: 8px; overflow-x: auto; margin: 24px 0;
}
.single-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 80px; padding-top: 40px; border-top: 1px solid var(--dim);
  font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
}
.single-nav a { color: var(--accent); text-decoration: none; }

/* --- FOOTER --- */
.device-footer {
  position: relative; z-index: 1;
  text-align: center; padding: 40px;
  font-size: 10px; letter-spacing: 3px;
  text-transform: uppercase; color: var(--dim);
}

/* --- PAGINATION --- */
.pagination { margin-top: 60px; text-align: center; }
.pagination .nav-links { display: flex; gap: 8px; justify-content: center; }
.pagination a, .pagination span {
  display: inline-block; padding: 8px 16px;
  border: 1px solid var(--dim); border-radius: 4px;
  font-size: 11px; letter-spacing: 2px; text-decoration: none; color: var(--fg);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); color: var(--bg); border-color: var(--accent); }

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .device-section { padding: 80px 24px; }
  .device-nav { padding: 16px 20px; }
  .device-nav .nav-links {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10,10,15,0.97); flex-direction: column;
    align-items: center; justify-content: center; gap: 32px; z-index: 99;
  }
  .device-nav .nav-links.open { display: flex; }
  .device-nav .nav-links a { font-size: 16px; letter-spacing: 6px; }
  .nav-toggle { display: flex; z-index: 101; }
  .sound-pad { grid-template-columns: repeat(4, 1fr); gap: 8px; max-width: 360px; }
  .project-grid { grid-template-columns: 1fr; }
  .stats-row { gap: 32px; }
}
