/**
 * Developer Portal - Components
 */

/* ========================================
   BASE STYLES & TYPOGRAPHY
   ======================================== */

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

html {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--font-weight-regular);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--font-weight-bold);
  line-height: 1.2;
  color: var(--text-primary);
}

h1 {
  font-size: var(--text-4xl);
  font-weight: var(--font-weight-extrabold);
}

h2 {
  font-size: var(--text-3xl);
  font-weight: var(--font-weight-bold);
}

h3 {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-semibold);
}

h4 {
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
}

p {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
}

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

a:hover {
  color: var(--accent-hover);
}

code, pre, kbd, samp {
  font-family: var(--font-mono);
}

code {
  font-size: 0.9em;
  background: var(--bg-code-inline);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-xs);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  overflow-x: auto;
}

pre code {
  background: transparent;
  padding: 0;
}

/* ========================================
   LAYOUT
   ======================================== */

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container-narrow {
  max-width: var(--container-narrow);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* ========================================
   NAVIGATION
   ======================================== */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-overlay);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 1000;
  display: flex;
  align-items: center;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--text-primary);
}

.nav-logo svg {
  width: 32px;
  height: 32px;
}

.nav-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  background: var(--accent-subtle);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  list-style: none;
}

.nav-links a {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--duration-fast);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text-primary);
}

.nav-cta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* ========================================
   BUTTONS
   ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-gentle);
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-sm);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
}

.btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

/* ========================================
   HERO
   ======================================== */

.hero {
  padding: calc(var(--header-height) + var(--space-24)) 0 var(--space-24);
  text-align: center;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-text);
  margin-bottom: var(--space-6);
}

.hero-eyebrow::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: var(--radius-full);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.hero h1 {
  font-size: clamp(var(--text-4xl), 6vw, var(--text-6xl));
  margin-bottom: var(--space-6);
}

.hero h1 .accent {
  color: var(--accent-text);
}

.hero-subtitle {
  font-size: var(--text-xl);
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto var(--space-8);
}

.hero-ctas {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

/* ========================================
   STATS BAR
   ======================================== */

.stats-bar {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  padding: var(--space-8);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-8);
  max-width: 900px;
  margin: var(--space-16) auto;
}

.stat {
  text-align: center;
}

.stat-value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 800;
  color: var(--accent-text);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* ========================================
   CODE BLOCKS
   ======================================== */

.code-block {
  position: relative;
  background: var(--bg-code);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-subtle);
}

.code-dots {
  display: flex;
  gap: var(--space-2);
}

.code-dot {
  width: 12px;
  height: 12px;
  border-radius: var(--radius-full);
}

.code-dot-red {
  background: #e07575;
}
.code-dot-yellow {
  background: #e0b860;
}
.code-dot-green {
  background: #6bc48f;
}

.code-lang {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
}

.code-copy {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  padding: var(--space-2);
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--duration-fast);
}

.code-block:hover .code-copy {
  opacity: 1;
}

.code-copy:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.code-content {
  padding: var(--space-4);
  overflow-x: auto;
}

.code-content pre {
  background: transparent;
  padding: 0;
  margin: 0;
}

/* Syntax highlighting */
.token.comment {
  color: var(--syntax-comment);
}
.token.keyword {
  color: var(--syntax-keyword);
}
.token.string {
  color: var(--syntax-string);
}
.token.number {
  color: var(--syntax-number);
}
.token.function {
  color: var(--syntax-function);
}
.token.variable {
  color: var(--syntax-variable);
}
.token.operator {
  color: var(--syntax-operator);
}
.token.class-name {
  color: var(--syntax-class);
}

/* ========================================
   TERMINAL ANIMATION
   ======================================== */

.terminal {
  background: var(--bg-code);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}

.terminal-header {
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-subtle);
}

.terminal-title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-left: var(--space-4);
}

.terminal-body {
  padding: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.8;
}

.terminal-line {
  display: flex;
  align-items: flex-start;
  margin-bottom: var(--space-2);
}

.terminal-prompt {
  color: var(--success);
  margin-right: var(--space-2);
  user-select: none;
}

.terminal-command {
  color: var(--text-primary);
}

.terminal-output {
  color: var(--text-muted);
  padding-left: var(--space-4);
}

.terminal-cursor {
  display: inline-block;
  width: 8px;
  height: 18px;
  background: var(--accent-primary);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* ========================================
   CARDS
   ======================================== */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--duration-normal) var(--ease-gentle);
}

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

.card-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
  color: var(--accent-primary);
}

.card h3 {
  font-size: var(--text-lg);
  margin-bottom: var(--space-2);
}

.card p {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

/* ========================================
   ENDPOINT CARDS
   ======================================== */

.endpoint-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.endpoint-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.endpoint-header:hover {
  background: var(--bg-glass);
}

.endpoint-method {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.method-get {
  background: var(--method-get);
  color: var(--bg-code);
}
.method-post {
  background: var(--method-post);
  color: var(--bg-code);
}
.method-put {
  background: var(--method-put);
  color: var(--bg-code);
}
.method-delete {
  background: var(--method-delete);
  color: var(--bg-code);
}
.method-patch {
  background: var(--method-patch);
  color: var(--bg-code);
}

.endpoint-path {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.endpoint-description {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-left: auto;
}

.endpoint-body {
  padding: var(--space-5);
  border-top: 1px solid var(--border-subtle);
  display: none;
}

.endpoint-card.open .endpoint-body {
  display: block;
}

/* ========================================
   SECTIONS
   ======================================== */

.section {
  padding: var(--space-24) 0;
}

.section-header {
  text-align: center;
  max-width: 600px;
  margin: 0 auto var(--space-12);
}

.section-header h2 {
  margin-bottom: var(--space-4);
}

.section-header p {
  color: var(--text-secondary);
  font-size: var(--text-lg);
}

.section-alt {
  background: var(--bg-secondary);
}

/* ========================================
   GRIDS
   ======================================== */

.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ========================================
   SIDEBAR LAYOUT (for docs)
   ======================================== */

.docs-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  gap: var(--space-8);
  max-width: var(--container-max);
  margin: 0 auto;
  padding: calc(var(--header-height) + var(--space-8)) var(--space-6) var(--space-16);
}

.sidebar {
  position: sticky;
  top: calc(var(--header-height) + var(--space-8));
  height: fit-content;
  max-height: calc(100vh - var(--header-height) - var(--space-16));
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: var(--space-6);
}

.sidebar-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.sidebar-links {
  list-style: none;
}

.sidebar-links li {
  margin-bottom: var(--space-1);
}

.sidebar-links a {
  display: block;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast);
}

.sidebar-links a:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.sidebar-links a.active {
  background: var(--accent-subtle);
  color: var(--accent-text);
}

.docs-content {
  min-width: 0;
}

/* ========================================
   FOOTER
   ======================================== */

.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-16) 0 var(--space-8);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr);
  gap: var(--space-12);
  margin-bottom: var(--space-12);
}

.footer-brand p {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-top: var(--space-4);
  max-width: 280px;
}

.footer-column h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-4);
}

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

.footer-links li {
  margin-bottom: var(--space-2);
}

.footer-links a {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

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

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .footer-bottom {
    flex-direction: column;
    gap: var(--space-4);
    text-align: center;
  }
}

/* ========================================
   THEME TOGGLE
   ======================================== */
.theme-toggle {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 1px solid var(--border-medium);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-gentle);
  color: var(--text-muted);
  box-shadow: var(--shadow-md);
  z-index: 1000;
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  transform: scale(1.05);
  box-shadow: var(--shadow-lg);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* Show sun icon in Zen (light) mode, moon in Cedar (dark) mode */
.theme-toggle .sun-icon { display: none; }
.theme-toggle .moon-icon { display: block; }

[data-theme="zen"] .theme-toggle .sun-icon { display: block; }
[data-theme="zen"] .theme-toggle .moon-icon { display: none; }
