/*
 * global.css — YieldSwarm unified design system
 * Owns: shared components (buttons, cards, forms, loading states, utilities, toast).
 * Does NOT own: page-specific layouts, section-level styles (hero, layers, etc).
 * Include on every page via <link> after theme.css.
 */

/* ===== DESIGN TOKENS ===== */
:root {
  --ys-radius-sm: 6px;
  --ys-radius-md: 10px;
  --ys-radius-lg: 14px;
  --ys-radius-xl: 20px;
  --ys-radius-pill: 100px;

  --ys-space-xs: 0.25rem;
  --ys-space-sm: 0.5rem;
  --ys-space-md: 1rem;
  --ys-space-lg: 1.5rem;
  --ys-space-xl: 2rem;
  --ys-space-2xl: 3rem;
  --ys-space-3xl: 4rem;
  --ys-space-4xl: 6rem;

  --ys-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --ys-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --ys-shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --ys-shadow-glow-green: 0 0 20px rgba(0, 255, 136, 0.15), 0 0 60px rgba(0, 255, 136, 0.05);
  --ys-shadow-glow-cyan: 0 0 20px rgba(0, 212, 255, 0.15), 0 0 60px rgba(0, 212, 255, 0.05);

  --ys-transition-fast: 0.15s ease;
  --ys-transition-base: 0.25s ease;
  --ys-transition-slow: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}


/* ===== TYPOGRAPHY UTILITIES ===== */
.ys-text-xs   { font-size: 0.7rem; }
.ys-text-sm   { font-size: 0.8rem; }
.ys-text-base { font-size: 0.95rem; }
.ys-text-lg   { font-size: 1.15rem; }
.ys-text-xl   { font-size: 1.4rem; }
.ys-text-2xl  { font-size: 1.8rem; }
.ys-text-3xl  { font-size: 2.4rem; }

.ys-text-mono { font-family: var(--font-mono, 'JetBrains Mono', monospace); }
.ys-text-display { font-family: var(--font-display, 'Space Grotesk', sans-serif); }

.ys-text-green   { color: var(--accent-green); }
.ys-text-cyan    { color: var(--accent-cyan); }
.ys-text-amber   { color: var(--accent-amber); }
.ys-text-primary { color: var(--text-primary); }
.ys-text-muted   { color: var(--text-muted); }
.ys-text-secondary { color: var(--text-secondary); }

.ys-font-bold   { font-weight: 700; }
.ys-font-medium { font-weight: 500; }
.ys-uppercase   { text-transform: uppercase; letter-spacing: 0.1em; }


/* ===== BUTTON SYSTEM ===== */
.ys-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-weight: 600;
  font-size: 0.88rem;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  border: none;
  cursor: pointer;
  border-radius: var(--ys-radius-md);
  padding: 0.7rem 1.4rem;
  transition: all var(--ys-transition-fast);
  position: relative;
  overflow: hidden;
}
.ys-btn:focus-visible {
  outline: 2px solid var(--accent-green);
  outline-offset: 3px;
}

/* Primary — high-contrast green CTA */
.ys-btn-primary {
  background: var(--accent-green);
  color: #08090d;
  font-weight: 700;
}
.ys-btn-primary:hover {
  background: #00e67a;
  transform: translateY(-1px);
  box-shadow: var(--ys-shadow-glow-green);
}
.ys-btn-primary:active {
  transform: translateY(0);
  box-shadow: none;
  background: #00e67a;
}

/* Secondary — outlined, subtle */
.ys-btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.ys-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}
.ys-btn-secondary:active {
  transform: translateY(0);
  opacity: 0.85;
}

/* Ghost — minimal, text-only feel */
.ys-btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.5rem 0.9rem;
}
.ys-btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}
.ys-btn-ghost:active {
  background: rgba(255, 255, 255, 0.1);
  opacity: 0.85;
}

/* Accent variants */
.ys-btn-cyan {
  background: var(--accent-cyan);
  color: #08090d;
  font-weight: 700;
}
.ys-btn-cyan:hover {
  background: #00bfe6;
  transform: translateY(-1px);
  box-shadow: var(--ys-shadow-glow-cyan);
}
.ys-btn-cyan:active {
  transform: translateY(0);
  box-shadow: none;
  background: #00bfe6;
}

.ys-btn-amber {
  background: var(--accent-amber);
  color: #08090d;
  font-weight: 700;
}
.ys-btn-amber:hover {
  background: #e69900;
  transform: translateY(-1px);
}
.ys-btn-amber:active {
  transform: translateY(0);
  opacity: 0.85;
}

/* Button sizes */
.ys-btn-sm {
  font-size: 0.78rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--ys-radius-sm);
}
.ys-btn-lg {
  font-size: 1rem;
  padding: 0.85rem 1.8rem;
  border-radius: var(--ys-radius-lg);
}
.ys-btn-xl {
  font-size: 1.1rem;
  padding: 1rem 2.2rem;
  border-radius: var(--ys-radius-lg);
}
.ys-btn-pill {
  border-radius: var(--ys-radius-pill);
}
.ys-btn-block {
  display: flex;
  width: 100%;
}

/* Disabled state */
.ys-btn:disabled,
.ys-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Button icon arrow animation */
.ys-btn .ys-btn-arrow {
  transition: transform var(--ys-transition-fast);
}
.ys-btn:hover .ys-btn-arrow {
  transform: translateX(3px);
}
.ys-btn:active .ys-btn-arrow {
  transform: translateX(1px);
}


/* ===== CARD SYSTEM ===== */
.ys-card {
  background: var(--bg-surface, #0f1117);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  border-radius: var(--ys-radius-lg);
  padding: var(--ys-space-lg);
  position: relative;
  overflow: hidden;
  transition: border-color var(--ys-transition-fast), background var(--ys-transition-fast);
}
.ys-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}
.ys-card:active {
  border-color: rgba(255, 255, 255, 0.12);
  background: var(--bg-elevated, #161922);
}

/* Card with top accent stripe */
.ys-card-accent::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-green), transparent);
  opacity: 0.6;
}
.ys-card-accent.cyan::before {
  background: linear-gradient(90deg, var(--accent-cyan), transparent);
}
.ys-card-accent.amber::before {
  background: linear-gradient(90deg, var(--accent-amber), transparent);
}

/* Interactive card */
.ys-card-interactive {
  cursor: pointer;
}
.ys-card-interactive:hover {
  background: var(--bg-elevated, #161922);
  border-color: rgba(0, 255, 136, 0.15);
  transform: translateY(-2px);
  box-shadow: var(--ys-shadow-md);
}
.ys-card-interactive:active {
  background: var(--bg-elevated, #161922);
  transform: translateY(0);
}

/* Card elevated */
.ys-card-elevated {
  background: var(--bg-elevated, #161922);
}


/* ===== FORM SYSTEM ===== */
.ys-input,
.ys-textarea,
.ys-select {
  width: 100%;
  background: var(--bg-surface, #0f1117);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  border-radius: var(--ys-radius-md);
  padding: 0.75rem 1rem;
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-size: 0.92rem;
  color: var(--text-primary, #e8eaf0);
  transition: border-color var(--ys-transition-fast), box-shadow var(--ys-transition-fast);
  outline: none;
}
.ys-input::placeholder,
.ys-textarea::placeholder {
  color: var(--text-muted, #5a5e72);
}
.ys-input:focus,
.ys-textarea:focus,
.ys-select:focus {
  border-color: var(--border-accent, rgba(0, 255, 136, 0.2));
  box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.08);
}

/* Input with error */
.ys-input-error {
  border-color: #ff4466 !important;
  box-shadow: 0 0 0 3px rgba(255, 68, 102, 0.1) !important;
}

/* Form label */
.ys-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary, #8b8fa3);
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}

/* Form group */
.ys-form-group {
  margin-bottom: var(--ys-space-lg);
}

/* Validation message */
.ys-field-error {
  font-size: 0.75rem;
  color: #ff4466;
  margin-top: 0.35rem;
  display: none;
}
.ys-field-error.visible {
  display: block;
}

/* Form help text */
.ys-field-help {
  font-size: 0.75rem;
  color: var(--text-muted, #5a5e72);
  margin-top: 0.35rem;
}

/* Textarea */
.ys-textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.6;
}

/* Select */
.ys-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8fa3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}


/* ===== BADGE / TAG SYSTEM ===== */
.ys-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: var(--ys-radius-pill);
  letter-spacing: 0.03em;
}
.ys-badge-green {
  color: var(--accent-green);
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.2);
}
.ys-badge-cyan {
  color: var(--accent-cyan);
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.2);
}
.ys-badge-amber {
  color: var(--accent-amber);
  background: rgba(255, 170, 0, 0.1);
  border: 1px solid rgba(255, 170, 0, 0.2);
}
.ys-badge-red {
  color: #ff4466;
  background: rgba(255, 68, 102, 0.1);
  border: 1px solid rgba(255, 68, 102, 0.2);
}

/* Live status dot */
.ys-badge .ys-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: ys-pulse-dot 2s ease-in-out infinite;
}
@keyframes ys-pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}


/* ===== LOADING STATES ===== */

/* Skeleton loader */
.ys-skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface, #0f1117) 25%,
    var(--bg-elevated, #161922) 50%,
    var(--bg-surface, #0f1117) 75%
  );
  background-size: 200% 100%;
  animation: ys-skeleton-shimmer 1.8s ease-in-out infinite;
  border-radius: var(--ys-radius-sm);
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}
.ys-skeleton * {
  visibility: hidden;
}
@keyframes ys-skeleton-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Skeleton variants */
.ys-skeleton-text {
  height: 0.85rem;
  width: 80%;
  margin-bottom: 0.5rem;
}
.ys-skeleton-text:last-child {
  width: 55%;
}
.ys-skeleton-heading {
  height: 1.4rem;
  width: 45%;
  margin-bottom: 0.75rem;
}
.ys-skeleton-stat {
  height: 2rem;
  width: 100%;
  margin-bottom: 0.4rem;
}
.ys-skeleton-card {
  min-height: 120px;
}

/* Spinner */
.ys-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  border-top-color: var(--accent-green);
  border-radius: 50%;
  animation: ys-spin 0.7s linear infinite;
}
.ys-spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}
@keyframes ys-spin {
  to { transform: rotate(360deg); }
}

/* Full-section loading */
.ys-loading-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 4rem 2rem;
  color: var(--text-muted, #5a5e72);
  font-size: 0.85rem;
}


/* ===== EMPTY STATES ===== */
.ys-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 2rem;
  gap: 0.75rem;
}
.ys-empty-state-icon {
  font-size: 2.5rem;
  opacity: 0.4;
  margin-bottom: 0.5rem;
}
.ys-empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary, #e8eaf0);
}
.ys-empty-state-desc {
  font-size: 0.88rem;
  color: var(--text-muted, #5a5e72);
  max-width: 360px;
  line-height: 1.6;
}


/* ===== TOAST / NOTIFICATIONS ===== */
.ys-toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.ys-toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.2rem;
  border-radius: var(--ys-radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--bg-elevated, #161922);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  box-shadow: var(--ys-shadow-lg);
  pointer-events: auto;
  animation: ys-toast-in 0.3s var(--ys-transition-slow);
  max-width: 380px;
}
.ys-toast-success {
  border-color: rgba(0, 255, 136, 0.3);
  color: var(--accent-green);
}
.ys-toast-error {
  border-color: rgba(255, 68, 102, 0.3);
  color: #ff4466;
}
.ys-toast-info {
  border-color: rgba(0, 212, 255, 0.3);
  color: var(--accent-cyan);
}
@keyframes ys-toast-in {
  from { opacity: 0; transform: translateX(1rem); }
  to   { opacity: 1; transform: translateX(0); }
}
.ys-toast-out {
  animation: ys-toast-out 0.25s ease forwards;
}
@keyframes ys-toast-out {
  to { opacity: 0; transform: translateX(1rem) scale(0.95); }
}


/* ===== DIVIDER ===== */
.ys-divider {
  border: none;
  border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  margin: var(--ys-space-xl) 0;
}
.ys-divider-text {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted, #5a5e72);
}
.ys-divider-text::before,
.ys-divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle, rgba(255, 255, 255, 0.06));
}


/* ===== SECTION HEADER ===== */
.ys-section-label {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted, #5a5e72);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.ys-section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle, rgba(255, 255, 255, 0.06));
}

.ys-section-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}


/* ===== TABLE ===== */
.ys-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  border-radius: var(--ys-radius-lg);
}
.ys-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.ys-table th {
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted, #5a5e72);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated, #161922);
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  white-space: nowrap;
}
.ys-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  color: var(--text-primary, #e8eaf0);
}
.ys-table tbody tr:last-child td {
  border-bottom: none;
}
.ys-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}


/* ===== STAT VALUE (reusable) ===== */
.ys-stat-value {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
.ys-stat-label {
  font-size: 0.72rem;
  color: var(--text-muted, #5a5e72);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
}


/* ===== TOOLTIP ===== */
[data-ys-tooltip] {
  position: relative;
  cursor: help;
}
[data-ys-tooltip]::after {
  content: attr(data-ys-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated, #161922);
  color: var(--text-primary, #e8eaf0);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: var(--ys-radius-sm);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--ys-transition-fast);
  z-index: 100;
}
[data-ys-tooltip]:hover::after {
  opacity: 1;
}


/* ===== SCROLL TO TOP ===== */
.ys-scroll-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-elevated, #161922);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  color: var(--text-secondary, #8b8fa3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 50;
  opacity: 0;
  transform: translateY(1rem);
  pointer-events: none;
  transition: all var(--ys-transition-base);
  font-size: 1.2rem;
}
.ys-scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.ys-scroll-top:hover {
  background: rgba(0, 255, 136, 0.1);
  border-color: rgba(0, 255, 136, 0.2);
  color: var(--accent-green);
}
.ys-scroll-top:active {
  background: rgba(0, 255, 136, 0.15);
  border-color: rgba(0, 255, 136, 0.3);
  color: var(--accent-green);
}


/* ===== PAGE TRANSITION ===== */
@keyframes ys-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ys-fade-in {
  animation: ys-fade-in 0.4s ease both;
}


/* ===== RESPONSIVE GRID UTILITIES ===== */
.ys-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.ys-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.ys-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

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


/* ===== FLEX UTILITIES ===== */
.ys-flex       { display: flex; }
.ys-flex-col   { flex-direction: column; }
.ys-flex-wrap  { flex-wrap: wrap; }
.ys-items-center { align-items: center; }
.ys-justify-between { justify-content: space-between; }
.ys-justify-center  { justify-content: center; }
.ys-gap-xs  { gap: var(--ys-space-xs); }
.ys-gap-sm  { gap: var(--ys-space-sm); }
.ys-gap-md  { gap: var(--ys-space-md); }
.ys-gap-lg  { gap: var(--ys-space-lg); }
.ys-gap-xl  { gap: var(--ys-space-xl); }


/* ===== SPACING UTILITIES ===== */
.ys-mt-sm { margin-top: var(--ys-space-sm); }
.ys-mt-md { margin-top: var(--ys-space-md); }
.ys-mt-lg { margin-top: var(--ys-space-lg); }
.ys-mt-xl { margin-top: var(--ys-space-xl); }
.ys-mb-sm { margin-bottom: var(--ys-space-sm); }
.ys-mb-md { margin-bottom: var(--ys-space-md); }
.ys-mb-lg { margin-bottom: var(--ys-space-lg); }
.ys-mb-xl { margin-bottom: var(--ys-space-xl); }


/* ===== PAGE CONTAINER ===== */
.ys-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--ys-space-xl);
}
.ys-page-narrow {
  max-width: 820px;
  margin: 0 auto;
  padding: var(--ys-space-xl);
}
.ys-page-wide {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--ys-space-xl);
}


/* ===== SMOOTH PAGE ENTER ===== */
body {
  animation: ys-page-enter 0.35s ease both;
}
@keyframes ys-page-enter {
  from { opacity: 0; }
  to   { opacity: 1; }
}


/* ===== LINK STYLES ===== */
.ys-link {
  color: var(--accent-cyan, #00d4ff);
  text-decoration: none;
  transition: color var(--ys-transition-fast);
}
.ys-link:hover {
  color: #33ddff;
  text-decoration: underline;
}
.ys-link:active {
  opacity: 0.75;
}


/* ===== RESPONSIVE HELPERS ===== */
@media (max-width: 640px) {
  .ys-hide-mobile { display: none !important; }
  .ys-page, .ys-page-narrow, .ys-page-wide {
    padding: var(--ys-space-md);
  }
}
@media (min-width: 641px) {
  .ys-hide-desktop { display: none !important; }
}
