/*
 * Rahmen der Web-Fassung des Onboardings. Die Masse folgen der App:
 *   lib/presentation/onboarding/page/onboard_view.dart      (Aufbau, Schritt-Icons, Abzeichen)
 *   lib/presentation/onboarding/widget/backward_forward.dart (Next/Back)
 *   lib/presentation/onboarding/widget/intro_page.dart       (Titel, Text)
 *   lib/common/theme/dimens.dart, app_text_theme.dart, app_color.dart
 * Aendert sich dort das Aussehen, muss diese Datei mit. "Telefon" heisst in der App: kuerzere Seite
 * unter 600 (Dimens.isPhone) -- hier dieselbe Grenze als Media-Bedingung.
 */
@font-face {
  font-family: "PTSerif";
  src: url("fonts/PTSerif-Bold.ttf") format("truetype");
  font-weight: 700 900;
  font-display: swap;
}
@font-face {
  font-family: "SourceSansPro";
  src: url("fonts/SourceSansPro-Regular.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "SourceSansPro";
  src: url("fonts/SourceSansPro-Semibold.otf") format("opentype");
  font-weight: 600;
  font-display: swap;
}

:root {
  --primary: #12477b;              /* AppColor.primaryColor */
  --primary-12: rgba(18, 71, 123, 0.12);
  --primary-15: rgba(18, 71, 123, 0.15);
  --primary-50: rgba(18, 71, 123, 0.5);
  --title: #1e2538;                /* AppColor.black */
  --text: #676766;                 /* AppColor.mainTextColor */
  --pad-h: 20px;                   /* Dimens.screenHPadding */
  --pad-v: 18px;                   /* Dimens.screenVPadding */
  --gap-section: 12px;             /* Dimens.sectionGap */
  --gap-nav: 24px;                 /* Dimens.navButtonGap */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #fff;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: "SourceSansPro", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
[hidden] { display: none !important; }

/* ---- Aufbau: oben die Tour, unten die Textbox (Column in onboard_view.dart) ---- */
.tour {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.stage-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  pointer-events: none;            /* die Tour laeuft von selbst, wie in der App */
  touch-action: none;
}

/* Abzeichen "Lido Sky Data": nur im ersten Schritt, oben rechts (_buildDataSourceBadge) */
.badge {
  position: absolute;
  top: calc(100vh * 43 / 1024);
  top: calc(100dvh * 43 / 1024);
  right: calc(100vw * 40 / 1366 + var(--safe-r));
  width: min(220px, calc(100vw * 220 / 1366));
  height: auto;
  aspect-ratio: 220 / 84.33;
  object-fit: contain;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.badge.is-shown { opacity: 1; }

.loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: #fff;
  color: var(--text);
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--primary-12);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Textbox (_buildBottomSheet) ---- */
.sheet {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 70%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--pad-v) calc(var(--pad-h) + var(--safe-r)) calc(var(--pad-v) + var(--safe-b)) calc(var(--pad-h) + var(--safe-l));
  background: rgba(255, 255, 255, 0.9);
  border-radius: 24px 24px 0 0;    /* Dimens.bottomSheetRadius */
}

/* Alle vier Texte liegen in derselben Zelle: die Box ist so hoch wie der laengste (wie
   _measuredIntroHeight) und springt beim Weiterschalten nicht. */
.pages {
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
  display: grid;
  overflow-y: auto;
  scrollbar-width: none;
}
.pages::-webkit-scrollbar { display: none; }
.page {
  grid-area: 1 / 1;
  justify-self: center;
  width: 100%;
  max-width: 640px;                /* Dimens.introContentMaxWidth */
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translateX(24px);
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out, visibility 0s linear 0.3s;
}
.page.is-before { transform: translateX(-24px); }
.page.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
}
.page-title {
  margin: 0;
  font-family: "PTSerif", Georgia, "Times New Roman", serif;
  font-weight: 800;
  font-size: 24px;
  line-height: 1;
  color: var(--title);
}
.page-text {
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.4;
  white-space: pre-line;           /* die Texte der App tragen Zeilenumbrueche */
  color: var(--text);
}

/* ---- Bedienzeile (_buildNavigationControls) ---- */
.nav-fit {
  flex: none;
  width: 100%;
  margin-top: var(--gap-section);
  display: flex;
  justify-content: center;
}
.nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transform-origin: top center;    /* frame.js verkleinert die Zeile, wenn sie nicht passt (FittedBox) */
}

.steps { display: flex; align-items: center; gap: 12px; }
.step {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 20px var(--primary-12);
  display: flex;
  align-items: center;
  justify-content: center;
}
.step img { width: 24px; height: 24px; display: block; }
.step-in { display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.step.is-active {
  width: 58px;
  height: 58px;
  background: var(--primary-12);
  box-shadow: none;
}
.step.is-active .step-in { width: 50px; height: 50px; background: var(--primary-50); }
.step.is-active img { width: 36px; height: 36px; }

.btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;                        /* Dimens.iconTextGap */
  padding: 11px 20px;              /* Dimens.vPaddingSm / screenHPadding */
  border-radius: 8px;
  box-shadow: 0 4px 20px var(--primary-15);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.4;
  white-space: nowrap;
}
.btn .arrow { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.btn .arrow-done { stroke-width: 2; display: none; }
.btn-back { margin-right: var(--gap-nav); background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-next { margin-left: var(--gap-nav); background: var(--primary); color: #fff; }
.btn-next.is-done .arrow-next { display: none; }
.btn-next.is-done .arrow-done { display: block; }
.btn:disabled, .step:disabled, .skip:disabled { cursor: default; }
.tour.is-waiting .btn-next { opacity: 0.55; }

.skip {
  flex: none;
  font-size: 14px;
  line-height: 1.4;
  color: var(--primary);
  text-decoration: underline;
}
.skip-inline { margin-left: var(--gap-nav); display: none; }
.skip-below { margin-top: 4px; }   /* Dimens.labelBottomGap */
.skip.is-off { visibility: hidden; }             /* der Platz bleibt, die Zeile darueber springt nicht */
.skip-inline.is-off { display: none; }

/* Telefon (Dimens.isPhone): runde Knoepfe ohne Schrift, groesseres Abzeichen */
@media (max-width: 599px), (max-height: 599px) {
  .btn { width: 36px; height: 36px; padding: 0; border-radius: 50%; justify-content: center; box-shadow: none; }
  .btn .btn-label { display: none; }
  .btn .arrow { width: 18px; height: 18px; }
  .btn-back { background: var(--primary); color: #fff; border: 0; }
  .badge {
    top: calc(12px + var(--safe-t));
    right: calc(var(--pad-h) + var(--safe-r));
    width: 38vw;
  }
}

/* Querformat: Skip neben Next statt darunter (_skipBesideNext) */
@media (orientation: landscape) {
  .skip-inline { display: block; }
  .skip-below { display: none; }
}

/* Telefon quer: das Abzeichen hoechstens 22 % der Hoehe */
@media (orientation: landscape) and (max-height: 599px) {
  .badge {
    width: auto;
    height: min(calc(38vw * 84.33 / 220), 22vh);
  }
}

/* Sehr kleine Flaechen (Werbeplatz in einer fremden App): dichter setzen, damit die Tour sichtbar bleibt */
@media (max-height: 420px) {
  :root { --pad-v: 10px; --gap-section: 8px; }
  .page-title { font-size: 20px; }
  .page-text { font-size: 13px; }
  .sheet { max-height: 62%; }
}
@media (max-width: 340px) {
  :root { --pad-h: 14px; }
  .page-title { font-size: 21px; }
}

/* ---- Schluss ---- */
.end {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  padding: calc(24px + var(--safe-t)) calc(24px + var(--safe-r)) calc(24px + var(--safe-b)) calc(24px + var(--safe-l));
  background: #fff;
  color: var(--text);
  overflow-y: auto;
  animation: end-in 0.35s ease both;
}
@keyframes end-in { from { opacity: 0; } to { opacity: 1; } }
.end-box { width: 100%; max-width: 440px; margin: auto; text-align: center; }
.end-logo { width: min(227px, 62%); height: auto; }
.end-title {
  margin: 28px 0 0;
  font-family: "PTSerif", Georgia, "Times New Roman", serif;
  font-weight: 800;
  font-size: 28px;
  line-height: 1.1;
  color: var(--title);
}
.end-text { margin: 10px 0 0; font-size: 16px; line-height: 1.4; color: var(--text); }
.end-links { margin-top: 26px; display: grid; gap: 12px; }
.end-link {
  display: block;
  padding: 11px 20px;
  border-radius: 8px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 20px var(--primary-15);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.4;
  text-decoration: none;
}
.end-link.is-plain { background: #fff; color: var(--primary); }
.end-replay { margin-top: 20px; font-size: 14px; color: var(--primary); text-decoration: underline; }

@media (max-height: 520px) {
  .end-title { margin-top: 14px; font-size: 22px; }
  .end-text { font-size: 14px; margin-top: 6px; }
  .end-links { margin-top: 14px; grid-template-columns: 1fr 1fr; gap: 8px; }
  .end-link { padding: 8px 12px; font-size: 15px; }
  .end-replay { margin-top: 12px; }
  .end-logo { width: min(170px, 50%); }
}

@media (prefers-reduced-motion: reduce) {
  .page, .badge, .loader, .end { transition: none; animation: none; }
  .page, .page.is-before { transform: none; }
}
