/* ==========================================================================
   Bluebridge design system — engineering-led, editorial, industrial
   Type: Archivo (variable width — display set semi-expanded for an industrial
   voice; text at normal width) + IBM Plex Mono for technical metadata.
   Shapes: hairlines and near-square corners. Blue is reserved for interaction,
   data and emphasis. Imagery is framed and captioned like documentation.
   ========================================================================== */

:root {
  --blue: #0a75b3; --ink: #0c3a5e; --body: #1f4a6b; --muted: #4a6880;
  --surface: #f3f7fa; --tint: #e4eef4; --deep: #0f3b52; --pale: #a9d1ea;
  --line: #dde6ec; --line-2: #c9d7e0;
  --sans: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
  --gutter: clamp(20px, 4vw, 56px);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Base ---------- */
.bb { background: #ffffff; color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; font-optical-sizing: auto; }
.bb *, .bb *::before, .bb *::after { box-sizing: border-box; }
.bb img { display: block; max-width: 100%; }
.bb a { color: inherit; text-decoration: none; }
.bb ::selection { background: var(--pale); color: var(--ink); }
.bb :is(a, button, input, textarea, select):focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: 1440px; margin: 0 auto; padding-inline: var(--gutter); }
.g12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: 24px; }
.sp-2 { grid-column-end: span 2; } .sp-3 { grid-column-end: span 3; } .sp-4 { grid-column-end: span 4; } .sp-5 { grid-column-end: span 5; }
.sp-6 { grid-column-end: span 6; } .sp-7 { grid-column-end: span 7; } .sp-8 { grid-column-end: span 8; } .sp-9 { grid-column-end: span 9; }
.sp-10 { grid-column-end: span 10; } .sp-12 { grid-column: 1 / -1; }
.st-2 { grid-column-start: 2; } .st-4 { grid-column-start: 4; } .st-5 { grid-column-start: 5; } .st-6 { grid-column-start: 6; }
.st-3 { grid-column-start: 3; } .st-7 { grid-column-start: 7; } .st-8 { grid-column-start: 8; } .st-9 { grid-column-start: 9; } .st-10 { grid-column-start: 10; }
.sec { padding-block: clamp(72px, 9vw, 136px); }
.sec-sm { padding-block: clamp(48px, 6vw, 88px); }
.stack { display: flex; flex-direction: column; }
.rule { border-top: 1px solid var(--line-2); }
.rule-ink { border-top: 1px solid var(--ink); }
.surface { background: var(--surface); }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.cols-1-3 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 24px; }
.cols-meta { display: grid; grid-template-columns: 120px 1fr 32px; gap: 24px; }
@media (max-width: 900px) {
  .cols-2, .cols-3, .cols-1-3 { grid-template-columns: 1fr; }
  .cols-meta { grid-template-columns: 1fr 24px; }
  .cols-meta > :first-child { grid-column: 1 / -1; }
  .g12 > * { grid-column: 1 / -1 !important; }
  .g12 { row-gap: 32px; }
  .hide-m { display: none !important; }
}

/* ---------- Type ---------- */
.t-display { font-size: clamp(46px, 6.6vw, 104px); line-height: 0.95; font-weight: 500; font-stretch: 112%; letter-spacing: -0.04em; margin: 0; }
.t-h1 { font-size: clamp(40px, 5vw, 76px); line-height: 0.98; font-weight: 500; font-stretch: 110%; letter-spacing: -0.035em; margin: 0; }
.t-h2 { font-size: clamp(30px, 3.3vw, 50px); line-height: 1.04; font-weight: 500; font-stretch: 108%; letter-spacing: -0.028em; margin: 0; }
.t-h3 { font-size: 22px; line-height: 1.25; font-weight: 600; letter-spacing: -0.012em; margin: 0; }
.t-h4 { font-size: 18px; line-height: 1.3; font-weight: 600; letter-spacing: -0.005em; margin: 0; }
.t-lead { font-size: clamp(18px, 1.5vw, 21px); line-height: 1.5; color: var(--body); margin: 0; }
.t-body { font-size: 16px; line-height: 1.62; color: var(--body); margin: 0; }
.t-small { font-size: 14px; line-height: 1.55; color: var(--muted); margin: 0; }
.t-num { font-size: clamp(48px, 5.2vw, 80px); line-height: 0.9; font-weight: 400; font-stretch: 100%; letter-spacing: -0.05em; font-variant-numeric: tabular-nums; }
.t-mono { font-family: var(--sans); font-size: 14px; line-height: 1.45; letter-spacing: 0; color: var(--muted); }
.t-mono-ink { font-family: var(--sans); font-size: 14px; line-height: 1.45; color: var(--ink); }
.t-blue { color: var(--blue); }
.measure { max-width: 34em; }
.label { display: inline-flex; align-items: center; gap: 12px; font-family: var(--mono); font-size: 12.5px; line-height: 1.4; color: var(--muted); }
.label::before { content: ""; width: 24px; height: 1px; background: currentColor; }

/* ---------- Actions ---------- */
.btn { display: inline-flex; align-items: center; justify-content: space-between; gap: 28px; min-height: 52px; padding: 0 20px 0 22px; border-radius: 2px; border: 1px solid transparent; font-family: var(--sans); font-size: 15px; font-weight: 500; letter-spacing: 0; cursor: pointer; transition: background-color 180ms var(--ease), color 180ms var(--ease), border-color 180ms var(--ease); }
.btn-sm { min-height: 40px; padding: 0 14px 0 16px; gap: 20px; font-size: 14px; }
.btn-primary { background: var(--blue); color: #ffffff !important; }
.btn-primary:hover { background: var(--deep); }
.btn-line { border-color: var(--ink); color: var(--ink); background: transparent; }
.btn-line:hover { background: var(--ink); color: #ffffff !important; }
.arr { display: inline-block; font-family: var(--mono); transition: transform 220ms var(--ease-out); }
.link { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; color: var(--ink); background-image: linear-gradient(currentColor, currentColor); background-size: 100% 1px; background-position: 0 100%; background-repeat: no-repeat; padding-bottom: 3px; transition: color 180ms var(--ease), background-size 300ms var(--ease-out); }
.link:hover { color: var(--blue); }
.link-quiet { background-size: 0 1px; }
.link-quiet:hover { background-size: 100% 1px; }

/* ---------- Figures & placeholders ---------- */
.fig { margin: 0; display: flex; flex-direction: column; gap: 12px; }
.fig-frame { position: relative; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.fig-frame img { width: 100%; height: 100%; object-fit: cover; }
.fig-pad { padding: clamp(16px, 2.4vw, 36px); display: flex; align-items: center; justify-content: center; }
.fig-pad img { height: auto; box-shadow: 0 1px 0 var(--line), 0 18px 40px rgba(11, 34, 51, 0.10); }
.fig figcaption { display: flex; justify-content: space-between; gap: 16px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ph { position: relative; display: flex; align-items: flex-end; padding: 16px; border: 1px dashed var(--line-2); background: repeating-linear-gradient(135deg, #f6f9fb 0 10px, #edf3f7 10px 11px); font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ticks { position: relative; }
.ticks::before, .ticks::after { content: ""; position: absolute; width: 14px; height: 14px; border-color: var(--ink); border-style: solid; pointer-events: none; }
.ticks::before { top: -1px; left: -1px; border-width: 1px 0 0 1px; }
.ticks::after { bottom: -1px; right: -1px; border-width: 0 1px 1px 0; }
.grid-paper { background-color: #f7fafc; background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 32px 32px; background-position: -1px -1px; }

/* ---------- Lists, rows, specs ---------- */
.row-link { display: grid; align-items: baseline; transition: background-color 200ms var(--ease); }
.row-link:hover { background: var(--surface); }
.row-link:hover .arr, .btn:hover .arr, .link:hover .arr { transform: translateX(4px); }
.spec { display: grid; grid-template-columns: minmax(120px, 0.9fr) 2fr; border-top: 1px solid var(--ink); }
.spec > * { padding: 12px 0; border-bottom: 1px solid var(--line-2); margin: 0; }
.spec dt { font-family: var(--mono); font-size: 12.5px; color: var(--muted); padding-right: 16px; }
.spec dd { font-size: 16px; color: var(--ink); font-weight: 500; }
.ticklist { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-2); }
.ticklist li { display: grid; grid-template-columns: 28px 1fr; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15.5px; color: var(--body); }
.ticklist li::before { content: "—"; font-family: var(--mono); color: var(--blue); }
.seg { display: inline-flex; border: 1px solid var(--ink); border-radius: 2px; }
.seg button { min-height: 44px; padding: 0 18px; border: 0; background: transparent; font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer; transition: background-color 180ms var(--ease), color 180ms var(--ease); }
.seg button + button { border-left: 1px solid var(--ink); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--ink); color: #ffffff; }
.seg button:not([aria-pressed="true"]):not([aria-selected="true"]):hover { background: var(--surface); }
.field { display: flex; flex-direction: column; gap: 8px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.field :is(input, textarea, select) { font-family: var(--sans); font-size: 16px; color: var(--ink); background: #ffffff; border: 0; border-bottom: 1px solid var(--ink); border-radius: 0; padding: 12px 0; outline: none; transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease); }
.field :is(input, select) { height: 48px; }
.field :is(input, textarea, select):focus { border-bottom-color: var(--blue); box-shadow: 0 1px 0 0 var(--blue); }

/* ---------- Diagram primitives (SVG) ---------- */
.dg-edge { fill: none; stroke: var(--line-2); stroke-width: 1.25; }
.dg-node rect { fill: #ffffff; stroke: var(--ink); stroke-width: 1; }
.dg-node.is-core rect { fill: var(--ink); }
.dg-node.is-core text { fill: #ffffff; }
.dg-node text, .dg-text { font-family: var(--mono); font-size: 12px; fill: var(--ink); }
.dg-cap { font-family: var(--mono); font-size: 11px; fill: var(--muted); letter-spacing: 0.04em; }
.dg-pulse { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 6 100; stroke-dashoffset: 6; opacity: 0; }
.dg-hl rect { stroke: var(--blue); }
.dg-hl text { fill: var(--blue); }
.dg-dim { opacity: 0.35; transition: opacity 600ms var(--ease); }
.dg-on { opacity: 1; transition: opacity 600ms var(--ease); }

/* Flow connectors between HTML nodes */
.flow-line { position: relative; overflow: hidden; height: 1px; background: var(--ink); }
.flow-node { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; background: #ffffff; border: 1px solid var(--ink); min-width: 0; }
.flow-node.is-core { background: var(--ink); color: #ffffff; }
.flow-node.is-core .t-mono { color: var(--pale); }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  @keyframes bb-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
  @keyframes bb-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
  @keyframes bb-pulse { 0% { stroke-dashoffset: 6; opacity: 1; } 100% { stroke-dashoffset: -100; opacity: 1; } }
  @keyframes bb-build { 0% { opacity: 0; transform: translateY(6px); } 15%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
  @keyframes bb-ripple { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(3); opacity: 0; } }
  @keyframes bb-scan { from { transform: translateY(0); } to { transform: translateY(var(--scan, 100px)); } }
  @keyframes bb-detect { 0%, 40% { opacity: 0; } 52%, 90% { opacity: 1; } 100% { opacity: 0; } }
  @keyframes bb-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  @keyframes bb-progress-b { from { transform: scaleX(0); } to { transform: scaleX(1); } }

  /* Page entrance: header content arrives in reading order */
  .enter > * { animation: bb-in 800ms var(--ease-out) both; }
  .enter > *:nth-child(2) { animation-delay: 80ms; } .enter > *:nth-child(3) { animation-delay: 160ms; }
  .enter > *:nth-child(4) { animation-delay: 240ms; } .enter > *:nth-child(n+5) { animation-delay: 320ms; }
  /* Rules draw across before content settles */
  .draw { animation: bb-wipe 1100ms var(--ease-out) both; }

  /* Data pulses travel along diagram edges */
  .dg-pulse { animation: bb-pulse 3.4s cubic-bezier(.45, 0, .55, 1) infinite; }
  .d1 { animation-delay: 0s !important; } .d2 { animation-delay: .55s !important; } .d3 { animation-delay: 1.1s !important; }
  .d4 { animation-delay: 1.65s !important; } .d5 { animation-delay: 2.2s !important; } .d6 { animation-delay: 2.75s !important; }
  .dg-build { animation: bb-build 6s var(--ease-out) infinite both; transform-box: fill-box; }
  .dg-ripple { transform-box: fill-box; transform-origin: center; animation: bb-ripple 3.2s var(--ease-out) infinite both; }
  .dg-scan { animation: bb-scan 3.4s ease-in-out infinite alternate; }
  .dg-detect { animation: bb-detect 3.4s linear infinite both; }

  .flow-line::after { content: ""; position: absolute; top: -1px; bottom: -1px; left: 0; width: 36%; background: linear-gradient(90deg, transparent, var(--blue), transparent); animation: bb-run 2.4s linear infinite; }
  @keyframes bb-run { from { transform: translateX(-100%); } to { transform: translateX(300%); } }

  /* Images settle; links nudge */
  .fig-frame img { transition: transform 900ms var(--ease-out); }
  a:hover .fig-frame img { transform: scale(1.025); }

  @supports (animation-timeline: view()) {
    .rv { animation: bb-in linear both; animation-timeline: view(); animation-range: entry 0% entry 40%; }
    .rv-draw { animation: bb-wipe linear both; animation-timeline: view(); animation-range: entry 0% entry 60%; }
  }
}
@media (prefers-reduced-motion: reduce) {
  .dg-pulse { display: none; }
  .dg-ripple, .dg-scan { display: none; }
}
