/* ============================================================================
   AVINYAI — COMPONENTS: buttons, surfaces, diagram primitives, forms
   ========================================================================= */

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 44px;
  padding: 0 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: -0.008em;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}

.btn__arrow { transition: transform var(--t) var(--ease); }
.btn:hover .btn__arrow { transform: translateX(3px); }

.btn--primary {
  background: #C2CEFF;
  color: #0A1124;
  font-weight: 550;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 10px 28px -16px rgba(160, 182, 255, 0.85);
}
.btn--primary:hover { background: #D6DEFF; box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 14px 32px -16px rgba(160,182,255,1); }
.btn--primary:active { transform: translateY(1px); }

.btn--ghost {
  background: rgba(126, 158, 205, 0.04);
  border-color: var(--line-2);
  color: var(--ink);
}
.btn--ghost:hover { border-color: var(--line-3); background: rgba(126, 158, 205, 0.09); }

.btn--sm { height: 36px; padding: 0 15px; font-size: 0.8125rem; }
.btn--lg { height: 50px; padding: 0 26px; font-size: 0.9375rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Quiet inline link with arrow */
.link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #A9C3FF;
  transition: color var(--t-fast) var(--ease), gap var(--t-fast) var(--ease);
}
.link:hover { color: #CBD9FF; gap: 11px; }

/* ---- Surfaces ---------------------------------------------------------- */
.panel {
  background: linear-gradient(180deg, rgba(13, 22, 40, 0.86), rgba(8, 15, 29, 0.86));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

/* ---- Chips / capability labels ---------------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: var(--ink-2);
  padding: 5px 10px;
  border: 1px solid var(--line-2);
  border-radius: 3px;
  background: rgba(126, 158, 205, 0.035);
}
.chip--violet { color: #C4AFFC; border-color: rgba(139, 92, 246, 0.28); background: var(--violet-dim); }

/* Status pills used inside diagrams */
.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 3px;
  border: 1px solid currentColor;
}
.status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status--allow { color: var(--green); background: rgba(52, 211, 153, 0.09); }
.status--challenge { color: var(--amber); background: rgba(240, 178, 58, 0.09); }
.status--deny { color: var(--red); background: rgba(240, 89, 107, 0.09); }
.status--idle { color: var(--ink-3); background: transparent; }

/* ---- Diagram primitives ----------------------------------------------- */
.diagram {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(120% 120% at 50% -20%, rgba(47, 107, 255, 0.07), transparent 62%),
    linear-gradient(180deg, #0A1120, #070D19);
  overflow: hidden;
}

.diagram__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(126, 158, 205, 0.055) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(126, 158, 205, 0.055) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: radial-gradient(100% 100% at 50% 30%, #000 30%, transparent 82%);
  mask-image: radial-gradient(100% 100% at 50% 30%, #000 30%, transparent 82%);
  pointer-events: none;
}

/* SVG semantics shared across every diagram */
.d-node { fill: #101B30; stroke: var(--line-2); }
.d-node--hi { fill: #14213A; stroke: rgba(91, 140, 255, 0.42); }
.d-node--core { fill: #0E1A31; stroke: rgba(91, 140, 255, 0.55); }
.d-node--ai { fill: #150F2B; stroke: rgba(139, 92, 246, 0.42); }

.d-text { font-family: var(--sans); font-size: 11px; font-weight: 500; fill: var(--ink); letter-spacing: -0.01em; }
.d-text--sm { font-family: var(--mono); font-size: 8.5px; fill: var(--ink-3); letter-spacing: 0.09em; }
.d-text--accent { fill: #A9C3FF; }
.d-text--violet { fill: #C4AFFC; }

.d-wire { fill: none; stroke: rgba(126, 158, 205, 0.20); stroke-width: 1; }
.d-wire--dash { stroke-dasharray: 3 4; stroke: rgba(126, 158, 205, 0.16); }

/* Comet pulse: a short dash travelling along the wire path */
.d-pulse {
  fill: none;
  stroke: var(--blue-hi);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 14 620;
  stroke-dashoffset: 634;
  animation: comet 3.4s linear infinite;
  filter: drop-shadow(0 0 3px rgba(91, 140, 255, 0.85));
}
.d-pulse--cyan { stroke: var(--cyan); filter: drop-shadow(0 0 3px rgba(34, 211, 238, 0.8)); }
.d-pulse--violet { stroke: var(--violet); filter: drop-shadow(0 0 3px rgba(139, 92, 246, 0.8)); }
.d-pulse--slow { animation-duration: 5s; }

@keyframes comet { to { stroke-dashoffset: 0; } }

/* Breathing halo for core blocks */
.d-halo { animation: halo 4.4s ease-in-out infinite; transform-origin: center; }
@keyframes halo {
  0%, 100% { opacity: 0.24; }
  50% { opacity: 0.62; }
}

.d-blip { animation: blip 2.6s ease-in-out infinite; }
@keyframes blip {
  0%, 100% { opacity: 0.25; }
  50% { opacity: 1; }
}

/* Verdict groups inside the risk-engine diagram */
.risk-out { transition: opacity var(--t) var(--ease); }
.is-cycling .risk-out { opacity: 0.34; }
.is-cycling .risk-out.is-on { opacity: 1; }
.risk-out.is-on rect { filter: drop-shadow(0 0 10px rgba(91, 140, 255, 0.28)); }

/* ---- Mobile vertical flow (stands in for wide diagrams) --------------- */
.vflow { display: none; }

/* ---- Metric tiles ----------------------------------------------------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.metric {
  padding: 28px 26px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.metric__value {
  font-family: var(--display);
  font-size: clamp(1.5rem, 2.6vw, 2.125rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.metric__unit { color: #7FA5FF; }
.metric__label {
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--ink-2);
}
.metric__note {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---- Form ------------------------------------------------------------- */
.form { display: grid; gap: 20px; }
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-2);
  margin-bottom: 8px;
}
.field .req { color: #7FA5FF; }

.field input,
.field select,
.field textarea {
  width: 100%;
  background: rgba(8, 15, 29, 0.72);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.9375rem;
  color: var(--ink);
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

.field textarea { min-height: 124px; resize: vertical; line-height: 1.55; }
.field select { appearance: none; cursor: pointer; padding-right: 38px; }

.field__select { position: relative; }
.field__select::after {
  content: "";
  position: absolute;
  right: 15px; top: 46px;
  width: 7px; height: 7px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: rotate(45deg);
  pointer-events: none;
}

.field input::placeholder,
.field textarea::placeholder { color: var(--ink-3); }

.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--line-3); }

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: rgba(91, 140, 255, 0.7);
  background: rgba(13, 22, 40, 0.9);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.14);
}

.field__error {
  font-size: 0.75rem;
  color: var(--red);
  margin-top: 6px;
  min-height: 1em;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
}
.field.is-invalid .field__error { opacity: 1; transform: none; }
.field.is-invalid input,
.field.is-invalid select,
.field.is-invalid textarea { border-color: rgba(240, 89, 107, 0.6); }

.form__status {
  font-size: 0.875rem;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  display: none;
}
.form__status.is-visible { display: block; }
.form__status.is-ok { color: var(--green); border-color: rgba(52, 211, 153, 0.32); background: rgba(52, 211, 153, 0.07); }
.form__status.is-err { color: var(--red); border-color: rgba(240, 89, 107, 0.32); background: rgba(240, 89, 107, 0.07); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
