@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap');
@import './variables.css';

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

html {
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Chinese system fonts */
:lang(zh) {
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
}

body {
  background-color: var(--color-bg);
  color: var(--color-white);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  min-height: 100vh;
  overflow-x: hidden;
}

img, video, svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
}

ul, ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  line-height: var(--leading-tight);
  font-weight: var(--weight-bold);
}

/* Page layout wrapper */
.page-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-content {
  flex: 1;
  padding-top: var(--navbar-h);
}

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

/* Section spacing */
.section {
  padding-block: var(--space-24);
}

@media (max-width: 768px) {
  .section {
    padding-block: var(--space-16);
  }
}

/* Selection */
::selection {
  background: var(--color-green-glow);
  color: var(--color-green);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg);
}
::-webkit-scrollbar-thumb {
  background: var(--color-surface);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-green-dim);
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--color-green);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Visually hidden (accessibility) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ═══════════════════════════════════════════════
   PRELOADER
═══════════════════════════════════════════════ */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #080808;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  transition: opacity 0.55s ease, visibility 0.55s ease;
}

#preloader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Logo container */
.preloader__logo {
  position: relative;
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Real logo image — inverted to white on dark bg */
.preloader__logo img {
  width: 140px;
  height: 140px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0;
  transform: scale(0.85);
  animation: preloader-logo-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.1s forwards;
}

/* Rotating accent ring around logo */
.preloader__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 180, 219, 0.15);
  border-top-color: #00B4DB;
  animation: preloader-spin 1.2s linear infinite;
}

.preloader__ring--2 {
  inset: 8px;
  border-top-color: transparent;
  border-right-color: rgba(0, 180, 219, 0.4);
  animation-duration: 2s;
  animation-direction: reverse;
}

/* Progress bar */
.preloader__bar {
  width: 180px;
  height: 2px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  overflow: hidden;
  opacity: 0;
  animation: preloader-fade-in 0.4s ease 0.5s forwards;
}

.preloader__bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00B4DB, rgba(0, 180, 219, 0.4));
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* Label */
.preloader__label {
  position: absolute;
  bottom: -2rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: rgba(0, 180, 219, 0.6);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  animation: preloader-fade-in 0.4s ease 0.6s forwards;
}

/* Dots */
.preloader__dots {
  display: inline-block;
}
.preloader__dots::after {
  content: '';
  animation: preloader-dots 1.4s steps(4, end) infinite;
}

/* Body locked while loading */
body.is-loading {
  overflow: hidden;
}

/* Keyframes */
@keyframes preloader-logo-in {
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes preloader-fade-in {
  to { opacity: 1; }
}

@keyframes preloader-dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  #preloader { transition: none; }
  .preloader__ring { animation: none; }
  .preloader__logo img { animation: none; opacity: 1; transform: none; }
}
