/*
Every Layout Token System
Fluid scale and design tokens for consistent spacing and sizing
*/

/* Fluid Scale - Utopia-style responsive tokens */
:root {
  /* Fluid spacing scale - grows from mobile to desktop */
  --s-1: clamp(0.25rem, 0.2vw + 0.2rem, 0.375rem);
  --s-2: clamp(0.5rem, 0.4vw + 0.3rem, 0.75rem);
  --s-3: clamp(0.75rem, 0.6vw + 0.4rem, 1rem);
  --s-4: clamp(1rem, 0.9vw + 0.5rem, 1.25rem);
  --s-5: clamp(1.5rem, 1.2vw + 0.7rem, 2rem);
  --s-6: clamp(2rem, 1.8vw + 1rem, 3rem);
  --s-7: clamp(3rem, 2.5vw + 1.5rem, 4.5rem);

  /* Fluid typography scale - responsive type sizes */
  --text-xs: clamp(0.75rem, 0.1vw + 0.7rem, 0.8rem);
  --text-sm: clamp(0.875rem, 0.15vw + 0.8rem, 0.9rem);
  --text-base: clamp(1rem, 0.2vw + 0.9rem, 1.1rem);
  --text-lg: clamp(1.125rem, 0.3vw + 1rem, 1.25rem);
  --text-xl: clamp(1.25rem, 0.4vw + 1.1rem, 1.4rem);
  --text-2xl: clamp(1.5rem, 0.6vw + 1.3rem, 1.75rem);
  --text-3xl: clamp(1.875rem, 0.8vw + 1.6rem, 2.25rem);
  --text-4xl: clamp(2.25rem, 1.2vw + 1.9rem, 3rem);
  --text-5xl: clamp(3rem, 1.8vw + 2.4rem, 4rem);
  --text-6xl: clamp(3.75rem, 2.5vw + 3rem, 5.5rem);

  /* Typography rhythm and spacing */
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-loose: 1.75;

  /* Font weights */
  --font-light: 300;
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;
  --font-extrabold: 800;

  /* Layout tokens */
  --gap: var(--s-3);          /* Default gap for layouts */
  --measure: 60ch;            /* Comfortable reading measure */
  --measure-short: 45ch;      /* Narrow content */
  --measure-long: 80ch;       /* Wide content */

  /* Size tokens for components */
  --size-xs: var(--s-1);
  --size-sm: var(--s-2);
  --size-md: var(--s-3);
  --size-lg: var(--s-4);
  --size-xl: var(--s-5);

  /* Border radius scale */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Shadow scale */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

  /* NEW: Theme-aware semantic colors using DaisyUI variables */
  --fg-default: oklch(var(--bc));      /* DaisyUI base content - always correct for theme */
  --fg-muted: oklch(var(--bc) / 0.6);  /* Muted text with 60% opacity */
  --fg-brand: oklch(var(--p));         /* DaisyUI primary color */
  --fg-success: oklch(var(--su));      /* DaisyUI success color */
  --fg-warning: oklch(var(--wa));      /* DaisyUI warning color */
  --fg-error: oklch(var(--er));        /* DaisyUI error color */

  --bg-surface: oklch(var(--b1));      /* DaisyUI base-100 - main background */
  --bg-subtle: oklch(var(--b2));       /* DaisyUI base-200 - subtle background */
  --bg-muted: oklch(var(--b3));        /* DaisyUI base-300 - muted background */

  --border-default: oklch(var(--bc) / 0.2);   /* Subtle border using base content */
  --border-strong: oklch(var(--bc) / 0.4);    /* Stronger border */
}

/* Theme-aware base styles - use our semantic tokens */
html, body {
  background-color: var(--bg-surface);
  color: var(--fg-default);
}

/* Ensure dropdown works with any theme */
.dropdown-content {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-default);
  color: var(--fg-default);
}

/* Enhanced typography utilities */
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-3xl { font-size: var(--text-3xl); }
.text-4xl { font-size: var(--text-4xl); }
.text-5xl { font-size: var(--text-5xl); }
.text-6xl { font-size: var(--text-6xl); }

.leading-tight { line-height: var(--line-height-tight); }
.leading-normal { line-height: var(--line-height-normal); }
.leading-loose { line-height: var(--line-height-loose); }

.font-light { font-weight: var(--font-light); }
.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }
.font-extrabold { font-weight: var(--font-extrabold); }

/* Enhanced heading styles with better hierarchy */
.heading-hero {
  font-size: var(--text-6xl);
  font-weight: var(--font-extrabold);
  line-height: var(--line-height-tight);
  letter-spacing: -0.025em;
}

.heading-1 {
  font-size: var(--text-5xl);
  font-weight: var(--font-bold);
  line-height: var(--line-height-tight);
  letter-spacing: -0.025em;
}

.heading-2 {
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  line-height: var(--line-height-tight);
  letter-spacing: -0.025em;
}

.heading-3 {
  font-size: var(--text-3xl);
  font-weight: var(--font-semibold);
  line-height: var(--line-height-tight);
}

.heading-4 {
  font-size: var(--text-2xl);
  font-weight: var(--font-semibold);
  line-height: var(--line-height-normal);
}

.heading-5 {
  font-size: var(--text-xl);
  font-weight: var(--font-medium);
  line-height: var(--line-height-normal);
}

.heading-6 {
  font-size: var(--text-lg);
  font-weight: var(--font-medium);
  line-height: var(--line-height-normal);
}

/* Content type styles */
.text-body {
  font-size: var(--text-base);
  line-height: var(--line-height-normal);
  color: var(--fg-default);
}

.text-caption {
  font-size: var(--text-sm);
  line-height: var(--line-height-normal);
  color: var(--fg-muted);
}

.text-label {
  font-size: var(--text-sm);
  line-height: var(--line-height-normal);
  font-weight: var(--font-medium);
  color: var(--fg-default);
}

/* Demo styling for primitive examples */
.demo-box {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: var(--s-3);
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  line-height: var(--line-height-normal);
}

.demo-box-sm {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: var(--s-1) var(--s-2);
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: 500;
  font-size: 0.875rem;
}

.demo-box-large {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: var(--s-5) var(--s-6);
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: 500;
}

.demo-box-alt {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  padding: var(--s-3);
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: 500;
}

.code-block {
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--s-3);
  font-family: 'SF Mono', Monaco, 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;
  font-size: 0.875rem;
  overflow-x: auto;
  white-space: pre;
  color: var(--fg-default);
}

/* Utility classes for token usage */
.space-s-1 { gap: var(--s-1); }
.space-s-2 { gap: var(--s-2); }
.space-s-3 { gap: var(--s-3); }
.space-s-4 { gap: var(--s-4); }
.space-s-5 { gap: var(--s-5); }
.space-s-6 { gap: var(--s-6); }
.space-s-7 { gap: var(--s-7); }

.pad-s-1 { padding: var(--s-1); }
.pad-s-2 { padding: var(--s-2); }
.pad-s-3 { padding: var(--s-3); }
.pad-s-4 { padding: var(--s-4); }
.pad-s-5 { padding: var(--s-5); }
.pad-s-6 { padding: var(--s-6); }
.pad-s-7 { padding: var(--s-7); }

/* Container width utilities */
.measure { max-width: var(--measure); }
.measure-short { max-width: var(--measure-short); }
.measure-long { max-width: var(--measure-long); }

/* Interactive resizable demo containers */
.resizable-demo {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: linear-gradient(
    90deg,
    var(--bg-surface) 0%,
    var(--bg-subtle) 50%,
    var(--bg-surface) 100%
  );
  min-width: 200px;
  max-width: 100%;
  resize: horizontal;
  overflow: auto;
  padding: var(--s-3);
  transition: all 0.2s ease;
}

.resizable-demo:hover {
  border-color: var(--fg-brand);
  box-shadow: 0 0 0 1px oklch(var(--p) / 0.3);
}

.resizable-demo::after {
  content: '↔️ Drag to resize';
  position: absolute;
  top: -1.5rem;
  right: 0;
  font-size: 0.75rem;
  color: var(--fg-muted);
  background: var(--bg-surface);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.resizable-demo:hover::after {
  opacity: 1;
}

/* Width indicators for demos */
.width-indicator {
  position: absolute;
  bottom: -2rem;
  left: 0;
  font-size: 0.75rem;
  color: var(--fg-brand);
  font-weight: 600;
  background: var(--bg-surface);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
}

/* Responsive behavior animations */
.responsive-animation {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Demo states for different breakpoints */
.demo-mobile {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border-color: #f59e0b;
}

.demo-tablet {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  border-color: #3b82f6;
}

.demo-desktop {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  border-color: #10b981;
}
