/* ==============================
   Doriax Tests - Styles
   ============================== */

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

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #0f0f18;
  --bg-card: #12121d;
  --bg-card-hover: #181828;
  --border-color: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b8;
  --text-muted: #6b6b80;
  --accent-1: #6c5ce7;
  --accent-2: #a29bfe;
  --accent-3: #00cec9;
  --accent-gradient: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 50%, #00cec9 100%);
  --accent-glow: rgba(108, 92, 231, 0.3);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.5);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --container-max: 1200px;
  --test-stage-max: 1000px;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  margin: 0;
}

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4, h5, p, ol, ul, table { margin: 0; }

a {
  color: var(--accent-2);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-3); }

.text-gradient {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Container --- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 24px;
}

/* ==============================
   Navigation
   ============================== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 16px 0;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  transition: all var(--transition);
}

.has-canvas .navbar {
  background: var(--bg-primary);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.nav-logo-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.nav-logo-wordmark {
  height: 18px;
  width: auto;
  object-fit: contain;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.nav-links a:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.nav-github {
  display: flex !important;
  align-items: center;
  padding: 8px !important;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ==============================
   Page Content
   ============================== */
.page-content {
  padding-top: 80px;
  min-height: calc(100vh - 200px);
}

.page-header {
  text-align: center;
  padding: 48px 0 32px;
}

.page-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.page-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ==============================
   Tests Grid (Index)
   ============================== */
.tests-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  padding: 0 0 80px;
}

.test-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition);
}

.test-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.test-card-thumb {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-bottom: 1px solid var(--border-color);
}

.test-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.test-card:hover .test-card-thumb img {
  transform: scale(1.05);
}

.test-card-body {
  padding: 20px;
}

.test-card-body h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.test-card-body h3 a {
  color: var(--text-primary);
}

.test-card-body h3 a:hover {
  color: var(--accent-2);
}

.test-card-langs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.test-card-langs a {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-3);
  background: rgba(0, 206, 201, 0.1);
  border: 1px solid rgba(0, 206, 201, 0.2);
  padding: 3px 10px;
  border-radius: 100px;
  transition: all var(--transition);
}

.test-card-langs a:hover {
  background: rgba(0, 206, 201, 0.2);
  color: #fff;
}

.test-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ==============================
   Test Page
   ============================== */
.test-header {
  text-align: center;
  padding: 40px 0 24px;
}

.test-title {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.test-lang-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-3);
  background: rgba(0, 206, 201, 0.1);
  border: 1px solid rgba(0, 206, 201, 0.2);
  padding: 4px 14px;
  border-radius: 100px;
  margin-bottom: 12px;
}

.test-change {
  font-size: 0.9rem;
  color: var(--accent-2);
}

.test-change:hover {
  color: var(--accent-3);
}

/* Canvas area */
.test-stage {
  max-width: var(--test-stage-max);
  margin: 0 auto;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  background: #000;
}

.canvas-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-card);
  z-index: 1;
}

.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; }
div.emscripten { text-align: center; }
div.emscripten_border { border: 1px solid var(--border-color); }

canvas.emscripten {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
}

#output {
  width: 80%;
  height: 100px;
  margin: 0 auto;
  margin-top: 24px;
  padding: 12px 16px;
  display: block;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: 'JetBrains Mono', 'Lucida Console', Monaco, monospace;
  font-size: 0.85rem;
  outline: none;
  resize: none;
}

.spinner {
  height: 50px;
  width: 50px;
  margin: 0px auto;
  animation: rotation 0.8s linear infinite;
  border-left: 10px solid var(--accent-1);
  border-right: 10px solid var(--accent-1);
  border-bottom: 10px solid var(--accent-1);
  border-top: 10px solid var(--accent-3);
  border-radius: 100%;
  background-color: var(--accent-2);
}

@keyframes rotation {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

#status {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 8px;
}

/* Test action buttons */
.test-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 32px 0;
  flex-wrap: wrap;
}

.test-actions a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  transition: all var(--transition);
  cursor: pointer;
}

.test-actions a:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* Code snippet */
#code-snippet {
  margin: 24px 0 48px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

#code-snippet div {
  border: none !important;
  border-radius: 0;
  background: #272822 !important;
  margin: 0 !important;
  padding: 0 !important;
}

#code-snippet pre {
  background: #272822 !important;
  color: #f8f8f2 !important;
  padding: 16px;
  margin: 0;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}

#code-snippet table {
  background: #272822 !important;
}

#code-snippet td {
  background: #272822 !important;
}

/* ==============================
   Footer
   ============================== */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 48px 0 32px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 48px;
  margin-bottom: 48px;
}

.footer-logo {
  margin-bottom: 16px;
}

.footer-logo-img {
  height: 48px;
  width: auto;
  object-fit: contain;
  border-radius: 8px;
}

.footer-brand p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.7;
  max-width: 320px;
  margin-bottom: 20px;
}

.footer-social {
  display: flex;
  gap: 12px;
}

.footer-social a {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.footer-social a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.footer-links h4 {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.footer-links ul {
  list-style: none;
}

.footer-links li {
  margin-bottom: 10px;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: color var(--transition);
}

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

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
  text-align: center;
}

.footer-bottom p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-bottom a {
  color: var(--text-secondary);
}

/* ==============================
   Responsive
   ============================== */
@media (max-width: 1024px) {
  .tests-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }
}

@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
    position: relative;
    z-index: 1002;
  }
  .nav-toggle.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .nav-toggle.active span:nth-child(2) {
    opacity: 0;
  }
  .nav-toggle.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
  .nav-links {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
    z-index: 1001;
  }
  .nav-links.open {
    opacity: 1;
    visibility: visible;
  }
  .nav-links a {
    font-size: 1.2rem;
    padding: 12px 24px;
  }
  .tests-grid {
    grid-template-columns: 1fr;
  }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

@media (max-width: 480px) {
  .test-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .test-actions a {
    justify-content: center;
  }
}
