/* Community: the pack gallery, pack pages, Pack Studio and the guide
   (scripts/build-community.mjs). Class names match the gallery's own
   scripts in community/assets/. */

/* ------------------------------------------------------------ hero */
.c-hero h1 { font-size: clamp(2.6rem, 1.5rem + 4vw, 5rem); max-width: 12ch; }
.c-hero.small h1 { font-size: clamp(2.2rem, 1.4rem + 3vw, 4rem); max-width: 18ch; }
.c-hero-grid { display: grid; gap: 2.5rem; align-items: center; }
@media (min-width: 980px) { .c-hero-grid { grid-template-columns: 1.1fr .9fr; } }
.c-stats { display: flex; flex-wrap: wrap; gap: .5rem 1.8rem; color: var(--text-2); }
.c-stats b { font: 700 1.6rem/1 var(--f-pixel); color: var(--paper); margin-right: .3rem; }

/* the strip under the hero */
.c-sub { position: sticky; top: 72px; z-index: 40; border-block: 1px solid var(--line); background: rgba(8, 18, 20, .86); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.c-sub .wrap { display: flex; gap: .3rem; overflow-x: auto; scrollbar-width: none; padding-block: .55rem; }
.c-sub a { flex: none; padding: .5rem .85rem; border-radius: 9px; color: var(--text-2); text-decoration: none; font-weight: 700; font-size: .92rem; }
.c-sub a:hover { color: var(--paper); background: rgba(168, 236, 217, .06); }
.c-sub a[aria-current='page'] { background: var(--coral); color: var(--ink); }
.c-sub a:last-child { margin-left: auto; color: var(--text-3); }

/* ------------------------------------------------------------ stages */
.stage { position: relative; display: grid; place-items: center; min-height: 360px; border-radius: 22px; overflow: hidden; border: 1px solid var(--line-2);
  background: radial-gradient(60% 45% at 50% 100%, rgba(234, 217, 182, .2), transparent 70%), radial-gradient(60% 60% at 50% 20%, rgba(63, 184, 163, .16), transparent 70%), linear-gradient(180deg, #0a1b1c, #11302d);
  box-shadow: 0 50px 100px -40px rgba(0, 0, 0, .9); }
.stage-crab { position: relative; z-index: 2; width: min(78%, 340px); margin-top: 24px; }
.stage-crab svg { width: 100%; height: auto; overflow: visible; }
@media (prefers-reduced-motion: no-preference) { .stage-crab svg { animation: breathe 3.2s ease-in-out infinite; } .stage .part-eyes:not(.acc) { animation: blink 5s steps(1) infinite; transform-origin: bottom; } }
.stage .part { transform-box: fill-box; transform-origin: center; }
.stage-floor { position: absolute; left: 50%; bottom: 52px; width: 55%; height: 20px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 0, 0, .45), transparent); z-index: 1; }
.stage-fx { position: absolute; inset: 0; z-index: 3; pointer-events: none; --fall-h: 340px; --orbit-r: 150px; }
.stage-caption { position: absolute; left: 0; right: 0; bottom: 14px; margin: 0; padding: 0 12px; text-align: center; font: 600 .76rem/1.3 var(--f-mono); color: var(--text-3); z-index: 4; }
.stage-decor { position: absolute; z-index: 1; left: 6%; bottom: 60px; width: 30%; display: grid; justify-items: center; align-items: end; pointer-events: none; }
.stage-decor svg { max-width: 100%; height: auto; }
.stage.big { min-height: 440px; }
.c-stage { min-height: 400px; }
.c-stage .stage-crab { width: min(64%, 300px); }

/* speech bubbles */
.bubble { position: relative; display: inline-block; padding: .3rem .65rem; border-radius: 9px; background: var(--paper); color: var(--ink); font: 700 .82rem/1.25 var(--f-pixel); box-shadow: 3px 3px 0 rgba(0, 0, 0, .3); }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -5px; transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--paper); border-bottom: 0; }
.bubble.mini { padding: 1px 6px; font-size: .7rem; }
.bubble.mini::after { border-width: 3px; bottom: -3px; }
.card-bubble { position: absolute; top: 14px; right: 16px; max-width: 46%; }
.stage-bubble { position: absolute; z-index: 4; top: 20px; left: 50%; transform: translateX(-50%); margin: 0; max-width: 70%; font-size: .95rem; padding: .45rem .8rem; }
.scene-art { display: grid; justify-items: center; gap: 9px; width: 100%; }
.beats { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.beats i { font: 600 .62rem/1.4 var(--f-mono); font-style: normal; color: var(--foam); background: rgba(127, 214, 194, .12); border-radius: 4px; padding: 1px 5px; }

/* ------------------------------------------------------------ gallery */
.c-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.c-tools { display: flex; gap: .5rem; flex-wrap: wrap; }
.c-search input, .c-tools select { min-height: 44px; padding: 0 .9rem; border-radius: 11px; border: 1px solid var(--line-2); background: rgba(8, 18, 20, .7); color: var(--paper); font: inherit; font-size: .95rem; }
.c-search input { width: min(360px, 80vw); }
.c-search input::placeholder { color: var(--text-3); }
.c-search input:focus, .c-tools select:focus { outline: none; border-color: var(--glass); box-shadow: 0 0 0 3px rgba(127, 214, 194, .18); }
.fchips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1.6rem; }
.fchip { padding: .5rem .9rem; border-radius: 999px; border: 1px solid var(--line-2); background: rgba(19, 40, 39, .5); color: var(--text-2); font: 700 .86rem/1 var(--f-body); cursor: pointer; transition: background-color .2s, color .2s, border-color .2s; }
.fchip:hover { color: var(--paper); border-color: var(--glass); }
.fchip.on { background: var(--coral); border-color: transparent; color: var(--ink); }
.empty { padding: 2rem; text-align: center; color: var(--text-2); }

.pack-grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.pack-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; transition: transform .45s var(--ease-out), border-color .3s; }
.pack-card:hover { transform: translateY(-5px); border-color: rgba(255, 122, 92, .45); }
.card-stage { position: relative; display: grid; place-items: center; height: 200px; background: radial-gradient(60% 60% at 50% 40%, rgba(127, 214, 194, .14), transparent 70%), var(--abyss); border-bottom: 1px solid var(--line); }
.card-stage svg { width: 58%; height: auto; overflow: visible; transition: transform .5s var(--ease-spring); }
.pack-card:hover .card-stage svg { transform: translateY(-6px) rotate(-2deg); }
.card-body { display: flex; flex-direction: column; gap: .45rem; padding: 1.2rem 1.3rem 1.3rem; flex: 1; }
.card-body h3 { font: 700 1.3rem/1.15 var(--f-pixel); }
.card-body h3 a { color: var(--paper); text-decoration: none; }
.card-body h3 a:hover { color: var(--coral-hi); }
.by { color: var(--text-3); font-size: .86rem; }
.by b { color: var(--text-2); }
.desc { color: var(--text-2); font-size: .95rem; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: .4rem; }
.thumb { width: 40px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: var(--abyss); border: 1px solid var(--line); }
.thumb svg { max-width: 30px; max-height: 24px; width: auto; height: 24px; overflow: visible; }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: .8rem; margin-top: auto; padding-top: .8rem; }
.counts { font: 600 .72rem/1.3 var(--f-mono); color: var(--text-3); }

.item-grid, .try-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.tile { display: grid; justify-items: center; gap: .3rem; padding: .9rem .6rem .8rem; border-radius: 14px; border: 1px solid var(--line); background: rgba(13, 28, 29, .7); color: var(--text-2); text-decoration: none; font: inherit; text-align: center; cursor: pointer; transition: transform .25s var(--ease-spring), border-color .2s, background-color .2s; }
.tile:hover { color: var(--paper); transform: translateY(-3px); border-color: var(--line-2); }
.tile-art { height: 72px; width: 100%; display: grid; place-items: center; }
.tile-art svg { max-width: 92%; max-height: 72px; width: auto; height: 72px; overflow: visible; }
.tile-art .fx-art { height: 34px; }
.tile-art .decor-art, .thumb .decor-art { image-rendering: pixelated; }
.tile-art .decor-art { height: 56px; }
.tile-name { font-weight: 700; font-size: .86rem; color: var(--paper); line-height: 1.2; }
.tile-pack { font: 500 .66rem/1.3 var(--f-mono); color: var(--text-3); }
.rarity-rare { border-color: rgba(127, 214, 194, .3); }
.rarity-epic { border-color: rgba(198, 120, 255, .38); }
.rarity-legendary { border-color: rgba(255, 209, 102, .45); box-shadow: inset 0 0 30px -12px rgba(255, 209, 102, .35); }
.try[aria-pressed='true'] { border-color: var(--coral); background: rgba(255, 122, 92, .14); }

.c-safe { display: grid; gap: 2rem; padding: clamp(2rem, 1.5rem + 3vw, 3.5rem); border-radius: 24px; border: 1px solid rgba(127, 214, 194, .35); background: radial-gradient(70% 100% at 0% 100%, rgba(63, 184, 163, .2), transparent 60%), var(--deep); }
@media (min-width: 900px) { .c-safe { grid-template-columns: .8fr 1.2fr; align-items: center; } }
.c-safe h2 { margin-top: .9rem; }
.c-safe ul { list-style: none; display: grid; gap: 1rem; }
.c-safe li { color: var(--text-2); padding-left: 1.6rem; position: relative; }
.c-safe li::before { content: '✓'; position: absolute; left: 0; color: var(--glass); font-weight: 800; }
.c-safe li b { color: var(--paper); }

/* ------------------------------------------------------------ pack page */
.pack-hero { display: grid; gap: 2.5rem; margin-top: 1.4rem; align-items: start; }
@media (min-width: 980px) { .pack-hero { grid-template-columns: 1.05fr .95fr; } }
.pack-info h1 { font-size: clamp(2.4rem, 1.5rem + 3vw, 4rem); }
.install-hint { padding: .8rem 1rem; border-radius: 10px; border: 1px solid rgba(255, 209, 102, .4); background: rgba(255, 209, 102, .08); color: var(--text-2); font-size: .92rem; }
.share-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.share-row > span { font: 600 .72rem/1 var(--f-mono); color: var(--text-3); text-transform: uppercase; letter-spacing: .1em; margin-right: .3rem; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .5rem 1.2rem; margin: 0; padding: 1rem 1.2rem; border-radius: 14px; border: 1px solid var(--line); background: rgba(13, 28, 29, .6); font-size: .92rem; }
.facts dt { font: 600 .7rem/1.6 var(--f-mono); color: var(--glass); text-transform: uppercase; letter-spacing: .08em; }
.facts dd { margin: 0; color: var(--text-2); }
.facts code { color: var(--foam); font-size: .82rem; }
.small { font-size: .88rem; }
.try-grid { margin-top: 1.2rem; }
.readme { max-width: 820px; }
.readme h3, .readme h4 { margin-top: 1.4rem; }

/* ------------------------------------------------------------ studio */
.c-studio { padding-block: 2rem 4rem; }
.studio { display: grid; gap: 1.2rem; }
@media (min-width: 1000px) { .studio { grid-template-columns: 1fr 1fr; align-items: start; } }
.studio .panel { border: 1px solid var(--line-2); border-radius: 20px; background: rgba(13, 28, 29, .8); padding: 1rem; }
.toolbar { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.toolbar .btn { min-height: 38px; padding: .45rem .85rem; font-size: .88rem; border-radius: 10px; }
#src { display: block; width: 100%; min-height: 560px; resize: vertical; padding: 1rem; border-radius: 12px; border: 1px solid var(--line-2); background: #061011; color: var(--foam); font: 400 .8rem/1.6 var(--f-mono); tab-size: 2; }
#src:focus { outline: none; border-color: var(--glass); }
.status { margin: .8rem 0 0; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.status.ok { color: var(--glass); }
.status.bad { color: #ff9b8f; }
.problems { margin: .5rem 0 0; padding-left: 1.2rem; color: #ffb3aa; font-size: .9rem; }
.problems li.warn { color: var(--sun); }
.studio .stage { min-height: 400px; }
.pickers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin: 1rem 0; }
.pickers label { display: grid; gap: .3rem; font: 600 .7rem/1.3 var(--f-mono); color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.pickers select { min-height: 40px; border-radius: 9px; padding: 0 .6rem; border: 1px solid var(--line-2); background: rgba(8, 18, 20, .7); color: var(--paper); font: 400 .9rem var(--f-body); text-transform: none; letter-spacing: 0; }
.submit-box { padding: 1rem 1.1rem; border-radius: 12px; border: 1px solid rgba(127, 214, 194, .3); background: rgba(63, 184, 163, .08); color: var(--text-2); font-size: .94rem; }
.submit-box b { color: var(--paper); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------ guide */
.c-guide .prose { max-width: none; }
.c-guide h2 { font: 700 var(--step-2)/1.15 var(--f-pixel); margin-top: 2.4rem; }
.c-guide p, .c-guide li { color: var(--text-2); }
.c-guide strong { color: var(--paper); }
.c-guide pre { padding: 1rem 1.2rem; border-radius: 12px; border: 1px solid var(--line-2); background: #061011; color: var(--foam); overflow-x: auto; font-size: .82rem; line-height: 1.7; }
.c-guide code { color: var(--foam); }
.c-guide .steps { counter-reset: s; list-style: none; padding: 0; display: grid; gap: .7rem; }
.c-guide .steps li { counter-increment: s; position: relative; padding: .9rem 1rem .9rem 3.4rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(13, 28, 29, .6); }
.c-guide .steps li::before { content: counter(s); position: absolute; left: 1rem; top: .85rem; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--coral); color: var(--ink); font: 700 .9rem/1 var(--f-pixel); }
.c-guide .rules { border-left: 3px solid var(--sun); padding: .4rem 0 .4rem 1rem; }
.c-guide .kicker { display: none; }
