/* resets & global text/link */

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
html, body { overflow-x: hidden; }

body {
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: #0d1117;
  opacity: 1;
  transition: opacity 220ms ease;
}

.loading-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-overlay-inner {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.loading-pretext {
  font-size: 24px;
  line-height: 1.2;
  color: #c9d1d9;
  font-weight: 500;
  min-height: 1.2em;
}

.loading-gif {
  width: 88px;
  height: 88px;
  image-rendering: pixelated;
}

.loading-text {
  font-size: 24px;
  line-height: 1.2;
  color: #c9d1d9;
  font-weight: 500;
  min-height: 1.2em;
}

.loading-pretext.typing::after,
.loading-text.typing::after {
  content: "";
  display: inline-block;
  width: 1px;
  height: 1.05em;
  margin-left: 3px;
  background: #8b949e;
  vertical-align: text-bottom;
  animation: loading-caret 0.8s steps(1, end) infinite;
}

.loading-continue {
  border: 1px solid #3fb950;
  border-radius: 8px;
  background: rgba(63, 185, 80, 0.2);
  color: #adf2c1;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 14px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.loading-continue:hover {
  background: rgba(63, 185, 80, 0.3);
  border-color: #56d364;
}

.loading-continue.is-ready {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  animation: loading-continue-flicker 1s steps(2, end) infinite;
}

@keyframes loading-caret {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes loading-continue-flicker {
  0%, 48% {
    opacity: 1;
  }
  50%, 100% {
    opacity: 0.45;
  }
}

img,
iframe {
  max-width: 100%;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

.page { padding-top: 58px; }

/* Keep topbar static; animate only content/footer on page transition */
.page,
.site-footer {
  opacity: 1;
  transition: opacity 180ms ease;
}

body.page-leave .page,
body.page-leave .site-footer {
  opacity: 0;
}

/* Simple site-wide motion */
.reveal {
  opacity: 0;
  transform: translateY(10px);
}

body.is-ready .reveal {
  animation: fade-up 460ms ease-out both;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Selection/switch animations */
.tab-content {
  opacity: 0;
  transform: translateY(4px);
}

.tab-content.active {
  opacity: 1;
  transform: translateY(0);
}

.tab-content.switch-in,
.pexp-main.switch-in,
.blog-panel.switch-in {
  animation: switch-in 220ms ease-out both;
}

.select-pop {
  animation: select-pop 140ms ease-out;
}

@keyframes switch-in {
  from {
    opacity: 0.3;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes select-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.004); }
  100% { transform: scale(1); }
}

/* Hover motion polish */
.panel,
.skill-chip,
.project-nav-item,
.blog-timeline-item {
  transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.nav-link,
.theme-btn {
  transition: none;
}

.panel:hover {
  transform: translateY(-1px);
}

/* Respect reduced-motion users */
@media (prefers-reduced-motion: reduce) {
  .reveal,
  body.is-ready .reveal {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .panel,
  .skill-chip,
  .project-nav-item,
  .blog-timeline-item {
    transition: none;
  }
}
