/* --- Emergence.ai–style palette --- */
:root {
  --em-bg: #05060a;
  --em-bg-mid: #0a0c12;
  --em-bg-elevated: #0f1219;
  --em-surface: #131720;
  --em-surface-hover: #1a1f2e;
  --em-border: rgba(30, 41, 59, 0.6);
  --em-border-hover: rgba(51, 65, 85, 0.8);
  --em-text: #f1f5f9;
  --em-text-muted: #94a3b8;
  --em-accent: #3b82f6;
  --em-accent-dim: rgba(59, 130, 246, 0.15);
}

/* --- Reset & base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", system-ui, sans-serif;
  background: linear-gradient(165deg, var(--em-bg) 0%, var(--em-bg-mid) 35%, var(--em-surface) 70%, var(--em-bg-mid) 100%);
  color: var(--em-text);
}

/* --- Layout --- */
.page {
  min-height: 100vh;
  padding: clamp(2rem, 6vw, 4rem);
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- Header --- */
.header {
  text-align: center;
  margin-bottom: clamp(2.5rem, 8vw, 4rem);
}

.title {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  color: var(--em-text);
}

.caption {
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  font-weight: 400;
  color: var(--em-text-muted);
  margin: 0;
  max-width: 28ch;
}

/* --- Tiles grid --- */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, 280px);
  gap: 1.5rem;
  justify-content: center;
}

/* --- Tile: square + flip --- */
.tile {
  display: block;
  position: relative;
  width: 280px;
  height: 280px;
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  perspective: 800px;
  flex-shrink: 0;
}

.tile:focus-visible .tile-inner {
  outline: 2px solid var(--em-accent);
  outline-offset: 2px;
}

.tile-inner {
  position: absolute;
  inset: 0;
  width: 280px;
  height: 280px;
  border-radius: inherit;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}

.tile:hover .tile-inner {
  transform: rotateY(180deg);
}

.tile:hover .tile-front {
  border-color: var(--em-border-hover);
}

.tile-front,
.tile-back {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 1px solid var(--em-border);
}

.tile-front {
  background: var(--em-surface);
}

.tile-back {
  background: var(--em-surface-hover);
  border-color: var(--em-border-hover);
  box-shadow: inset 0 0 0 1px var(--em-accent-dim);
  transform: rotateY(180deg);
}

.tile-badge {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--em-text-muted);
  padding: 0.2em 0.5em;
  border: 1px solid var(--em-border);
  border-radius: 4px;
}

.tile-name {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--em-text);
  text-align: center;
  white-space: nowrap;
}

.tile-desc {
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--em-text-muted);
  text-align: center;
}

@media (max-width: 920px) {
  .tiles {
    grid-template-columns: repeat(2, 280px);
  }
}

@media (max-width: 620px) {
  .tiles {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 280px;
  }
  .tile {
    width: 100%;
    height: 0;
    padding-bottom: 100%;
    margin: 0 auto;
  }
  .tile-inner {
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
  }
  .tile-name {
    white-space: normal;
  }
}
