/* Turnkey bookkeeping, unfolded from its line in the accounting card, plus the mission's three
   promises. The sheet is a letter folded in three (FoldingSheet): the middle panel is what you
   do, the top panel unfolds upward and the bottom one downward. Origami paper is white on the
   face and coloured on the back, so a fold shows fern (top) or brass (bottom). */

/* ─── The mission's three promises (approach section) ─── */

.mission__promises {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  counter-reset: promise;
}

.mission__promises li {
  display: grid;
  grid-template-columns: var(--space-6) 1fr;
  align-items: baseline;
  counter-increment: promise;
  line-height: 1.5;
}

.mission__promises li::before {
  content: counter(promise) ".";
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-style: italic;
  color: var(--color-primary);
}

/* ─── The highlighted line in the accounting card ─── */

.points .points__feature {
  padding-block: 3px;
}

.feature-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  margin-inline: calc(-1 * var(--space-2));
  padding: 4px var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--color-primary-subtle);
  color: var(--fern-700);
  font: 700 var(--text-sm) / 1.35 var(--font-body);
  text-align: left;
  cursor: pointer;
  width: calc(100% + 2 * var(--space-2));
  transition: background-color var(--duration-hover) ease, color var(--duration-hover) ease;
}

/* A tiny folded corner: it lifts when the line is hovered, inviting the sheet to unfold. */
.feature-link::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: linear-gradient(225deg, var(--fern-500), var(--fern-700));
  clip-path: polygon(0 0, 100% 100%, 0 100%);
  border-bottom-left-radius: 2px;
  transform: scale(0.6);
  transform-origin: 100% 0;
  transition: transform var(--duration-base) var(--ease-fold);
}

.feature-link__icon {
  flex: none;
  width: 18px;
  height: 18px;
  margin-left: auto;
  transition: transform var(--duration-base) var(--ease-fold);
}

.feature-link:hover,
.feature-link:focus-visible {
  background: color-mix(in srgb, var(--fern-300) 26%, var(--paper-050));
  color: var(--moss-900);
}

.feature-link:hover::after,
.feature-link:focus-visible::after {
  transform: scale(1.4);
}

.feature-link:hover .feature-link__icon,
.feature-link:focus-visible .feature-link__icon {
  transform: translateY(-1px) scale(1.08);
}

@media (max-width: 820px), (pointer: coarse) {
  .feature-link {
    min-height: var(--size-touch);
  }
}

.feature-link[aria-expanded="true"] {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
}

/* ─── The dialog ─── */

:root:has(.qb[open]) {
  overflow: hidden;
}

.qb {
  width: min(70rem, 100vw - 2 * var(--gutter));
  max-width: none;
  max-height: 100dvh;
  margin: auto;
  padding: var(--space-6) 0;
  overflow: visible auto;
  overscroll-behavior: contain;
  border: 0;
  background: transparent;
  color: var(--color-text);
  perspective: 2400px;
  scrollbar-width: none;
}

.qb::backdrop {
  background: color-mix(in srgb, var(--ink-900) 48%, transparent);
  backdrop-filter: blur(2px);
}

.qb__sheet {
  position: relative;
  display: grid;
  grid-auto-rows: 1fr;
  transform-style: preserve-3d;
  transform-origin: 50% 50%;
}

.qb__panel {
  position: relative;
  transform-style: preserve-3d;
}

/* Front faces are paper; the crease shading sits where the panels meet. */
.qb__face,
.qb__panel--you {
  background: var(--color-surface);
  backface-visibility: hidden;
}

.qb__face {
  position: relative;
  height: 100%;
}

.qb__panel--top {
  transform-origin: 50% 100%;
}

.qb__panel--top .qb__face {
  border-radius: var(--paper-radius) var(--paper-radius) 0 0;
  box-shadow: inset 0 -14px 14px -14px color-mix(in srgb, var(--shadow-ink) 16%, transparent);
}

.qb__panel--you {
  box-shadow: inset 0 14px 14px -14px color-mix(in srgb, var(--shadow-ink) 12%, transparent), inset 0 -14px 14px -14px color-mix(in srgb, var(--shadow-ink) 12%, transparent);
}

.qb__panel--bottom {
  transform-origin: 50% 0;
}

.qb__panel--bottom .qb__face {
  border-radius: 0 0 var(--paper-radius) var(--paper-radius);
  box-shadow: inset 0 14px 14px -14px color-mix(in srgb, var(--shadow-ink) 16%, transparent);
}

/* The whole letter casts one soft shadow on the page below it. */
.qb__sheet::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: var(--paper-radius);
  box-shadow: 0 30px 60px -28px color-mix(in srgb, var(--shadow-ink) 60%, transparent);
  transform: translateZ(-2px);
}

/* The coloured back of a fold. */
.qb__back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  transform: rotateX(180deg);
}

.qb__panel--top .qb__back {
  background: linear-gradient(170deg, var(--fern-500), var(--fern-700));
}

.qb__panel--bottom .qb__back {
  background: linear-gradient(10deg, var(--brass-400), var(--brass-600));
}

/* Darkens a face while it is turned away from the light, mid-fold (animated by FoldingSheet). */
.qb__shade {
  position: absolute;
  inset: 0;
  background: var(--ink-900);
  opacity: 0;
  pointer-events: none;
}

/* ─── Top panel: the title and the bank feed ─── */

.qb__panel--top .qb__face {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
  align-items: center;
  gap: var(--space-7);
  padding: var(--space-7) var(--space-7) var(--space-6);
}

.qb__title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 1.2rem + 1.6vw, 2.75rem);
  font-weight: 400;
  line-height: 1.08;
  text-wrap: balance;
}

.qb__title em {
  display: block;
  font-family: var(--font-serif);
  color: var(--color-primary);
}

.qb__sync {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(3rem, 0.6fr) auto;
  align-items: center;
  gap: var(--space-4);
}

.qb__bank {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-sm);
  line-height: 1.45;
  color: var(--color-text-secondary);
}

.qb__bank-art {
  position: relative;
  width: 64px;
  margin-right: var(--space-4);
}

.qb__clock {
  position: absolute;
  top: -20px;
  right: -20px;
  display: grid;
  justify-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-accent-text);
}

.qb__clock .qb-icon {
  width: 26px;
  height: 26px;
}

.qb__flow {
  width: 100%;
  height: 24px;
  overflow: visible;
}

.qb__flow path {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 2;
  stroke-dasharray: 5 5;
  vector-effect: non-scaling-stroke;
}

.qb__flow .qb__flow-head {
  stroke-dasharray: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.qb__hub {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--fern-700);
}

/* ─── The icons: flat paper facets in four tones ─── */

.qb-icon {
  width: 44px;
  height: 44px;
  flex: none;
}

.qb-icon--lg {
  width: 64px;
  height: 64px;
}

.qb-icon--hub {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 6px 6px color-mix(in srgb, var(--shadow-ink) 18%, transparent));
}

/* No ancestor in these selectors: the shapes are matched where they are drawn, inside the
   <symbol>s, not under the <use> that shows them. */
.qb-t1 { fill: var(--fern-600); }
.qb-t2 { fill: var(--fern-700); }
.qb-t3 { fill: var(--brass-400); }
.qb-t4 { fill: var(--paper-200); }

/* ─── You / We ─── */

.qb__panel--you,
.qb__panel--bottom .qb__face {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  align-content: center;
  column-gap: var(--space-6);
  padding: var(--space-6) var(--space-7);
}

.qb__panel--you {
  --who: var(--color-accent-text);
  --num-bg: var(--brass-600);
}

.qb__panel--bottom {
  --who: var(--color-primary);
  --num-bg: var(--fern-600);
}

.qb__who {
  align-self: start;
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 400;
  line-height: 1;
  color: var(--who);
}

.qb__steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-5);
}

.qb__steps--we {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.qb__step {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "num icon"
    "text text";
  align-content: start;
  align-items: center;
  gap: var(--space-3) var(--space-2);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.qb__step > span:last-child {
  grid-area: text;
  align-self: start;
}

/* The dashed path that runs from one step to the next. */
.qb__step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 22px;
  left: calc(28px + 44px + var(--space-3));
  right: calc(-1 * var(--space-5) + var(--space-2));
  border-top: 2px dashed color-mix(in srgb, var(--num-bg) 55%, transparent);
}

.qb__num {
  grid-area: num;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--num-bg);
  color: var(--paper-050);
  font-size: var(--text-xs);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 2px 3px color-mix(in srgb, var(--shadow-ink) 22%, transparent);
}

.qb__step .qb-icon {
  grid-area: icon;
}

.qb__month-end {
  margin-top: var(--space-1);
  padding-left: 1.1em;
  list-style: decimal;
  color: var(--color-text-secondary);
}

/* The line where your work stops: a cut across the page, with a stop sign at its end. */
.qb__stop {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-6);
  font-family: var(--font-serif);
  font-size: var(--text-lg);
  font-style: italic;
  white-space: nowrap;
}

.qb__stop::before {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--color-text);
  order: -1;
}

.qb__stop-sign {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: var(--signal-red);
  color: var(--paper-050);
  font: 700 10px / 1 var(--font-body);
  font-style: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%);
}

.qb__plus {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-sm);
}

.qb__plus .qb-icon {
  width: 36px;
  height: 36px;
}

.qb__plus strong {
  color: var(--color-accent-text);
}

.qb__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 2;
  display: grid;
  place-items: center;
  width: var(--size-touch);
  height: var(--size-touch);
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  transform: translateZ(4px);
  transition: background-color var(--duration-hover) ease, opacity var(--duration-base) ease;
}

.qb__close svg {
  width: 22px;
  height: 22px;
}

.qb__close:hover {
  background: var(--color-surface-sunken);
}

.qb:not([data-state="open"]) .qb__close {
  opacity: 0;
  pointer-events: none;
}

/* ─── Narrower screens: the steps stack; panels keep their own height ─── */

@media (max-width: 1023px) {
  .qb__sheet {
    grid-auto-rows: auto;
  }

  .qb__panel--top .qb__face {
    grid-template-columns: 1fr;
    gap: var(--space-5);
    padding: var(--space-7) var(--space-5) var(--space-5);
  }

  .qb__panel--you,
  .qb__panel--bottom .qb__face {
    grid-template-columns: 1fr;
    row-gap: var(--space-4);
    padding: var(--space-5);
  }

  .qb__steps,
  .qb__steps--we {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .qb__step {
    grid-template-columns: auto auto 1fr;
    grid-template-areas: "num icon text";
  }

  .qb__step:not(:last-child)::after {
    content: none;
  }

  .qb__stop {
    white-space: normal;
    font-size: var(--text-base);
  }

  .qb__plus {
    grid-column: 1;
  }
}

@media (max-width: 520px) {
  .qb {
    width: calc(100vw - 2 * var(--space-3));
    padding-block: var(--space-3);
  }

  .qb__sync {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .qb__flow {
    display: none;
  }
}
