/* =========================================================================
 * iso-clar.css — peces isomètriques només CSS amb la línia gràfica clara (03)
 * Requereix tokens.css + componentes.css + claro.css.
 *
 *  .iso-scene            escenari amb perspectiva (fons blanc gel)
 *    .iso-fit            escala l'escena (--sc)
 *      .iso-plane        plataforma girada en isomètric (flex)
 *        .iso-col        columna extruïda: <div class="iso-col c2" style="--h:120"><i></i><i></i><i></i><span>Etiqueta</span></div>
 *                        i:1 = tapa · i:2 = cara frontal · i:3 = cara lateral · span = etiqueta al terra
 *                        --w amplada · --d profunditat · --h alçada (px) · --z elevació (px)
 *        .iso-stack      columna apilada (diverses .iso-col amb --z)
 *        .iso-funnel     embut de lloses centrades
 *        .iso-pie        donut extruït per capes (<i style="--k:0"> … )
 *        .iso-wall       mur vertical a la vora del fons (per a àrees)
 *    .iso-tag            etiqueta flotant HTML
 * ========================================================================= */

/* ---- Escenari ---- */
.iso-scene {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    min-height: var(--sh, 360px);
    perspective: 2200px;
    overflow: hidden;
    border-radius: var(--r-md);
    background:
        radial-gradient(circle, var(--b-200) 1px, transparent 1.4px) 0 0 / 22px 22px,
        radial-gradient(600px 300px at 50% 70%, var(--b-50), #fff 70%);
}
.iso-scene.plain { background: none; }
.iso-fit { transform: scale(var(--sc, 1)); transform-style: preserve-3d; display: flex; align-items: center; justify-content: center; }

/* ---- Plataforma ---- */
.iso-plane {
    --gap3: 22px;
    position: relative;
    display: flex; align-items: flex-end; gap: var(--gap3);
    padding: 28px;
    transform: rotateX(58deg) rotateZ(-42deg);
    transform-style: preserve-3d;
    background:
        linear-gradient(var(--b-100) 1px, transparent 1px) 0 0 / 30px 30px,
        linear-gradient(90deg, var(--b-100) 1px, transparent 1px) 0 0 / 30px 30px,
        #fff;
    border: 1px solid var(--b-200);
    border-radius: 6px;
    box-shadow: 0 0 0 8px rgba(255, 255, 255, .7), 24px 24px 50px rgba(0, 64, 92, .14);
}
.iso-plane.wrap { flex-wrap: wrap; align-items: flex-start; }
.iso-plane.bare { background: none; border: 0; box-shadow: none; }

/* ---- Columna extruïda ---- */
.iso-col {
    --w: 44px; --d: var(--w);
    --hh: calc(var(--h, 60) * var(--grow) * 1px);
    --top: var(--b-100); --front: var(--b-500); --front2: var(--b-600); --side: var(--b-700); --side2: var(--b-800);
    position: relative; flex: none;
    width: var(--w); height: var(--d);
    transform-style: preserve-3d;
    transform: translateZ(calc(var(--z, 0) * var(--grow) * 1px));
    animation: grow 1.8s var(--ease) both;
}

.iso-col > i { position: absolute; display: block; }
.iso-col > i:nth-child(1) {                       /* tapa */
    inset: 0;
    transform: translateZ(var(--hh));
    background: linear-gradient(135deg, #fff 10%, var(--top));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .8);
}

.iso-col > i:nth-child(2) {                       /* cara frontal */
    left: 0; width: var(--w);
    top: calc(var(--d) - var(--hh)); height: var(--hh);
    transform-origin: bottom; transform: rotateX(-90deg);
    background: linear-gradient(to top, var(--front2), var(--front));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}

.iso-col > i:nth-child(3) {                       /* cara lateral (vora esquerra: és la que es veu amb rotateZ(-42deg)) */
    top: 0; height: var(--d);
    left: 0; width: var(--hh);
    transform-origin: left; transform: rotateY(-90deg);
    background: linear-gradient(to right, var(--side2), var(--side));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.iso-col::before {                                /* ombra al terra */
    content: ''; position: absolute; inset: 0;
    background: rgba(0, 64, 92, .16);
    transform: translate(calc(var(--hh) * .22), calc(var(--hh) * .22));
    filter: blur(5px);
}
.iso-stack .iso-col::before, .iso-funnel .iso-col:not(:first-child)::before, .iso-col.noshadow::before { content: none; }
.iso-col > span {                                 /* etiqueta estirada al terra */
    position: absolute; top: calc(var(--d) + 8px); left: -10px; right: -10px;
    text-align: center; font-size: 11px; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}

/* Tons de la gamma */
.iso-col.c1 { --top: var(--b-300); --front: var(--b-700); --front2: var(--b-800); --side: var(--b-800); --side2: var(--b-900); }
.iso-col.c2 { --top: var(--b-200); --front: var(--b-600); --front2: var(--b-700); --side: var(--b-700); --side2: var(--b-800); }
.iso-col.c3 { --top: var(--b-100); --front: var(--b-500); --front2: var(--b-600); --side: var(--b-600); --side2: var(--b-700); }
.iso-col.c4 { --top: var(--b-50);  --front: var(--b-400); --front2: var(--b-500); --side: var(--b-500); --side2: var(--b-600); }
.iso-col.c5 { --top: #fff;         --front: var(--b-300); --front2: var(--b-400); --side: var(--b-400); --side2: var(--b-500); }
.iso-col.c6 { --top: #fff;         --front: var(--b-200); --front2: var(--b-300); --side: var(--b-300); --side2: var(--b-400); }
.iso-col.alert { --top: #FFE3E1; --front: #F97C75; --front2: #E9625B; --side: #D9534C; --side2: #B23A34; }
.iso-col.glass { --top: rgba(255, 255, 255, .7); --front: rgba(143, 195, 221, .35); --front2: rgba(60, 140, 192, .25); --side: rgba(60, 140, 192, .35); --side2: rgba(31, 116, 164, .35); }
.iso-col.glass > i { box-shadow: inset 0 0 0 1px rgba(60, 140, 192, .55); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }

/* Retards escalonats */
.iso-plane > *:nth-child(2) { animation-delay: .08s; } .iso-plane > *:nth-child(3) { animation-delay: .16s; }
.iso-plane > *:nth-child(4) { animation-delay: .24s; } .iso-plane > *:nth-child(5) { animation-delay: .32s; }
.iso-plane > *:nth-child(6) { animation-delay: .40s; } .iso-plane > *:nth-child(7) { animation-delay: .48s; }
.iso-plane > *:nth-child(8) { animation-delay: .56s; } .iso-plane > *:nth-child(n+9) { animation-delay: .64s; }

/* Flotació (cubs decoratius) */
.iso-col.float { animation: iso-float 5s ease-in-out infinite; --grow: 1; }
@keyframes iso-float { 0%, 100% { transform: translateZ(calc(var(--z, 40) * 1px)); } 50% { transform: translateZ(calc(var(--z, 40) * 1px + 16px)); } }

/* ---- Columna apilada ---- */
.iso-stack { position: relative; flex: none; width: var(--w, 44px); height: var(--w, 44px); transform-style: preserve-3d; animation: grow 1.8s var(--ease) both; }
.iso-stack > .iso-col { position: absolute; inset: 0; animation: none; }
.iso-stack::before { content: ''; position: absolute; inset: 0; background: rgba(0, 64, 92, .16); transform: translate(26px, 26px); filter: blur(6px); }
.iso-stack > span { position: absolute; top: calc(var(--w, 44px) + 8px); left: -10px; right: -10px; text-align: center; font-size: 11px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }

/* ---- Embut de lloses ---- */
.iso-funnel { --s: 220px; position: relative; flex: none; width: var(--s); height: var(--s); transform-style: preserve-3d; }
.iso-funnel > .iso-col { position: absolute; --d: var(--w); left: calc((var(--s) - var(--w)) / 2); top: calc((var(--s) - var(--w)) / 2); }
.iso-funnel > .iso-col:nth-child(2) { animation-delay: .1s; } .iso-funnel > .iso-col:nth-child(3) { animation-delay: .2s; }
.iso-funnel > .iso-col:nth-child(4) { animation-delay: .3s; } .iso-funnel > .iso-col:nth-child(5) { animation-delay: .4s; }
.iso-funnel > .iso-col:nth-child(6) { animation-delay: .5s; } .iso-funnel > .iso-col:nth-child(7) { animation-delay: .6s; }

/* ---- Donut extruït ---- */
.iso-pie { --s: 220px; position: relative; flex: none; width: var(--s); height: var(--s); transform-style: preserve-3d; animation: grow 1.8s var(--ease) both; }
.iso-pie::before { content: ''; position: absolute; inset: 4%; border-radius: 50%; background: rgba(0, 64, 92, .18); transform: translate(18px, 18px); filter: blur(10px); }
.iso-pie > i {
    position: absolute; inset: 0; border-radius: 50%;
    background: var(--pie);
    -webkit-mask: radial-gradient(circle, transparent 36%, #000 36.5%); mask: radial-gradient(circle, transparent 36%, #000 36.5%);
    transform: translateZ(calc(var(--k) * 3px * var(--grow)));
    filter: brightness(calc(.62 + var(--k) * .03));
}
.iso-pie > i:last-child { filter: none; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6); }

/* ---- Mur vertical (vora del fons) ---- */
.iso-wall {
    position: absolute; left: 0; right: 0;
    top: calc(-1 * var(--wh, 140px)); height: var(--wh, 140px);
    transform-origin: bottom; transform: rotateX(-90deg);
    background: linear-gradient(to top, rgba(238, 247, 251, .95), rgba(255, 255, 255, .7));
    border: 1px solid var(--b-200); border-bottom: 0;
    padding: 12px 16px 0;
}
.iso-wall .area { --h: calc(var(--wh, 140px) - 12px); border-bottom: 0; background: none; }

/* ---- Etiquetes flotants ---- */
.iso-tag {
    position: absolute; z-index: 2;
    display: flex; flex-direction: column; gap: 1px;
    padding: 8px 12px; border-radius: 8px;
    background: #fff; border-left: 3px solid var(--b-700);
    box-shadow: 0 10px 26px rgba(0, 64, 92, .14);
    font-size: 12px; color: var(--ink-2); white-space: nowrap;
    animation: float 6s ease-in-out infinite;
}
.iso-tag b { font-size: 18px; font-weight: 600; color: var(--ink); line-height: 1.1; }
.iso-tag.t2 { border-color: var(--b-500); animation-delay: -2s; }
.iso-tag.t3 { border-color: var(--b-300); animation-delay: -4s; }
.iso-tag.alert { border-color: var(--st-alert); }

/* Llegenda numerada al costat d'una escena */
.iso-legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.iso-legend > div { display: flex; align-items: center; gap: 10px; color: var(--ink-2); }
.iso-legend > div b { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }
.iso-legend i { width: 14px; height: 14px; border-radius: 3px; flex: none; }
.iso-legend .k1 { background: var(--b-800); } .iso-legend .k2 { background: var(--b-700); } .iso-legend .k3 { background: var(--b-600); }
.iso-legend .k4 { background: var(--b-500); } .iso-legend .k5 { background: var(--b-400); } .iso-legend .k6 { background: var(--b-300); }
.iso-legend .k7 { background: var(--b-200); } .iso-legend .ka { background: var(--st-alert); }

@media (max-width: 760px) {
    .iso-fit { --sc: .68 !important; }
    .iso-scene { min-height: 280px; }
    .iso-tag { display: none; }
}
