/* ── #features: the feature directory ──────────────────────────────────────
   Owns the "what you get" column, the three accordion groups (#groups > .grp),
   their ledgers of feature rows, the (hidden) little demos inside each row, and
   .landing-after-intro: the backdrop of everything below the marquee and the
   fireflies canvas that sits behind this section.
   Desktop first: base rules, then max-width:1050px, 700px, then reduced motion. */

/* ── Section layout ── */
#features {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(240px, .8fr) minmax(0, 1.7fr);
  gap: clamp(32px, 5vw, 76px);
  align-items: start;
  width: 100%;
  max-width: 1500px;
  margin-inline: auto;
  padding: 64px var(--gutter) 88px;
  zoom: 1;
  scroll-margin-top: 110px;
  /* Perf: the section is laid out lazily; the placeholder height keeps the scrollbar stable. */
  content-visibility: auto;
  contain-intrinsic-size: 1px 750px;
}

/* ── "what you get" column ── */
#features .head {
  display: block;
  position: sticky;
  top: 128px;
  margin: 0;
  padding-top: 18px;
  text-align: left;
}

#features .head .eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
  margin-bottom: 22px;
}

#features .head .eyebrow::before {
  content: '';
  width: 24px;
  height: 1px;
  background: #f00646;
}

#features .head h2 {
  max-width: 390px;
  font-size: clamp(32px, 3.2vw, 48px);
  line-height: 1.15;
  letter-spacing: -.035em;
  text-wrap: balance;
}

#features .head h2 em {
  display: block;
  margin-top: 7px;
}

/* ── Groups: three accordions ── */
#features .groups {
  display: grid;
  gap: 12px;
  align-items: start;
  min-width: 0;
  border: 0;
  counter-reset: group;
}

/* Each group's aura tints its demos (var(--crimson) inside a group) and its icon. */
#features [data-aura="rose"] {
  --aura: 255, 151, 177;
}

#features [data-aura="mint"] {
  --aura: 130, 224, 182;
}

/* Distinct group colors, kept soft against the black page. */
#features .grp:nth-child(1) {
  --group-color: 244, 111, 151;
  --group-title: #f6a8c1;
}

#features .grp:nth-child(2) {
  --group-color: 114, 193, 151;
  --group-title: #a0d7b8;
}

#features .grp:nth-child(3) {
  --group-color: 163, 137, 232;
  --group-title: #c4b0f5;
}

#features .grp {
  --crimson: rgb(var(--aura));
  position: relative;
  min-width: 0;
  overflow: hidden;
  counter-increment: group;
  border: 1px solid rgba(var(--group-color), .2);
  border-radius: 16px;
  background:
    linear-gradient(165deg, #ffffff07, transparent 45%),
    linear-gradient(115deg, rgba(var(--group-color), .085), rgba(var(--group-color), .015) 75%);
  box-shadow: inset 0 1px 0 #ffffff10;
  transition: border-color .3s, background .3s, box-shadow .3s;
}

/* Hover drops the inset top highlight; an open group's own shadow (below) still wins. */
#features .grp:hover {
  border-color: rgba(var(--group-color), .4);
  background: linear-gradient(115deg, rgba(var(--group-color), .12), rgba(var(--group-color), .025) 75%);
  box-shadow: none;
}

#features .grp[open] {
  border-color: rgba(var(--group-color), .42);
  background: linear-gradient(125deg, rgba(var(--group-color), .11), rgba(var(--group-color), .02) 70%);
  box-shadow: 0 14px 42px -32px rgba(var(--group-color), .3);
}

/* ── Group header (summary) ── */
#features .grp__t {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-width: 0;
  padding: 22px 24px;
  text-align: left;
  list-style: none;
  cursor: pointer;
}

#features .grp__t::-webkit-details-marker {
  display: none;
}

#features .grp__t::before {
  content: '0' counter(group);
  font: 500 12px/1 system-ui;
  letter-spacing: .08em;
  color: rgba(var(--group-color), .8);
  transition: color .3s;
}

#features .grp__t:focus-visible {
  outline: 2px solid var(--group-title);
  outline-offset: -4px;
  border-radius: 14px;
}

/* The icon is hidden in this layout; the counter takes its column. */
#features .cosmic-icon {
  display: none;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: rgb(var(--aura));
  filter: drop-shadow(0 0 10px rgba(var(--aura), .3));
}

#features .grp__t > span:not(.chev) {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-width: 0;
}

#features .grp__h {
  display: block;
  font-family: Arial, sans-serif;
  font-size: clamp(22px, 2vw, 28px);
  font-style: normal;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -.025em;
  color: var(--group-title);
  text-decoration: none;
}

#features .grp__t .names {
  display: block;
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #8f8a94;
}

#features .grp__t .chev {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(var(--group-color), .1);
  color: var(--group-title);
  font-size: 0;
  transition: transform .45s;
}

#features .grp__t .chev::before {
  content: '+';
  font: 300 23px/1 Arial;
}

#features .grp[open] .grp__t .chev {
  transform: rotate(45deg);
}

/* ── Ledger: the rows inside an open group ── */
#features .drop {
  display: block;
}

#features .drop__in {
  overflow: hidden;
  min-height: 0;
}

/* Demo loops only tick while a group is open and on screen (landing/features.js sets .is-demo-active). */
#features .grp:not([open]) .drop *,
#features .grp:not([open]) .drop *::before,
#features .grp:not([open]) .drop *::after,
#features .grp:not(.is-demo-active) .drop *,
#features .grp:not(.is-demo-active) .drop *::before,
#features .grp:not(.is-demo-active) .drop *::after {
  animation-play-state: paused !important;
}

#features .ledger {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
  min-width: 0;
  padding: 0 24px 16px 70px;
  border: 0;
  background: none;
  counter-reset: feature;
}

#features .fr {
  display: block;
  position: relative;
  min-width: 0;
  min-height: 0;
  /* Inert while the row is display:block; kept so the row's computed style is unchanged. */
  gap: 14px;
  margin: 0;
  padding: 20px 0;
  border: 0;
  border-top: 1px solid rgba(var(--group-color), .12);
  border-radius: 0;
  background: none;
  counter-increment: feature;
}

/* The gold-star pointer belongs to the Cursors row. */
#features .fr.cursor-gold {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 22 22'><path d='M11 1l2.6 6.4L20 8.3l-5 4.6 1.5 6.8L11 16.4 5.5 19.7 7 12.9 2 8.3l6.4-.9z' fill='%23E6C36B' stroke='%23000' stroke-width='1'/></svg>") 11 11, auto;
}

/* gap is 10px: the old `.landing-atmosphere #groups .fr h3` outranked the 8px of `#features .fr h3`. */
#features .fr h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  padding: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  letter-spacing: -.01em;
  color: #eee;
  overflow-wrap: anywhere;
}

#features .fr p {
  max-width: 48ch;
  margin: 0;
  font-size: 16px;
  line-height: 1.65;
  color: #9c97a2;
  text-wrap: pretty;
}

/* ── Tier badges ── */
#features .feature-tier {
  display: inline-flex;
  align-items: center;
  margin: 0;
  padding: 2px 6px;
  font: 500 9px/1.4 Arial, sans-serif;
  letter-spacing: .02em;
  white-space: nowrap;
  border: 1px solid #ffffff14;
  border-radius: 5px;
  background: #ffffff06;
  color: #aaa;
}

#features .feature-tier--evergloom {
  color: #a8c8a1;
  background: #91bd7809;
  border-color: #91bd7820;
}

#features .feature-tier--bloodmoon {
  color: #ed9cae;
  background: #f0064609;
  border-color: #f0064620;
}

/* ── Little demos ──
   Every row carries a small demo (.fd), but this layout hides them (display:none).
   Their rules stay so the hidden markup keeps its computed style; nothing here paints. */
#features .fd {
  display: none;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--ash);
  overflow-wrap: anywhere;
  opacity: .92;
  transition: filter .3s, opacity .3s;
}

#features .fr:hover .fd {
  opacity: 1;
}

#features .fd b {
  color: var(--text);
  font-weight: 600;
}

#features .fd .k {
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 600;
}

#features .fd .eq {
  display: inline-flex;
  gap: 2px;
  align-items: flex-end;
  height: 14px;
}

#features .fd .eq i {
  width: 3px;
  height: 100%;
  border-radius: 1px;
  background: var(--crimson);
  transform-origin: 50% 100%;
  animation: eq 1s ease-in-out infinite;
}

#features .fd .eq i:nth-child(2) {
  animation-delay: .15s;
}

#features .fd .eq i:nth-child(3) {
  animation-delay: .3s;
}

#features .fd .eq i:nth-child(4) {
  animation-delay: .45s;
}

#features .fd .eq i:nth-child(5) {
  animation-delay: .6s;
}

#features .fd .clip {
  position: relative;
  width: 58px;
  height: 34px;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: linear-gradient(120deg, #3a0a18, #0d0d10 40%, #5a0a26 70%, #111);
  background-size: 300% 100%;
  animation: clipmove 4s linear infinite;
}

#features .fd .clip::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .06) 0 1px, transparent 1px 3px);
}

#features .fd .fxname {
  min-width: 0;
  font-weight: 800;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -.02em;
  color: var(--text);
  overflow-wrap: anywhere;
}

#features .fxname.glow {
  text-shadow: 0 0 14px var(--crimson), 0 0 30px rgba(240, 6, 70, .6);
}

#features .fxname.gradient {
  background: linear-gradient(90deg, var(--crimson), #ff9ab5, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#features .fxname.shimmer {
  background: linear-gradient(90deg, var(--ash) 0 40%, #fff 50%, var(--ash) 60% 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.4s linear infinite;
}

#features .fd .curs {
  display: inline-flex;
  gap: 14px;
  font-size: 16px;
  color: var(--ivory);
}

#features .fd .curs span {
  transition: transform .3s var(--spring);
}

#features .fd .curs span:hover {
  transform: scale(1.4);
}

#features .fd .curs .g {
  color: var(--gold);
  text-shadow: 0 0 10px var(--gold);
}

#features .fd .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
}

#features .fd .badge .ck {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  font-size: 8.5px;
}

#features .fd .badge.gold .ck {
  background: var(--gold);
  color: #221a00;
  animation: halo 2s ease-in-out infinite;
}

#features .fd .badge.gold .nm {
  background: linear-gradient(90deg, #f3d98a, var(--gold), #fff2c2, var(--gold));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 2.2s linear infinite;
}

#features .ring {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 0;
  max-width: 100%;
}

#features .ring span {
  max-width: 100%;
  padding: 2px 7px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: 10.5px;
  color: var(--ash);
  background: var(--ink-2);
  overflow-wrap: anywhere;
}

#features .ring i {
  display: inline-block;
  width: 12px;
  height: 1px;
  background: var(--crimson);
  animation: pulseline 1.6s ease-in-out infinite;
}

#features .ring i:nth-child(4) {
  animation-delay: .5s;
}

#features .spark {
  width: 96px;
  height: 30px;
  flex-shrink: 0;
}

#features .spark path {
  fill: none;
  stroke: var(--crimson);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-dasharray: 300;
  stroke-dashoffset: 300;
}

#features .spark .area {
  fill: rgba(240, 6, 70, .12);
  stroke: none;
  opacity: 0;
  transition: opacity .8s .6s;
}

#features .grp[open] .spark path {
  animation: draw 1.6s var(--ease) forwards;
}

#features .grp[open] .spark .area {
  opacity: 1;
}

#features .profile-demo-layout {
  display: grid;
  grid-template-columns: 18px 42px;
  gap: 5px;
}

#features .profile-demo-layout i {
  height: 12px;
  border-radius: 3px;
  background: #a6e7b750;
}

#features .profile-demo-layout i:first-child {
  grid-row: span 2;
  height: 29px;
}

#features .font-preview {
  font-size: 26px;
  word-spacing: 16px;
}

#features .font-preview em {
  font-family: var(--font-serif);
}

#features .font-preview b {
  font-family: var(--font-hand);
}

#features .palette-preview {
  display: flex;
  gap: 9px;
}

#features .palette-preview i {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eee8e2;
}

#features .palette-preview i:nth-child(2) {
  background: #f00646;
}

#features .palette-preview i:nth-child(3) {
  background: #82e0b6;
}

#features .palette-preview i:nth-child(4) {
  background: #91b7ff;
}

#features .link-preview {
  padding: 8px 14px;
  border-radius: 8px;
  color: #eee8e2;
  background: #ffffff12;
}

#features .link-preview--outline {
  border: 1px solid #ffffff40;
  border-radius: 999px;
  background: transparent;
}

#features .flip {
  width: 112px;
  height: 44px;
  padding: 0;
  perspective: 500px;
  flex-shrink: 0;
  cursor: pointer;
}

#features .flip:focus-visible {
  outline: 2px solid var(--ivory);
  outline-offset: 4px;
  border-radius: 5px;
}

#features .flip__in {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .5s var(--ease);
}

#features .flip[aria-pressed="true"] .flip__in {
  transform: rotateY(180deg);
}

#features .flip__f,
#features .flip__b {
  display: grid;
  place-items: center;
  position: absolute;
  inset: 0;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: var(--panel-2);
  font-size: 11.5px;
  backface-visibility: hidden;
}

#features .flip__f {
  color: var(--text);
  font-weight: 600;
}

#features .flip__f::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  border-style: solid;
  border-width: 0 9px 9px 0;
  border-color: transparent var(--ink) var(--panel-3) transparent;
}

#features .flip__b {
  transform: rotateY(180deg);
  font-family: var(--font-hand);
  font-size: 14px;
  color: var(--ivory);
  background: #1a0f13;
}

#features .moon {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(238, 232, 226, .35));
}

#features .moon .disc {
  fill: #1a1b1e;
  stroke: var(--line-2);
  stroke-width: .5;
}

#features .moon .lit {
  fill: var(--ivory);
}

@keyframes eq {
  0%, 100% {
    transform: scaleY(.3);
  }
  50% {
    transform: scaleY(1);
  }
}

@keyframes clipmove {
  to {
    background-position: 300% 0;
  }
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

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

@keyframes halo {
  0%, 100% {
    box-shadow: 0 0 0 3px rgba(230, 195, 107, .22), 0 0 10px rgba(230, 195, 107, .5);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(230, 195, 107, .1), 0 0 20px rgba(230, 195, 107, .9);
  }
}

@keyframes pulseline {
  0%, 100% {
    opacity: .3;
  }
  50% {
    opacity: 1;
  }
}

/* ── Everything after the intro: backdrop and fireflies canvas ──
   .landing-after-intro wraps the sections below the marquee. It paints their dark red backdrop,
   and its own stacking context keeps the z-index:-1 fireflies canvas above the page. The canvas
   is one continuous red particle field, prepended by landing/features.js and positioned over
   #features. */
.landing-after-intro {
  position: relative;
  isolation: isolate;
  min-width: 0;
  background:
    linear-gradient(to bottom, #000 0 100px, transparent 440px),
    radial-gradient(ellipse 70% 650px at 100% 780px, rgba(141, 0, 31, .18), transparent 78%),
    radial-gradient(ellipse 65% 900px at 0% 42%, rgba(141, 0, 31, .15), transparent 78%),
    radial-gradient(ellipse 75% 1000px at 100% 78%, rgba(141, 0, 31, .18), transparent 78%),
    #000;
}

.landing-after-intro > .feature-fireflies {
  position: absolute;
  left: 0;
  width: 100%;
  z-index: -1;
  pointer-events: none;
  opacity: .85;
}

.landing-after-intro > .feature-fireflies[hidden] {
  display: none;
}

/* ── Tablet: the column folds above the groups ── */
@media (max-width: 1050px) {
  #features {
    display: block;
    /* Inert while display:block; kept so the section's computed style is unchanged. */
    gap: 28px;
  }

  #features .head {
    position: static;
    padding: 0;
  }

  #features .head .eyebrow {
    margin-bottom: 14px;
  }

  #features .head h2 {
    max-width: 700px;
  }

  #features .head h2 em {
    display: inline;
  }

  #features .groups {
    margin-top: 28px;
  }
}

/* ── Phones: three tidy accordions ── */
@media (max-width: 700px) {
  #features {
    gap: 24px;
    padding-block: 38px 52px;
  }

  #features .head h2 {
    font-size: clamp(30px, 8vw, 40px);
    text-wrap: initial;
  }

  #features .groups {
    margin-top: 26px;
  }

  #features .grp {
    border: 1px solid rgba(var(--group-color), .18);
    border-radius: 18px;
    background: linear-gradient(120deg, rgba(var(--group-color), .065), #100d11 80%);
  }

  #features .grp__t {
    grid-template-columns: 22px minmax(0, 1fr) 30px;
    gap: 10px;
    padding: 18px 16px;
  }

  #features .grp__t::before {
    font-size: 11px;
  }

  #features .grp__t > span:not(.chev) {
    gap: 4px;
  }

  #features .grp__t .names {
    font-size: 12px;
    line-height: 1.6;
  }

  #features .grp__t .chev {
    width: 30px;
    height: 30px;
  }

  #features .ledger {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 0 18px 12px;
  }

  #features .fr {
    padding: 18px 0;
  }

  .landing-after-intro {
    background: radial-gradient(ellipse 90% 650px at 100% 24%, #280b182f, transparent), #080709;
  }

  .landing-after-intro > .feature-fireflies {
    opacity: .45;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  #features .grp,
  #features .grp__t::before {
    transition: none;
  }

  #features .drop *,
  #features .drop *::before,
  #features .drop *::after {
    animation-delay: 0s !important;
  }

  #features .spark path {
    stroke-dashoffset: 0;
  }
}
