/* =========================================================================
   tech.css — Ecosistema atómico de tecnologías, panel y catálogo.
   ========================================================================= */

.tech-head {
    max-width: 820px;
    margin-bottom: clamp(32px, 4vw, 52px);
}

.atom-layout {
    display: grid;
    gap: clamp(24px, 4vw, 44px);
    align-items: start;
}

@media (min-width: 1180px) {
    .atom-layout { grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr); align-items: center; }
}

.atom-stage { min-width: 0; }

/* ------------------------------ Barra de controles ------------------------------ */
.atom-toolbar {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.atom-filters {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.atom-filters button {
    min-height: 34px;
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 500;
    transition: color var(--fast) ease, border-color var(--fast) ease, background-color var(--fast) ease;
}

.atom-filters button:hover { color: var(--text); border-color: var(--line-2); }

.atom-filters button[aria-pressed="true"] {
    border-color: rgba(96, 165, 250, 0.6);
    background: rgba(37, 99, 235, 0.18);
    color: #fff;
}

.atom-controls { display: flex; gap: 6px; flex: none; }

.atom-ctl {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line-2);
    border-radius: 12px;
    color: var(--text-soft);
    transition: border-color var(--fast) ease, background-color var(--fast) ease, color var(--fast) ease;
}

.atom-ctl:hover { border-color: var(--line-blue); color: #fff; background: rgba(59, 130, 246, 0.12); }
.atom-ctl:disabled { opacity: 0.45; cursor: default; }
.atom-ctl .i-play { display: none; }
.atom-ctl[aria-pressed="true"] .i-play { display: block; }
.atom-ctl[aria-pressed="true"] .i-pause { display: none; }

@media (max-width: 720px) {
    /* Filtros en una fila desplazable dentro de su propio contenedor */
    .atom-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
        scrollbar-width: none;
        -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
        mask-image: linear-gradient(90deg, #000 88%, transparent);
    }
    .atom-filters::-webkit-scrollbar { display: none; }
    .atom-filters button { flex: none; min-height: 38px; }
}

/* ---------------------------------- Átomo ---------------------------------- */
.atom {
    position: relative;
    width: 100%;
    max-width: 780px;
    aspect-ratio: 1 / 0.86;
    margin-inline: auto;
    touch-action: pan-y;          /* el desplazamiento vertical de la página sigue funcionando */
    overflow: clip;
    overflow-clip-margin: 24px;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    isolation: isolate;
}

.atom.is-dragging { cursor: grabbing; }
/* Móvil: la órbita ocupa casi todo el ancho de la pantalla para separar sus seis órbitas */
.atom.is-compact { aspect-ratio: 1 / 1; overflow-clip-margin: 0px; }

@media (max-width: 600px) {
    .atom { width: calc(100% + var(--gutter) * 2 - 8px); max-width: none; margin-inline: calc(var(--gutter) * -1 + 4px); }
}

.atom-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.atom-items { position: absolute; inset: 0; }

.atom-item {
    --size: 40px;
    position: absolute;
    top: 0;
    left: 0;
    width: var(--size);
    height: var(--size);
    margin: calc(var(--size) / -2) 0 0 calc(var(--size) / -2);
    border-radius: 50%;
    will-change: transform, opacity;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 400ms ease;
}

.atom-item.is-core { --size: 48px; }

.atom-item-in {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--c) 34%, rgba(148, 163, 184, 0.18));
    border-radius: 50%;
    background:
        radial-gradient(circle at 34% 26%, color-mix(in srgb, var(--c) 24%, transparent), transparent 62%),
        color-mix(in srgb, var(--ink-2) 95%, transparent);
    box-shadow:
        0 0 20px -8px color-mix(in srgb, var(--c) 75%, transparent),
        inset 0 1px rgba(255, 255, 255, 0.1);
    color: var(--c);
    transition: transform 420ms var(--ease), border-color 300ms ease, box-shadow 300ms ease;
}

.atom-item.is-core .atom-item-in {
    box-shadow: 0 0 30px -6px color-mix(in srgb, var(--c) 80%, transparent), inset 0 1px rgba(255, 255, 255, 0.12);
}

.atom-item .i { width: 50%; height: 50%; }
.atom-item .glyph { font-size: 0.8rem; }

.glyph {
    font-family: var(--mono);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.04em;
}

/* Nombre al pasar el puntero o al seleccionar */
.atom-item::after {
    content: attr(data-name);
    position: absolute;
    top: calc(100% + 7px);
    left: 50%;
    padding: 3px 9px;
    border: 1px solid var(--line-2);
    border-radius: 999px;
    background: color-mix(in srgb, var(--ink) 92%, transparent);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.64rem;
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, -4px);
    transition: opacity 200ms ease, transform 300ms var(--ease);
    pointer-events: none;
}

@media (hover: hover) {
    .atom-item:hover .atom-item-in {
        transform: scale(1.14);
        border-color: var(--c);
        box-shadow: 0 0 34px -4px color-mix(in srgb, var(--c) 90%, transparent);
    }

    .atom-item:hover::after { opacity: 1; transform: translate(-50%, 0); }
}

.atom-item.is-selected .atom-item-in {
    border-color: var(--c);
    box-shadow:
        0 0 0 4px color-mix(in srgb, var(--c) 22%, transparent),
        0 0 42px -2px color-mix(in srgb, var(--c) 95%, transparent);
}

.atom-item.is-selected::after { opacity: 1; transform: translate(-50%, 0); }

.atom-item.is-related .atom-item-in {
    border-color: color-mix(in srgb, var(--c) 70%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 12%, transparent), 0 0 28px -6px var(--c);
}

.atom-item.is-dim { filter: grayscale(0.7); }

/* Núcleo */
.atom-core {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 30;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    width: clamp(58px, 12%, 92px);
    aspect-ratio: 1;
    border: 1px solid rgba(252, 198, 36, 0.4);
    border-radius: 50%;
    background: radial-gradient(circle at 50% 32%, rgba(252, 198, 36, 0.2), color-mix(in srgb, var(--ink-2) 97%, transparent) 70%);
    box-shadow:
        0 0 0 8px rgba(252, 198, 36, 0.04),
        0 0 70px -10px rgba(252, 198, 36, 0.5),
        inset 0 1px rgba(255, 255, 255, 0.14);
    color: #fcc624;
    transform: translate(-50%, -50%);
    transition: box-shadow 400ms ease, border-color 400ms ease;
}

.atom-core .i { width: 38%; height: 38%; position: relative; }

.atom-core-name {
    position: relative;
    color: var(--text);
    font-family: var(--mono);
    font-size: clamp(0.54rem, 0.48rem + 0.3vw, 0.68rem);
    letter-spacing: 0.04em;
}

.atom-core-glow {
    position: absolute;
    inset: -12px;
    border: 1px solid rgba(252, 198, 36, 0.25);
    border-radius: 50%;
    animation: core-breathe 4s ease-in-out infinite;
}

.atom-core.is-selected {
    border-color: #fcc624;
    box-shadow:
        0 0 0 8px rgba(252, 198, 36, 0.1),
        0 0 90px -6px rgba(252, 198, 36, 0.65),
        inset 0 1px rgba(255, 255, 255, 0.14);
}

@keyframes core-breathe {
    0%, 100% { transform: scale(1); opacity: 0.75; }
    50% { transform: scale(1.1); opacity: 0.2; }
}

.atom.is-paused-user .atom-core-glow { animation-play-state: paused; }

.atom-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    text-align: center;
}

/* Entrada escalonada de las tecnologías */
.js .atom .atom-item-in { opacity: 0; transform: scale(0.3); }

.js .atom.is-in .atom-item-in {
    opacity: 1;
    transform: none;
    transition: opacity 600ms ease calc(var(--k) * 30ms), transform 800ms var(--ease) calc(var(--k) * 30ms), border-color 300ms ease, box-shadow 300ms ease;
}

.js .atom.is-in .atom-item:hover .atom-item-in { transform: scale(1.14); transition-delay: 0ms; }

.atom.is-compact .atom-item { --size: 30px; }
.atom.is-compact .atom-item.is-core { --size: 36px; }
.atom.is-compact .atom-item::after { display: none; }
.atom.is-compact .atom-item.is-selected::after { display: block; }

/* ---------------------------------- Panel ---------------------------------- */
.tech-panel {
    --c: #fcc624;
    position: relative;
    display: grid;
    gap: 22px;
    min-width: 0;
    padding: clamp(22px, 3vw, 30px);
    overflow: hidden;
    border: 1px solid var(--line-2);
    border-radius: var(--r-lg);
    background:
        radial-gradient(380px 220px at 100% 0%, color-mix(in srgb, var(--c) 14%, transparent), transparent 70%),
        linear-gradient(160deg, color-mix(in srgb, var(--ink-3) 88%, transparent), color-mix(in srgb, var(--ink-2) 62%, transparent));
    box-shadow: 0 30px 80px -50px rgba(37, 99, 235, 0.9);
}

.tech-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--c), transparent);
    opacity: 0.85;
}

.tech-panel-body { position: relative; }

.tech-panel-body.is-switching > * { animation: panel-in 540ms var(--ease) both; }
.tech-panel-body.is-switching > *:nth-child(2) { animation-delay: 50ms; }
.tech-panel-body.is-switching > *:nth-child(3) { animation-delay: 90ms; }
.tech-panel-body.is-switching > *:nth-child(4) { animation-delay: 130ms; }

@keyframes panel-in {
    from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
    to { opacity: 1; transform: none; filter: none; }
}

.tech-panel-top { display: flex; align-items: center; gap: 16px; }

.tech-panel-logo {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    flex: none;
    border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
    border-radius: 16px;
    background: radial-gradient(circle at 35% 25%, color-mix(in srgb, var(--c) 24%, transparent), color-mix(in srgb, var(--ink-2) 95%, transparent) 70%);
    box-shadow: 0 0 34px -8px color-mix(in srgb, var(--c) 80%, transparent);
    color: var(--c);
}

.tech-panel-logo .i { width: 52%; height: 52%; }
.tech-panel-logo .glyph { font-size: 1.05rem; }

.tech-panel-level {
    color: color-mix(in srgb, var(--c) 70%, #fff);
    font-family: var(--mono);
    font-size: 0.66rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.tech-panel-name {
    margin-top: 4px;
    font-size: clamp(1.4rem, 1.2rem + 0.8vw, 1.85rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.tech-panel-cat {
    display: inline-flex;
    margin-top: 16px;
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.66rem;
}

.tech-panel-desc {
    margin-top: 14px;
    color: var(--text-soft);
    font-size: 0.97rem;
    line-height: 1.7;
}

.tech-panel-related { margin-top: 18px; }

.tech-panel-label {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.64rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.tech-related {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.tech-related-none { color: var(--muted); font-size: 0.85rem; }

.tech-panel-foot {
    display: grid;
    gap: 12px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.tech-quick { display: flex; flex-wrap: wrap; gap: 8px; }

.tech-quick button,
.tech-related button,
.tech-catalog button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 6px 12px 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-soft);
    font-size: 0.84rem;
    font-weight: 500;
    transition: border-color var(--fast) ease, background-color var(--fast) ease, color var(--fast) ease, transform var(--mid) var(--ease);
}

.tech-related button { min-height: 32px; font-size: 0.8rem; }

.tech-quick .i,
.tech-related .i,
.tech-catalog .i { color: var(--c); font-size: 1.05rem; }

.tech-quick .glyph,
.tech-related .glyph,
.tech-catalog .glyph { color: var(--c); width: 1.05rem; text-align: center; font-size: 0.72rem; }

.tech-quick button:hover,
.tech-related button:hover,
.tech-catalog button:hover {
    border-color: color-mix(in srgb, var(--c) 55%, transparent);
    color: var(--text);
}

.tech-quick button:active,
.tech-catalog button:active { transform: scale(0.96); }

.tech-quick button[aria-pressed="true"],
.tech-catalog button[aria-pressed="true"] {
    border-color: var(--c);
    background: color-mix(in srgb, var(--c) 14%, transparent);
    color: #fff;
    box-shadow: 0 0 20px -8px var(--c);
}

/* -------------------------------- Catálogo -------------------------------- */
.tech-catalog {
    display: grid;
    gap: 1px;
    margin-top: clamp(36px, 5vw, 60px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--line);
}

@media (min-width: 700px) {
    .tech-catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
    .tech-catalog { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.cat {
    padding: 18px 18px 20px;
    background: color-mix(in srgb, var(--ink-2) 94%, transparent);
}

.cat h3 {
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.66rem;
    font-weight: 400;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.cat--core h3 { color: var(--blue-pale); }

.cat ul {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin-top: 12px;
}

.tech-catalog button { min-height: 34px; font-size: 0.8rem; }
.cat--extra button, .cat--geo button { color: var(--muted); }

/* ------------------------------- Tema claro ------------------------------- */
[data-theme="light"] .atom-filters button[aria-pressed="true"] { border-color: rgba(37, 99, 235, 0.5); background: rgba(37, 99, 235, 0.12); color: var(--blue-strong); }
[data-theme="light"] .atom-ctl:hover { color: var(--blue-strong); }
[data-theme="light"] .tech-quick button[aria-pressed="true"],
[data-theme="light"] .tech-catalog button[aria-pressed="true"] { color: var(--text); }
[data-theme="light"] .tech-panel-level { color: color-mix(in srgb, var(--c) 55%, #0a1430); }
[data-theme="light"] .atom-core { color: #92400e; }
[data-theme="light"] .atom-item-in { background: radial-gradient(circle at 34% 26%, color-mix(in srgb, var(--c) 22%, transparent), transparent 62%), #fff; box-shadow: 0 6px 16px -8px rgba(30, 58, 110, 0.45), 0 0 18px -10px var(--c); }
[data-theme="light"] .atom-item .i { filter: saturate(1.1) brightness(0.88); }
[data-theme="light"] .atom-item[data-name="Express.js"] .i,
[data-theme="light"] .atom-item[data-name="JSON"] .i { color: #334155; }
