/* ============================================================================
   Cortex — Features, How it works, Security
   Requires /css/tokens.css and /css/base.css. All classes prefixed .feat-.
   ========================================================================== */

/* ---- Section hooks -------------------------------------------------------- */
.feat { overflow: hidden; }

.feat-grid { align-items: stretch; }

.feat-sec__copy { min-width: 0; }

/* ---- Pillar cards --------------------------------------------------------- */
.feat-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  height: 100%;
  overflow: hidden;
}

/* faint emerald wash that brightens on hover */
.feat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(ellipse 70% 50% at 10% 0%, var(--c-accent-soft), transparent 70%);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}

.feat-card:hover::after,
.feat-card:focus-within::after {
  opacity: 1;
}

.feat-card__icon {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  flex: none;
  color: var(--c-accent-hover);
  background: linear-gradient(160deg, var(--c-surface-3), var(--c-surface-1));
  border: 1px solid var(--c-border-hover);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-inset-top), 0 0 0 1px rgba(16, 185, 129, 0);
  transition:
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}

.feat-card__icon svg {
  width: 26px;
  height: 26px;
}

.feat-card:hover .feat-card__icon,
.feat-card:focus-within .feat-card__icon {
  border-color: var(--c-border-accent);
  box-shadow: var(--sh-inset-top), var(--glow-accent);
  transform: translateY(-2px);
}

.feat-card__title {
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
}

.feat-card__body {
  color: var(--c-text-muted);
  font-weight: 300;
  font-size: var(--fs-base);
  flex: 1 1 auto;
  text-wrap: pretty;
}

.feat-card__body code {
  font-size: 0.85em;
  color: var(--c-accent-hover);
}

.feat-card__spec {
  margin-block-start: auto;
  padding-block-start: var(--sp-4);
  border-top: 1px solid var(--c-border);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--c-accent);
  overflow-wrap: anywhere;
}

/* ---- How it works: steps -------------------------------------------------- */
.feat-how .section__header {
  position: relative;
}

.feat-steps {
  position: relative;
  display: grid;
  gap: var(--sp-8);
  grid-template-columns: 1fr;
  counter-reset: feat-step;
}

.feat-step {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: start;
}

/* vertical connector (mobile / tablet) */
.feat-step::before {
  content: "";
  position: absolute;
  left: 25px;
  top: 52px;
  bottom: calc(var(--sp-8) * -1);
  width: 2px;
  background: linear-gradient(to bottom, var(--c-border-accent), var(--c-border));
}

.feat-step:last-child::before {
  display: none;
}

.feat-step__num {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--c-text-on-accent);
  background: linear-gradient(160deg, var(--c-accent-hover), var(--c-accent-deep));
  border-radius: var(--r-lg);
  box-shadow: var(--glow-accent), var(--sh-inset-top);
  /* isometric top-face cut */
  clip-path: polygon(0 12%, 12% 0, 100% 0, 100% 88%, 88% 100%, 0 100%);
}

.feat-step__card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  height: 100%;
}

.feat-step__title {
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
}

.feat-step__body {
  color: var(--c-text-muted);
  font-weight: 300;
  text-wrap: pretty;
}

.feat-step__body code {
  font-size: 0.85em;
}

.feat-step__host {
  color: var(--c-accent-hover);
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

.feat-step__list {
  display: grid;
  gap: var(--sp-2);
  margin-block-start: auto;
  padding-block-start: var(--sp-3);
  border-top: 1px solid var(--c-border);
  font-size: var(--fs-sm);
  color: var(--c-text-muted);
}

.feat-step__list li {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
}

.feat-step__list .status-dot {
  position: relative;
  top: -1px;
  width: 6px;
  height: 6px;
  box-shadow: none;
}

.feat-step__list code {
  font-size: 0.85em;
}

/* config.yml block */
.feat-code {
  position: relative;
  margin: 0;
  padding: var(--sp-4);
  padding-block-start: calc(var(--sp-4) + 14px);
  background: var(--c-bg-deep);
  border: 1px solid var(--c-border-hover);
  border-radius: var(--r-md);
  box-shadow: var(--sh-inset-top);
  font-size: var(--fs-xs);
  line-height: 1.7;
  white-space: pre;
  tab-size: 2;
}

/* traffic-light dots, pure CSS */
.feat-code::before {
  content: "";
  position: absolute;
  top: 10px;
  left: var(--sp-4);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-text-faint);
  box-shadow: 14px 0 0 var(--c-text-faint), 28px 0 0 var(--c-text-faint);
  opacity: 0.6;
}

.feat-code:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.feat-code__c { color: var(--c-text-faint); }
.feat-code__k { color: var(--c-cyan); }
.feat-code__s { color: var(--c-accent-hover); }

/* desktop: three columns, horizontal connector behind the numbers */
@media (min-width: 900px) {
  .feat-steps {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-6);
  }

  .feat-steps::before {
    content: "";
    position: absolute;
    top: 26px;
    left: calc(100% / 6);
    right: calc(100% / 6);
    height: 2px;
    background: linear-gradient(
      to right,
      var(--c-border-accent),
      var(--c-accent-glow) 50%,
      var(--c-border-accent)
    );
    -webkit-mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
    mask-image: linear-gradient(to right, transparent, #000 8%, #000 92%, transparent);
  }

  .feat-step {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: var(--sp-5);
  }

  .feat-step::before {
    display: none;
  }

  .feat-step__card {
    width: 100%;
  }
}

/* ---- Security ------------------------------------------------------------- */
.feat-sec {
  overflow: hidden;
}

/* ambient glow behind the ledger */
.feat-sec::before {
  content: "";
  position: absolute;
  top: 20%;
  right: -10%;
  width: min(60vw, 720px);
  aspect-ratio: 1;
  pointer-events: none;
  background: radial-gradient(circle, var(--c-accent-glow), transparent 65%);
  filter: blur(60px);
  opacity: 0.35;
  z-index: 0;
}

.feat-sec__grid {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--sp-12);
  grid-template-columns: 1fr;
  align-items: center;
}

.feat-sec__header {
  margin-block-end: var(--sp-6);
}

.feat-sec__prose {
  display: grid;
  gap: var(--sp-4);
  color: var(--c-text-muted);
  font-weight: 300;
  text-wrap: pretty;
}

.feat-sec__prose code {
  font-size: 0.85em;
}

.feat-sec__stat {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--c-accent-hover);
  font-variant-numeric: tabular-nums;
}

.feat-check {
  display: grid;
  gap: var(--sp-3);
  margin-block-start: var(--sp-8);
  grid-template-columns: 1fr;
}

@media (min-width: 480px) {
  .feat-check { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.feat-check__item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-sm);
  color: var(--c-text);
  background: var(--c-surface-1);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-inset-top);
  transition: border-color var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

.feat-check__item:hover {
  border-color: var(--c-border-accent);
  transform: translateX(2px);
}

.feat-check__icon {
  width: 22px;
  height: 22px;
  flex: none;
  padding: 3px;
  color: var(--c-text-on-accent);
  background: var(--c-accent);
  border-radius: var(--r-xs);
  box-shadow: 0 0 12px -2px var(--c-accent-glow);
}

/* ---- Ledger visual -------------------------------------------------------- */
.feat-ledger-wrap {
  margin: 0;
  min-width: 0;
}

.feat-ledger {
  position: relative;
  overflow: hidden;
  padding: var(--sp-5);
  border-color: var(--c-border-hover);
  box-shadow: var(--sh-xl), var(--sh-inset-top), 0 0 60px -20px var(--c-accent-glow);
}

.feat-ledger .scanline-overlay {
  z-index: 0;
  opacity: 0.6;
}

.feat-ledger > *:not(.scanline-overlay) {
  position: relative;
  z-index: 1;
}

.feat-ledger__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding-block-end: var(--sp-4);
  margin-block-end: var(--sp-4);
  border-bottom: 1px solid var(--c-border);
}

.feat-ledger__name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--c-text);
}

.feat-ledger__tenant {
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
}

.feat-ledger__verified {
  text-transform: none;
  letter-spacing: 0.02em;
}

.feat-ledger__verified .status-dot {
  width: 6px;
  height: 6px;
}

.feat-ledger__list {
  position: relative;
  display: grid;
  gap: var(--sp-3);
  padding-inline-start: var(--sp-5);
}

/* the chain itself: a vertical rail with a node per entry */
.feat-ledger__list::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 14px;
  bottom: 14px;
  width: 2px;
  background: linear-gradient(to bottom, var(--c-accent-deep), var(--c-accent), var(--c-accent-hover));
  box-shadow: 0 0 10px -2px var(--c-accent-glow);
  border-radius: 1px;
}

.feat-ledger__entry {
  position: relative;
  display: grid;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: rgba(15, 17, 21, 0.55);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  transition: border-color var(--dur-base) var(--ease-out), background-color var(--dur-base) var(--ease-out);
}

.feat-ledger__entry::before {
  content: "";
  position: absolute;
  left: calc(var(--sp-5) * -1 + 1px);
  top: 14px;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--c-bg);
  border: 2px solid var(--c-accent);
  box-shadow: 0 0 8px var(--c-accent-glow);
  transform: rotate(45deg);
}

.feat-ledger__entry:hover {
  border-color: var(--c-border-accent);
  background: rgba(20, 23, 29, 0.85);
}

.feat-ledger__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2) var(--sp-3);
  font-size: var(--fs-sm);
}

.feat-ledger__seq {
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
}

.feat-ledger__row .badge {
  font-size: 0.68rem;
  padding-block: 0.1em;
}

.feat-ledger__who {
  color: var(--c-text);
  font-weight: 400;
  min-width: 0;
  overflow-wrap: anywhere;
}

.feat-ledger__actor {
  color: var(--c-text-muted);
}

.feat-ledger__time {
  margin-inline-start: auto;
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  font-variant-numeric: tabular-nums;
}

.feat-ledger__hashes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-1) var(--sp-2);
  font-size: var(--fs-xs);
  letter-spacing: 0.02em;
}

.feat-ledger__k {
  color: var(--c-text-faint);
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
}

.feat-ledger__v {
  padding: 0.05em 0.45em;
  color: var(--c-text-muted);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xs);
}

/* prev pointer that matches the entry above */
.feat-ledger__v--link {
  color: var(--c-cyan);
  border-color: rgba(34, 211, 238, 0.3);
  background: var(--c-cyan-soft);
}

/* the entry's own hash */
.feat-ledger__v--own {
  color: var(--c-accent-hover);
  border-color: var(--c-border-accent);
  background: var(--c-accent-soft);
}

.feat-ledger__arrow {
  color: var(--c-text-faint);
}

.feat-ledger__foot {
  margin-block-start: var(--sp-4);
  padding-block-start: var(--sp-3);
  border-top: 1px solid var(--c-border);
  font-size: var(--fs-xs);
  color: var(--c-text-faint);
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}

.feat-ledger__caption {
  margin-block-start: var(--sp-3);
  font-size: var(--fs-xs);
  letter-spacing: 0.04em;
  text-align: right;
}

@media (min-width: 900px) {
  .feat-sec__grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: var(--sp-16);
  }

  .feat-ledger {
    padding: var(--sp-6);
  }
}

/* tight phones: keep the ledger rows readable */
@media (max-width: 400px) {
  .feat-ledger { padding: var(--sp-4); }
  .feat-ledger__entry { padding: var(--sp-3); }
  .feat-ledger__time { flex-basis: 100%; margin-inline-start: 0; }
}

/* ---- Reduced motion ------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .feat-card::after,
  .feat-card__icon,
  .feat-check__item,
  .feat-ledger__entry {
    transition: none;
  }

  .feat-card:hover .feat-card__icon,
  .feat-check__item:hover {
    transform: none;
  }
}
