/* ============================================================
   QuantX Story Modules (Homepage)
   Three feature sections: QMT / Docs / Resources
   Theme-aware: adapts to light/dark via CSS variables
   ============================================================ */

/* ---- Story section ---- */
.story {
  border-bottom: 1px solid var(--color-border-subtle);
}
.story:last-child { border-bottom: 0; }

.story-inner {
  width: min(1100px, calc(100% - 64px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 36px;
  padding: 48px 0;
}

.copy {
  min-width: 0;
  max-width: 650px;
}
.story.reverse .copy { order: 2; }
.story.reverse .visual { order: 1; }

/* ---- Headings ---- */
.story h2 {
  margin: 0;
  max-width: 620px;
  font-size: 36px;
  line-height: 1.04;
  letter-spacing: -.055em;
  font-weight: 520;
  color: var(--color-text-emphasis);
}

.story .lead {
  margin: 12px 0 0;
  max-width: 620px;
  color: var(--color-text-secondary);
  font-size: 15px;
  line-height: 1.65;
  letter-spacing: -.01em;
}

/* ---- Accordion ---- */
.accordion {
  width: 100%;
  max-width: 620px;
  margin-top: 20px;
  border-top: 1px solid var(--color-border);
}

.accordion-item {
  border-bottom: 1px solid var(--color-border);
}

.accordion-trigger {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 10px 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--color-text-emphasis);
}

.accordion-trigger span:first-child {
  min-width: 0;
  font-size: 15px;
  line-height: 1.35;
  font-weight: 560;
}

.symbol {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: grid;
  place-items: center;
  font-size: 26px;
  line-height: 1;
  font-weight: 300;
  transform: translateY(-1px);
  color: var(--color-text-secondary);
}

.accordion-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows .3s ease, opacity .3s ease;
}

.accordion-item.open .accordion-panel {
  grid-template-rows: 1fr;
  opacity: 1;
}

.accordion-panel > div {
  overflow: hidden;
}

.accordion-panel p {
  margin: 0;
  padding: 0 36px 18px 0;
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.72;
}

/* ---- CTA buttons ---- */
.cta-row {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.cta {
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--color-background-primary-solid);
  color: var(--color-surface);
  text-decoration: none;
  font-size: 14px;
  font-weight: 560;
  transition: transform .18s ease, background .18s ease;
}
.cta:hover { transform: translateY(-1px); background: var(--color-background-primary-solid-hover); }
.cta.secondary {
  background: var(--color-background-primary-soft);
  color: var(--color-text-emphasis);
}
.cta.secondary:hover { background: var(--color-border); }

.arrow {
  width: 16px;
  height: 16px;
  transition: transform .18s ease;
}
.cta:hover .arrow { transform: translateX(3px); }
.cta.external:hover .arrow { transform: translate(2px, -2px); }

/* ---- Visual container ---- */
.visual {
  min-width: 0;
  position: relative;
  aspect-ratio: 1/1;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  box-shadow: 0 22px 60px -46px rgba(20, 20, 20, .28);
  background:
    radial-gradient(circle at 76% 10%, rgba(255,255,255,.72), transparent 26%),
    radial-gradient(circle at 18% 22%, rgba(214,207,196,.78), transparent 34%),
    radial-gradient(circle at 62% 86%, rgba(110,114,122,.44), transparent 38%),
    linear-gradient(145deg, #7f848c 0%, #d9d7d2 42%, #2f3136 100%);
}

[data-theme="dark"] .visual {
  box-shadow: 0 22px 60px -46px rgba(0, 0, 0, .5);
}

.visual::before {
  content: "";
  position: absolute;
  inset: -16%;
  background:
    radial-gradient(circle at 80% 18%, rgba(255,255,255,.48), transparent 26%),
    radial-gradient(circle at 16% 28%, rgba(186,176,163,.42), transparent 34%),
    radial-gradient(circle at 54% 84%, rgba(54,57,63,.36), transparent 38%);
  filter: blur(34px);
  transform: scale(1.08);
}

.visual-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.mock-window {
  position: relative;
  z-index: 2;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, .05);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 55px rgba(29, 24, 72, .22);
}

/* ---- Module 1: QMT window ---- */
.qmt-window {
  width: 58%;
  height: 84%;
  display: flex;
  flex-direction: column;
  background: #171717;
  color: #f7f7f7;
}

.mini-top {
  height: 42px;
  flex: 0 0 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  font-size: 13px;
}
.mini-dots { display: flex; gap: 5px; }
.mini-dots i { width: 7px; height: 7px; border-radius: 50%; background: #6d6d6d; }
.mini-dots i:first-child { background: #ff6259; }
.mini-dots i:nth-child(2) { background: #ffbd2e; }
.mini-dots i:nth-child(3) { background: #28c840; }

.qmt-body {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 18px 18px 14px;
}

.qmt-query {
  align-self: flex-end;
  max-width: 78%;
  padding: 11px 13px;
  border-radius: 16px 16px 4px 16px;
  background: #272727;
  font-size: 12px;
  line-height: 1.55;
}

.qmt-answer {
  margin-top: 18px;
  color: #e6e6e6;
  font-size: 11.5px;
  line-height: 1.65;
}

.qmt-code {
  margin-top: 14px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px;
  background: #111;
  color: #dfdfdc;
  font: 10.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.qmt-composer {
  margin-top: auto;
  min-height: 72px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 14px;
  background: #202020;
  color: #878787;
  font-size: 11px;
}

.play {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, .36);
  border-radius: 50%;
  background: rgba(31, 31, 31, .62);
  color: #fff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .18);
  backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
}
.visual:hover .play {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.03);
}
.play svg { width: 20px; height: 20px; margin-left: 2px; }

/* ---- Module 2: Docs window ---- */
.docs-window {
  width: 90%;
  height: 72%;
  display: grid;
  grid-template-columns: 26% 74%;
  color: #202124;
}
.docs-sidebar {
  padding: 18px 14px;
  border-right: 1px solid #e7e7e7;
  background: #f8f8f8;
}
.docs-brand { font-size: 13px; font-weight: 700; margin-bottom: 18px; }
.docs-nav { display: grid; gap: 8px; }
.docs-nav span {
  height: 23px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 6px;
  color: #5f6368;
  font-size: 9px;
}
.docs-nav span.active {
  background: #ececec;
  color: #202124;
  font-weight: 600;
}
.docs-main { padding: 17px 19px; background: #fff; }
.docs-breadcrumb { color: #777; font-size: 8.5px; }
.docs-main h3 { margin: 11px 0 5px; font-size: 17px; line-height: 1.25; }
.docs-main p { margin: 0 0 12px; color: #666; font-size: 8.7px; line-height: 1.6; }
.api-card { overflow: hidden; border: 1px solid #e4e4e4; border-radius: 7px; }
.api-head {
  height: 29px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-bottom: 1px solid #e5e5e5;
  background: #fafafa;
  font-size: 8.6px;
  font-weight: 600;
}
.api-code {
  padding: 11px;
  background: #181818;
  color: #e7e7e7;
  font: 8px/1.65 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ---- Module 3: Resource window ---- */
.resource-window {
  width: 90%;
  height: 70%;
  display: grid;
  grid-template-columns: 28% 72%;
  background: #fff;
  color: #202124;
}
.resource-left {
  padding: 16px 13px;
  border-right: 1px solid #e7e7e7;
  background: #f7f7f7;
}
.resource-left h4 { margin: 0 0 15px; font-size: 13px; }
.resource-left div {
  height: 24px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 6px;
  color: #656565;
  font-size: 8.7px;
}
.resource-left div.active {
  background: #e9e9e9;
  color: #202020;
  font-weight: 600;
}
.resource-main { padding: 15px; }
.resource-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.resource-titlebar strong { font-size: 12px; }
.resource-titlebar span { color: #777; font-size: 8px; }
.resource-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.resource-card {
  overflow: hidden;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  background: #fff;
}
.thumb {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, rgba(255, 255, 255, .14), transparent), #1e1e1e;
  position: relative;
}
.thumb::before {
  content: "";
  position: absolute;
  inset: 17% 12%;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 5px;
  background:
    linear-gradient(90deg, transparent 0 12%, rgba(255, 255, 255, .08) 12% 13%, transparent 13%),
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, .09) 0 1px, transparent 1px 8px);
}
.resource-card p {
  margin: 0;
  padding: 8px 9px 9px;
  color: #333;
  font-size: 8.5px;
  line-height: 1.35;
}

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .story-inner {
    width: min(1100px, calc(100% - 48px));
    grid-template-columns: 1fr;
    gap: 32px;
    padding: 40px 0;
  }
  .story.reverse .copy,
  .story.reverse .visual { order: initial; }
  .copy { max-width: none; }
  .story h2 { font-size: 36px; }
  .story .lead { font-size: 17px; }
}

@media (max-width: 640px) {
  .story-inner {
    width: calc(100% - 32px);
    padding: 36px 0;
    gap: 28px;
  }
  .story h2 { font-size: 30px; }
  .story .lead {
    margin-top: 16px;
    font-size: 15px;
    line-height: 1.7;
  }
  .accordion { margin-top: 24px; }
  .accordion-trigger {
    min-height: 60px;
    padding: 10px 0;
  }
  .accordion-trigger span:first-child { font-size: 15px; }
  .accordion-panel p { font-size: 13px; }
  .visual { border-radius: 14px; }
  .qmt-window { width: 64%; height: 82%; }
}

