/* ========================================
   WORLD: PFP FORGE
   Community PFP generator. Lab-specimen framing:
   a single composited "specimen" card on the left,
   trait controls on the right. Parchment palette,
   serif display, mono labels, orange accents.

   Assets are wired later via /assets/pfp/manifest.json
   (see docs/pfp-generator.md). Until then the canvas
   draws procedural placeholder art so the tool is fully
   functional. Nothing here assumes real assets exist.
======================================== */

[data-world="pfp"] {
    --bg-primary: #F2E8D2;
    --bg-secondary: #E9DDC2;
    --bg-elevated: #FBF5E6;
    --bg-card: #F7EFDB;

    --text-primary: #241C12;
    --text-secondary: rgba(36, 28, 18, 0.78);
    --text-muted: rgba(36, 28, 18, 0.55);

    --accent-primary: #C04400;
    --accent-secondary: #9A3600;
    --accent-tertiary: #D9621E;
    --accent-glow: rgba(217, 79, 0, 0.14);

    --border-subtle: rgba(36, 28, 18, 0.10);
    --border-light: rgba(36, 28, 18, 0.17);
    --border-accent: rgba(192, 68, 0, 0.34);

    /* Forge-specific */
    --pfp-tick: rgba(36, 28, 18, 0.42);
    --pfp-cell: 1px solid var(--border-light);
}

.world-pfp {
    position: relative;
    min-height: 100vh;
    padding: calc(var(--nav-height) + 40px) 0 88px;
    overflow: hidden;
}

/* Warm glow + dotted lab paper, echoing soon-section / home orbs */
.world-pfp::before {
    content: '';
    position: absolute;
    top: -10%;
    left: 50%;
    width: min(760px, 90vw);
    height: 760px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 64%);
    filter: blur(90px);
    z-index: 0;
    pointer-events: none;
}

.world-pfp::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(36, 28, 18, 0.06) 1px, transparent 1px);
    background-size: 22px 22px;
    z-index: 0;
    pointer-events: none;
}

.pfp {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

/* ---------- Header ---------- */

.pfp__head {
    max-width: 720px;
    margin: 0 0 34px;
}

.pfp__tag {
    display: inline-block;
    margin-bottom: 16px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent-primary);
}

.pfp__title {
    font-size: clamp(2.4rem, 6vw, 4rem);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -0.03em;
}

.pfp__title .pfp__z {
    color: var(--accent-primary);
}

.pfp__sub {
    margin-top: 14px;
    max-width: 560px;
    font-size: clamp(1rem, 2.2vw, 1.18rem);
    line-height: 1.6;
    color: var(--text-secondary);
}

.pfp__status {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-top: 18px;
    padding: 7px 15px;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 500;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background: var(--bg-elevated);
}

.pfp__status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-primary);
    animation: pfp-pulse 2.4s ease-out infinite;
}

@keyframes pfp-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(192, 68, 0, 0.5); }
    70%  { box-shadow: 0 0 0 11px rgba(192, 68, 0, 0); }
    100% { box-shadow: 0 0 0 0 rgba(192, 68, 0, 0); }
}

/* ---------- Layout ---------- */

.pfp__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: clamp(24px, 4vw, 56px);
    align-items: start;
}

/* ---------- Stage / specimen card ---------- */

.pfp-stage {
    position: sticky;
    top: calc(var(--nav-height) + 28px);
}

.pfp-card {
    position: relative;
    padding: 18px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.6) inset,
        0 24px 60px -28px rgba(36, 28, 18, 0.45);
}

/* Registration corner ticks — lab/print framing */
.pfp-card__ticks::before,
.pfp-card__ticks::after,
.pfp-card__frame::before,
.pfp-card__frame::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--pfp-tick);
    z-index: 2;
}
.pfp-card__ticks::before { top: 8px;    left: 8px;    border-right: none; border-bottom: none; }
.pfp-card__ticks::after  { top: 8px;    right: 8px;   border-left: none;  border-bottom: none; }
.pfp-card__frame::before { bottom: 8px; left: 8px;    border-right: none; border-top: none; }
.pfp-card__frame::after  { bottom: 8px; right: 8px;   border-left: none;  border-top: none; }

.pfp-canvas-wrap {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 2px;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(36,28,18,0.04), rgba(36,28,18,0.10));
}

.pfp-canvas-wrap canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: auto;
}

/* Fine film-grain + vignette over the specimen */
.pfp-canvas-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E"),
        radial-gradient(circle at 50% 42%, transparent 58%, rgba(36, 28, 18, 0.16) 100%);
    mix-blend-mode: multiply;
}

.pfp-card__caption {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-light);
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.pfp-card__serial { color: var(--text-secondary); }
.pfp-card__count strong {
    color: var(--accent-primary);
    font-weight: 700;
}

/* ---------- Controls panel ---------- */

.pfp-panel {
    min-width: 0;
}

.pfp-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.pfp-cat {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    cursor: pointer;
    transition:
        color 0.3s var(--ease-out-expo),
        border-color 0.3s var(--ease-out-expo),
        background 0.3s var(--ease-out-expo),
        transform 0.3s var(--ease-out-back);
}

.pfp-cat:hover {
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.pfp-cat.is-active {
    color: var(--bg-elevated);
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.pfp-cat__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}
.pfp-cat.is-active .pfp-cat__dot { opacity: 1; }

/* Tray of trait thumbnails */
.pfp-tray {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
    min-height: 120px;
    margin-bottom: 22px;
}

.pfp-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    padding: 0;
    background: var(--bg-card);
    border: var(--pfp-cell);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition:
        transform 0.3s var(--ease-out-back),
        border-color 0.3s var(--ease-out-expo),
        box-shadow 0.3s var(--ease-out-expo);
}

.pfp-cell:hover {
    transform: translateY(-3px);
    border-color: var(--border-accent);
}

.pfp-cell.is-selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary) inset;
}

.pfp-cell canvas,
.pfp-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Skeleton shimmer until a cell's thumb is rendered/loaded */
.pfp-cell[data-ready="0"]::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(100deg,
        var(--bg-secondary) 30%,
        var(--bg-elevated) 50%,
        var(--bg-secondary) 70%);
    background-size: 220% 100%;
    animation: pfp-shimmer 1.2s linear infinite;
}

@keyframes pfp-shimmer {
    0%   { background-position: 180% 0; }
    100% { background-position: -180% 0; }
}

.pfp-cell__label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 4px 6px;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    color: var(--text-secondary);
    background: linear-gradient(transparent, rgba(251, 245, 230, 0.92) 38%);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pfp-cell--none {
    display: flex;
    align-items: center;
    justify-content: center;
}
.pfp-cell--none::after {
    content: '∅';
    font-size: 1.4rem;
    color: var(--text-muted);
}

/* ---------- Actions ---------- */

.pfp-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 4px;
    border-top: 1px solid var(--border-subtle);
}

.pfp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 22px;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: 999px;
    cursor: pointer;
    transition:
        color 0.3s var(--ease-out-expo),
        border-color 0.3s var(--ease-out-expo),
        background 0.3s var(--ease-out-expo),
        transform 0.3s var(--ease-out-back);
}

.pfp-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.pfp-btn:active { transform: translateY(0); }

.pfp-btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
}

.pfp-btn--primary {
    color: var(--bg-elevated);
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    margin-left: auto;
}
.pfp-btn--primary:hover {
    color: var(--bg-elevated);
    background: var(--accent-secondary);
    border-color: var(--accent-secondary);
}

.pfp-btn--wide { flex: 1 1 200px; justify-content: center; }

/* ---------- Responsive ---------- */

@media (max-width: 920px) {
    .pfp__grid {
        grid-template-columns: 1fr;
        gap: 28px;
    }
    .pfp-stage {
        position: static;
        max-width: 440px;
        margin: 0 auto;
        width: 100%;
    }
    .pfp-btn--primary { margin-left: 0; }
}

@media (max-width: 768px) {
    .world-pfp { padding-top: calc(var(--nav-height) + 24px); }
    .pfp-tray { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}

/* Respect reduced motion — kill idle/shimmer animation */
@media (prefers-reduced-motion: reduce) {
    .pfp__status::before,
    .pfp-cell[data-ready="0"]::before {
        animation: none;
    }
}
