/* Base Styles - Transdisciplinary Skeleton v1.0 */

/* Reset and Base */
*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
}

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

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

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

/* Focus Styles */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Utility Classes */
.focus-outline:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-padding);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: var(--card-padding);
  box-shadow: var(--card-shadow);
  transition: transform var(--duration-normal) var(--easing-default),
              box-shadow var(--duration-normal) var(--easing-default);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Aspect Ratios */
.aspect-16-9 {
  aspect-ratio: 16 / 9;
}

.aspect-4-3 {
  aspect-ratio: 4 / 3;
}

.aspect-1-1,
.aspect-square {
  aspect-ratio: 1 / 1;
}

/* For dynamic aspect ratios from JSON */
.aspect-16-9 { aspect-ratio: 16 / 9; }
.aspect-4-3 { aspect-ratio: 4 / 3; }
.aspect-1-1 { aspect-ratio: 1 / 1; }

.placeholder-image {
  background: linear-gradient(135deg, var(--color-bg-muted) 0%, var(--color-bg-subtle) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-subtle);
  font-size: var(--text-sm);
  border-radius: var(--radius-md);
}

/* Loading states */
.skeleton {
  background: linear-gradient(90deg,
    var(--color-bg-subtle) 0%,
    var(--color-bg-muted) 50%,
    var(--color-bg-subtle) 100%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

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

/* HTMX specific */
.htmx-indicator {
  opacity: 0;
  transition: opacity var(--duration-fast) var(--easing-default);
}

.htmx-request .htmx-indicator {
  opacity: 1;
}

.htmx-settling {
  opacity: 0.5;
}

.htmx-swapping {
  opacity: 0;
  transition: opacity var(--duration-fast) var(--easing-default);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: var(--leading-tight);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

/* Responsive Typography */
@media (min-width: 640px) {
  h1 { font-size: var(--text-5xl); }
  h2 { font-size: var(--text-4xl); }
  h3 { font-size: var(--text-3xl); }
}

@media (min-width: 1024px) {
  h1 { font-size: var(--text-6xl); }
}

/* Skip Links */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-brand);
  color: white;
  padding: 8px 16px;
  text-decoration: none;
  z-index: 100;
  border-radius: 0 0 4px 0;
}

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

/* Forms (for future use) */
.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  transition: border-color var(--duration-fast) var(--easing-default);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-brand);
  box-shadow: 0 0 0 3px rgba(186, 167, 204, 0.1);
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --color-bg: #000000;
    --color-text: #ffffff;
    --color-brand: #ff99ff;
    --color-border: #ffffff;
  }

  .card {
    border: 2px solid var(--color-border);
  }
}

/* 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;
  }
}

/* Print styles */
@media print {
  body {
    background: white;
    color: black;
  }

  .no-print,
  nav,
  footer,
  .skip-link {
    display: none !important;
  }

  main {
    color: black;
    background: white;
  }
}

/* Touch Target Sizing */
button,
a,
input,
select,
textarea {
  min-height: 44px;
  min-width: 44px;
}

/* Error States */
.error-message {
  color: var(--color-error);
  font-size: var(--text-sm);
  margin-top: 4px;
}

.input-error {
  border-color: var(--color-error);
}

/* Required Field Indicator */
.required::after {
  content: " *";
  color: var(--color-error);
}