/* diagram.css */

/* ── Preserved ── */
.node-content { display:flex; align-items:flex-start; gap:12px; }
.node-content svg { flex-shrink:0; width:36px; height:36px; }
.node-text { flex:1; }
@media (max-width:600px) {
    .node-content { flex-direction:column; align-items:center; text-align:center; }
    .node-text { width:100%; }
}

/* ════════════════════════════════════
   CARD
   ════════════════════════════════════ */
.arch-card {
    background: var(--color-bg-white);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
}

/* ════════════════════════════════════
   STATUS BAR
   ════════════════════════════════════ */
.arch-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 9px 12px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    min-height: 44px;
}
.arch-status .trigger-button {
    flex-shrink: 0;
    width: auto; height: auto;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    font-family: Arial, sans-serif;
    padding: 6px 14px;
    background: linear-gradient(135deg, var(--color-azure-blue), var(--color-azure-dark));
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-button);
    transition: transform var(--transition-normal), box-shadow var(--transition-normal), opacity var(--transition-normal);
}
.arch-status .trigger-button:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--color-azure-light), var(--color-azure-blue));
    transform: translateY(-1px);
    box-shadow: var(--shadow-button-hover);
}
.arch-status .trigger-button:active:not(:disabled) { transform: translateY(0); }
.arch-status .trigger-button:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.arch-status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--color-border-medium);
    flex-shrink: 0;
    transition: background 0.3s, box-shadow 0.3s;
}
.arch-status-dot.arch-status-dot--active {
    background: var(--color-azure-blue);
    box-shadow: 0 0 5px rgba(0,120,212,0.4);
    animation: arch-blink 0.8s ease-in-out infinite;
}
.arch-status-dot.arch-status-dot--done {
    background: #1e7e3e;
    box-shadow: 0 0 5px rgba(30,126,62,0.4);
    animation: none;
}
@keyframes arch-blink { 0%,100%{opacity:1} 50%{opacity:0.25} }

.arch-status-text {
    font-size: 0.78rem; font-family: Arial, sans-serif;
    color: var(--color-text-secondary); flex: 1;
}
.arch-status-text strong { color: var(--color-text-primary); }
.arch-status-timing {
    font-size: 0.78rem; font-family: Arial, sans-serif;
    color: var(--color-text-secondary); flex-shrink: 0;
}
.arch-status-timing .arch-timing-value { color: #1e7e3e; font-weight: 600; }

/* ════════════════════════════════════
   DIAGRAM
   Two rows, each a flex row of equal-width
   node columns separated by connector gaps.
   position:relative so the SVG overlay sits inside it.
   ════════════════════════════════════ */
.arch-diagram {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 32px; /* vertical gap between rows — SVG lines cross this gap */
}

/* SVG overlay covers the full diagram */
.arch-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 1;
}

/* Each row: 3 node cells + 2 spacer cells between them */
.arch-row {
    display: grid;
    grid-template-columns: 1fr 48px 1fr 48px 1fr;
    align-items: center;
}

/* ════════════════════════════════════
   NODES
   ════════════════════════════════════ */
.arch-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    cursor: pointer;
    padding: 14px 10px 12px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--color-border-light);
    background: var(--color-bg-card);
    text-align: center;
    color: var(--color-text-secondary);
    user-select: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s, transform 0.15s, opacity 0.25s;
}

/* Default hover */
.arch-node:hover {
    border-color: var(--color-border-medium);
    background: #f0ede8;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Selected: node and all its connected nodes */
.arch-node.is-selected {
    border-color: var(--color-azure-light);
    background: #e8f2fc;
    box-shadow: 0 0 0 3px rgba(0,120,212,0.15), 0 2px 12px rgba(0,120,212,0.12);
    transform: translateY(-2px);
    color: var(--color-azure-blue);
}
.arch-node.is-connected {
    border-color: var(--color-border-medium);
    background: #f5f2ee;
    box-shadow: var(--shadow-sm);
}

/* Dimmed: everything else when a node is selected */
.arch-node.is-dimmed {
    opacity: 0.35;
    transform: none;
    box-shadow: none;
}

/* Animation states (driven by button.js) */
.arch-node.is-lit {
    border-color: var(--color-azure-light) !important;
    background: #e8f2fc !important;
    box-shadow: 0 0 0 3px rgba(0,120,212,0.15), 0 2px 12px rgba(0,120,212,0.15) !important;
    transform: none !important;
    color: var(--color-azure-blue);
}
.arch-node.is-done {
    border-color: #1e7e3e !important;
    border-width: 2px !important;
    background: #d4edda !important;
    box-shadow: 0 0 0 4px rgba(30,126,62,0.18), 0 2px 16px rgba(30,126,62,0.2) !important;
    transform: none !important;
    color: #1e7e3e;
}

.arch-icon { width:30px; height:30px; margin-bottom:8px; }
.arch-icon svg { width:100%; height:100%; color:inherit; }

.arch-name {
    font-size: 0.65rem; font-weight: 700;
    font-family: Arial, sans-serif;
    line-height: 1.35; color: var(--color-text-secondary);
    transition: color 0.2s;
}
.arch-node.is-selected .arch-name,
.arch-node.is-lit       .arch-name { color: var(--color-azure-blue); }
.arch-node.is-done      .arch-name { color: #1e7e3e; }

.arch-sub {
    font-size: 0.64rem; font-family: Arial, sans-serif;
    color: var(--color-text-secondary); margin-top: 3px;
    transition: color 0.2s;
}
.arch-node.is-lit  .arch-sub { color: var(--color-azure-light); }
.arch-node.is-done .arch-sub { color: #1e7e3e; }

/* ════════════════════════════════════
   TOOLTIP (shown on selected node)
   ════════════════════════════════════ */
.arch-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text-heading);
    color: #f0ede8;
    font-size: 0.63rem;
    font-family: Arial, sans-serif;
    line-height: 1.65;
    padding: 8px 12px;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 40;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.22);
    text-align: left;
}
.arch-tooltip::after {
    content: '';
    position: absolute;
    top: 100%; left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--color-text-heading);
}
.arch-node.is-selected .arch-tooltip { display: block; }

/* ════════════════════════════════════
   COUNTER BADGE
   ════════════════════════════════════ */
.arch-counter-badge {
    position: absolute; top: -1px; right: -1px;
    background: #1e7e3e; color: #fff;
    font-size: 0.6rem; font-weight: 600; font-family: Arial, sans-serif;
    padding: 2px 6px;
    border-radius: 0 var(--radius-md) 0 5px;
    opacity: 0; transform: scale(0.8);
    transition: opacity 0.3s, transform 0.3s;
}
.arch-counter-badge.arch-counter-badge--visible { opacity:1; transform:scale(1); }

/* ════════════════════════════════════
   HORIZONTAL CONNECTORS (row 1 only)
   ════════════════════════════════════ */
.arch-conn-h {
    display: flex; align-items: center;
    padding: 0 4px; z-index: 2;
}
.arch-conn-h--empty { pointer-events: none; }

.arch-conn-line {
    width: 100%; height: 2px;
    background: var(--color-border-light);
    border-radius: 1px; overflow: hidden; position: relative;
    transition: background 0.3s;
}
.arch-conn-line.arch-conn--active { background: var(--color-azure-light); }
.arch-conn-line::after {
    content: ''; position: absolute;
    top: -2px; left: -8px; width: 8px; height: 6px;
    border-radius: 50%; opacity: 0;
    background: var(--color-azure-blue);
    box-shadow: 0 0 6px var(--color-azure-blue);
}
.arch-conn-line.arch-conn--travelling::after      { animation: arch-fwd 0.45s ease-in forwards; }
.arch-conn-line.arch-conn--travelling-back::after {
    animation: arch-bck 0.45s ease-in forwards;
    background: #1e7e3e; box-shadow: 0 0 6px #1e7e3e;
}
@keyframes arch-fwd { 0%{opacity:1;transform:translateX(0)} 100%{opacity:1;transform:translateX(calc(100% + 32px))} }
@keyframes arch-bck { 0%{opacity:1;transform:translateX(calc(100% + 32px))} 100%{opacity:1;transform:translateX(0)} }

/* ════════════════════════════════════
   CHART
   ════════════════════════════════════ */
.arch-divider {
    border: none; border-top: 1px solid var(--color-border-light);
    margin: 1.75rem 0 1rem;
}
.arch-chart-total {
    font-size: 0.8rem; font-family: Arial, sans-serif;
    color: var(--color-text-secondary); margin-bottom: 0.75rem;
}
.arch-chart-total strong { color: var(--color-azure-blue); }

/* ════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════ */
@media (max-width: 680px) {
    .arch-card  { padding: var(--spacing-sm); }
    .arch-row   { grid-template-columns: 1fr 28px 1fr 28px 1fr; gap: 0; }
    .arch-node  { padding: 10px 6px 9px; }
    .arch-name  { font-size: 0.58rem; }
    .arch-sub   { font-size: 0.58rem; }
    .arch-icon  { width: 22px; height: 22px; }
    .arch-diagram { gap: 24px; }
    .arch-status-text { font-size: 0.7rem; }
}
@media (max-width: 440px) {
    .arch-row  { grid-template-columns: 1fr 16px 1fr 16px 1fr; }
    .arch-sub  { display: none; }
    .arch-tooltip { display: none !important; }
    .arch-status { flex-wrap: wrap; }
    .arch-status .trigger-button { width: 100%; }
}