/* ==========================================================================
   Gasthof Rechenhof — pre-boot loader
   --------------------------------------------------------------------------
   Linked from index.html and painted before Angular bootstraps, so this file
   must stay self-contained: no JavaScript, no webfont, no image, no network
   request of any kind.

   The markup lives inside <jhi-app>. Angular's selectRootElement discards the
   host element's children the moment AppComponent renders, and that wipe IS
   the teardown — there is no removal script. Anything moved outside <jhi-app>
   would stay on screen forever.

   Brand:
     #9f0020  deep red  = $primary (_bootstrap-variables.scss) and the
                          "Gasthof · Pension" plaque in logo-rechenhof.png
     #1f833a  green     = the Fraktur wordmark colour in logo-rechenhof.png
   ========================================================================== */

/* --------------------------------------------------------------------------
   Shared wrapper. Two elements in index.html carry .app-loading — the loader
   and the "could not load" fallback — so these rules stay neutral: no offset,
   no reserved height, nothing the error block would inherit to its cost.
   -------------------------------------------------------------------------- */
.app-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0 20px;
  font-family:
    system-ui,
    -apple-system,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
  color: #4a4a4a;
  /* No app stylesheet has loaded yet. Pin the surface white so a UA auto-dark
     mode cannot put white plaque text on a dark page. Matches $body-bg, so the
     hand-off to the booted app is flash-free. */
  background-color: #ffffff;
}

.app-loading p {
  display: block;
  margin: 0;
  font-weight: normal;
}

/* Only the loader gets the vertical stage, so the error fallback that follows
   it in the DOM is not pushed a whole viewport down. */
.app-loading--brand {
  min-height: 72vh;
  /* svh keeps iOS honest; the vh line above is the fallback for older engines.
     Do not let a "duplicate property" linter delete it. */
  min-height: 72svh;
  padding-bottom: 2rem;
}

/* --------------------------------------------------------------------------
   The loader
   -------------------------------------------------------------------------- */
.rh-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  /* Perceived speed: nothing is painted for the first 350 ms. On a warm cache
     Angular boots inside that window and the visitor never sees a loading
     state at all. `both` holds opacity 0 through the delay.
     opacity: 0 lives only inside the keyframes, never on a base rule, so if
     animations are stripped entirely the loader paints immediately rather
     than being stranded invisible. */
  animation: rh-in 240ms ease-out 350ms both;
}

/* Single source of truth for the width: wordmark, plaque and hairline are all
   exactly as wide, so the block reads as one piece of signwriting. */
.rh-loader__mark {
  width: min(78vw, 300px);
}

/* Tier 1 of the logo: the name, in green. The real thing is blackletter, but
   the Fraktur exists only as raster pixels in logo-rechenhof.png, and the one
   brand webfont ('Header-Schrift' = Zapfino) is declared inside an Angular
   component stylesheet and cannot load here. Spaced serif caps are the honest
   reduction; every family in the stack is OS-resident, so nothing is
   downloaded and there is no swap flash. */
.rh-loader .rh-loader__name,
.rh-loader .rh-loader__plaque-text {
  font-family:
    'Palatino Linotype', 'Book Antiqua', Palatino, 'URW Palladio L', P052, 'Iowan Old Style', Georgia, 'Liberation Serif',
    'Times New Roman', serif;
  font-weight: 400;
  text-transform: uppercase;
  /* letter-spacing leaves a trailing gap after the last glyph and drags centred
     text off-axis; half of it back as indent restores the optical centre. */
  text-indent: 0.26em;
  letter-spacing: 0.26em;
  white-space: nowrap;
}

/* specificity (0,2,0) intentionally beats `.app-loading p` (0,1,1) above */
.rh-loader .rh-loader__name {
  margin-bottom: 0.55rem;
  font-size: clamp(1.05rem, 4.6vw, 1.5rem);
  line-height: 1.15;
  color: #1f833a;
  text-align: center;
}

/* Tier 2 of the logo: the red plaque. Same device as .public-page-header in
   global.scss — #9f0020 ground, white centred text — with the notched corners
   of the banner in logo-rechenhof.png. */
.rh-loader__plaque {
  padding: 0.62em 0.5em 0.58em;
  background-color: #9f0020;
  clip-path: polygon(7px 0, 100% 0, 100% calc(100% - 7px), calc(100% - 7px) 100%, 0 100%, 0 7px);
  text-align: center;
}

.rh-loader__plaque-text {
  display: block;
  font-size: clamp(0.66rem, 2.7vw, 0.8125rem);
  line-height: 1.4;
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Indeterminate hairline. 3px is deliberate: it reads as progress without
   competing with the plaque above it.
   -------------------------------------------------------------------------- */
.rh-loader__track {
  position: relative;
  height: 3px;
  margin-top: 14px;
  overflow: hidden;
  background-color: rgba(159, 0, 32, 0.14);
}

.rh-loader__bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 42%;
  /* explicit rgba() rather than `transparent` so the fade never greys out */
  background-image: linear-gradient(90deg, rgba(159, 0, 32, 0) 0%, #9f0020 38%, #9f0020 62%, rgba(159, 0, 32, 0) 100%);
  transform: translateX(-100%);
  /* transform-only, so it composites on the GPU and never triggers layout.
     linear on purpose: eased travel parks the segment off-track for most of
     the cycle and reads as broken. Keep the constant speed. */
  animation: rh-travel 1.9s linear infinite;
}

.rh-loader .rh-loader__status {
  max-width: 22rem;
  margin-top: 16px;
  font-size: 0.8125rem;
  line-height: 1.5;
  letter-spacing: 0.06em;
  color: #5d474b;
  text-align: center;
  text-wrap: balance;
}

/* --------------------------------------------------------------------------
   Boot failure fallback (index.html reveals #app-error after 4s)
   -------------------------------------------------------------------------- */
.rh-error {
  max-width: 32rem;
  padding: 1.5rem 0 3rem;
  line-height: 1.6;
  text-align: center;
}

.rh-error__title {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  font-weight: 400;
  color: #9f0020;
}

.rh-error .rh-error__link {
  color: #9f0020;
  font-weight: bold;
}

.rh-error__en {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: #7a7a7a;
}

/* --------------------------------------------------------------------------
   Keyframes
   -------------------------------------------------------------------------- */
@keyframes rh-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 42%-wide segment: -100% is fully off the left, 240% fully off the right */
@keyframes rh-travel {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(240%);
  }
}

@keyframes rh-step {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes rh-breathe {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   Reduced motion: keep the 350 ms anti-flash delay, drop every movement. The
   reveal becomes a hard step, and the hairline stops travelling — it becomes a
   full-width red rule that breathes in opacity only. No translation, no scale,
   no rotation. The visible line "Einen Moment bitte …" carries the meaning.
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .rh-loader {
    animation: rh-step 1ms linear 350ms both;
  }

  .rh-loader__bar {
    width: 100%;
    background-image: none;
    background-color: #9f0020;
    transform: none;
    /* floor is 0.55, not 0.35: at 0.35 the composite over the track falls to
       ~1.9:1, at 0.55 it stays above the 3:1 required by WCAG 1.4.11 */
    animation: rh-breathe 2.4s ease-in-out infinite;
  }
}

/* --------------------------------------------------------------------------
   Short viewports (landscape phones): stop reserving 72vh of empty space.
   -------------------------------------------------------------------------- */
@media (max-height: 30rem) {
  .app-loading--brand {
    min-height: 0;
    padding-top: 2.5rem;
    padding-bottom: 1.5rem;
  }
}

/* --------------------------------------------------------------------------
   Windows high contrast: the UA discards brand fills, so restate the shapes
   with system colours or the loader collapses to a blank white page.
   -------------------------------------------------------------------------- */
@media (forced-colors: active) {
  .rh-loader__plaque {
    border: 1px solid CanvasText;
  }

  .rh-loader__track {
    border: 1px solid CanvasText;
    background-color: Canvas;
  }

  .rh-loader__bar {
    background-image: none;
    background-color: Highlight;
    forced-color-adjust: none;
  }
}
