/* =========================================================
   Architecture section + ambient background (level B) + cases
   ========================================================= */

/* ---------- ambient background (level B) ---------- */

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.ambient-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  will-change: transform;
}
.ambient-blob.b1 {
  width: 520px; height: 520px;
  left: -140px; top: -120px;
  background: radial-gradient(circle at 35% 35%, rgba(91, 140, 255, 0.38), transparent 68%);
  animation: ambientDrift 28s ease-in-out infinite alternate;
}
.ambient-blob.b2 {
  width: 460px; height: 460px;
  right: -160px; top: 14%;
  background: radial-gradient(circle at 60% 40%, rgba(56, 225, 176, 0.24), transparent 68%);
  animation: ambientDrift 36s ease-in-out infinite alternate-reverse;
}
.ambient-blob.b3 {
  width: 620px; height: 620px;
  left: 34%; bottom: -280px;
  background: radial-gradient(circle at 50% 50%, rgba(0, 156, 255, 0.20), transparent 70%);
  animation: ambientDrift 42s ease-in-out infinite alternate;
}
.ambient-grid {
  position: absolute;
  inset: -20%;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(ellipse at 50% 26%, #000 0%, transparent 70%);
  mask-image: radial-gradient(ellipse at 50% 26%, #000 0%, transparent 70%);
  opacity: 0.42;
  animation: ambientGrid 64s linear infinite;
}
@keyframes ambientDrift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(52px, -36px, 0) scale(1.1); }
}
@keyframes ambientGrid {
  to { transform: translate3d(0, 64px, 0); }
}

/* ---------- architecture tabs ---------- */

.arch-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.arch-tab {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 15px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-family: var(--font);
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.arch-tab:hover { color: var(--text); border-color: rgba(91, 140, 255, 0.4); }
.arch-tab span {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted-2);
}
.arch-tab.is-active {
  color: var(--text);
  border-color: rgba(91, 140, 255, 0.55);
  background: rgba(91, 140, 255, 0.12);
}
.arch-tab.is-active span { color: var(--accent-2); }

/* ---------- architecture panel ---------- */

.arch-panel {
  border: 1px solid var(--border);
  border-radius: 22px;
  background:
    radial-gradient(680px 260px at 20% 0%, rgba(91, 140, 255, 0.10), transparent 70%),
    linear-gradient(170deg, #0f1726, #0a0f19);
  padding: 20px 22px 20px;
  overflow: hidden;
}
.arch-canvas svg { display: block; width: 100%; height: auto; }

/* mobile diagram: stacked tiers instead of the wide SVG */
.arch-list { display: grid; gap: 18px; padding: 4px 2px 8px; }
.arch-list-tier { display: grid; gap: 8px; }
.arch-list-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.6px;
  color: var(--muted-2);
}
.arch-list-nodes { display: flex; flex-wrap: wrap; gap: 8px; }
.arch-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  border-left: 2.5px solid #5b8cff;
  background: rgba(255, 255, 255, 0.03);
}
.arch-chip b { font-size: 12.5px; font-weight: 600; }
.arch-chip small { font-size: 10.5px; color: var(--muted-2); }
.arch-chip.k-ui { border-left-color: #5b8cff; }
.arch-chip.k-cms { border-left-color: #38e1b0; }
.arch-chip.k-worker { border-left-color: #ffb042; }
.arch-chip.k-data { border-left-color: #a78bfa; }
.arch-chip.k-external { border-left-color: #38d6e1; }
.arch-chip.k-actor { border-left-color: #9ff0d6; }
.arch-chip.k-infra { border-left-color: #8ea3c0; }

.arch-diagram .an { opacity: 1; }
.arch-diagram.play .an { animation: archNodeIn 0.5s ease both; animation-delay: var(--d, 0s); }
@keyframes archNodeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.arch-diagram .ae { stroke-dasharray: 100; stroke-dashoffset: 0; }
.arch-diagram.play .ae { animation: archDraw 0.9s ease forwards; animation-delay: var(--d, 0.2s); }
@keyframes archDraw {
  from { stroke-dashoffset: 100; }
  to   { stroke-dashoffset: 0; }
}

.arch-svg .node-box { fill: #0d1728; stroke-width: 1.25; }
.arch-svg .node-dot { opacity: 0.95; }
.arch-svg .node-title { fill: #e9eef8; font-family: Inter, "Segoe UI", sans-serif; font-size: 11.5px; font-weight: 600; }
.arch-svg .node-sub { fill: #8fa1bd; font-family: Inter, "Segoe UI", sans-serif; font-size: 9.5px; }
.arch-svg .tier-label {
  fill: #6f7d94;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 9px;
  letter-spacing: 1.8px;
}
.arch-svg .ae { fill: none; stroke: #4d6892; stroke-width: 1.25; }

.k-ui .node-box { stroke: #5b8cff; }
.k-ui .node-dot { fill: #5b8cff; }
.k-cms .node-box { stroke: #38e1b0; }
.k-cms .node-dot { fill: #38e1b0; }
.k-worker .node-box { stroke: #ffb042; }
.k-worker .node-dot { fill: #ffb042; }
.k-data .node-box { stroke: #a78bfa; }
.k-data .node-dot { fill: #a78bfa; }
.k-external .node-box { stroke: #38d6e1; }
.k-external .node-dot { fill: #38d6e1; }
.k-actor .node-box { stroke: #9ff0d6; stroke-dasharray: 3 2; }
.k-actor .node-dot { fill: #9ff0d6; }
.k-infra .node-box { stroke: #8ea3c0; }
.k-infra .node-dot { fill: #8ea3c0; }

/* ---------- legend + meta ---------- */

.arch-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.6px;
  color: var(--muted-2);
}
.legend-dot { width: 8px; height: 8px; border-radius: 3px; }

.arch-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.arch-meta-main h3 { margin: 0; font-size: 17px; letter-spacing: -0.2px; }
.arch-meta-main p { margin: 5px 0 0; font-size: 13px; color: var(--muted); }
.arch-bullets { margin: 12px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.arch-bullets li {
  position: relative;
  padding-left: 14px;
  font-size: 12.8px;
  color: var(--muted);
}
.arch-bullets li::before {
  content: "";
  position: absolute;
  left: 0; top: 8px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--accent-2);
}
.arch-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.complexity {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #bdd0ff;
  border: 1px solid rgba(91, 140, 255, 0.3);
  background: rgba(91, 140, 255, 0.1);
  white-space: nowrap;
}
.complexity.mid { color: #ffd9a1; border-color: rgba(255, 176, 66, 0.3); background: rgba(255, 176, 66, 0.1); }
.complexity.high { color: #9ff0d6; border-color: rgba(56, 225, 176, 0.3); background: rgba(56, 225, 176, 0.1); }
.arch-side .project-tags { justify-content: flex-end; }

/* ---------- cases ---------- */

.case-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
.case-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 22px 22px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(170deg, #111a2b, #0a1019);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.case-card:hover { border-color: rgba(91, 140, 255, 0.42); transform: translateY(-3px); }
.case-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.case-num {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--accent-2);
}
.case-card h3 { margin: 0; font-size: 18px; letter-spacing: -0.3px; }
.case-domain { font-family: var(--mono); font-size: 11px; color: var(--muted-2); margin: -6px 0 0; }
.case-card p { margin: 0; font-size: 13.4px; color: var(--muted); }
.case-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.case-facts li {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10.5px;
  color: #b9c6de;
}
.case-link {
  margin-top: auto;
  padding-top: 8px;
  font-size: 13px;
  color: var(--accent-2);
  border-top: 1px solid var(--border);
}
.case-link:hover { color: #fff; }

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .ambient-blob,
  .ambient-grid,
  .arch-diagram .an,
  .arch-diagram .ae { animation: none !important; }
  .arch-diagram .ae { stroke-dashoffset: 0; }
  .arch-diagram .an { opacity: 1; }
}

/* ---------- responsive ---------- */

@media (max-width: 1024px) {
  .arch-meta { grid-template-columns: 1fr; }
  .arch-side { align-items: flex-start; }
  .case-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .arch-panel { padding: 14px 12px; border-radius: 16px; }
  .arch-tab { padding: 8px 11px; font-size: 12.5px; }
  .arch-meta { gap: 14px; }
  .case-cards { grid-template-columns: 1fr; }
  .arch-canvas { overflow-x: auto; }
  .arch-canvas svg { min-width: 720px; }
}
