/*
 * DISERC Design System — Phase 3: typography + reusable components
 * Motion is intentionally out of scope. Existing animation systems remain untouched.
 */

:root {
  --font-size-xs: 0.6875rem;
  --font-size-sm: 0.8125rem;
  --font-size-md: 0.9375rem;
  --font-size-lg: 1.0625rem;
  --font-size-xl: clamp(1.25rem, 1.05rem + .7vw, 1.75rem);
  --font-size-2xl: clamp(1.65rem, 1.15rem + 1.6vw, 2.5rem);
  --font-size-3xl: clamp(2.1rem, 1.35rem + 2.5vw, 3.5rem);
  --font-size-display: clamp(2.75rem, 1.6rem + 5.2vw, 6.5rem);

  --leading-tight: 1.04;
  --leading-snug: 1.2;
  --leading-body: 1.65;

  --control-height-sm: 36px;
  --control-height-md: 44px;
  --control-height-lg: 50px;
}

/* Typography primitives */
.ds-display {
  font-family: var(--display);
  font-size: var(--font-size-display);
  font-weight: 500;
  letter-spacing: -.05em;
  line-height: var(--leading-tight);
}

.ds-heading-xl {
  font-family: var(--display);
  font-size: var(--font-size-3xl);
  font-weight: 500;
  letter-spacing: -.045em;
  line-height: var(--leading-tight);
}

.ds-heading-lg {
  font-family: var(--display);
  font-size: var(--font-size-2xl);
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: var(--leading-tight);
}

.ds-heading-md {
  font-family: var(--display);
  font-size: var(--font-size-xl);
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: var(--leading-snug);
}

.ds-body-lg {
  color: var(--muted);
  font-size: var(--font-size-lg);
  line-height: 1.7;
}

.ds-body-sm {
  color: var(--muted);
  font-size: var(--font-size-sm);
  line-height: 1.55;
}

.ds-label {
  color: var(--muted);
  font: 600 var(--font-size-xs)/1.2 var(--mono);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.ds-mono {
  font-family: var(--mono);
  font-size: var(--font-size-sm);
}

/* Surface primitives */
.ds-surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.ds-surface-raised {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.ds-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  min-width: 0;
  overflow: hidden;
}

.ds-card-elevated {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  min-width: 0;
  overflow: hidden;
}

.ds-card-glass {
  background: var(--surface-glass);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-glass);
  min-width: 0;
  overflow: hidden;
  -webkit-backdrop-filter: blur(18px) saturate(125%);
  backdrop-filter: blur(18px) saturate(125%);
}

/* Bento layout primitive */
.ds-bento {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.ds-bento > * {
  min-width: 0;
}

.ds-bento-span-3 { grid-column: span 3; }
.ds-bento-span-4 { grid-column: span 4; }
.ds-bento-span-5 { grid-column: span 5; }
.ds-bento-span-6 { grid-column: span 6; }
.ds-bento-span-7 { grid-column: span 7; }
.ds-bento-span-8 { grid-column: span 8; }
.ds-bento-span-9 { grid-column: span 9; }
.ds-bento-span-12 { grid-column: span 12; }

/* Buttons — component-level baseline; existing hover/animation rules remain in place. */
.ds-btn,
.boton {
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  font: 600 var(--font-size-sm)/1 var(--body);
  gap: var(--space-3);
  justify-content: center;
  min-height: var(--control-height-md);
  padding: 10px 16px;
  text-align: center;
}

.ds-btn-sm { min-height: var(--control-height-sm); padding: 8px 12px; }
.ds-btn-lg { min-height: var(--control-height-lg); padding: 12px 20px; }

.ds-btn-primary,
.boton.primario {
  background: var(--blue);
  border-color: var(--blue);
  color: #02131e;
}

.ds-btn-secondary,
.boton.secundario {
  background: rgba(255,255,255,.02);
  border-color: var(--line-strong);
  color: var(--text);
}

.ds-btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.ds-btn-icon {
  min-width: var(--control-height-md);
  padding: 8px;
}

/* Badges and status */
.ds-badge,
.badge {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  display: inline-flex;
  font: 600 var(--font-size-xs)/1 var(--mono);
  gap: 7px;
  letter-spacing: .07em;
  min-height: 28px;
  padding: 6px 10px;
  text-transform: uppercase;
}

.ds-badge-blue { background: var(--blue-soft); border-color: var(--line-brand); color: var(--cyan); }
.ds-badge-success { background: rgba(25,197,170,.10); border-color: rgba(25,197,170,.30); color: #72e6d0; }
.ds-badge-warning { background: rgba(245,173,59,.10); border-color: rgba(245,173,59,.30); color: #ffd18a; }
.ds-badge-danger { background: rgba(255,82,100,.10); border-color: rgba(255,82,100,.30); color: #ff9da7; }

/* Form primitives */
.ds-field {
  display: grid;
  gap: 8px;
}

.ds-field label {
  color: var(--text);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.ds-field :where(input, textarea, select) {
  background: rgba(255,255,255,.025);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--text);
  min-height: var(--control-height-md);
  padding: 10px 12px;
  width: 100%;
}

.ds-field textarea {
  min-height: 120px;
  resize: vertical;
}

.ds-field :where(input, textarea, select)::placeholder {
  color: var(--subtle);
}

.ds-field :where(input, textarea, select):disabled {
  background: rgba(255,255,255,.012);
  cursor: not-allowed;
  opacity: .55;
}

.ds-field-help {
  color: var(--subtle);
  font-size: var(--font-size-xs);
  line-height: 1.45;
}

.ds-field-error {
  color: #ff9da7;
  font-size: var(--font-size-xs);
  line-height: 1.45;
}

/* Loading skeletons */
.ds-skeleton {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,.045) 25%,
    rgba(255,255,255,.09) 50%,
    rgba(255,255,255,.045) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  min-height: 1em;
}

.ds-skeleton-text { min-height: .85em; width: 70%; }
.ds-skeleton-title { min-height: 1.5em; width: 55%; }
.ds-skeleton-card { min-height: 180px; width: 100%; }
.ds-skeleton-circle { border-radius: 50%; height: 44px; min-height: 44px; width: 44px; }

/* Toast primitive */
.ds-toast-region {
  bottom: max(20px, env(safe-area-inset-bottom));
  display: grid;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  z-index: 400;
}

.ds-toast {
  align-items: flex-start;
  background: var(--surface-glass-strong);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  display: grid;
  gap: 4px;
  grid-template-columns: auto 1fr;
  padding: 14px 16px;
  -webkit-backdrop-filter: blur(20px) saturate(130%);
  backdrop-filter: blur(20px) saturate(130%);
}

.ds-toast-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
}

.ds-toast-message {
  color: var(--muted);
  font-size: var(--font-size-xs);
}

/* Responsive primitives */
@container diserc-content (max-width: 700px) {
  .ds-bento {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ds-bento > * {
    grid-column: span 2;
  }
}

@media (max-width: 700px) {
  .ds-bento {
    grid-template-columns: 1fr;
  }

  .ds-bento > * {
    grid-column: 1;
  }

  .ds-btn,
  .boton {
    min-height: 46px;
  }

  .ds-toast-region {
    left: 16px;
    max-width: none;
    right: 16px;
  }
}
