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81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
import { motion, useScroll, useTransform, type MotionValue } from "framer-motion";
import { useEffect, useRef, useState } from "react";
import { Link, useNavigate } from "react-router-dom";

import LangToggle from "../components/LangToggle";
import { useT } from "../i18n";
import "./presentation.css";

type Progress = MotionValue<number>;
type Range = [number, number];

const TEAM = [
  { roleKey: "tower1", name: "Txema Puch" },
  { roleKey: "pilot", name: "Mónica Gómez" },
  { roleKey: "tower2", name: "Roberto Molero" },
] as const;

const MOBILE_BREAKPOINT_QUERY = "(max-width: 900px)";

function useIsMobile(): boolean {
  const [isMobile, setIsMobile] = useState(false);
  useEffect(() => {
    if (typeof window === "undefined" || !window.matchMedia) return;
    const mql = window.matchMedia(MOBILE_BREAKPOINT_QUERY);
    const update = () => setIsMobile(mql.matches);
    update();
    mql.addEventListener("change", update);
    return () => mql.removeEventListener("change", update);
  }, []);
  return isMobile;
}

function useReveal(progress: Progress, range: Range, first = false): MotionValue<number> {
  const [start, end] = range;
  const pad = Math.min(0.04, (end - start) / 3);
  if (first) {
    return useTransform(progress, [start, end - pad, end], [1, 1, 0]);
  }
  return useTransform(progress, [start, start + pad, end - pad, end], [0, 1, 1, 0]);
}

function ImageScene({
  progress,
  range,
  image,
  kicker,
  title,
  sub,
  first,
}: {
  progress: Progress;
  range: Range;
  image: string;
  kicker: string;
  title: string;
  sub?: string;
  first?: boolean;
}) {
  const opacity = useReveal(progress, range, first);
  return (
    <motion.div className="scene" style={{ opacity, backgroundImage: `url(/presentation/${image})` }}>
      <div className="scene__veil" />
      <div className="scene__text">
        <div className="scene__kicker">{kicker}</div>
        <h2 className="scene__title">{title}</h2>
        {sub && <p className="scene__sub">{sub}</p>}
      </div>
    </motion.div>
  );
}

function WindowScene({
  progress,
  range,
  closing,
  kicker,
  title,
}: {
  progress: Progress;
  range: Range;
  closing: boolean;
  kicker: string;
  title: string;
}) {
  const opacity = useReveal(progress, range);
  const shadeFrom: Range = [range[0] + 0.02, range[0] + 0.07];
  const shadeY = useTransform(progress, shadeFrom, closing ? ["-100%", "0%"] : ["0%", "-100%"]);
  return (
    <motion.div className="scene" style={{ opacity, backgroundImage: "url(/presentation/window.jpg)" }}>
      <div className="scene__veil" />
      <motion.div className="scene__shade" style={{ y: shadeY }} />
      <div className="scene__text">
        <div className="scene__kicker">{kicker}</div>
        <h2 className="scene__title">{title}</h2>
      </div>
    </motion.div>
  );
}

function ExplainPanel({
  progress,
  range,
  title,
  body,
}: {
  progress: Progress;
  range: Range;
  title: string;
  body: string;
}) {
  const opacity = useReveal(progress, range);
  const y = useTransform(progress, range, [28, -28]);
  return (
    <motion.div className="explain__panel" style={{ opacity, y }}>
      <h3>{title}</h3>
      <p>{body}</p>
    </motion.div>
  );
}

function Explain({
  progress,
  range,
  panelRanges,
  header,
  panels,
}: {
  progress: Progress;
  range: Range;
  panelRanges: Range[];
  header: string;
  panels: { title: string; body: string }[];
}) {
  const opacity = useReveal(progress, range);
  return (
    <motion.div className="scene" style={{ opacity, backgroundImage: "url(/presentation/console.jpg)" }}>
      <div className="scene__veil" />
      <div className="explain__header">{header}</div>
      <div className="explain">
        {panels.map((panel, index) => (
          <ExplainPanel
            key={index}
            progress={progress}
            range={panelRanges[index]}
            title={panel.title}
            body={panel.body}
          />
        ))}
      </div>
    </motion.div>
  );
}

const INTRO_PANEL_RANGES: Range[] = [
  [0.51, 0.62],
  [0.62, 0.74],
  [0.74, 0.86],
];

export default function Presentation() {
  const t = useT();
  const s = t.scenes;
  const trackRef = useRef<HTMLDivElement>(null);
  const navigate = useNavigate();
  const handedOffRef = useRef(false);
  const { scrollYProgress } = useScroll({
    target: trackRef,
    offset: ["start start", "end end"],
  });

  useEffect(() => {
    const unsub = scrollYProgress.on("change", (value) => {
      if (value > 0.96 && !handedOffRef.current) {
        handedOffRef.current = true;
        navigate("/dashboard");
      }
    });
    return () => unsub();
  }, [scrollYProgress, navigate]);

  return (
    <div className="presentation">
      <motion.div
        className="presentation__progress"
        style={{ scaleX: scrollYProgress, width: "100%" }}
      />
      <div className="presentation__skip" style={{ display: "flex", gap: 8 }}>
        <LangToggle />
        <Link to="/dashboard">
          <button>{s.skip}</button>
        </Link>
      </div>
      <div className="presentation__track" ref={trackRef}>
        <div className="stage">
          <ImageScene
            progress={scrollYProgress}
            range={[0, 0.14]}
            first
            image="terminal.jpg"
            kicker={s.terminal.kicker}
            title={s.terminal.title}
            sub={s.terminal.sub}
          />
          <ImageScene
            progress={scrollYProgress}
            range={[0.13, 0.28]}
            image="jetbridge.jpg"
            kicker={s.jetbridge.kicker}
            title={s.jetbridge.title}
          />
          <ImageScene
            progress={scrollYProgress}
            range={[0.27, 0.42]}
            image="cabin.jpg"
            kicker={s.cabin.kicker}
            title={s.cabin.title}
            sub={s.cabin.sub}
          />
          <WindowScene
            progress={scrollYProgress}
            range={[0.41, 0.52]}
            closing
            kicker={s.closing.kicker}
            title={s.closing.title}
          />
          <Explain
            progress={scrollYProgress}
            range={[0.5, 0.92]}
            panelRanges={INTRO_PANEL_RANGES}
            header={s.explainHeader}
            panels={s.panels}
          />
        </div>
      </div>
    </div>
  );
}

export function PresentationFinal() {
  const t = useT();
  const s = t.scenes;
  const trackRef = useRef<HTMLDivElement>(null);
  const { scrollYProgress } = useScroll({
    target: trackRef,
    offset: ["start start", "end end"],
  });
  const [creditsVisible, setCreditsVisible] = useState(false);

  useEffect(() => {
    const unsub = scrollYProgress.on("change", (value) => {
      setCreditsVisible(value > 0.88);
    });
    return () => unsub();
  }, [scrollYProgress]);

  return (
    <div className="presentation">
      <motion.div
        className="presentation__progress"
        style={{ scaleX: scrollYProgress, width: "100%" }}
      />
      <div className="presentation__skip" style={{ display: "flex", gap: 8 }}>
        <LangToggle />
        <Link to="/dashboard">
          <button>{s.skip}</button>
        </Link>
      </div>
      <div className="presentation__track" ref={trackRef}>
        <div className="stage">
          <WindowScene
            progress={scrollYProgress}
            range={[0, 0.34]}
            closing={false}
            kicker={s.opening.kicker}
            title={s.opening.title}
          />
          <ImageScene
            progress={scrollYProgress}
            range={[0.33, 0.66]}
            image="leaving.jpg"
            kicker={s.leaving.kicker}
            title={s.leaving.title}
          />
          <Credits
            progress={scrollYProgress}
            range={[0.65, 1.0]}
            roles={s.ack.roles}
            teamHeader={s.ack.teamHeader}
            thanks={s.ack.thanks}
            subtitle={s.ack.subtitle}
            visible={creditsVisible}
          />
        </div>
      </div>
    </div>
  );
}

function Credits({
  progress,
  range,
  roles,
  teamHeader,
  thanks,
  subtitle,
  visible,
}: {
  progress: Progress;
  range: Range;
  roles: { tower1: string; pilot: string; tower2: string };
  teamHeader: string;
  thanks: string;
  subtitle: string;
  visible: boolean;
}) {
  const [start, end] = range;
  const pad = Math.min(0.04, (end - start) / 3);
  const opacity = useTransform(progress, [start, start + pad], [0, 1]);
  const textOpacity = useTransform(progress, [start + 0.03, start + 0.1], [0, 1]);
  const isMobile = useIsMobile();
  const roleFontSize = isMobile ? 11 : 12;
  const nameFontSize = isMobile ? 18 : 22;
  const teamBlockGap = isMobile ? 16 : 22;
  const logoWidth = isMobile ? "min(440px, 85vw)" : "min(440px, 70vw)";
  return (
    <motion.div
      className="scene"
      style={{ opacity, backgroundImage: "url(/presentation/acknowledgements.jpg)" }}
    >
      <div className="scene__veil" />
      <motion.div
        className="ack"
        style={{
          opacity: textOpacity,
          display: "flex",
          flexDirection: "column",
          alignItems: "center",
          gap: 18,
          textAlign: "center",
          padding: "24px",
        }}
      >
        <img
          src="/sadar-logo.png"
          alt="SADAR"
          className="radar-pulse"
          style={{ width: logoWidth, height: "auto", display: "block" }}
        />
        <p className="scene__sub" style={{ marginTop: 0 }}>{subtitle}</p>

        <div
          style={{
            marginTop: 24,
            fontFamily: "var(--mono)",
            fontSize: 13,
            letterSpacing: "0.32em",
            textTransform: "uppercase",
            color: "#ffffff",
            textShadow: "0 1px 6px rgba(0,0,0,0.85)",
          }}
        >
          {teamHeader}
        </div>

        <div
          style={{
            display: "flex",
            flexDirection: "column",
            gap: teamBlockGap,
            marginTop: 10,
            opacity: visible ? 1 : 0,
            transition: "opacity 600ms ease",
          }}
        >
          {TEAM.map((member, idx) => (
            <div key={idx} style={{ display: "flex", flexDirection: "column", gap: 6 }}>
              <div
                style={{
                  fontFamily: "var(--mono)",
                  fontSize: roleFontSize,
                  letterSpacing: "0.22em",
                  textTransform: "uppercase",
                  color: "#7fd1c6",
                  textShadow: "0 1px 5px rgba(0,0,0,0.85)",
                }}
              >
                {roles[member.roleKey]}
              </div>
              <div
                className="radar-name-pulse"
                style={{
                  fontFamily: "var(--mono)",
                  fontSize: nameFontSize,
                  letterSpacing: "0.1em",
                  color: "#ffffff",
                  animationDelay: `${idx * 0.4}s`,
                }}
              >
                {member.name}
              </div>
            </div>
          ))}
        </div>

        <div
          style={{
            marginTop: 32,
            fontFamily: "var(--mono)",
            fontSize: 16,
            letterSpacing: "0.2em",
            color: "#7fd1c6",
            textTransform: "uppercase",
            textShadow: "0 1px 6px rgba(0,0,0,0.85)",
          }}
        >
          {thanks}
        </div>
      </motion.div>
    </motion.div>
  );
}