/* Mistakes: Chapter 1 as a hand of playing cards. Dealt in, draggable with inertia, the seventh card sealed in gold wax.
   Without JS (or if scripts never start) the rail is a native horizontal scroller with snap points. */
.sec.mistakes {
  --rail-pad: max(var(--gutter), calc((100% - var(--wrap)) / 2 + var(--gutter)));
  --card-w: clamp(280px, 25vw, 360px);
  --card-h: clamp(430px, 54vh, 470px);
  --card-paper: #FBF8F1;
  padding: clamp(60px, 6.5vw, 84px) 0 clamp(56px, 6vw, 80px);
  overflow: clip;
  isolation: isolate;
}
.mistakes__arc { position: absolute; left: 0; top: 30%; width: 100%; height: 66%; z-index: -1; pointer-events: none; overflow: visible; }
.mistakes__arc-path { fill: none; stroke: var(--gold-deep); stroke-width: 1.4; stroke-opacity: .55; vector-effect: non-scaling-stroke; }

.mistakes__head { position: relative; }
.mistakes__bar { margin-top: 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px 48px; }
.mistakes__lede { flex: 1 1 auto; }
.mistakes__controls { flex: none; display: flex; align-items: center; gap: 14px; }
.mistakes__count { font-family: var(--f-display); color: var(--ink-soft); font-size: 1.05rem; white-space: nowrap; margin-right: 6px; font-variant-numeric: tabular-nums lining-nums; }
.mistakes__count-now { display: inline-block; min-width: .7em; font-size: 2.1rem; font-weight: 600; color: var(--ink); line-height: 1; vertical-align: -0.12em; }
.mistakes__progress { position: relative; width: clamp(90px, 10vw, 150px); height: 2px; background: rgba(24, 32, 47, .14); margin-right: 8px; }
.mistakes__progress-fill { position: absolute; inset: 0; background: var(--gold-deep); transform-origin: left; transform: scaleX(.142857); }
.mistakes__btn {
  width: 52px; height: 52px; display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--ink); border: 1px solid rgba(24, 32, 47, .35); border-radius: var(--r-btn);
  transition: background-color .35s var(--ease-out), color .35s var(--ease-out), border-color .35s, opacity .35s;
}
.mistakes__btn svg { width: 20px; height: 20px; }
.mistakes__btn:hover, .mistakes__btn:focus-visible { background: var(--ink); color: var(--ivory); border-color: var(--ink); }
.mistakes__btn[disabled] { opacity: .35; cursor: default; pointer-events: none; }

/* the rail: native scroller by default */
.mistakes__rail {
  position: relative; margin-top: clamp(14px, 2vh, 24px);
  padding: 22px var(--rail-pad) 34px;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-left: var(--rail-pad);
  outline: none;
}
.mistakes__rail:focus-visible { outline: 2px solid var(--gold-deep); outline-offset: -6px; }
.mistakes__track { display: flex; gap: clamp(18px, 1.8vw, 28px); width: max-content; }
.mistakes__card { flex: none; width: var(--card-w); height: var(--card-h); scroll-snap-align: start; perspective: 1400px; }
.mistakes__tilt, .mistakes__flip { position: relative; height: 100%; transform-style: preserve-3d; }
.mistakes__face { position: absolute; inset: 0; border-radius: var(--r-surface); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.mistakes__back { display: none; transform: rotateY(180deg); }

/* deck mode (JS running): the deck hangs off the right edge and is dragged */
.js:not(.oc-fallback) .mistakes__rail { overflow-x: clip; overflow-y: visible; }
.mistakes.is-deck .mistakes__rail { overflow-x: clip; overflow-y: visible; scroll-snap-type: none; }
.mistakes.is-deck .mistakes__back { display: block; }
.mistakes.is-deck .mistakes__track { cursor: grab; touch-action: pan-y; }
/* a long empty run after the last card keeps the track far wider than the screen (the rail clips it);
   the drag bounds and the counter stop at the last card, not at the end of this run */
.mistakes.is-deck .mistakes__track { padding-right: max(100vw, 1200px); }
.mistakes.is-deck .mistakes__track:active { cursor: grabbing; }

/* the card face: cream stock, the cover's dotted gold border, playing-card indices */
.mistakes__front {
  display: flex; flex-direction: column; overflow: hidden;
  padding: 84px clamp(26px, 2.4vw, 36px) 58px;
  background: var(--card-paper); color: var(--ink);
  box-shadow: 0 1px 0 rgba(24, 32, 47, .08), 0 18px 40px -22px rgba(24, 32, 47, .45), 0 40px 80px -50px rgba(24, 32, 47, .4);
  transition: box-shadow .6s var(--ease-out);
}
.mistakes__front::before { content: ''; position: absolute; inset: 12px; border: 1px dotted rgba(184, 135, 58, .75); pointer-events: none; }
.mistakes__front::after {
  content: ''; position: absolute; left: 12px; right: 12px; top: 12px; height: 3px; background: var(--gold);
  transform: scaleX(0); transform-origin: left; transition: transform .8s var(--ease-out);
}
.mistakes__card.is-active .mistakes__front::after { transform: scaleX(1); }
.mistakes__card.is-active .mistakes__front { box-shadow: 0 1px 0 rgba(24, 32, 47, .08), 0 26px 50px -24px rgba(24, 32, 47, .55), 0 60px 90px -50px rgba(24, 32, 47, .5); }
.mistakes__index { position: absolute; left: 26px; top: 24px; display: flex; flex-direction: column; align-items: center; gap: 6px; line-height: 1; }
.mistakes__index b { font-family: var(--f-display); font-weight: 600; font-size: 2rem; color: var(--ink); }
.mistakes__index i { width: 9px; height: 9px; background: var(--gold-deep); transform: rotate(45deg); }
.mistakes__index--foot { left: auto; top: auto; right: 26px; bottom: 24px; transform: rotate(180deg); }
.mistakes__pip {
  position: absolute; right: -.06em; top: 41%; transform: translateY(-50%);
  font-family: var(--f-display); font-style: italic; font-weight: 600; font-size: clamp(13rem, 19vw, 19rem); line-height: 1;
  color: transparent; -webkit-text-stroke: 1.2px rgba(184, 135, 58, .42); pointer-events: none;
}
.mistakes__title { position: relative; font-family: var(--f-display); font-weight: 600; font-size: clamp(1.3rem, 1.6vw, 1.55rem); line-height: 1.2; color: var(--ink); }
.mistakes__quote { position: relative; margin: auto 0 0; padding-top: 20px; }
.mistakes__quote::before { content: ''; position: absolute; left: 0; top: 0; width: 46px; height: 1px; background: var(--gold-deep); }
.mistakes__quote p { font-family: var(--f-display); font-style: italic; font-weight: 400; font-size: 1.12rem; line-height: 1.5; color: var(--ink-soft); }
.mistakes__quote footer { margin-top: 12px; font-size: 1rem; font-weight: 600; color: var(--ink-soft); display: flex; align-items: center; gap: 10px; }
.mistakes__quote footer::before { content: ''; width: 7px; height: 7px; background: var(--gold-deep); transform: rotate(45deg); flex: none; }
.mistakes__glare {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .5s;
  background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, .7), rgba(255, 255, 255, 0) 46%);
  mix-blend-mode: soft-light;
}
.mistakes__card:hover .mistakes__glare { opacity: 1; }

/* the sealed seventh card */
.mistakes__sealed {
  align-items: center; text-align: center; padding-top: 64px; padding-bottom: 52px; color: var(--mist);
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(226, 176, 98, .16), rgba(226, 176, 98, 0) 60%),
    radial-gradient(90% 60% at 50% 110%, rgba(59, 127, 224, .22), rgba(59, 127, 224, 0) 70%),
    var(--night);
}
.mistakes__sealed::before { border-color: rgba(226, 176, 98, .8); }
.mistakes__sealed .mistakes__index b { color: var(--gold); }
.mistakes__sealed .mistakes__index i { background: var(--gold); }
.mistakes__seal { width: clamp(96px, 8vw, 116px); height: auto; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .45)); flex: none; }
.mistakes__sealed .mistakes__title { color: var(--white); margin-top: 18px; }
.mistakes__sealed-text { margin-top: 10px; font-size: 1rem; line-height: 1.55; color: var(--mist); }
.mistakes__sealed-ctas { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.mistakes__sealed-ctas .btn { min-height: 48px; padding: 0 20px; }
.mistakes__buy { display: inline-flex; align-items: center; min-height: 44px; color: var(--gold); font-weight: 600; font-size: 1rem; text-decoration: none; padding: 10px 4px; background: linear-gradient(var(--gold), var(--gold)) 0 100% / 0 1px no-repeat; transition: background-size .5s var(--ease-out); }
.mistakes__buy:hover, .mistakes__buy:focus-visible { background-size: 100% 1px; }
.mistakes__glint {
  position: absolute; inset: -10% -60%; pointer-events: none; opacity: 0;
  background: linear-gradient(105deg, rgba(255, 236, 190, 0) 42%, rgba(255, 236, 190, .28) 49%, rgba(255, 255, 255, .5) 50%, rgba(255, 236, 190, .28) 51%, rgba(255, 236, 190, 0) 58%);
  mix-blend-mode: screen;
}

/* card backs (only seen while dealing) */
.mistakes__back {
  background:
    repeating-linear-gradient(45deg, rgba(226, 176, 98, .16) 0 1px, transparent 1px 18px),
    repeating-linear-gradient(-45deg, rgba(226, 176, 98, .16) 0 1px, transparent 1px 18px),
    var(--navy);
  box-shadow: 0 20px 40px -24px rgba(6, 11, 24, .6);
}
.mistakes__back::before { content: ''; position: absolute; inset: 12px; border: 1px dotted rgba(226, 176, 98, .8); }
.mistakes__back span { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 1.5px solid var(--gold); transform: rotate(45deg); background: var(--navy); }
.mistakes__back span::after { content: ''; position: absolute; inset: 16px; background: var(--gold); }

@media (max-width: 900px) {
  .mistakes__bar { flex-direction: column; align-items: stretch; }
  .mistakes__controls { justify-content: flex-start; }
  .mistakes__progress { flex: 1 1 auto; width: auto; }
}
@media (max-width: 760px) {
  .sec.mistakes { --card-w: min(300px, 78vw); --card-h: 450px; }
  .mistakes__rail { padding-top: 16px; padding-bottom: 26px; }
  .mistakes__pip { font-size: 13rem; }
}

/* without scripts the rail scrolls natively, so the step controls have nothing to drive */
.no-js .mistakes__controls, .oc-fallback .mistakes__controls { display: none; }

/* the parallax wrapper spans the whole track, so the clipping rail sits directly above a row wider than the screen */
.mistakes__shift { width: max-content; }
