/*
 * hyd-boot.css - the startup intro (#hyd-boot) and the returning-visit indicator (#hyd-refresh).
 *
 * hyd-boot.js builds both. #hyd-boot is a modal dialog: an Aqua-style window with the Riyal cat yawning once, a
 * striped bar and a Skip intro button, over a dotted plum wallpaper. #hyd-refresh is a small floating pill shown
 * instead on returning visits. #replay-startup is the desktop icon that replays the intro. All colours here are
 * plain literals (plum, chrome, rose); the sheet reads no theme custom properties.
 *
 * Animations are switched off by prefers-reduced-motion and by body.motion-off near the end of the file, all but
 * the first-paint hold (it only hides the window for its first 0.6 s). tools/build_release.py copies the rules
 * that name #hyd-boot into the released page’s inline style, so keep them self-contained.
 */

/* Aqua materials, using the desktop's existing plum, chrome and rose palette. */
#hyd-boot.hyd-boot {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: auto;
  box-sizing: border-box;
  color: #f6eafb;
  background: #100b1b;
  font-family: 'Lucida Grande', Tahoma, Arial, sans-serif;
  z-index: 9999;
}
#hyd-boot:not([open]) {
  display: none;
}
#hyd-boot::backdrop {
  background: #100b1b;
}

/* Stage: a full-screen centred column on a plum gradient; it wakes with a short fade (hyd-screen-wake). */
#hyd-boot .hyd-boot-stage {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  min-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  gap: 24px;
  background:
    radial-gradient(ellipse at 59% 39%, #55306865, transparent 65%),
    linear-gradient(145deg, #100b1b, #21142f 62%, #120d20);
  animation: hyd-screen-wake 650ms ease-out both;
}

/* Dotted wallpaper with two soft curved glows (the :before and :after arcs) that slide in once. */
#hyd-boot .hyd-boot-wallpaper {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: -1;
  pointer-events: none;
  background-image: radial-gradient(#dec5ec77 0.6px, transparent 0.9px);
  background-size: 43px 43px;
}
#hyd-boot .hyd-boot-wallpaper:before,
#hyd-boot .hyd-boot-wallpaper:after {
  content: '';
  position: absolute;
  width: 145%;
  height: 75%;
  left: -22%;
  top: 29%;
  border-radius: 50%;
  border-top: 1px solid #c6a4de40;
  box-shadow:
    0 -22px 46px -24px #d7b6ea80,
    inset 0 29px 50px -34px #eab1cf88;
  background: linear-gradient(175deg, #b088c01a, transparent 34%);
  transform: rotate(-22deg);
  animation: hyd-aqua-current 3s cubic-bezier(0.2, 0.6, 0.2, 1) both;
}
#hyd-boot .hyd-boot-wallpaper:after {
  left: -8%;
  top: 58%;
  width: 125%;
  height: 62%;
  transform: rotate(17deg);
  opacity: 0.6;
  animation-name: hyd-aqua-return;
}

/* The Aqua window: 450 px wide, bevelled border and scan-line background; it rises in with hyd-aqua-window. */
#hyd-boot .hyd-boot-window {
  position: relative;
  box-sizing: border-box;
  width: 450px;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid;
  border-color: #d9c7e8 #6f547f #594168 #c8b0dc;
  border-radius: 12px 12px 9px 9px;
  background:
    linear-gradient(135deg, #382443e8, #21162fe8 70%),
    repeating-linear-gradient(0deg, transparent 0 2px, #dfc1ef0a 2px 3px);
  box-shadow:
    0 0 0 1px #0b0712,
    0 26px 75px #07030db3,
    inset 0 0 0 1px #e6c9f01c;
  animation: hyd-aqua-window 660ms cubic-bezier(0.16, 0.8, 0.22, 1) 80ms both;
}

/* Title bar: an Aqua gradient strip with three lights (hue-rotated copies of one rose disc) on the
   left and a mark on the right. */
#hyd-boot .hyd-boot-bar {
  height: 32px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #6b527b;
  background: linear-gradient(#fff0ff, #d1bddd 45%, #aa90bc 49%, #e0cde8);
  color: #34243e;
  font:
    11px 'Lucida Grande',
    Tahoma,
    Arial,
    sans-serif;
  text-shadow: 0 1px #f5e9ff;
  box-shadow: inset 0 1px #fff5ff;
}
/* An empty 16px slot where a corner mark used to sit keeps the title where it was. */
#hyd-boot .hyd-boot-bar::after {
  content: '';
  flex: 0 0 16px;
}
#hyd-boot .hyd-boot-lights {
  display: flex;
  gap: 6px;
}
#hyd-boot .hyd-boot-lights i {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid #87536f;
  background: radial-gradient(ellipse at 35% 20%, #fff9ff 0, #f3b8d6 25%, #b45e8e 68%, #633452);
  box-shadow:
    0 1px #f7e8fc,
    inset 0 -1px 2px #541b5466;
}
#hyd-boot .hyd-boot-lights i:nth-child(2) {
  filter: hue-rotate(35deg);
  opacity: 0.8;
}
#hyd-boot .hyd-boot-lights i:nth-child(3) {
  filter: hue-rotate(280deg);
  opacity: 0.65;
}

/* Content: the Riyal cat art, name, description, progress track and a bottom row (welcome text and
   the Skip intro button). */
#hyd-boot .hyd-boot-content {
  position: relative;
  padding: 31px 39px 23px;
  text-align: center;
  background: repeating-linear-gradient(0deg, transparent 0 2px, #d9b9ee06 2px 3px);
}
#hyd-boot .hyd-boot-cat {
  display: grid;
  place-items: center;
  width: 160px;
  height: 160px;
  margin: 0 auto 18px;
  animation: hyd-cat-arrive 180ms ease-out both;
}

/* One yawn, once. Loading never waits for this animation to finish. */
#hyd-boot .hyd-boot-cat-frames,
.hyd-refresh-cat {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  background-image: url('assets/cat/riyal-yawn-v3.webp');
  background-size: 300% 200%;
  background-position: 0 0;
  background-repeat: no-repeat;
  transform-origin: 0 0;
  transform: translate(-2.355%, 7.445%) scale(0.876);
  animation: hyd-riyal-opening 2s step-end 1 forwards;
  filter: drop-shadow(0 3px 2px #140923);
}

/* The yawn sprite sheet holds 6 frames (3 columns by 2 rows, background-size 300% by 200%). The
   frames play forward to the widest yawn (50 to 62 percent) and back again in 2 s with step-end;
   each frame also carries its own translate and scale. */
@keyframes hyd-riyal-opening {
  0%,
  10%,
  96%,
  100% {
    background-position: 0 0;
    transform: translate(-2.355%, 7.445%) scale(0.876);
  }
  18%,
  90% {
    background-position: 50% 0;
    transform: translate(0.712%, 7.27%) scale(0.877756);
  }
  26%,
  84% {
    background-position: 100% 0;
    transform: translate(3.291%, 7.445%) scale(0.876);
  }
  34%,
  78% {
    background-position: 0 100%;
    transform: translate(-4.011%, 8.287%) scale(0.892057);
  }
  42%,
  70% {
    background-position: 50% 100%;
    transform: translate(-0.772%, 8.463%) scale(0.890244);
  }
  50%,
  62% {
    background-position: 100% 100%;
    transform: translate(2.291%, 8.811%) scale(0.88664);
  }
}

/* Name and description: plain light text; background, text fill and filter are reset so any shared
   heading treatment does not show through. */
#hyd-boot #hyd-boot-name {
  margin: 0;
  color: #f6edf9;
  font:
    500 31px/1.25 'Lucida Grande',
    Geneva,
    Tahoma,
    sans-serif;
  letter-spacing: -1px;
  background: none;
  -webkit-text-fill-color: currentColor;
  filter: none;
  text-shadow: 0 2px #170f22;
}
#hyd-boot #hyd-boot-name em {
  display: block;
  font: inherit;
  color: #e2b4d5;
  background: none;
  -webkit-text-fill-color: currentColor;
}
#hyd-boot #hyd-boot-description {
  margin: 14px 0 28px;
  color: #d9c7e5;
  font:
    12px/1.4 'Lucida Grande',
    Tahoma,
    Arial,
    sans-serif;
}

/* Progress track: an endless striped bar (hyd-startup-stripes, 800 ms per 24 px). It is decorative
   and shows activity only. */
#hyd-boot .hyd-boot-track {
  position: relative;
  height: 14px;
  margin: 0 20px 26px;
  overflow: hidden;
  border: 1px solid #bda0cf;
  border-radius: 10px;
  background: #160c20;
  box-shadow:
    0 1px #ecd7f53d,
    inset 0 2px 3px #060309;
}
#hyd-boot .hyd-boot-track > span {
  position: absolute;
  inset: 2px -28px;
  border-radius: 8px;
  background: repeating-linear-gradient(118deg, #936ba9 0 8px, #e2bddf 8px 16px, #705087 16px 24px);
  box-shadow:
    inset 0 3px 2px #fff0ffb3,
    inset 0 -2px #43225999;
  animation: hyd-startup-stripes 800ms linear infinite;
}

/* Bottom row: welcome text and the Skip intro button (an Aqua gradient pill). */
#hyd-boot .hyd-boot-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: #cbb6d6;
  font:
    10px 'Lucida Grande',
    Tahoma,
    Arial,
    sans-serif;
}
#hyd-boot .hyd-boot-skip {
  min-height: 32px;
  padding: 5px 14px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #b398c6;
  border-radius: 20px;
  background: linear-gradient(#f1e1fb 0, #c6afd8 44%, #856397 49%, #b79bcb 80%, #dac3eb);
  color: #27162f;
  box-shadow:
    inset 0 1px #fff6ff,
    0 2px 4px #0d051a80;
  text-shadow: 0 1px #efdbf788;
  font:
    11px 'Lucida Grande',
    Tahoma,
    Arial,
    sans-serif;
  cursor: pointer;
  transition:
    filter 0.16s,
    translate 0.16s;
}
#hyd-boot .hyd-boot-skip:hover {
  filter: brightness(1.13);
}
#hyd-boot .hyd-boot-skip:active {
  translate: 0 1px;
}
#hyd-boot .hyd-boot-skip:focus-visible {
  outline: 2px solid #efb2d6;
  outline-offset: 4px;
}

/* Caption under the window. */
#hyd-boot .hyd-boot-caption {
  font:
    10px 'Lucida Grande',
    Tahoma,
    Arial,
    sans-serif;
  letter-spacing: 0.2px;
  color: #bfa6ce;
}

/* Leaving: the dialog and its window fade away over 350 ms when the intro finishes, the window
   growing slightly and drifting up. */
#hyd-boot.is-leaving {
  animation: hyd-startup-away 350ms ease-in both;
}
#hyd-boot.is-leaving .hyd-boot-window {
  animation: hyd-window-away 350ms cubic-bezier(0.4, 0, 1, 1) both;
}

/* First paint: until the desk is ready (html[data-booted]) the dialog the page opens in its markup stays
   invisible for its first 0.6 s, so a fast load or a same-tab reload never flashes it, and its entrance starts
   when it shows (each delay below is its entrance delay above plus 600 ms). The release copies the boot rules
   into the page’s inline style (tools/build_release.py), so on a slow phone this window paints before the
   stylesheets arrive. Opacity, not visibility, so skip intro can still take focus while it is held, and
   !important keeps the hold under reduced motion too: it hides, it does not move. */
html:not([data-booted]) #hyd-boot.hyd-boot[open],
html:not([data-booted]) #hyd-boot.hyd-boot[open]::backdrop {
  animation: hyd-boot-hold 600ms step-end !important;
}
html:not([data-booted]) #hyd-boot :is(.hyd-boot-stage, .hyd-boot-cat, .hyd-boot-cat-frames),
html:not([data-booted]) #hyd-boot .hyd-boot-wallpaper:before,
html:not([data-booted]) #hyd-boot .hyd-boot-wallpaper:after {
  animation-delay: 600ms;
}
html:not([data-booted]) #hyd-boot .hyd-boot-window {
  animation-delay: 680ms;
}
@keyframes hyd-boot-hold {
  from,
  to {
    opacity: 0;
  }
}

/* !important so the replay icon stays hidden: display rules on desktop icon buttons would otherwise
   override the hidden attribute. */
#replay-startup[hidden] {
  display: none !important;
}

/* Page movement is orchestrated in JS so dragged window positions stay intact. */
#world .page {
  animation: none;
}

/* Keyframes. Entrance: screen wake, window rise, cat arrival and the two glow arcs. Progress
   stripes slide one 24 px stripe period per loop. Exit: startup-away fades the dialog, window-away
   the window. */
@keyframes hyd-screen-wake {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes hyd-aqua-window {
  from {
    opacity: 0;
    translate: 0 20px;
    scale: 0.94;
  }
  to {
    opacity: 1;
    translate: 0 0;
    scale: 1;
  }
}
@keyframes hyd-cat-arrive {
  from {
    opacity: 0;
    scale: 0.85;
  }
  to {
    opacity: 1;
    scale: 1;
  }
}
@keyframes hyd-aqua-current {
  from {
    translate: -5% 9%;
    opacity: 0.15;
  }
  to {
    translate: 0 0;
    opacity: 1;
  }
}
@keyframes hyd-aqua-return {
  from {
    translate: 5% 8%;
    opacity: 0;
  }
  to {
    translate: 0 0;
    opacity: 0.6;
  }
}
@keyframes hyd-startup-stripes {
  to {
    transform: translateX(24px);
  }
}
@keyframes hyd-startup-away {
  to {
    opacity: 0;
  }
}
@keyframes hyd-window-away {
  to {
    opacity: 0;
    scale: 1.04;
    translate: 0 -8px;
  }
}

/* Small phones: tighter padding, a smaller name and a 144 px cat. */
@media (max-width: 480px) {
  #hyd-boot .hyd-boot-content {
    padding: 28px 23px 21px;
  }
  #hyd-boot #hyd-boot-name {
    font-size: 26px;
    letter-spacing: -0.8px;
  }
  #hyd-boot .hyd-boot-cat {
    width: 144px;
    height: 144px;
    margin-bottom: 18px;
  }
  #hyd-boot .hyd-boot-track {
    margin-inline: 9px;
  }
}

/* No animation or transition inside the intro, for reduced motion and for body.motion-off (the
   Animations toggle). !important beats the animation declarations above. */
@media (prefers-reduced-motion: reduce) {
  #hyd-boot,
  #hyd-boot *,
  #hyd-boot *:before,
  #hyd-boot *:after {
    animation: none !important;
    transition: none !important;
  }
}
body.motion-off #hyd-boot,
body.motion-off #hyd-boot *,
body.motion-off #hyd-boot *:before,
body.motion-off #hyd-boot *:after {
  animation: none !important;
  transition: none !important;
}

/* Returning visits get a light, non-blocking Aqua activity indicator. */
#hyd-refresh {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 19px;
  border: 1px solid #b8a2ca;
  border-radius: 8px;
  color: #f5eafa;
  background: linear-gradient(#54415eea, #25192fea);
  box-shadow:
    inset 0 1px #f3dcff44,
    0 6px 25px #08040d66;
  font:
    12px/1.3 'Lucida Grande',
    Tahoma,
    Arial,
    sans-serif;
  pointer-events: none;
  white-space: nowrap;
}
#hyd-refresh[hidden] {
  display: none;
}
#hyd-refresh .hyd-refresh-cat {
  flex: none;
  width: 58px;
  height: 58px;
  filter: none;
}
#hyd-refresh.is-static .hyd-refresh-cat {
  animation: none;
}

/* The refresh cat is static for reduced motion and for motion-off (the script also adds is-static). */
@media (prefers-reduced-motion: reduce) {
  .hyd-refresh-cat {
    animation: none !important;
  }
}
body.motion-off .hyd-refresh-cat {
  animation: none !important;
}
