/*
 * Application stylesheet — minimal overrides
 * Most styling is handled by Tailwind CSS (app/assets/tailwind/application.css)
 * This file keeps only: fonts, animations, and JS-driven component styles
 */

@font-face {
  font-family: "Geist";
  src: url("/assets/GeistVF-5371dc46.woff") format("woff");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("/assets/GeistMonoVF-ce04edea.woff") format("woff");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

html {
  scroll-behavior: smooth;
}

/* ── Brand components ("The Technical Ledger") ─────── */

.card {
  background: var(--color-paper);
  border-radius: var(--radius-xl);
  padding: 1.4rem 1.5rem;
  box-shadow: inset 0 0 0 1px rgb(191 200 199 / 0.16);
}

.card-oat {
  background: var(--color-oat);
  border-radius: var(--radius-xl);
  padding: 1.4rem 1.5rem;
  box-shadow: none;
}

/* --- Error / open-outage card family (warm orange, coral accent) --- */
.card-error {
  background: #fbe6d6;
  border-radius: var(--radius-xl);
  padding: 1.4rem 1.5rem;
  box-shadow: inset 0 0 0 1px rgb(193 59 35 / 0.18);
}
/* Inner "Current Issue" panel on an error card — warm cream lift so it nests
   cleanly on the orange instead of the cool sage oat. */
.panel-error {
  background: #fdf4ec;
  box-shadow: inset 0 0 0 1px rgb(193 59 35 / 0.10);
}
/* "Error Details" monospace box — a slightly deeper warm peach inset (was the
   clashing pink), with warm-brown code text. */
.codebox-error { background: #f7e1d1; box-shadow: inset 0 0 0 1px rgb(193 59 35 / 0.12); }
.codebox-error .code-text { color: #7a4a37; }

/* --- "Never Seen" / unverified card family (soft cool blue = informational,
   distinct from an actual error) --- */
.card-info {
  background: #e9eff3;
  border-radius: var(--radius-xl);
  padding: 1.4rem 1.5rem;
  box-shadow: inset 0 0 0 1px rgb(46 84 104 / 0.14);
}
.panel-info { background: #eef4f8; box-shadow: inset 0 0 0 1px rgb(46 84 104 / 0.10); }
.text-info-ink { color: #3a5a6e; }

.card-floating {
  box-shadow: inset 0 0 0 1px rgb(191 200 199 / 0.16), 0 10px 30px rgb(5 66 64 / 0.08);
}

.ghost-rule-t {
  box-shadow: inset 0 1px 0 rgb(92 107 101 / 0.15);
}

.ghost-rule-b {
  box-shadow: inset 0 -1px 0 rgb(92 107 101 / 0.15);
}

.darkpanel {
  background:
    linear-gradient(rgb(233 240 239 / 0.05) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgb(233 240 239 / 0.05) 1px, transparent 1px) 0 0 / 28px 28px,
    radial-gradient(60% 60% at 50% 0%, rgb(255 200 87 / 0.14), transparent 55%),
    linear-gradient(160deg, #0a3634, #0f3f3d 55%, #073230);
  color: #eff3f0;
}

.darkpanel-quiet {
  background:
    linear-gradient(rgb(233 240 239 / 0.05) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgb(233 240 239 / 0.05) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--color-pine-cta);
  color: #eff3f0;
}

.darkpanel-topbar {
  background:
    linear-gradient(rgb(233 240 239 / 0.06) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgb(233 240 239 / 0.06) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--color-pine);
  color: #eff3f0;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.8rem 1.3rem;
  border-radius: var(--radius-lg);
  white-space: nowrap;
  cursor: pointer;
  border: 0;
  text-decoration: none;
  transition: background-color 150ms, color 150ms;
}

.btn:focus-visible {
  outline: 2px solid var(--color-gold-hover);
  outline-offset: 2px;
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  border-radius: 0.65rem;
}

.btn-gold {
  background: var(--color-gold-soft);
  color: var(--color-gold-ink);
}
.btn-gold:hover {
  background: var(--color-gold-hover);
}

.btn-pine {
  background: linear-gradient(135deg, var(--color-pine), var(--color-pine-soft));
  color: #ffffff;
}
.btn-pine:hover {
  background: var(--color-pine-cta);
}

.btn-ghost {
  background: var(--color-greige);
  color: var(--color-pine);
}
.btn-ghost:hover {
  background: var(--color-wash);
}

.btn-ghost-on-pine {
  background: rgb(255 255 255 / 0.12);
  color: #ffffff;
}
.btn-ghost-on-pine:hover {
  background: rgb(255 255 255 / 0.2);
}

.btn-danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}
.btn-danger:hover {
  background: var(--color-danger);
  color: #ffffff;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0.34rem 0.7rem;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.chip-op {
  background: var(--color-pine);
  color: #ffffff;
}

.chip-ver {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.chip-warn {
  background: rgb(253 198 86 / 0.45);
  color: var(--color-gold-ink);
}

.chip-dgr {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.chip-mute {
  background: var(--color-wash);
  color: var(--color-ink-muted);
}

.wm {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-headline);
  font-weight: 800;
  letter-spacing: -0.015em;
  line-height: 1;
  white-space: nowrap;
  color: var(--color-pine);
}
.wm .is {
  font-weight: 400;
  margin: 0 0.28em;
  color: var(--color-ink-muted);
}
.wm .on {
  display: inline-flex;
  align-items: center;
  color: var(--color-gold-hover);
}
.wm .dial {
  width: 1em;
  height: 1em;
  margin-right: 0.02em;
}
.wm-rev {
  color: #ffffff;
}
.wm-rev .is {
  color: rgb(255 255 255 / 0.62);
}
.wm-rev .on {
  color: var(--color-gold-soft);
}

/* ── Animations ─────────────────────────────────────── */

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.loading-dots {
  display: inline-flex;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Marching-dot spinner: a single filled dot orbits a faint track ring.
   Sized in em so it scales with surrounding text; colour follows currentColor. */
@keyframes sync-spinner-rotate {
  to { transform: rotate(360deg); }
}

.sync-spinner {
  display: inline-block;
  position: relative;
  width: 1.1em;
  height: 1.1em;
  vertical-align: -0.2em;
  animation: sync-spinner-rotate 0.9s linear infinite;
}

.sync-spinner::after {
  /* faint static track ring */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 0.12em solid currentColor;
  opacity: 0.18;
}

.sync-spinner::before {
  /* the marching dot, pinned to the top of the ring and carried around by the rotation */
  content: "";
  position: absolute;
  top: -0.05em;
  left: 50%;
  width: 0.34em;
  height: 0.34em;
  margin-left: -0.17em;
  border-radius: 50%;
  background: currentColor;
}

@media (prefers-reduced-motion: reduce) {
  .sync-spinner { animation-duration: 2.4s; }
}

/* Sync progress bar. Fills smoothly CLIENT-SIDE via a keyframe so it's immune to
   the poller replacing the section's innerHTML (a server-computed width can't
   animate across element swaps) and looks smooth regardless of how fast the sync
   actually is. It eases toward ~90% (never reaching 100% while indeterminate);
   the Stimulus controller adds .is-complete on success to finish it to 100%, then
   .is-fading to gracefully dissolve before the reload — instead of blinking away. */
@keyframes sync-progress-fill {
  from { width: 6%; }
  to   { width: 90%; }
}

.sync-progress-track {
  transition: opacity 300ms ease-out;
}

.sync-progress-bar {
  width: 6%;
  animation: sync-progress-fill 5s cubic-bezier(0.15, 0.75, 0.25, 1) forwards;
}

.sync-progress-track.is-complete .sync-progress-bar {
  width: 100%;
  animation: none;
  transition: width 260ms ease-out;
}

.sync-progress-track.is-fading {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .sync-progress-bar { animation: none; width: 90%; }
  .sync-progress-track.is-complete .sync-progress-bar { transition: none; }
  .sync-progress-track { transition: none; }
}

/* ── Pathway Step Cards (JS-driven, needs stable classes) ── */

.pathway-card-expanded {
  /* Marker class for JS querySelector — styled via Tailwind in template */
}

.steps-row {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.step-card {
  flex-shrink: 0;
  width: 200px;
  border: 1px solid #cfcabb;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  background: #eceee3;
  position: relative;
}

.step-card-handle {
  cursor: grab;
  font-size: 0.8rem;
  color: #5c6b65;
  text-align: center;
  letter-spacing: 0.15em;
  line-height: 1;
  margin-bottom: 0.2rem;
  user-select: none;
}

.step-card-handle:active {
  cursor: grabbing;
}

.step-card--dragging {
  opacity: 0.4;
}

.step-card--dragover {
  border-color: #054240;
  border-style: dashed;
}

.step-card--dropped {
  border-color: #054240;
  box-shadow: 0 0 0 3px rgba(5, 66, 64, 0.2);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.step-card:not(.step-card--dropped) {
  transition: border-color 0.5s ease 2.5s, box-shadow 0.5s ease 2.5s;
}

.step-card-title {
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #054240;
  margin-bottom: 0.35rem;
}

.step-card-role {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0.05rem 0.3rem;
  border-radius: 999px;
  background: rgb(92 107 101 / 0.12);
  color: #5c6b65;
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

.step-card-remove {
  position: absolute;
  top: 0.3rem;
  right: 0.4rem;
  background: none;
  border: none;
  color: #c13b23;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

/* Suggestion chip carries full trigger names too — keep it inside the card
   and let the name wrap rather than widen the column. */
.step-suggestion-chip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  max-width: 100%;
  font-size: 0.62rem;
  margin-bottom: 0.3rem;
}

.step-suggestion-chip code {
  overflow-wrap: anywhere;
}

/* Linked-trigger rows: the select must never dictate card width — a bare
   <select> sizes to its longest <option> (trigger names run long) and punches
   out of the fixed-width step card. Constrain it and clip with ellipsis; the
   dropdown itself still shows full option names when opened. */
.linked-trigger-rows {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.linked-trigger-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.linked-trigger-select {
  flex: 1;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0.28rem 0.4rem;
  border: 1px solid #cfcabb;
  border-radius: 7px;
  background: #ffffff;
  font-size: 0.68rem;
  color: #181c1c;
}

/* Saved links render as a static name, not a dropdown — the select only
   appears in the "+ add another trigger" flow. */
.linked-trigger-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  padding: 0.28rem 0.4rem;
  border: 1px solid transparent; /* aligns baseline with select rows */
  font-size: 0.68rem;
  color: #181c1c;
}

.linked-trigger-edit {
  display: inline-flex;
  align-items: center;
  color: #5c6b65;
  text-decoration: none;
  line-height: 1;
}

.linked-trigger-edit:hover {
  color: #054240;
}

.linked-trigger-edit .material-symbols-outlined {
  font-size: 0.85rem;
}

/* ── Pathway step view (monitoring cards) ─────────── */
/* Vertical step timeline: status icon column with a connecting rail, label
   beside it. Statuses color both the icon and their half of the rail. */

.pathway-step-track {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pathway-step {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.22rem 0;
}

.pathway-step-icon {
  display: inline-flex;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

/* Connecting rail between icons, colored by the lower step's status. */
.pathway-step + .pathway-step::before {
  content: "";
  position: absolute;
  left: 8px;
  top: -0.55rem;
  height: 1.1rem;
  width: 2px;
  background: currentColor;
  opacity: 0.45;
}

.pathway-step-label {
  font-size: 0.72rem;
  color: #181c1c;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pathway-step--passed { color: var(--color-pine, #054240); }
.pathway-step--failed { color: var(--color-danger, #c13b23); }
.pathway-step--gated { color: var(--color-gold-ink, #5d4200); }
.pathway-step--not_reached { color: var(--color-ink-muted, #5c6b65); }

.pathway-step--failed .pathway-step-label { color: var(--color-danger, #c13b23); font-weight: 600; }
.pathway-step--not_reached .pathway-step-label { color: var(--color-ink-muted, #5c6b65); }

/* ── URL List (JS-driven, triggers + pathways) ────── */

.url-list-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.url-list-input {
  flex: 1;
  padding: 0.28rem 0.5rem;
  border: 1px solid #cfcabb;
  border-radius: 7px;
  background: #ffffff;
  font-size: 0.68rem;
  color: #181c1c;
  font-family: "Geist Mono", ui-monospace, monospace;
  min-width: 0;
}

.url-list-remove {
  color: #c13b23;
  font-weight: 800;
  font-size: 0.72rem;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

.url-list-add {
  font-size: 0.7rem;
  color: #054240;
  font-weight: 800;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

/* ── Assertion Rows (step test builder) ───────────── */

.step-action-section {
  border-top: 1px solid #cfcabb;
  padding-top: 0.3rem;
  margin-top: 0.3rem;
}

.step-assertions {
  border-top: 1px solid #cfcabb;
  padding-top: 0.3rem;
  margin-top: 0.3rem;
}

.assertion-row {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.35rem;
  position: relative;
}

.assertion-row select,
.assertion-row input {
  font-size: 0.68rem;
  padding: 0.22rem 0.35rem;
  width: 100%;
}

.assertion-remove {
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  background: none;
  border: none;
  color: #c13b23;
  font-weight: 800;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0 0.15rem;
  line-height: 1;
}

.assertion-add {
  font-size: 0.65rem;
  color: #054240;
  font-weight: 800;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin-top: 0.15rem;
}

.step-json-area {
  width: 100%;
  min-height: 5rem;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 0.65rem;
  padding: 0.3rem;
  border: 1px solid #cfcabb;
  border-radius: 6px;
  background: #ffffff;
  color: #181c1c;
  resize: vertical;
}

.step-insert-template {
  font-size: 0.6rem;
  color: #054240;
  font-weight: 700;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin-top: 0.15rem;
}

/* ── Tooltip ──────────────────────────────────────── */

.tooltip {
  position: absolute;
  z-index: 100;
  max-width: 300px;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: #181c1c;
  color: #eff3f0;
  font-size: 0.75rem;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgb(5 66 64 / 0.14);
  pointer-events: none;
}

.tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #181c1c;
}

/* ── Lightbox (test run artifacts) ────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgb(5 66 64 / 0.45);
  backdrop-filter: blur(6px);
}

.lightbox[hidden] {
  display: none;
}

.lightbox-panel {
  width: min(95vw, 1400px);
  height: min(95vh, 900px);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem;
  border-radius: 1rem;
  background: #ffffff;
  box-shadow: 0 24px 64px rgb(5 66 64 / 0.18);
}

.lightbox-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #cfcabb;
}

.lightbox-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.lightbox-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #181c1c;
}

.lightbox-description {
  font-size: 0.875rem;
  color: #404848;
}

.lightbox-page {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lightbox-page-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #5c6b65;
}

.lightbox-page-link {
  color: #054240;
  font-size: 0.875rem;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-page-link:hover {
  text-decoration: underline;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.lightbox-frame {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 1rem;
  border-radius: 0.75rem;
  background: #eceee3;
}

.lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0.5rem;
}

.lightbox-html {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0.5rem;
  background: #ffffff;
}

/* ── Responsive ───────────────────────────────────── */

@media (max-width: 980px) {
  .steps-row { flex-direction: column; }
  .step-card { width: 100%; }
}
