/* ============================================================
   Diocletian — Interactive Flowchart Stylesheet
   Covers: Technical Architecture & Business Methodology
   ============================================================ */

/* ── Section wrapper ─────────────────────────────────────── */
.flowchart-section {
  padding: 60px 0 80px;
  position: relative;
  overflow: visible;
}

.flowchart-section .container--flow {
  width: 100%;
  padding: 0 32px;
  max-width: none;
}

/* ── Framework tab switcher ──────────────────────────────── */
.fw-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 48px;
  border-bottom: 2px solid rgba(255,255,255,0.12);
  padding-bottom: 0;
}

.fw-tab {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 28px 16px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  margin-bottom: -2px;
  border-bottom: 2px solid transparent;
  transition: border-color 0.25s, opacity 0.25s;
  opacity: 0.55;
}

.fw-tab:hover { opacity: 0.8; }

.fw-tab--active {
  border-bottom-color: #C4942E;
  opacity: 1;
}

.fw-tab__label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.01em;
}

.fw-tab__sub {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.45);
  font-family: var(--font-mono);
}

/* ── Framework visibility ────────────────────────────────── */
.framework { display: block; }
.framework--hidden { display: none; }

.framework__switch {
  margin-top: 40px;
  text-align: center;
}

.fw-switch-btn {
  background: none;
  border: 1.5px solid rgba(196,148,46,0.4);
  color: #C4942E;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.fw-switch-btn:hover {
  background: rgba(196,148,46,0.1);
  border-color: #C4942E;
}

/* ── Animation controls ──────────────────────────────────── */
.fc-anim-ctrl {
  text-align: right;
  margin-bottom: 16px;
}

.fc-skip-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.35);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  cursor: pointer;
  padding: 6px 0;
  transition: color 0.2s;
}

.fc-skip-btn:hover { color: rgba(255,255,255,0.7); }

.fc-hint {
  text-align: center;
  margin-top: 20px;
  color: rgba(255,255,255,0.35);
  font-size: 0.82rem;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  animation: fc-hint-pulse 2.5s ease-in-out infinite;
}

@keyframes fc-hint-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.7; }
}

/* ── Animation stage text overlay ───────────────────────── */
.fc-stage-text {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s;
  z-index: 10;
}

.fc-stage-text--visible { opacity: 1; }

.fc-stage-text__main {
  font-size: 1.1rem;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  display: block;
  margin-bottom: 4px;
}

.fc-stage-text__sub {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.4);
  font-family: var(--font-mono);
}

/* ══════════════════════════════════════════════════════════
   FRAMEWORK 1 — TECHNICAL ARCHITECTURE
   ══════════════════════════════════════════════════════════ */

/* ── Grid container ──────────────────────────────────────── */
.tech-flowchart {
  position: relative;
  display: grid;
  grid-template-columns: 245px 148px 216px minmax(210px, 1fr) minmax(190px, 1fr);
  gap: 0 16px;
  align-items: start;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
}

/* ── SVG arrow overlay ───────────────────────────────────── */
.fc-svg-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 2;
}

/* ── Column shared styles ────────────────────────────────── */
.fc-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.fc-nodes {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Column headers ──────────────────────────────────────── */
.fc-col-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
  padding: 0 4px;
}

.fc-col-header--clickable {
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 14px;
  transition: background 0.2s;
  position: relative;
}

.fc-col-header--clickable:hover {
  background: rgba(255,255,255,0.06);
}

.fc-col-header--clickable:focus-visible {
  outline: 2px solid #C4942E;
  outline-offset: 2px;
}

.fc-col-header__title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.01em;
}

.fc-col-header__sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
  font-family: var(--font-mono);
}

.fc-expand-icon {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 1.1rem;
  color: rgba(255,255,255,0.3);
  transition: transform 0.2s;
}

.fc-col-header--clickable:hover .fc-expand-icon,
.fc-col-header--clickable[aria-expanded="true"] .fc-expand-icon {
  color: #C4942E;
  transform: rotate(45deg);
}

/* ── Base node style ─────────────────────────────────────── */
.fc-node {
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.fc-node:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.fc-node:focus-visible {
  outline: 2px solid #C4942E;
  outline-offset: 2px;
}

.fc-node__icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fc-node__icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.fc-node__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.fc-node__text strong {
  font-size: 0.83rem;
  font-weight: 700;
  line-height: 1.2;
  color: inherit;
}

.fc-node__text span {
  font-size: 0.72rem;
  opacity: 0.75;
  font-family: var(--font-mono);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Animation: node visibility ──────────────────────────── */
.fc-node,
.fc-col-header,
.fc-interstitial,
.fc-col--uns .fc-nodes,
.fc-col--capabilities .fc-col-header,
.fc-col--capabilities .fc-nodes,
.fc-col--outcomes .fc-col-header,
.fc-col--outcomes .fc-nodes {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease, box-shadow 0.2s;
}

/* Stage classes – JS adds .fc-anim-done to skip, or stages sequentially */
.fc-col--systems .fc-col-header.fc-visible,
.fc-col--systems .fc-node.fc-visible {
  opacity: 1;
  transform: translateY(0);
}

.fc-interstitial.fc-visible {
  opacity: 1;
  transform: translateY(0);
}

.fc-col--uns .fc-nodes.fc-visible {
  opacity: 1;
  transform: translateY(0);
}

.fc-col--capabilities .fc-col-header.fc-visible,
.fc-col--capabilities .fc-nodes.fc-visible {
  opacity: 1;
  transform: translateY(0);
}

.fc-col--outcomes .fc-col-header.fc-visible,
.fc-col--outcomes .fc-nodes.fc-visible {
  opacity: 1;
  transform: translateY(0);
}

/* skip animation — everything visible immediately */
.tech-flowchart.fc-anim-done .fc-node,
.tech-flowchart.fc-anim-done .fc-col-header,
.tech-flowchart.fc-anim-done .fc-interstitial,
.tech-flowchart.fc-anim-done .fc-col--uns .fc-nodes,
.tech-flowchart.fc-anim-done .fc-col--capabilities .fc-col-header,
.tech-flowchart.fc-anim-done .fc-col--capabilities .fc-nodes,
.tech-flowchart.fc-anim-done .fc-col--outcomes .fc-col-header,
.tech-flowchart.fc-anim-done .fc-col--outcomes .fc-nodes {
  opacity: 1;
  transform: translateY(0);
}

/* ── Column 1 node colours (warm pastels on dark bg) ─────── */
.fc-node--erp {
  background: rgba(244, 162, 97, 0.22);
  border: 1px solid rgba(244, 162, 97, 0.5);
  color: #F4A261;
}

.fc-node--planning {
  background: rgba(116, 185, 154, 0.22);
  border: 1px solid rgba(116, 185, 154, 0.5);
  color: #74B99A;
}

.fc-node--mfg {
  background: rgba(91, 141, 184, 0.22);
  border: 1px solid rgba(91, 141, 184, 0.5);
  color: #7FaDD4;
}

.fc-node--sheets {
  background: rgba(244, 204, 112, 0.22);
  border: 1px solid rgba(244, 204, 112, 0.5);
  color: #F4CC70;
}

.fc-node--bi {
  background: rgba(155, 142, 196, 0.22);
  border: 1px solid rgba(155, 142, 196, 0.5);
  color: #B0A0D8;
}

.fc-node--logistics {
  background: rgba(224, 127, 127, 0.22);
  border: 1px solid rgba(224, 127, 127, 0.5);
  color: #E07F7F;
}

/* ── Interstitial: Translation Layer ────────────────────── */
.fc-interstitial {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 8px 0;
  min-height: 520px;
  background: rgba(50, 55, 65, 0.30);
  border-radius: 6px;
  border: 1px solid rgba(150, 150, 150, 0.12);
}

.interstitial__trigger {
  position: relative;
  z-index: 5;
  background: rgba(100, 100, 100, 0.25);
  border: 1px dashed rgba(160, 160, 160, 0.5);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s;
  width: 100%;
}

.interstitial__trigger:hover {
  background: rgba(100, 100, 100, 0.40);
}

.interstitial__trigger:focus-visible {
  outline: 2px solid #C4942E;
  outline-offset: 2px;
}

.interstitial__label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.03em;
  margin-bottom: 3px;
}

.interstitial__hint {
  display: block;
  font-size: 0.64rem;
  color: rgba(255,255,255,0.3);
  font-family: var(--font-mono);
}

.interstitial__chaos {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.i-box {
  position: absolute;
  background: rgba(80, 80, 80, 0.35);
  border: 1px solid rgba(150, 150, 150, 0.35);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.62rem;
  font-family: var(--font-mono);
  color: rgba(200, 200, 200, 0.6);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.interstitial__svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: opacity 0.8s ease;
}

.interstitial__svg--clean {
  opacity: 0;
}

/* When UNS appears: swap to clean paths */
.fc-interstitial.resolved .interstitial__svg:not(.interstitial__svg--clean) {
  opacity: 0;
}
.fc-interstitial.resolved .interstitial__svg--clean {
  opacity: 1;
}

/* ── Column 2: Unified Namespace ─────────────────────────── */
.fc-col--uns .fc-nodes {
  margin-top: 58px; /* align UNS group vertically centred against col1 */
}

/* Sub-nodes: Normalise, Historian, Structure */
.fc-node--nc,
.fc-node--historian,
.fc-node--structure {
  background: rgba(196, 148, 46, 0.12);
  border: 1px solid rgba(196, 148, 46, 0.4);
  color: #D4A845;
}

/* MAIN UNS node */
.fc-node--uns-main {
  background: #C4942E;
  border: 2px solid #D4A845;
  color: #fff;
  padding: 18px 16px;
  box-shadow: 0 4px 24px rgba(196, 148, 46, 0.35);
  margin: 8px 0;
}

.fc-node--uns-main .fc-node__text strong {
  font-size: 0.95rem;
}

.fc-node--uns-main .fc-node__text span {
  opacity: 0.85;
  font-size: 0.75rem;
}

.fc-node--uns-main:hover {
  box-shadow: 0 8px 32px rgba(196, 148, 46, 0.5);
  background: #D4A235;
}

/* ── Column 3: Capabilities (cool blues) ─────────────────── */
.fc-node--analytics {
  background: rgba(74, 144, 217, 0.22);
  border: 1px solid rgba(74, 144, 217, 0.5);
  color: #7AB5E8;
}

.fc-node--currentstate {
  background: rgba(62, 130, 208, 0.22);
  border: 1px solid rgba(62, 130, 208, 0.5);
  color: #72B1E8;
}

.fc-node--holistic-ai {
  background: rgba(52, 116, 193, 0.22);
  border: 1px solid rgba(52, 116, 193, 0.5);
  color: #6AA3DC;
}

.fc-node--simulation {
  background: rgba(45, 107, 172, 0.22);
  border: 1px solid rgba(45, 107, 172, 0.5);
  color: #5E97CE;
}

.fc-node--ml {
  background: rgba(36, 93, 152, 0.22);
  border: 1px solid rgba(36, 93, 152, 0.5);
  color: #5889C0;
}

/* ── Column 4: Outcomes (greens + pinks) ─────────────────── */
.fc-node--prod,
.fc-node--demand {
  background: rgba(82, 161, 122, 0.22);
  border: 1px solid rgba(82, 161, 122, 0.5);
  color: #72C19A;
}

.fc-node--exec,
.fc-node--event,
.fc-node--rapid {
  background: rgba(192, 107, 159, 0.22);
  border: 1px solid rgba(192, 107, 159, 0.5);
  color: #D490BE;
}

/* ══════════════════════════════════════════════════════════
   FRAMEWORK 2 — BUSINESS METHODOLOGY
   ══════════════════════════════════════════════════════════ */

.biz-flowchart {
  position: relative;
  max-width: 580px;
  margin: 0 auto;
}

.biz-flow {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
}

/* ── Business nodes ──────────────────────────────────────── */
.biz-node {
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(196, 148, 46, 0.25);
  border-left: 3px solid #C4942E;
  border-radius: 10px;
  padding: 18px 20px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
  position: relative;
}

.biz-node:hover {
  background: rgba(196, 148, 46, 0.1);
  border-color: rgba(196, 148, 46, 0.6);
  transform: translateX(4px);
}

.biz-node:focus-visible {
  outline: 2px solid #C4942E;
  outline-offset: 2px;
}

.biz-node.biz-node--open {
  background: rgba(196, 148, 46, 0.12);
  border-left-color: #E0A830;
}

.biz-node__marker {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(196, 148, 46, 0.2);
  border: 1px solid rgba(196, 148, 46, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: #C4942E;
}

.biz-node__body {
  flex: 1;
}

.biz-node__body strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 2px;
}

.biz-node__body span {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.45);
  font-family: var(--font-mono);
}

.biz-node__expand {
  flex-shrink: 0;
  font-size: 1.2rem;
  color: rgba(255,255,255,0.3);
  transition: transform 0.2s, color 0.2s;
  font-weight: 300;
  line-height: 1;
}

.biz-node.biz-node--open .biz-node__expand {
  transform: rotate(45deg);
  color: #C4942E;
}

/* Expand panel inside business node */
.biz-node__panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.biz-node__panel-inner {
  margin: 0 -20px -18px;
  padding: 18px 20px 20px;
  border-top: 1px solid rgba(196, 148, 46, 0.2);
  color: rgba(255,255,255,0.65);
  font-size: 0.88rem;
  line-height: 1.8;
}

.biz-node__panel-inner h3 {
  font-size: 0.82rem;
  color: #C4942E;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 16px 0 6px;
  font-weight: 700;
}

.biz-node__panel-inner h3:first-child {
  margin-top: 0;
}

.biz-node__panel-inner p {
  margin-bottom: 10px;
}

.biz-node__panel-inner ul {
  list-style: none;
  padding: 0;
}

.biz-node__panel-inner ul li {
  position: relative;
  padding-left: 16px;
  margin-bottom: 5px;
  font-size: 0.85rem;
}

.biz-node__panel-inner ul li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: #C4942E;
  font-weight: 600;
}

/* ── Business connectors ─────────────────────────────────── */
.biz-connector {
  display: flex;
  justify-content: center;
  padding: 0;
  height: 24px;
  align-items: center;
  position: relative;
  margin-left: 36px; /* align with marker center */
}

.biz-connector__line {
  width: 2px;
  height: 100%;
  background: linear-gradient(to bottom, rgba(196,148,46,0.3), rgba(196,148,46,0.5));
}

/* Loop-back indicator */
.biz-node--loop-end {
  border-left-color: rgba(196,148,46,0.5);
}

.biz-node__loop-label {
  position: absolute;
  bottom: -22px;
  left: 48px;
  font-size: 0.7rem;
  color: rgba(196,148,46,0.55);
  font-family: var(--font-mono);
  pointer-events: none;
}

/* Loop-back dashed visual */
.biz-loop-arrow {
  position: absolute;
  left: -55px;
  top: 0;
  width: 55px;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

/* ══════════════════════════════════════════════════════════
   NODE DETAIL PANEL (slide-in from right)
   ══════════════════════════════════════════════════════════ */

.node-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(500px, 100vw);
  height: 100vh;
  background: #1A2E3E;
  border-left: 1px solid rgba(196,148,46,0.25);
  z-index: 10000;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,0.5);
}

.node-panel--open {
  transform: translateX(0);
}

.node-panel__inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.node-panel__close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  z-index: 2;
}

.node-panel__close:hover { background: rgba(255,255,255,0.15); }

.node-panel__close svg {
  width: 16px;
  height: 16px;
  stroke: rgba(255,255,255,0.6);
}

.node-panel__content {
  padding: 56px 32px 40px;
  overflow-y: auto;
  flex: 1;
  color: rgba(255,255,255,0.75);
  font-size: 0.92rem;
  line-height: 1.85;
}

.node-panel__content h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
  line-height: 1.25;
}

.node-panel__content .panel-subtitle {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #C4942E;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(196,148,46,0.2);
}

.node-panel__content h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #C4942E;
  margin: 22px 0 8px;
  font-weight: 700;
}

.node-panel__content p {
  margin-bottom: 12px;
}

.node-panel__content ul {
  list-style: none;
  padding: 0;
  margin-bottom: 12px;
}

.node-panel__content ul li {
  position: relative;
  padding-left: 18px;
  margin-bottom: 6px;
  font-size: 0.88rem;
}

.node-panel__content ul li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: #C4942E;
  font-weight: 600;
}

/* Backdrop */
.node-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.node-panel-backdrop--visible {
  opacity: 1;
  pointer-events: all;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════ */

@media (max-width: 1100px) {
  .tech-flowchart {
    grid-template-columns: 210px 128px 190px minmax(175px,1fr) minmax(160px,1fr);
    gap: 0 10px;
  }

  .fc-col--uns .fc-nodes {
    margin-top: 52px;
  }
}

@media (max-width: 900px) {
  /* Horizontal scroll on tablet rather than breaking layout */
  .framework#fw-technical {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tech-flowchart {
    grid-template-columns: 200px 120px 185px 185px 175px;
    gap: 0 8px;
    min-width: 890px;
  }
}

@media (max-width: 640px) {
  .fw-tabs { flex-direction: column; border-bottom: none; gap: 2px; }
  .fw-tab { border: 1px solid rgba(255,255,255,0.12); border-radius: 8px; margin-bottom: 0; border-bottom: 1px solid rgba(255,255,255,0.12); padding: 12px 16px; }
  .fw-tab--active { border-color: #C4942E; background: rgba(196,148,46,0.1); }
  .node-panel { width: 100vw; }
  .biz-flowchart { max-width: 100%; padding: 0 4px; }
}

/* ── Reduce motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .fc-node,
  .fc-col-header,
  .fc-interstitial,
  .fc-col--uns .fc-nodes,
  .fc-col--capabilities .fc-col-header,
  .fc-col--capabilities .fc-nodes,
  .fc-col--outcomes .fc-col-header,
  .fc-col--outcomes .fc-nodes {
    transition: none;
  }
  .tech-flowchart:not(.fc-anim-done) .fc-node,
  .tech-flowchart:not(.fc-anim-done) .fc-col-header,
  .tech-flowchart:not(.fc-anim-done) .fc-interstitial {
    opacity: 1;
    transform: none;
  }
}
