/* Etude Open Architecture & Modularity section (#architecture, [data-architecture])
   Editorial restraint inspired by Notion's architecture flow — calm surfaces, crisp
   hairlines, live SVG dotted conduits, subtle animated signal dots, full Light & Dark
   mode fidelity, zero layout shift, and zero horizontal overflow at any viewport. */

#architecture {
  --arch-wire: rgba(13, 13, 13, 0.22);
  --arch-wire-dim: rgba(13, 13, 13, 0.08);
  --arch-card-shadow: 0 1px 3px rgba(13, 13, 13, 0.035), 0 6px 18px -10px rgba(13, 13, 13, 0.07);
  --arch-os-shadow: 0 2px 18px -6px rgba(13, 13, 13, 0.055), 0 0 0 1px rgba(13, 13, 13, 0.04);
  --arch-hub-shadow: 0 12px 28px -12px rgba(13, 13, 13, 0.16), 0 0 0 6px var(--background);
  --arch-mod-bg: color-mix(in oklab, var(--surface) 64%, var(--card));
  --arch-mod-border: color-mix(in oklab, var(--border) 78%, transparent);
  --arch-check-bg: #2a7f5f;
  --arch-check-fg: #ffffff;
  --arch-dot-1: #3d8973;
  --arch-dot-2: #2f6db8;
  --arch-dot-3: #c06c14;
  --arch-dot-4: #5d979c;
}

[data-theme="dark"] #architecture {
  --arch-wire: rgba(255, 255, 255, 0.22);
  --arch-wire-dim: rgba(255, 255, 255, 0.075);
  --arch-card-shadow: 0 2px 10px -4px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.035);
  --arch-os-shadow: 0 16px 40px -18px rgba(0, 0, 0, 0.62), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  --arch-hub-shadow: 0 14px 34px -12px rgba(0, 0, 0, 0.72), 0 0 0 6px var(--background);
  --arch-mod-bg: #171a20;
  --arch-mod-border: rgba(255, 255, 255, 0.07);
  --arch-check-bg: #3f9b76;
  --arch-check-fg: #0b120f;
  --arch-dot-1: #7db0b3;
  --arch-dot-2: #7aaef0;
  --arch-dot-3: #e7a455;
  --arch-dot-4: #5cc49a;
}

/* ----------------------------------------------------- Top Editorial Header */
.arch-h2 {
  max-width: none;
}

.arch-pillars {
  display: grid;
  gap: 1.35rem 2.6rem;
  margin-top: clamp(1.35rem, 2.5vw, 1.95rem);
}
@media (min-width: 820px) {
  .arch-pillars {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.arch-pillar h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.016em;
  line-height: 1.3;
  margin: 0 0 0.42rem;
  color: var(--foreground);
}

.arch-pillar p {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.56;
  color: var(--secondary-ink);
  text-wrap: pretty;
}

/* ---------------------------------------------------- Interactive Flow Stage */
.arch-stage {
  position: relative;
  margin-top: clamp(2rem, 3.7vw, 2.85rem);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "inputs"
    "hub"
    "os"
    "foot";
  gap: 0;
  align-items: stretch;
}

@media (min-width: 960px) {
  .arch-stage {
    grid-template-columns: minmax(18.5rem, 20.5rem) minmax(7.75rem, 11.25rem) minmax(0, 1fr);
    grid-template-rows: auto auto;
    grid-template-areas:
      "inputs hub os"
      "foot . .";
  }
}

/* Full-span desktop SVG conduits */
.arch-wires {
  display: none;
}

@media (min-width: 960px) {
  .arch-wires {
    display: block;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 1;
  }
}

.arch-wire-base {
  fill: none;
  stroke: var(--arch-wire);
  stroke-width: 1.25;
  stroke-dasharray: 2.5 4.5;
  stroke-linecap: round;
  transition: stroke 0.22s var(--ease), opacity 0.22s var(--ease);
}

.arch-stage.has-active .arch-wire-base {
  opacity: 0.34;
}

.arch-wire-base.is-active {
  stroke: var(--brand);
  opacity: 0.32;
}

.arch-wire-hi {
  fill: none;
  stroke: var(--brand);
  stroke-width: 1.75;
  stroke-dasharray: 3.5 5;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity 0.22s var(--ease);
}

.arch-wire-hi.is-active {
  opacity: 1;
  animation: arch-dash-flow 1.15s linear infinite;
}

@keyframes arch-dash-flow {
  from { stroke-dashoffset: 17; }
  to { stroke-dashoffset: 0; }
}

.arch-port-dot {
  fill: var(--background);
  stroke: var(--arch-wire);
  stroke-width: 1.35;
  opacity: 0;
  transition: opacity 0.2s var(--ease), stroke 0.2s var(--ease), fill 0.2s var(--ease);
}

.arch-port-dot.is-active {
  opacity: 1;
  fill: var(--brand);
  stroke: var(--background);
  stroke-width: 1.75;
}

.arch-signal-dot {
  stroke: var(--background);
  stroke-width: 1.5;
  transition: opacity 0.24s var(--ease);
}

.arch-stage.has-active .arch-signal-dot.is-idle {
  opacity: 0.14;
}

.arch-signal-dot.is-focus {
  opacity: 0;
}

.arch-signal-dot.is-focus.is-active {
  opacity: 1;
}

/* ----------------------------------------------------- Left Column: 5 Layers */
.arch-inputs {
  grid-area: inputs;
  position: relative;
  z-index: 2;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.62rem;
  align-content: space-between;
}

@media (min-width: 600px) and (max-width: 959px) {
  .arch-inputs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .arch-node:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

.arch-node {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.72rem;
  width: 100%;
  min-width: 0;
  padding: 0.7rem 0.86rem;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--arch-card-shadow);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    transform 0.2s var(--ease),
    opacity 0.2s var(--ease);
}

.arch-node:hover {
  border-color: var(--border-strong);
}

.arch-node:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.arch-stage.has-active .arch-node:not(.is-active) {
  opacity: 0.56;
}

.arch-node.is-active {
  border-color: color-mix(in oklab, var(--brand) 52%, transparent);
  box-shadow:
    0 8px 22px -10px color-mix(in oklab, var(--brand) 28%, rgba(0, 0, 0, 0.14)),
    0 0 0 1px color-mix(in oklab, var(--brand) 24%, transparent);
}

@media (min-width: 960px) {
  .arch-node.is-active {
    transform: translateX(3px);
  }
}

[data-theme="dark"] .arch-node.is-active {
  background: #161a20;
}

.arch-node-ic {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 9px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in oklab, var(--node-tint, var(--brand)) 18%, transparent);
  background: color-mix(in oklab, var(--node-tint, var(--brand)) 10%, var(--surface));
  color: var(--node-tint, var(--brand));
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.18s var(--ease);
}

.arch-node-ic svg {
  width: 1.06rem;
  height: 1.06rem;
}

.arch-node.is-active .arch-node-ic {
  background: color-mix(in oklab, var(--node-tint, var(--brand)) 16%, var(--surface));
  border-color: color-mix(in oklab, var(--node-tint, var(--brand)) 34%, transparent);
}

.arch-node-copy {
  min-width: 0;
  flex: 1;
}

.arch-node-title {
  display: block;
  font-size: 0.89rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.24;
  color: var(--foreground);
}

.arch-node-sub {
  display: block;
  margin-top: 0.12rem;
  font-size: 0.725rem;
  line-height: 1.32;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.arch-node-check {
  width: 1.22rem;
  height: 1.22rem;
  border-radius: 50%;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--arch-check-bg);
  color: var(--arch-check-fg);
  opacity: 0.86;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.arch-node-check svg {
  width: 0.72rem;
  height: 0.72rem;
}

.arch-node.is-active .arch-node-check {
  opacity: 1;
  transform: scale(1.06);
}

/* Subtle quiet footer strip under the 5 rows (Notion "and hundreds more" rhythm) */
.arch-footnote {
  grid-area: foot;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.48rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
  padding: 0 0.1rem;
}

.arch-foot-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.24rem;
  flex: none;
}

.arch-foot-badge {
  display: inline-grid;
  place-items: center;
  height: 1.3rem;
  padding: 0 0.32rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 620;
  letter-spacing: 0.02em;
  color: var(--secondary-ink);
}

.arch-foot-text {
  font-size: 0.74rem;
  line-height: 1.35;
  color: var(--muted-foreground);
}

/* ----------------------------------------------------- Center Origami Hub */
.arch-hub-col {
  grid-area: hub;
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0;
}

@media (min-width: 960px) {
  .arch-hub-col {
    padding: 0;
  }
}

/* Mobile / tablet vertical dotted bridge */
.arch-vbridge {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 24px;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 1;
}

.arch-vbridge line {
  stroke: var(--arch-wire);
  stroke-width: 1.4;
  stroke-dasharray: 2.5 4.5;
  stroke-linecap: round;
  transition: stroke 0.22s var(--ease);
}

.arch-stage.has-active .arch-vbridge line {
  stroke: var(--brand);
}

@media (min-width: 960px) {
  .arch-vbridge {
    display: none;
  }
}

.arch-hub {
  position: relative;
  z-index: 2;
  width: 4.75rem;
  height: 4.75rem;
  border-radius: 50%;
  background: var(--card);
  border: 1.5px solid var(--border-strong);
  box-shadow: var(--arch-hub-shadow);
  display: grid;
  place-items: center;
  transition:
    border-color 0.24s var(--ease),
    transform 0.26s var(--ease),
    box-shadow 0.24s var(--ease);
}

[data-theme="dark"] .arch-hub {
  background: #171a20;
  border-color: rgba(255, 255, 255, 0.2);
}

.arch-stage.has-active .arch-hub {
  border-color: var(--brand);
  transform: scale(1.045);
}

.arch-hub-mark {
  width: 2.7rem;
  height: 2.7rem;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 1px 1.5px rgba(13, 20, 18, 0.18));
}

[data-theme="dark"] .arch-hub-mark {
  filter: none;
}

/* ------------------------------------------- Right Panel: Etude Workspace OS */
.arch-os {
  grid-area: os;
  position: relative;
  z-index: 2;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.05rem;
  padding: clamp(1.2rem, 2.2vw, 1.65rem);
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--arch-os-shadow);
}

[data-theme="dark"] .arch-os {
  background: #121419;
}

.arch-os-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  flex-wrap: wrap;
}

.arch-os-title {
  margin: 0;
  font-size: clamp(1.28rem, 2vw, 1.56rem);
  font-weight: 620;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--foreground);
}

.arch-os-route {
  font-family: var(--font-mono);
  font-size: 0.71rem;
  font-weight: 500;
  color: var(--muted-foreground);
  letter-spacing: -0.01em;
  transition: color 0.2s var(--ease);
}

.arch-stage.has-active .arch-os-route {
  color: var(--brand);
}

/* 2x2 Architectural Modules Grid */
.arch-os-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.78rem;
}

@media (min-width: 580px) {
  .arch-os-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.arch-mod {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.62rem;
  min-width: 0;
  padding: 0.92rem 0.98rem;
  border-radius: 13px;
  border: 1px solid var(--arch-mod-border);
  background: var(--arch-mod-bg);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    opacity 0.18s var(--ease);
}

.arch-mod:hover {
  border-color: var(--border-strong);
}

.arch-mod:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

.arch-stage.has-active .arch-mod:not(.is-active) {
  opacity: 0.54;
}

.arch-mod.is-active {
  border-color: color-mix(in oklab, var(--brand) 52%, transparent);
  background: color-mix(in oklab, var(--brand) 6.5%, var(--card));
  box-shadow:
    0 6px 20px -12px color-mix(in oklab, var(--brand) 28%, rgba(0, 0, 0, 0.14)),
    0 0 0 1px color-mix(in oklab, var(--brand) 20%, transparent);
}

[data-theme="dark"] .arch-mod.is-active {
  background: color-mix(in oklab, var(--brand) 10%, #15191f);
  border-color: color-mix(in oklab, var(--brand) 58%, transparent);
  box-shadow:
    0 8px 24px -12px rgba(0, 0, 0, 0.5),
    0 0 0 1px color-mix(in oklab, var(--brand) 24%, transparent);
}

.arch-mod-head {
  display: flex;
  align-items: center;
  gap: 0.62rem;
  min-width: 0;
}

.arch-mod-ic {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 7px;
  flex: none;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--mod-tint, var(--brand)) 12%, var(--card));
  color: var(--mod-tint, var(--brand));
  border: 1px solid color-mix(in oklab, var(--mod-tint, var(--brand)) 20%, transparent);
}

.arch-mod-ic svg {
  width: 0.96rem;
  height: 0.96rem;
}

.arch-mod-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 600;
  letter-spacing: -0.018em;
  line-height: 1.25;
  color: var(--foreground);
}

.arch-mod-desc {
  margin: 0.44rem 0 0;
  font-size: 0.81rem;
  line-height: 1.48;
  color: var(--secondary-ink);
  text-wrap: pretty;
}

/* Editorial mini-structural wireframe / spec footer inside each quadrant */
.arch-mod-wire {
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
  padding-top: 0.62rem;
  border-top: 1px solid var(--divider);
}

.arch-mod-bars {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.arch-mod-bars i {
  display: block;
  height: 4px;
  border-radius: 99px;
  background: color-mix(in oklab, var(--foreground) 11%, transparent);
  transition: background-color 0.22s var(--ease);
}

.arch-mod.is-active .arch-mod-bars i:first-child {
  background: color-mix(in oklab, var(--brand) 65%, transparent);
}

.arch-mod.is-active .arch-mod-bars i:nth-child(2) {
  background: color-mix(in oklab, var(--brand) 32%, transparent);
}

.arch-mod-code {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.69rem;
  line-height: 1.35;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s var(--ease);
}

.arch-mod.is-active .arch-mod-code {
  color: var(--brand);
}

/* Bottom live technical contract strip inside Workspace panel */
.arch-preview {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding-top: 0.82rem;
  border-top: 1px solid var(--divider);
  min-width: 0;
}

.arch-preview-tag {
  flex: none;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 620;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.48rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--secondary-ink);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.arch-stage.has-active .arch-preview-tag {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand);
}

.arch-preview-text {
  min-width: 0;
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--secondary-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 579px) {
  .arch-preview {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
  .arch-preview-text {
    white-space: normal;
    overflow: visible;
    word-break: break-word;
  }
  .arch-os {
    padding: 1.25rem 1.1rem;
    border-radius: 16px;
  }
}

/* ------------------------------------------------------ Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .arch-wire-hi.is-active {
    animation: none;
  }
  .arch-signal-dot {
    display: none;
  }
  .arch-node,
  .arch-node-ic,
  .arch-node-check,
  .arch-hub,
  .arch-mod,
  .arch-wire-base,
  .arch-wire-hi,
  .arch-preview-tag {
    transition: none;
  }
  .arch-node.is-active,
  .arch-stage.has-active .arch-hub,
  .arch-node.is-active .arch-node-check {
    transform: none;
  }
}
