/* === Global Styles === */

:root {
  /* Palette */
  --bg:          #0e1419;
  --bg-surface:  #151d25;
  --bg-elevated: #1a242e;
  --card:        #0f1418;
  --accent:      #6ee7b7;
  --accent-glow: rgba(110, 231, 183, 0.15);
  --accent-dim:  #3ec996;
  --muted:       #7a8fa3;
  --text:        #e6eef6;
  --text-dim:    rgba(230, 238, 246, 0.65);
  --danger:      #ff5e5e;
  --glitch-cyan: #00fff7;
  --glitch-pink: #ff00c8;

  /* Spacing scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;

  /* Typography */
  --font-sans: 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;

  /* Layout */
  --max-width:      960px;
  --topbar-height:  52px;
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-med:  300ms var(--ease-out);
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Subtle animated gradient on the body background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-glow), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(110, 231, 183, 0.04), transparent);
  pointer-events: none;
  z-index: 0;
}

/* === Layout === */
.container {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: var(--space-xl) auto;
  padding: 0 var(--space-lg);
}

/* === Topbar === */
.site-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(14, 20, 25, 0.85);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  padding: 0 var(--space-lg);
  height: var(--topbar-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  transition: background var(--transition-med);
}

.site-topbar .topbar-inner {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
}

.topbar-logo {
  height: calc(var(--topbar-height) - 12px);
  width: auto;
  flex: 0 0 auto;
  object-fit: contain;
  display: inline-block;
  transform-origin: center center;
  transition: filter var(--transition-fast), transform var(--transition-fast);
}

.topbar-logo:hover {
  filter: drop-shadow(0 0 8px var(--accent-glow));
  transform: scale(1.08);
}

/* Topbar logo rotation */
@keyframes topbar-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.topbar-logo.rotating { animation: topbar-spin 6s linear infinite; }
[data-page-hidden] .topbar-logo.rotating { animation-play-state: paused; }

/* SVG sub-elements */
.controller { opacity: 1; fill: currentColor; }
.rotor { transform-origin: 50% 50%; animation: topbar-spin 6s linear infinite; }

/* === Nav Links (topbar) === */
.topbar-nav {
  display: flex;
  gap: var(--space-md);
  align-items: center;
}

.topbar-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.topbar-nav a:hover,
.topbar-nav a:focus-visible {
  color: var(--accent);
  background: rgba(110, 231, 183, 0.06);
}

.topbar-nav a.active {
  color: var(--accent);
}

/* === Hero Logo === */
.hero-logo {
  display: flex;
  justify-content: center;
  margin: var(--space-lg) 0 var(--space-xl);
  position: relative;
}

.hero-logo object,
.hero-logo img {
  width: 340px;
  height: 340px;
  max-width: 85%;
  object-fit: contain;
  filter: drop-shadow(0 0 40px rgba(110, 231, 183, 0.08));
  transition: filter var(--transition-med);
}

.hero-logo:hover object,
.hero-logo:hover img {
  filter: drop-shadow(0 0 60px rgba(110, 231, 183, 0.15));
}

/* === Typography === */
h1 { margin: 0; font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { margin: 0 0 var(--space-sm); font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
h3 { margin: 0 0 var(--space-xs); font-size: 1.1rem; font-weight: 600; }
.tagline { margin: 0; color: var(--muted); font-size: 1rem; }

/* === Hero Section === */
.hero {
  margin-top: 0;
  padding: var(--space-lg) var(--space-xl);
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-elevated));
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-lg);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.2),
    0 8px 32px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  transition: box-shadow var(--transition-med), border-color var(--transition-med);
}

.hero:hover {
  border-color: rgba(110, 231, 183, 0.08);
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.2),
    0 12px 48px rgba(0, 0, 0, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hero h2 {
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  color: var(--text-dim);
  line-height: 1.7;
  max-width: 580px;
}

/* === (status-badge removed — no dev hints) === */

/* === Project Cards === */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

.project-card {
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: transform var(--transition-fast), box-shadow var(--transition-med), border-color var(--transition-med);
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity var(--transition-med);
}

.project-card:hover {
  transform: translateY(-2px);
  border-color: rgba(110, 231, 183, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.project-card:hover::before {
  opacity: 1;
}

.project-card h3 { color: var(--text); }

.project-card p {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.6;
}

.project-card .card-tag {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--accent);
  background: rgba(110, 231, 183, 0.06);
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: var(--space-sm);
  margin-right: 4px;
}

.card-link-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  text-decoration: none;
}

/* === Buttons === */
.buttons { display: flex; gap: var(--space-md); margin-top: var(--space-md); flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--accent);
  color: #04201a;
  border: none;
  font-weight: 600;
  box-shadow: 0 2px 12px rgba(110, 231, 183, 0.2);
}

.btn.primary:hover {
  background: var(--accent-dim);
  box-shadow: 0 4px 20px rgba(110, 231, 183, 0.3);
}

/* === Utility Sections === */
.note { color: var(--muted); font-size: 0.9rem; }

.about, .help, .contact {
  margin-top: var(--space-lg);
  padding: var(--space-lg);
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
}

/* === Footer === */
.site-footer {
  position: relative;
  z-index: 1;
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  margin-top: var(--space-2xl);
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.site-footer a:hover { color: var(--text); }

/* === Subtle Glitch Effect (main site — rare, brief) === */
@keyframes glitch-text {
  0%, 100% { transform: translate(0); filter: none; }
  20%      { transform: translate(-2px, 1px); filter: hue-rotate(90deg); }
  40%      { transform: translate(2px, -1px); filter: hue-rotate(-90deg); }
  60%      { transform: translate(-1px, -1px); }
  80%      { transform: translate(1px, 2px); filter: hue-rotate(45deg); }
}

@keyframes glitch-clip {
  0%   { clip-path: inset(40% 0 61% 0); }
  20%  { clip-path: inset(92% 0 1% 0); }
  40%  { clip-path: inset(43% 0 1% 0); }
  60%  { clip-path: inset(25% 0 58% 0); }
  80%  { clip-path: inset(54% 0 7% 0); }
  100% { clip-path: inset(58% 0 43% 0); }
}

@keyframes scanline {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(100vh); }
}

/* Applied by JS randomly */
.glitch-active {
  animation: glitch-text 200ms steps(4) 1 !important;
}

/* Scanline overlay — toggled by JS */
.scanline-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(110, 231, 183, 0.06);
  z-index: 9999;
  pointer-events: none;
  animation: scanline 4s linear infinite;
  opacity: 0;
  transition: opacity 0.3s;
}

.scanline-overlay.visible {
  opacity: 1;
}

/* RGB split pseudo-element for glitched elements */
.glitch-split {
  position: relative;
}

.glitch-split::before,
.glitch-split::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
}

.glitch-split.glitch-active::before {
  color: var(--glitch-cyan);
  opacity: 0.6;
  transform: translate(-2px, -1px);
  clip-path: inset(0 0 50% 0);
}

.glitch-split.glitch-active::after {
  color: var(--glitch-pink);
  opacity: 0.6;
  transform: translate(2px, 1px);
  clip-path: inset(50% 0 0 0);
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  .rotor { animation: none; }
  .topbar-logo.rotating { animation: none; }
  .glitch-active { animation: none !important; }
  .scanline-overlay { animation: none; }
  .status-badge::before { animation: none; }
  body::before { display: none; }
  .corrupted-block { animation: none !important; }
  .c-box { animation: none !important; display: none; }
  .glitch-smiley { animation: none; }
}

/* === Corrupted Block — shakes violently with colored glitch boxes === */
@keyframes block-shake {
  0%   { transform: translate(0, 0) rotate(0deg); }
  10%  { transform: translate(-3px, 2px) rotate(-0.5deg); }
  20%  { transform: translate(4px, -1px) rotate(0.5deg); }
  30%  { transform: translate(-2px, -3px) rotate(-0.3deg); }
  40%  { transform: translate(3px, 1px) rotate(0.4deg); }
  50%  { transform: translate(-1px, 3px) rotate(-0.2deg); }
  60%  { transform: translate(2px, -2px) rotate(0.3deg); }
  70%  { transform: translate(-4px, 1px) rotate(-0.4deg); }
  80%  { transform: translate(1px, -1px) rotate(0.2deg); }
  90%  { transform: translate(-2px, 2px) rotate(-0.3deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.corrupted-block {
  position: relative;
  animation: block-shake 0.1s steps(5) infinite;
  border-color: rgba(255, 0, 200, 0.5) !important;
  overflow: hidden;
  filter: contrast(1.5) saturate(1.5);
}

.corrupted-block:hover {
  animation: block-shake 0.05s steps(5) infinite;
}

/* Layer that holds the colored glitch rectangles */
.corruption-box-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

/* Individual colored glitch boxes */
.c-box {
  position: absolute;
  pointer-events: none;
  mix-blend-mode: screen;
}

@keyframes cbox-flash-1 {
  0%, 85%, 100% { opacity: 0; }
  86%           { opacity: 0.85; transform: translate(-5px, 3px) scaleX(1.1); }
  88%           { opacity: 0; }
  92%           { opacity: 0.6; transform: translate(3px, -2px) scaleX(0.95); }
  94%           { opacity: 0; }
}
@keyframes cbox-flash-2 {
  0%, 78%, 100% { opacity: 0; }
  80%           { opacity: 0.7; transform: translate(4px, -4px) scaleY(1.2); }
  82%           { opacity: 0; }
  90%           { opacity: 0.9; transform: translate(-2px, 5px); }
  92%           { opacity: 0; }
}
@keyframes cbox-flash-3 {
  0%, 70%, 100% { opacity: 0; }
  72%           { opacity: 0.8; transform: translate(2px, 2px) skewX(5deg); }
  74%           { opacity: 0; }
  95%           { opacity: 0.65; transform: translate(-3px, -3px); }
  97%           { opacity: 0; }
}
@keyframes cbox-flash-4 {
  0%, 60%, 100% { opacity: 0; }
  62%           { opacity: 0.5; }
  64%           { opacity: 0; }
  88%           { opacity: 0.75; transform: translate(5px, -1px); }
  90%           { opacity: 0; }
}
@keyframes cbox-flash-5 {
  0%, 50%, 100% { opacity: 0; }
  52%           { opacity: 0.6; transform: translate(-4px, 4px) scaleX(1.3); }
  55%           { opacity: 0; }
  83%           { opacity: 0.8; }
  85%           { opacity: 0; }
}

.c-box-1 {
  top: 10%;
  left: 5%;
  width: 40%;
  height: 8px;
  background: var(--glitch-cyan);
  animation: cbox-flash-1 2.5s steps(3) infinite;
}

.c-box-2 {
  top: 35%;
  right: 8%;
  width: 25%;
  height: 12px;
  background: var(--glitch-pink);
  animation: cbox-flash-2 3.1s steps(4) infinite;
}

.c-box-3 {
  bottom: 25%;
  left: 15%;
  width: 35%;
  height: 6px;
  background: #ffe600;
  animation: cbox-flash-3 2.8s steps(3) infinite;
}

.c-box-4 {
  top: 55%;
  left: 0;
  width: 60%;
  height: 4px;
  background: var(--danger);
  animation: cbox-flash-4 3.5s steps(5) infinite;
}

.c-box-5 {
  bottom: 10%;
  right: 5%;
  width: 45%;
  height: 10px;
  background: var(--glitch-cyan);
  animation: cbox-flash-5 2.2s steps(4) infinite;
}

.glitch-smiley {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  color: rgba(255, 58, 58, 0.7);
  text-shadow: 0 0 8px rgba(255, 58, 58, 0.4);
  text-decoration: none;
  opacity: 1;
  transition: transform 0.3s ease, color 0.3s ease;
  user-select: none;
  animation: smiley-breathe 3s ease-in-out infinite;
  cursor: pointer;
  z-index: 10;
}

.glitch-smiley:hover {
  color: var(--danger);
  text-shadow: 0 0 12px rgba(255, 58, 58, 0.8), 0 0 24px rgba(255, 58, 58, 0.4);
  transform: translate(-50%, -50%) scale(1.15);
}

@keyframes smiley-breathe {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -50%) scale(1.06); }
}

.hero {
  position: relative;
}

/* === Music Player === */
.music-player {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9000;
  background: rgba(21, 29, 37, 0.95);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(110, 231, 183, 0.05);
  overflow: hidden;
  width: 440px;
  transition: transform var(--transition-med), box-shadow var(--transition-med);
}

.music-player:hover {
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(110, 231, 183, 0.1);
}

.mp-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.mp-thumb {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.music-player .mp-thumb {
  display: block;
  max-width: 56px;
  max-height: 56px;
  max-inline-size: 56px;
  inline-size: 56px;
  width: 56px;
  height: 56px;
}

.mp-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mp-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  white-space: normal;
  overflow: visible;
  word-break: break-word;
}

.mp-artist {
  font-size: 0.7rem;
  color: var(--muted);
  white-space: normal;
  overflow: visible;
  word-break: break-word;
}

.music-player .mp-title a {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: text-decoration 140ms var(--ease-out), color 140ms var(--ease-out);
}
.music-player .mp-title a:hover {
  text-decoration: underline;
}

.mp-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.mp-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.mp-btn:hover {
  color: var(--accent);
  background: rgba(110, 231, 183, 0.08);
}

.mp-btn-play {
  color: var(--text);
}

.mp-progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}

.mp-progress {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 0 0 0 var(--radius-md);
  transition: width 0.3s linear;
}

/* === Responsive === */
@media (max-width: 640px) {
  :root {
    --topbar-height: 44px;
  }

  .container {
    padding: 0 var(--space-md);
    margin: var(--space-lg) auto;
  }

  .hero {
    padding: var(--space-md) var(--space-lg);
  }

  .hero-logo object,
  .hero-logo img {
    width: 220px;
    height: 220px;
  }

  .projects-grid {
    grid-template-columns: 1fr;
  }

  .buttons { flex-direction: column; }

  .topbar-nav { gap: var(--space-sm); }
  .topbar-nav a { font-size: 0.8rem; }

  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }

  .glitch-smiley { font-size: 1.4rem; }

  .music-player {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
  }

  .music-player .mp-thumb {
    width: 44px;
    height: 44px;
    max-width: 44px;
    max-height: 44px;
    max-inline-size: 44px;
    inline-size: 44px;
  }
}
