/* ============================================
   Dumbphone Labs Artifact Gallery
   Global Styles
   ============================================ */

/* CSS Custom Properties */
:root {
  /* Fonts */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Libre Baskerville', Georgia, 'Times New Roman', serif;

  /* Primary Palette */
  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-200: #a7f3d0;
  --emerald-400: #34d399;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-800: #065f46;
  --emerald-900: #064e3b;

  --teal-600: #0d9488;
  --teal-700: #0f766e;
  --teal-800: #115e59;

  /* Background */
  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;

  /* Accent Colors */
  --purple-600: #9333ea;
  --purple-700: #7e22ce;
  --purple-800: #6b21a8;
  --amber-500: #f59e0b;
  --amber-600: #d97706;

  /* Semantic Colors */
  --color-primary: var(--emerald-800);
  --color-primary-light: var(--emerald-600);
  --color-secondary: var(--teal-700);
  --color-accent-theory: var(--purple-800);
  --color-accent-location: var(--amber-600);
  --color-accent-infra: var(--teal-600);

  /* Light Mode */
  --bg-primary: var(--stone-50);
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --text-primary: var(--stone-900);
  --text-secondary: var(--stone-600);
  --text-muted: var(--stone-400);
  --border-color: var(--stone-200);
  --shadow-color: rgba(0, 0, 0, 0.1);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

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

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;

  /* Layout */
  --max-width: 1400px;
  --header-height: 80px;
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: var(--stone-900);
    --bg-secondary: var(--stone-800);
    --bg-card: var(--stone-800);
    --text-primary: var(--stone-100);
    --text-secondary: var(--stone-300);
    --text-muted: var(--stone-500);
    --border-color: var(--stone-700);
    --shadow-color: rgba(0, 0, 0, 0.3);
    --color-primary: var(--emerald-400);
    --color-primary-light: var(--emerald-400);
  }
}

/* Manual dark mode toggle */
[data-theme="dark"] {
  --bg-primary: var(--stone-900);
  --bg-secondary: var(--stone-800);
  --bg-card: var(--stone-800);
  --text-primary: var(--stone-100);
  --text-secondary: var(--stone-300);
  --text-muted: var(--stone-500);
  --border-color: var(--stone-700);
  --shadow-color: rgba(0, 0, 0, 0.3);
  --color-primary: var(--emerald-400);
  --color-primary-light: var(--emerald-400);
}

/* ============================================
   Reset & Base
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--bg-primary) 0%, var(--emerald-50) 100%);
  min-height: 100vh;
}

@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(135deg, var(--stone-900) 0%, var(--stone-800) 100%);
  }
}

[data-theme="dark"] body {
  background: linear-gradient(135deg, var(--stone-900) 0%, var(--stone-800) 100%);
}

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

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

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-light);
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

@media (max-width: 768px) {
  h1 { font-size: 2rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
}

/* ============================================
   Layout
   ============================================ */

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

/* ============================================
   Header
   ============================================ */

.site-header {
  padding: var(--space-lg) 0;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.header-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.back-link:hover {
  color: var(--color-primary);
}

.back-link svg {
  width: 16px;
  height: 16px;
}

.site-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  background: linear-gradient(135deg, var(--emerald-800) 0%, var(--teal-700) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.05em;
}

@media (prefers-color-scheme: dark) {
  .site-title {
    background: linear-gradient(135deg, var(--emerald-400) 0%, var(--teal-600) 100%);
    -webkit-background-clip: text;
    background-clip: text;
  }
}

[data-theme="dark"] .site-title {
  background: linear-gradient(135deg, var(--emerald-400) 0%, var(--teal-600) 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.site-description {
  color: var(--text-secondary);
  max-width: 600px;
  font-size: 1rem;
}

.header-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}

/* ============================================
   Controls / Filters
   ============================================ */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg) 0;
}

.control-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.control-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.control-select,
.control-input {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.875rem;
  min-width: 150px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.control-select:focus,
.control-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(6, 95, 70, 0.1);
}

.control-input {
  min-width: 200px;
}

.control-input::placeholder {
  color: var(--text-muted);
}

.theme-toggle {
  padding: var(--space-sm);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* ============================================
   Gallery Grid
   ============================================ */

.gallery {
  padding: var(--space-xl) 0 var(--space-3xl);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-lg);
}

@media (max-width: 1200px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: 1fr;
  }
}

.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-3xl);
  color: var(--text-secondary);
}

/* ============================================
   Artifact Card
   ============================================ */

.artifact-card {
  position: relative;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 1px 3px var(--shadow-color);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.artifact-card:hover {
  transform: scale(1.03);
  box-shadow: 0 10px 40px var(--shadow-color);
}

.artifact-card:focus-within {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.artifact-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.artifact-card-link:focus {
  outline: none;
}

.artifact-thumbnail {
  aspect-ratio: 16 / 10;
  background: linear-gradient(135deg, var(--emerald-800) 0%, var(--teal-700) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.artifact-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.artifact-thumbnail-placeholder {
  color: rgba(255, 255, 255, 0.5);
  font-size: 3rem;
}

.artifact-content {
  padding: var(--space-md);
}

.artifact-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-category {
  background: var(--emerald-100);
  color: var(--emerald-800);
}

.badge-project {
  background: var(--stone-200);
  color: var(--stone-700);
}

.badge-featured {
  background: var(--amber-500);
  color: white;
}

.badge-draft {
  background: var(--stone-300);
  color: var(--stone-600);
}

.badge-archived {
  background: var(--stone-400);
  color: white;
}

@media (prefers-color-scheme: dark) {
  .badge-category {
    background: var(--emerald-900);
    color: var(--emerald-200);
  }
  .badge-project {
    background: var(--stone-700);
    color: var(--stone-300);
  }
}

[data-theme="dark"] .badge-category {
  background: var(--emerald-900);
  color: var(--emerald-200);
}

[data-theme="dark"] .badge-project {
  background: var(--stone-700);
  color: var(--stone-300);
}

.artifact-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
}

.artifact-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.artifact-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-md);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.artifact-date {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.artifact-ai-badge {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--purple-600);
}

/* ============================================
   Card Hover Overlay
   ============================================ */

.artifact-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, var(--bg-card) 0%, var(--bg-card) 80%, transparent 100%);
  padding: var(--space-lg);
  padding-top: var(--space-2xl);
  transform: translateY(100%);
  transition: transform var(--transition-base);
  pointer-events: none;
}

.artifact-card:hover .artifact-overlay,
.artifact-card:focus-within .artifact-overlay {
  transform: translateY(0);
  pointer-events: auto;
}

.overlay-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.overlay-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
}

.tag {
  display: inline-flex;
  padding: 0.125rem 0.5rem;
  background: var(--stone-100);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

@media (prefers-color-scheme: dark) {
  .tag {
    background: var(--stone-700);
    color: var(--stone-300);
  }
}

[data-theme="dark"] .tag {
  background: var(--stone-700);
  color: var(--stone-300);
}

.overlay-authors {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.overlay-authors strong {
  color: var(--text-secondary);
}

.overlay-fingerprint {
  font-family: monospace;
  font-size: 0.625rem;
  color: var(--text-muted);
  word-break: break-all;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  background: linear-gradient(135deg, var(--emerald-800) 0%, var(--teal-700) 100%);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(6, 95, 70, 0.3);
}

/* ============================================
   Footer
   ============================================ */

.site-footer {
  padding: var(--space-2xl) 0;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  text-align: center;
}

.footer-org {
  font-family: var(--font-heading);
  font-size: 1rem;
  color: var(--text-primary);
}

.footer-location {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.footer-contact a {
  color: var(--color-primary);
}

.footer-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto;
}

/* ============================================
   Utility Classes
   ============================================ */

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

.visually-hidden {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* ============================================
   Loading State
   ============================================ */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-3xl);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* ============================================
   No JS Fallback
   ============================================ */

.no-js .artifact-overlay {
  display: none;
}

.no-js .controls {
  display: none;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  .controls,
  .theme-toggle,
  .artifact-overlay {
    display: none;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .artifact-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
  }
}
