/* ---------------------------------------------------------------------------
   Texture — shell styles (home grid, toy layer, shared tokens)
   Toys ship their own stylesheets scoped to .toy-<id>.
--------------------------------------------------------------------------- */

:root {
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --ease-spring: cubic-bezier(.2, 1.4, .4, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --sh-bg: #0b0c10;
  --sh-ink: #e9eaf0;
  --sh-dim: rgba(233, 234, 240, .5);
  --sh-faint: rgba(233, 234, 240, .3);
  --sh-tile: #15171e;
  --sh-line: rgba(255, 255, 255, .08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; background: var(--sh-bg); }
body {
  font-family: var(--font);
  color: var(--sh-ink);
  background: var(--sh-bg);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  position: fixed;
  inset: 0;
}
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }

#shell { position: fixed; inset: 0; overflow: hidden; }

/* ---- Home: the swatch grid ------------------------------------------ */
#home {
  position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y;
  padding: calc(var(--safe-top) + 26px) calc(var(--safe-right) + 20px) calc(var(--safe-bottom) + 28px) calc(var(--safe-left) + 20px);
  transition: transform .36s var(--ease-out), opacity .36s ease, filter .36s ease;
  transform-origin: 50% 50%;
}
#home.pushed { transform: scale(.94); opacity: .5; filter: brightness(.6); pointer-events: none; }
#home-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.wordmark h1 { font-size: 34px; font-weight: 800; letter-spacing: -1px; line-height: 1.05; }
.wordmark p { color: var(--sh-dim); font-size: 14px; font-weight: 500; margin-top: 4px; }
.toggles { display: flex; gap: 8px; padding-top: 2px; }
.toggle {
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--sh-line); background: var(--sh-tile);
  display: grid; place-items: center; cursor: pointer; color: var(--sh-ink);
  transition: transform .18s var(--ease-spring), color .2s, background .2s;
}
.toggle:active { transform: scale(.92); }
.toggle .when-off { display: none; }
.toggle.off { color: var(--sh-faint); }
.toggle.off .when-on { display: none; }
.toggle.off .when-off { display: block; }

.swatches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; }
.swatch { display: flex; flex-direction: column; gap: 10px; background: none; border: none; padding: 0; text-align: left; cursor: pointer; min-width: 0; }
.swatch .tile {
  position: relative; width: 100%; aspect-ratio: 4 / 5; border-radius: 22px; overflow: hidden; background: var(--sw-color, var(--sh-tile));
  box-shadow: 0 16px 36px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .07);
  transition: transform .22s var(--ease-spring), box-shadow .22s;
  transform: translateZ(0);
}
.swatch:active .tile { transform: scale(.96); box-shadow: 0 8px 20px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .07); }
.swatch canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.swatch .name { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
.swatch .tag { color: var(--sh-dim); font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
#home-foot { margin-top: 34px; color: var(--sh-faint); font-size: 12px; text-align: center; }

/* ---- Toy layer: slides in from the right, follows the edge swipe ---- */
#toy-layer {
  position: absolute; inset: 0; background: var(--sh-bg);
  transform: translate3d(100%, 0, 0); will-change: transform;
  box-shadow: -24px 0 60px rgba(0, 0, 0, .55);
}
#toy-layer.in { transition: transform .38s var(--ease-out); transform: translate3d(0, 0, 0); }
#toy-layer.out { transition: transform .26s ease-in; transform: translate3d(100%, 0, 0); }
#toy-layer.dragging { transition: none; }
#home.dragging { transition: none; }
.toy-root { position: absolute; inset: 0; overflow: hidden; }

#edge-hint {
  position: absolute; left: 0; top: 50%; width: 4px; height: 64px; margin-top: -32px; border-radius: 0 4px 4px 0;
  background: rgba(255, 255, 255, .35); opacity: 0; pointer-events: none; z-index: 50; transition: opacity .5s ease;
}
#edge-hint.show { opacity: 1; }

@media (min-width: 720px) {
  #home { padding-left: calc(var(--safe-left) + 40px); padding-right: calc(var(--safe-right) + 40px); }
  #home-head, .swatches, #home-foot { max-width: 940px; margin-left: auto; margin-right: auto; }
  .swatches { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  #home, #toy-layer.in, #toy-layer.out, .swatch .tile { transition-duration: .01s; }
}
