/* ── You Cannot Refuse a Shape by Filling It ───────────── */
/* No rounds, no brush, no score — a vessel and falling sand. Sand
   can't be forced to perfectly fill anything; it finds its own angle
   of repose, leaves air pockets, and whatever doesn't fit spills onto
   the ground beside the vessel instead of vanishing. The physics is
   the argument, not a number standing in for it. */

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

:root {
  --bg-deep: #0a0c10;
  --text-primary: #b9c0c6;
  --text-dim: #8a939b;
  --text-faint: #767f86;
  --text-bright: #dde3e7;
  --accent-sand: #c9a066;
  --accent-vessel: #6a7688;
}

html {
  min-height: 100%;
  background: var(--bg-deep);
}

body {
  font-family: Georgia, 'Times New Roman', 'Palatino Linotype', serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.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;
}

.grain-overlay {
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  z-index: 100;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  animation: grainShift 0.5s steps(1) infinite;
}

@keyframes grainShift {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2%, -1%); }
  50% { transform: translate(1%, 2%); }
  75% { transform: translate(-1%, -2%); }
}

.shape-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.1rem;
  padding: 3rem 1.5rem;
  text-align: center;
}

.shape-title {
  font-size: clamp(1.3rem, 3.4vw, 2rem);
  font-weight: 400;
  color: var(--text-bright);
  letter-spacing: 0.04em;
  max-width: 500px;
}

.shape-instruction {
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.9;
  letter-spacing: 0.02em;
  max-width: 340px;
}

.vessel-stage {
  width: min(70vw, 340px);
  height: min(90vw, 440px);
}

#vesselCanvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 4px;
  cursor: crosshair;
  touch-action: none;
}

#vesselCanvas:focus-visible {
  outline: 2px solid var(--text-bright);
  outline-offset: 4px;
}

.shape-line {
  min-height: 1.6em;
  font-size: 0.95rem;
  font-style: italic;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  transition: color 0.6s ease;
  max-width: 380px;
}

.shape-line.grace {
  color: var(--accent-sand);
  text-shadow: 0 0 20px rgba(201, 160, 102, 0.3);
}

.shape-actions {
  display: flex;
  gap: 1.2rem;
  align-items: center;
}

.text-button {
  font: inherit;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: none;
  border: none;
  border-bottom: 1px solid rgba(106, 118, 136, 0.35);
  padding: 0.2em 0;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: 0.03em;
  transition: color 300ms ease, border-color 300ms ease;
}

.text-button:hover {
  color: var(--text-bright);
  border-bottom-color: var(--accent-sand);
}

.text-button:focus-visible {
  outline: 2px solid var(--text-bright);
  outline-offset: 4px;
}

.text-button[aria-pressed="true"] {
  color: var(--text-bright);
  border-bottom-color: var(--accent-sand);
}

.vessel-select {
  display: flex;
  gap: 1.1rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.85rem;
}

.sand-palette {
  display: flex;
  gap: 0.7rem;
  align-items: center;
}

.sand-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  padding: 0;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.sand-swatch:hover {
  transform: scale(1.15);
}

.sand-swatch:focus-visible {
  outline: 2px solid var(--text-bright);
  outline-offset: 3px;
}

.sand-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--bg-deep), 0 0 0 4px var(--text-bright);
}

.shape-epigraph {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--text-faint);
  line-height: 1.7;
  max-width: 340px;
  margin-top: 0.4rem;
}

.noscript {
  text-align: center;
  padding: 2rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.noscript a {
  color: var(--text-primary);
  text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
  .grain-overlay { animation: none; }
  .shape-line { transition: none; }
}

::selection {
  background: rgba(201, 160, 102, 0.22);
  color: var(--text-bright);
}
