/* ==========================================================================
   fraMesh Lab — herramientas de predimensionamiento (lab.framesh.xyz)
   Mismo sistema visual que framesh.xyz
   ========================================================================== */

:root {
  --blue: #0055ff;
  --blue-hi: #3b7bff;
  --cyan: #00d2ff;
  --ink: #07080b;
  --ink-2: #0e1015;
  --ink-3: #161922;
  --paper: #f2f2ee;
  --text-inv: #eef0f5;
  --text-inv-2: #8d93a3;
  --line-inv: rgba(255, 255, 255, .12);
  --ok: #5fd08a;
  --bad: #ff5c5c;
  --f-logo: 'Tomorrow', sans-serif;
  --f-display: 'Tomorrow', 'Inter Tight', system-ui, sans-serif;
  --f-sans: 'Inter Tight', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;
  --gutter: clamp(16px, 4vw, 56px);
  --maxw: 1440px;
  --ease: cubic-bezier(.2, .7, .1, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ink); color: var(--text-inv); font: 17px/1.55 var(--f-sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
::selection { background: var(--blue); color: #fff; }
:focus-visible { outline: 2px solid var(--blue-hi); outline-offset: 3px; }
.mono { font-family: var(--f-mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.blue { color: var(--blue-hi); }
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Encabezado ---------- */
.logo { font-family: var(--f-logo); color: var(--blue); font-size: 24px; letter-spacing: -.02em; line-height: 1; display: inline-flex; align-items: baseline; gap: 10px; }
.logo b { font-weight: 600; }
.logo .tag { font-family: var(--f-mono); font-size: 11px; letter-spacing: .08em; color: var(--text-inv-2); }
.lab-header { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 28px; padding: 14px var(--gutter); background: rgba(7, 8, 11, .82); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4); border-bottom: 1px solid var(--line-inv); }
.lab-nav { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.lab-nav a { padding: 8px 14px; border-radius: 999px; font-size: 14.5px; color: var(--text-inv-2); white-space: nowrap; transition: color .2s, background .2s; }
.lab-nav a:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.lab-nav a.is-on { color: #fff; background: var(--blue); }
.lab-header .to-main { font-size: 11px; color: var(--text-inv-2); white-space: nowrap; }
.lab-header .to-main:hover { color: #fff; }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; gap: 10px; height: 50px; padding: 0 24px; font-size: 15px; font-weight: 500; border-radius: 999px; transition: background .25s, color .25s, border-color .25s; white-space: nowrap; }
.btn .arr { transition: transform .3s var(--ease); }
.btn:hover .arr { transform: translateX(4px); }
.btn--blue { background: var(--blue); color: #fff; }
.btn--blue:hover { background: #1a66ff; }
.btn--ghost { border: 1px solid rgba(255, 255, 255, .35); color: #fff; }
.btn--ghost:hover { border-color: #fff; background: rgba(255, 255, 255, .08); }

/* ---------- Portada del Lab y de cada herramienta ---------- */
.intro { position: relative; padding: clamp(56px, 8vw, 110px) 0 clamp(36px, 5vw, 64px); }
.intro::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .6;
  background-image: linear-gradient(var(--line-inv) 1px, transparent 1px), linear-gradient(90deg, var(--line-inv) 1px, transparent 1px);
  background-size: 64px 64px; mask-image: radial-gradient(ellipse at 20% 30%, #000 0%, transparent 70%); -webkit-mask-image: radial-gradient(ellipse at 20% 30%, #000 0%, transparent 70%); }
.intro .wrap { position: relative; }
.crumbs { color: var(--text-inv-2); display: flex; gap: 10px; margin: 0 0 22px; font-size: 11px; }
.crumbs a:hover { color: #fff; }
.intro h1 { font-size: clamp(38px, 5.6vw, 84px); line-height: 1; letter-spacing: -.035em; font-weight: 500; margin: 0 0 20px; max-width: 16ch; }
.intro p.lead { color: #c3c8d4; font-size: clamp(17px, 1.4vw, 20px); max-width: 640px; margin: 0; }

/* Tarjetas de herramientas */
.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1px; background: var(--line-inv); border: 1px solid var(--line-inv); margin-bottom: clamp(64px, 8vw, 120px); }
.tool { background: var(--ink); padding: 28px; display: flex; flex-direction: column; gap: 14px; min-height: 320px; transition: background .3s; }
.tool:hover { background: var(--ink-2); }
.tool-top { display: flex; justify-content: space-between; color: var(--text-inv-2); font-size: 11px; }
.tool-top span:first-child { color: var(--blue-hi); }
.tool svg { width: 120px; height: 80px; margin: 18px 0 8px; }
.tool svg * { stroke: var(--text-inv); stroke-width: 1.2; fill: none; vector-effect: non-scaling-stroke; }
.tool svg .acc { stroke: var(--blue-hi); }
.tool svg .dim { stroke: var(--text-inv-2); stroke-dasharray: 3 3; }
.tool:hover svg * { stroke: var(--blue-hi); }
.tool h2 { font-size: 26px; letter-spacing: -.025em; font-weight: 500; margin: 0; line-height: 1.1; }
.tool p { color: var(--text-inv-2); margin: 0; font-size: 15px; flex: 1; }
.tool .go { font-size: 11px; color: #fff; }
.tool:hover .go { color: var(--blue-hi); }

/* ---------- Calculadora ---------- */
.lab { display: grid; grid-template-columns: 400px 1fr; border: 1px solid var(--line-inv); background: var(--ink-2); }
.lab-controls { padding: 28px; border-right: 1px solid var(--line-inv); display: flex; flex-direction: column; gap: 24px; }
.ctl { display: block; }
.ctl-top { display: flex; justify-content: space-between; gap: 12px; color: var(--text-inv-2); font-size: 11px; margin-bottom: 12px; }
.ctl-top b { color: #fff; font-weight: 500; text-transform: none; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 1px; background: linear-gradient(90deg, var(--blue-hi) var(--p, 50%), var(--line-inv) var(--p, 50%)); }
input[type=range]::-moz-range-track { height: 1px; background: var(--line-inv); }
input[type=range]::-moz-range-progress { height: 1px; background: var(--blue-hi); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7.5px; background: var(--ink); border: 1.5px solid var(--blue-hi); transform: rotate(45deg); }
input[type=range]::-moz-range-thumb { width: 13px; height: 13px; background: var(--ink); border: 1.5px solid var(--blue-hi); border-radius: 0; transform: rotate(45deg); }
select { width: 100%; appearance: none; -webkit-appearance: none; background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238d93a3'/%3E%3C/svg%3E") no-repeat right 14px center; border: 1px solid var(--line-inv); color: #fff; font: 15px var(--f-sans); padding: 11px 36px 11px 14px; border-radius: 0; cursor: pointer; }
select:focus { border-color: var(--blue-hi); outline: none; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line-inv); }
.seg button { padding: 10px 4px; font-size: 11px; color: var(--text-inv-2); border-right: 1px solid var(--line-inv); transition: background .2s, color .2s; font-family: var(--f-mono); letter-spacing: .04em; }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: #fff; }
.seg button.is-on { background: var(--blue); color: #fff; }

.results { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line-inv); border-left: 1px solid var(--line-inv); }
.res { padding: 14px; border-right: 1px solid var(--line-inv); border-bottom: 1px solid var(--line-inv); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.res > span { font-size: 10px; color: var(--text-inv-2); text-transform: none; }
.res b { font-size: 24px; font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.res small { font-size: 11px; color: var(--text-inv-2); }
.res--wide { grid-column: 1 / -1; }
.res--hi b { color: var(--cyan); font-size: 30px; }
.util { height: 4px; background: var(--line-inv); margin-top: 8px; position: relative; }
.util::after { content: ''; position: absolute; left: 100%; top: -4px; bottom: -4px; width: 1px; background: var(--text-inv-2); }
.util span { display: block; height: 100%; width: 0; background: var(--blue-hi); transition: width .3s var(--ease), background .3s; max-width: 100%; }
.util span.over { background: var(--bad); }
.verdict { margin: 0; font-size: 11.5px; text-transform: none; letter-spacing: .02em; padding: 12px 14px; border: 1px solid var(--line-inv); color: var(--text-inv-2); line-height: 1.5; }
.verdict.ok { border-color: rgba(59, 123, 255, .5); color: #cfe0ff; }
.verdict.bad { border-color: rgba(255, 77, 77, .5); color: #ffc9c9; }

.stage { position: relative; display: flex; flex-direction: column; min-height: 520px;
  background-image: linear-gradient(var(--line-inv) 1px, transparent 1px), linear-gradient(90deg, var(--line-inv) 1px, transparent 1px); background-size: 40px 40px; background-position: -1px -1px; }
.stage-head { display: flex; justify-content: space-between; gap: 12px; padding: 16px 20px; font-size: 11px; color: var(--text-inv-2); border-bottom: 1px solid var(--line-inv); background: var(--ink-2); }
.stage-head b { color: #fff; font-weight: 500; }
.stage-body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px; gap: 24px; }
.stage canvas { flex: 1; width: 100%; min-height: 380px; display: block; }
.stage svg.plot { width: 100%; height: auto; overflow: visible; }
.plot path { fill: none; }
.plot text { font-family: var(--f-mono); font-size: 10px; fill: var(--text-inv-2); letter-spacing: .04em; }
.plot .axis { stroke: rgba(255, 255, 255, .35); stroke-width: 1; }
.plot .grid { stroke: var(--line-inv); stroke-width: 1; }
.plot .curve { fill: none; stroke: var(--cyan); stroke-width: 2.5; }
.plot .area { fill: url(#fill); }
.plot .ghost { fill: none; stroke: rgba(255, 255, 255, .25); stroke-dasharray: 4 4; }
.plot .mark { fill: var(--ink); stroke: #fff; stroke-width: 1.5; }
.plot .guide { stroke: var(--blue-hi); stroke-dasharray: 3 3; }
.plot .solid { fill: rgba(59, 123, 255, .35); stroke: var(--blue-hi); }
.plot .support { fill: none; stroke: #fff; stroke-width: 1.2; }
.note { margin: 0; padding: 12px 20px; font-size: 10px; color: var(--text-inv-2); border-top: 1px solid var(--line-inv); background: var(--ink-2); text-transform: none; letter-spacing: .02em; }

/* Explicación y llamado a la acción */
.explain { display: grid; grid-template-columns: 1fr 2fr; gap: 40px; padding: clamp(48px, 6vw, 80px) 0; border-bottom: 1px solid var(--line-inv); }
.explain h2 { font-size: 11px; color: var(--blue-hi); margin: 6px 0 0; font-weight: 400; }
.explain-body { color: #c3c8d4; max-width: 720px; }
.explain-body p { margin: 0 0 1em; }
.explain-body code { font-family: var(--f-mono); font-size: 14px; color: #fff; background: var(--ink-3); padding: 1px 6px; }
.cta { display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap; padding: clamp(48px, 6vw, 80px) 0; }
.cta h2 { font-size: clamp(28px, 3.6vw, 52px); letter-spacing: -.03em; font-weight: 500; margin: 0; line-height: 1.05; }
.cta .actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- Pie ---------- */
.lab-footer { border-top: 1px solid var(--line-inv); padding: 28px 0 32px; color: var(--text-inv-2); font-size: 11px; }
.lab-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.lab-footer a:hover { color: #fff; }

/* Tipografía display: títulos y resultados */
.intro h1, .tool h2, .res b, .cta h2 { font-family: var(--f-display); font-weight: 500; letter-spacing: -.025em; }
.intro h1 { line-height: 1.02; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .lab { grid-template-columns: 1fr; }
  .lab-controls { border-right: 0; border-bottom: 1px solid var(--line-inv); }
  .stage { min-height: 420px; }
}
@media (max-width: 820px) {
  body { font-size: 16px; }
  .lab-header { flex-wrap: wrap; gap: 10px 16px; }
  .lab-nav { order: 3; flex-basis: 100%; }
  .lab-header .to-main { margin-left: auto; }
  .explain { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-width: 560px) {
  .lab-controls { padding: 20px; }
  .res b { font-size: 21px; }
  .res--hi b { font-size: 26px; }
  .stage-body { padding: 16px 8px; }
  .cta .actions .btn { flex: 1; justify-content: center; }
}

/* Aviso "En desarrollo" (lo agrega common.js debajo de la introducción) */
.lab-beta { margin: 18px 0 0; max-width: 640px; color: var(--text-inv-2); font-size: 14px; line-height: 1.6; }
.lab-beta .mono { display: inline-flex; align-items: center; gap: 7px; margin-right: 8px; padding: 3px 10px; border: 1px solid rgba(255, 176, 32, .45); border-radius: 999px; color: #ffb020; font-size: 10.5px; white-space: nowrap; vertical-align: 1px; }
.lab-beta .mono::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #ffb020; animation: beta-pulse 2s ease-in-out infinite; }
.lab-beta a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
@keyframes beta-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .lab-beta .mono::before { animation: none; } }
