/* Reset */

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

html {
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

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: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

/* Design tokens */

:root {
  /* Colors */
  --color-primary: #333333;
  --color-secondary: #666666;
  --color-accent: #0066cc;
  --color-background: #f0eeeb;
  --color-surface: #f5f5f5;
  --color-border: #e0e0e0;
  --color-text: #333333;
  --color-text-muted: #888888;
  --color-error: #cc0000;
  --color-success: #007700;

  /* Typography */
  --font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Helvetica, Arial, sans-serif;
  --font-size-xs: 0.75rem;    /* 12px */
  --font-size-sm: 0.875rem;   /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;   /* 18px */
  --font-size-xl: 1.25rem;    /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  --font-size-3xl: 1.875rem;  /* 30px */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-bold: 700;
  --line-height-tight: 1.25;
  --line-height-base: 1.5;
  --line-height-relaxed: 1.75;

  /* Spacing */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */

  /* Layout */
  --container-max-width: 1200px;
  --container-padding: var(--space-4);

  /* Border */
  --border-radius-sm: 4px;
  --border-radius-base: 8px;
  --border-radius-lg: 12px;
  --border-radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-base: 0 2px 8px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Z-index layers */
  --z-base: 0;
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-overlay: 300;
  --z-modal: 400;
  --z-toast: 500;
}

/* Base styles */

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-background);
  line-height: var(--line-height-base);
}

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

/* Screen-reader only */
.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;
}

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

/* Component error state — shown when a fragment fails to load */

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-8);
  text-align: center;
}

.error-state__message {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.error-state__retry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: var(--border-radius-sm);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.error-state__retry:hover {
  color: var(--color-background);
  background-color: var(--color-accent);
}

/* Network error banner — fixed top bar, auto-dismisses on reconnect */

.network-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-toast);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-6);
  background-color: #b91c1c;
  color: #ffffff;
  font-size: var(--font-size-sm);
  transform: translateY(-100%);
  transition: transform var(--transition-base);
}

.network-banner--visible {
  transform: translateY(0);
}

.network-banner__message {
  flex: 1;
}

.network-banner__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.network-banner__retry {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--border-radius-sm);
  transition: background-color var(--transition-fast);
}

.network-banner__retry:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.network-banner__dismiss {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: var(--font-size-lg);
  color: rgba(255, 255, 255, 0.8);
  transition: color var(--transition-fast);
  line-height: 1;
}

.network-banner__dismiss:hover {
  color: #ffffff;
}

/* Scroll reveal — data-reveal fades up, data-reveal-stagger staggers children */

[data-reveal] {
  opacity: 0;
  transform: translateY(30px);
  will-change: opacity, transform;
}

[data-reveal].is-visible {
  animation: reveal-up 0.6s ease-out forwards;
}

/* Stagger children with incremental delay */
[data-reveal-stagger] > * {
  opacity: 0;
  transform: translateY(20px);
  will-change: opacity, transform;
}

[data-reveal-stagger].is-visible > * {
  animation: reveal-up 0.5s ease-out forwards;
}

[data-reveal-stagger].is-visible > *:nth-child(1) { animation-delay: 0ms; }
[data-reveal-stagger].is-visible > *:nth-child(2) { animation-delay: 60ms; }
[data-reveal-stagger].is-visible > *:nth-child(3) { animation-delay: 120ms; }
[data-reveal-stagger].is-visible > *:nth-child(4) { animation-delay: 180ms; }
[data-reveal-stagger].is-visible > *:nth-child(5) { animation-delay: 240ms; }
[data-reveal-stagger].is-visible > *:nth-child(6) { animation-delay: 300ms; }
[data-reveal-stagger].is-visible > *:nth-child(7) { animation-delay: 360ms; }
[data-reveal-stagger].is-visible > *:nth-child(8) { animation-delay: 420ms; }
[data-reveal-stagger].is-visible > *:nth-child(9) { animation-delay: 480ms; }

/* Directional variants */

[data-reveal="left"] {
  opacity: 0;
  transform: translateX(-30px);
  will-change: opacity, transform;
}

[data-reveal="right"] {
  opacity: 0;
  transform: translateX(30px);
  will-change: opacity, transform;
}

[data-reveal="left"].is-visible {
  animation: reveal-left 0.6s ease-out forwards;
}

[data-reveal="right"].is-visible {
  animation: reveal-right 0.6s ease-out forwards;
}

@keyframes reveal-up {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes reveal-left {
  to { opacity: 1; transform: translateX(0); }
}

@keyframes reveal-right {
  to { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal],
  [data-reveal="left"],
  [data-reveal="right"],
  [data-reveal-stagger] > * {
    opacity: 1;
    transform: none;
    will-change: auto;
    animation: none;
  }
}
