/* ===================================================================
   COMPONENT · FOLDER STACK  (design system)
   -------------------------------------------------------------------
   A single continuous panel split into stacked sections that read as
   file-folder tabs. Opens as an accordion (one section at a time).

   Pairs with: components/folder-stack.js  (geometry engine)
   Full spec:  components/folder-stack.md  (math, diagrams, gotchas)

   THEME TOKENS CONSUMED (must be defined by the host theme):
     --panel-bg  --panel-border  --panel-text  --panel-text-soft
     --open-bg   --open-text     --blur        --shadow
     --badge-bg  --badge-fg      --sage
   GEOMETRY CONSTANTS are mirrored in folder-stack.js → FolderStack.GEO.
   If you change a radius here, change it THERE TOO (CR=18, TAB_R=12).
   =================================================================== */

/* ---- shell ------------------------------------------------------- */
/* Top-left corner is SQUARE on purpose: the first tab sits there. */
.fstack{display:flex; flex-direction:column; border-radius:0 18px 18px 18px; margin-top:56px; position:relative;
  background:var(--panel-bg); border:1px solid var(--panel-border); box-shadow:var(--shadow);
  -webkit-backdrop-filter:var(--blur); backdrop-filter:var(--blur)}

/* Three layers that only the Glass theme switches on (see §Glass below).
   NOTE: .fstack-svg must stay the LAST child of .fstack — the JS engine
   and the :last-of-type selectors below depend on it. See gotcha G1. */
.fdr-fill{display:none}      /* per-section tint, shaped by clip-path */
.fstack-glass{display:none}  /* one continuous frosted sheet          */
.fstack-svg{display:none}    /* one single stroked outline            */

/* ---- section ----------------------------------------------------- */
/* padding-bottom:76px is what makes every section the SAME height when
   closed (a hard requirement). Do not special-case the last one. */
.fdr{position:relative; cursor:pointer; padding:18px 24px 76px;
  border-radius:0 18px 0 0; transition:background .35s, color .35s}
.fdr + .fdr{border-top:1px solid var(--panel-border)}
.fdr.open{background:var(--open-bg); color:var(--open-text)}

/* ---- tab (the "lengüita") ---------------------------------------- */
/* Sits on top of the previous section, flush left, same fill as its own
   section so tab + body read as one folder. */
.ftab{position:absolute; bottom:100%; left:0; z-index:3;
  /* COMPONENTE: GEOMETRIA INTERNA. La pestana no usa la escala de espacio de
     pagina: su alto sale del recorte del stack. Ver folder-stack.md. */
  display:inline-flex; align-items:center; gap:11px; padding:13px 26px; line-height:1;
  font-family:'Poppins'; font-weight:600; font-size:18px; color:var(--panel-text);
  background:var(--panel-bg); border:1px solid var(--panel-border);
  -webkit-backdrop-filter:var(--blur); backdrop-filter:var(--blur);
  border-radius:12px 12px 0 0; box-shadow:0 2px 9px rgba(28,43,32,.12)}
.fdr.open .ftab{background:var(--open-bg); color:var(--open-text)}
.ftab .tn{font-family:'Poppins'; font-weight:800; font-size:19px; color:var(--sage)}
.fdr.open .ftab .tn{color:rgba(255,255,255,.92)}

/* ---- head row: subtitle (left) + count (right) ------------------- */
/* min-height = el alto exacto del badge de conteo (29.5px medidos: 13px de
   Poppins + 5px de padding arriba y abajo). El badge solo se dibuja cuando
   count > 0, así que sin este min-height la fila mide 21.75px en las etapas
   vacías y ESA sección queda ~8px más baja que las demás — rompe el requisito
   1 del componente ("todas iguales cuando están cerradas"). Reservar el alto
   es lo que lo mantiene, y no depende de cuántas etapas estén cargadas. */
.fsec-head{display:flex; align-items:center; justify-content:space-between; gap:12px; min-height:29.5px}
.fdr-sub{font-size:14.5px; font-weight:400; color:var(--panel-text-soft)}
.fdr.open .fdr-sub{color:rgba(255,255,255,.9)}
.fcount2{flex:none; background:var(--badge-bg); color:var(--badge-fg);
  font-family:'Poppins'; font-weight:700; font-size:13px; padding:5px 13px; border-radius:999px}
.fdr.open .fcount2{background:rgba(255,255,255,.22); color:#fff}

/* ---- collapsible body -------------------------------------------- */
/* grid-template-rows 0fr→1fr animates height without a fixed max-height. */
.fdr-collapse{display:grid; grid-template-rows:0fr; transition:grid-template-rows .42s cubic-bezier(.4,0,.2,1)}
.fdr.open .fdr-collapse{grid-template-rows:1fr}
.fdr-inner{overflow:hidden; min-height:0}
.fdr-detail{padding-top:14px}
.fsec-foot{display:flex; justify-content:flex-end; margin-top:16px}

/* ===================================================================
   GLASS VARIANT (body.theme-g)
   The shell stops painting itself. Instead three stacked layers:
     z0  .fstack-glass  ONE frosted sheet spanning the whole stack
     z0  .fdr-fill      per-section tint, carved by clip-path (JS)
     z2  .fstack-svg    ONE stroked path: frame + stepped dividers (JS)
   Result: continuous glass, no seams, a single hairline outline.
   =================================================================== */
body.theme-g .fstack{background:transparent; border:0; box-shadow:none; -webkit-backdrop-filter:none; backdrop-filter:none}

/* the continuous sheet — bottom corners SQUARE, top-right rounded (CR) */
body.theme-g .fstack-glass{display:block; position:absolute; inset:0; z-index:0; pointer-events:none;
  background:var(--panel-bg); border-radius:0 18px 0 0;
  -webkit-backdrop-filter:var(--blur); backdrop-filter:var(--blur)}

body.theme-g .fdr{position:relative; z-index:1}
body.theme-g .fdr + .fdr{border-top:0}

/* Tint only — NO blur of its own (the sheet behind already blurs).
   Its shape comes entirely from the JS clip-path. */
body.theme-g .fdr-fill{display:block; position:absolute; inset:0; z-index:0; pointer-events:none;
  background:transparent}
body.theme-g .fdr:last-of-type .fdr-fill{border-radius:0}
body.theme-g .fdr.open{background:transparent}
body.theme-g .fdr.open .fdr-fill{background:var(--open-bg)}

/* An OPEN section (except the last) bleeds EXT=18px past its own bottom.
   That overflow strip is where the convex tip lives — the tip paints the
   triangle left by the next section's rounded step. See gotcha G1: this
   MUST be :last-of-type, not :last-child (last child is the <svg>). */
body.theme-g .fdr.open:not(:last-of-type) .fdr-fill{bottom:-18px}

body.theme-g .fsec-head, body.theme-g .fdr-collapse{position:relative; z-index:1}

/* Tab outline is drawn by the SVG, so kill its own border. Only the FIRST
   tab keeps a blur: it sticks out above the sheet, over the background. */
body.theme-g .ftab{border:0; -webkit-backdrop-filter:none; backdrop-filter:none}
body.theme-g .fdr:first-child .ftab{-webkit-backdrop-filter:var(--blur); backdrop-filter:var(--blur)}

body.theme-g .fstack-svg{display:block; position:absolute; inset:0; z-index:2; width:100%; height:100%; overflow:visible; pointer-events:none}
body.theme-g .fstack-svg path{fill:none; stroke:var(--panel-border); stroke-width:1; vector-effect:non-scaling-stroke}
