/* ============================================
   REDRAG Tools — Core CSS
   Design Tokens, Reset, Base, Layout, Utilities
   Version: 2.0.0
   ============================================ */

/* ------------------------------------------
   1. DESIGN TOKENS
   ------------------------------------------ */
:root {
  /* Brand (Light Mode) */
  --rt-primary: #482dff;
  --rt-primary-light: #6b55ff;
  --rt-primary-dark: #3a24cc;

  /* Backgrounds (Light Mode) */
  --rt-bg-base: #fdfcff;
  --rt-bg-elevated: #fffdfc;
  --rt-bg-card: #ffffff;
  --rt-bg-card-hover: #f1f1f0;
  --rt-bg-input: #f4f4f5;
  --rt-bg-overlay: rgba(253, 252, 255, 0.85);

  /* Borders (Light Mode) */
  --rt-border-default: #e5e7eb;
  --rt-border-hover: #d1d5db;
  --rt-border-focus: #482dff;

  /* Text (Light Mode) */
  --rt-text-primary: #08102b;
  --rt-text-secondary: #343435;
  --rt-text-muted: #6c6f74;
  --rt-text-disabled: #9ca3af;

  /* Semantic (Light Mode) */
  --rt-success: #45a557;
  --rt-warning: #ff990a;
  --rt-danger: #f44336;
  --rt-info: #0062d1;
}

[data-theme="dark"] {
  /* Brand (Dark Mode) */
  --rt-primary: #8775f5;
  --rt-primary-light: #9e8fff;
  --rt-primary-dark: #6e5ece;

  /* Backgrounds (Dark Mode) */
  --rt-bg-base: #1e1e1e;
  --rt-bg-elevated: #252526;
  --rt-bg-card: #2d2d30;
  --rt-bg-card-hover: #3e3e42;
  --rt-bg-input: #333333;
  --rt-bg-overlay: rgba(30, 30, 30, 0.85);

  /* Borders (Dark Mode) */
  --rt-border-default: #333333;
  --rt-border-hover: #4d4d4d;
  --rt-border-focus: #8775f5;

  /* Text (Dark Mode) */
  --rt-text-primary: #fffdfc;
  --rt-text-secondary: #989b9f;
  --rt-text-muted: #737373;
  --rt-text-disabled: #555555;

  /* Semantic (Dark Mode) */
  --rt-success: #45a557;
  --rt-warning: #ff990a;
  --rt-danger: #f44336;
  --rt-info: #0062d1;
}

:root {
  /* Typography Scale (fluid) */
  --rt-text-hero: clamp(36px, 6vw, 64px);
  --rt-text-h1: clamp(28px, 4vw, 40px);
  --rt-text-h2: clamp(24px, 3.5vw, 32px);
  --rt-text-h3: 20px;
  --rt-text-h4: 17px;
  --rt-text-body: 15px;
  --rt-text-body-lg: 17px;
  --rt-text-small: 13px;
  --rt-text-xs: 11px;

  /* Font Weights */
  --rt-weight-regular: 400;
  --rt-weight-medium: 500;
  --rt-weight-semibold: 600;
  --rt-weight-bold: 700;
  --rt-weight-extrabold: 800;
  --rt-weight-black: 900;

  /* Spacing (8px base) */
  --rt-space-1: 4px;
  --rt-space-2: 8px;
  --rt-space-3: 12px;
  --rt-space-4: 16px;
  --rt-space-5: 24px;
  --rt-space-6: 32px;
  --rt-space-8: 48px;
  --rt-space-10: 64px;
  --rt-space-12: 80px;

  /* Border Radius */
  --rt-radius-sm: 8px;
  --rt-radius: 12px;
  --rt-radius-lg: 16px;
  --rt-radius-xl: 20px;
  --rt-radius-full: 9999px;

  /* Shadows */
  --rt-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --rt-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --rt-shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.5);
  --rt-shadow-glow: 0 4px 16px rgba(230, 57, 70, 0.3);
  --rt-shadow-glow-lg: 0 8px 32px rgba(230, 57, 70, 0.4);

  /* Transitions */
  --rt-transition-fast: all 0.15s ease;
  --rt-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --rt-transition-slow: all 0.35s ease;
  --rt-transition-bounce: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-Index Scale */
  --rt-z-base: 0;
  --rt-z-dropdown: 50;
  --rt-z-sticky: 100;
  --rt-z-overlay: 200;
  --rt-z-modal: 300;
  --rt-z-toast: 400;

  /* Layout */
  --rt-container-max: 1280px;
  --rt-header-height: 72px;
}

/* ------------------------------------------
   2. CSS RESET (Minimal, Targeted)
   ------------------------------------------ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--rt-bg-base);
  color: var(--rt-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Remove default list styles */
ul, ol {
  list-style: none;
}

/* Remove default button styles */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

/* Remove default link underline, inherit color */
a {
  color: inherit;
  text-decoration: none;
}

/* Images responsive by default */
img, svg, video {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Remove default fieldset styles */
fieldset {
  border: none;
  padding: 0;
}

/* Accessible focus states */
*:focus-visible {
  outline: 2px solid var(--rt-primary-light);
  outline-offset: 2px;
  border-radius: 4px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

/* ------------------------------------------
   3. BASE TYPOGRAPHY
   ------------------------------------------ */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--rt-weight-extrabold);
  line-height: 1.2;
  color: var(--rt-text-primary);
}

h1 { font-size: var(--rt-text-h1); letter-spacing: -0.5px; }
h2 { font-size: var(--rt-text-h2); letter-spacing: -0.5px; }
h3 { font-size: var(--rt-text-h3); letter-spacing: -0.3px; }
h4 { font-size: var(--rt-text-h4); }

p {
  font-size: var(--rt-text-body);
  line-height: 1.7;
  color: var(--rt-text-secondary);
}

strong, b {
  font-weight: var(--rt-weight-bold);
  color: var(--rt-text-primary);
}

/* ------------------------------------------
   4. LAYOUT
   ------------------------------------------ */

/* Container */
.rt-container {
  max-width: var(--rt-container-max);
  margin: 0 auto;
  padding: 0 var(--rt-space-5);
}

@media (max-width: 768px) {
  .rt-container {
    padding: 0 var(--rt-space-4);
  }
}

/* Section spacing */
.rt-section {
  padding: var(--rt-space-10) 0;
}

@media (max-width: 768px) {
  .rt-section {
    padding: var(--rt-space-8) 0;
  }
}

/* Tool Layout Grid */
.rt-tool-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--rt-space-5);
  align-items: start;
  padding-bottom: var(--rt-space-5);
}

/* Prevent grid blowout causing horizontal scroll on mobile */
.rt-tool-layout > * {
  min-width: 0;
}

@media (max-width: 1000px) {
  .rt-tool-layout {
    grid-template-columns: 1fr;
  }
}

/* Sidebar */
.rt-sidebar {
  position: sticky;
  top: calc(var(--rt-header-height) + var(--rt-space-4));
}

@media (max-width: 1000px) {
  .rt-sidebar {
    position: static;
  }
}

/* Content Section (SEO articles) */
.rt-content-section {
  padding: var(--rt-space-8) 0;
  border-top: 1px solid var(--rt-border-default);
}

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

.rt-content-section h3 {
  margin: var(--rt-space-6) 0 var(--rt-space-3);
}

.rt-content-section p {
  margin-bottom: var(--rt-space-4);
}

.rt-content-section ul,
.rt-content-section ol {
  color: var(--rt-text-secondary);
  margin-bottom: var(--rt-space-4);
  padding-left: var(--rt-space-5);
}

.rt-content-section li {
  margin-bottom: var(--rt-space-2);
  line-height: 1.7;
}

.rt-content-section a {
  color: var(--rt-primary-light);
  font-weight: var(--rt-weight-semibold);
}

.rt-content-section a:hover {
  text-decoration: underline;
}

/* ------------------------------------------
   5. UTILITY CLASSES
   ------------------------------------------ */

/* Text */
.u-text-center { text-align: center; }
.u-text-left { text-align: left; }
.u-text-right { text-align: right; }

.u-text-primary { color: var(--rt-text-primary); }
.u-text-secondary { color: var(--rt-text-secondary); }
.u-text-muted { color: var(--rt-text-muted); }

/* Display */
.u-hidden { display: none !important; }
.u-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Spacing */
.u-mb-1 { margin-bottom: var(--rt-space-1); }
.u-mb-2 { margin-bottom: var(--rt-space-2); }
.u-mb-3 { margin-bottom: var(--rt-space-3); }
.u-mb-4 { margin-bottom: var(--rt-space-4); }
.u-mb-5 { margin-bottom: var(--rt-space-5); }
.u-mb-6 { margin-bottom: var(--rt-space-6); }

.u-mt-4 { margin-top: var(--rt-space-4); }
.u-mt-5 { margin-top: var(--rt-space-5); }

/* Flex */
.u-flex { display: flex; }
.u-flex-col { flex-direction: column; }
.u-items-center { align-items: center; }
.u-justify-between { justify-content: space-between; }
.u-gap-2 { gap: var(--rt-space-2); }
.u-gap-3 { gap: var(--rt-space-3); }

/* Width */
.u-w-full { width: 100%; }

/* ------------------------------------------
   6. ACCESSIBILITY
   ------------------------------------------ */

/* Skip to main content link */
.rt-skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--rt-primary);
  color: white;
  padding: 8px 16px;
  font-weight: var(--rt-weight-bold);
  font-size: var(--rt-text-small);
  z-index: 9999;
  transition: top 0.3s;
  border-radius: 0 0 var(--rt-radius-sm) 0;
}

.rt-skip-link:focus {
  top: 0;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast mode adjustments */
@media (prefers-contrast: high) {
  :root {
    --rt-border-default: #555;
    --rt-text-secondary: #ccc;
    --rt-text-muted: #aaa;
  }
}

/* ------------------------------------------
   7. ANIMATIONS
   ------------------------------------------ */
@keyframes rt-fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rt-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes rt-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes rt-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
/* ============================================
   REDRAG Tools — Core CSS (Phase 7 Patch)
   Additions: font-display swap, content-visibility
   ============================================ */

/* Font display swap for faster text rendering */
body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-display: swap;
}

/* Content visibility for below-fold sections (performance) */
.rt-content-section {
  content-visibility: auto;
  contain-intrinsic-size: 0 500px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .rt-hero__glow {
    animation: none !important;
  }
}

/* Print styles for accessibility */
@media print {
  .rt-header, .rt-footer, .rt-mobile-menu-btn, .rt-mobile-menu {
    display: none !important;
  }
  body {
    background: white;
    color: black;
  }
  .rt-card {
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}
