/*
 * hyd-wishes.css - the Wishes window (#desk-wishes) and its phone sheet (#wishes-sheet).
 *
 * hyd-wishes.js builds the window, its dock button and the phone dialog sheet. The window shows a rock photograph
 * (the sky) with one star button per approved wish, a label that appears beside the selected star, an action row,
 * and a make-a-wish card. Wishes live only for the visit. At 620 px and under the window moves into
 * #wishes-sheet, a dialog sized by --phone-sheet-* (defined in hyd-world.css).
 *
 * Loaded near the end of the cascade, after the shared desktop-window sheets. Each !important group is explained
 * where it is used.
 */

/* The owner-selected rock photograph inside the existing silver desktop chrome. */
html[data-theme] #world #home #desk-wishes {
  top: 115px;
  left: 24%;
  right: auto;
  width: 520px;
  rotate: 0deg;
  background: #1c1a20;
  color: #f5f3f6;
}

/* Desktop chrome inherits the same scale as the other site windows. */
/* !important keeps the Minar title face whichever generic window-title font rule
   (hyd-mac-windows.css, hyd-classic-desktop.css) matches. */
html[data-theme] #world #home #desk-wishes .window-grab {
  font-family: 'Hyd Minar', sans-serif !important;
  font-size: 13px;
}

/* Phone sheet: the title bar and its buttons keep 44 px touch targets. The !important sizes match
   the shared desktop-window rules, which also use !important. */
@media (max-width: 620px) {
  html[data-theme] #world #home #wishes-sheet #desk-wishes .desktop-titlebar {
    height: 44px !important;
    min-height: 44px !important;
  }
  html[data-theme] #world #home #wishes-sheet #desk-wishes .window-grab {
    height: 100%;
    min-height: 0;
    padding-inline: 90px 8px;
  }
  html[data-theme] #world #home #wishes-sheet #desk-wishes .desktop-titlebar > div {
    height: 44px;
    left: 2px;
    gap: 0;
  }
  html[data-theme] #world #home #wishes-sheet #desk-wishes .desktop-titlebar > div > button {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
}

/* Window body and the dark paper surface of the wishes content. */
html[data-theme] #world #home #desk-wishes .desktop-window-body {
  padding: 0;
}
#desk-wishes .wishes-body {
  font: calc(13 * var(--px))/1.5 var(--desktop-font);
  color: #f5f3f6;
  background: #1c1a20;
}

/* !important so hidden parts stay hidden: display rules in this sheet would otherwise override the
   hidden attribute. */
#desk-wishes [hidden] {
  display: none !important;
}

/* The sky: a rock photograph texture (::before) under a dark wash (::after), holding the star field. */
#desk-wishes .wishes-sky {
  position: relative;
  isolation: isolate;
  height: 310px;
  overflow: hidden;
  background: #1d171e;
}
#desk-wishes .wishes-sky::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -2;
  background: url('assets/wishes-rock-texture.webp') center/cover no-repeat;
}
#desk-wishes .wishes-sky::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: #1c1a208c;
  pointer-events: none;
}
#desk-wishes .wishes-sky-status {
  margin: 0;
  padding: 18px;
  color: #c8c4cd;
}

/* Action row and its Finder-style buttons (32 px tall, 44 px on touch). */
#desk-wishes .wishes-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
}
#desk-wishes .wishes-actions button {
  min-height: 32px;
  min-width: 44px;
  padding: 5px 10px;
  border: 1px solid var(--finder-border);
  border-radius: 5px;
  background: var(--finder-button);
  color: var(--finder-ink);
  font: calc(13 * var(--px))/1.3 var(--desktop-font);
  box-shadow: inset 0 1px #fff8;
}

/* Make-a-wish card: heading, labelled inputs, error line and actions. */
#desk-wishes .wishes-card {
  padding: 18px;
  background: #1c1a20;
}
#desk-wishes .wishes-card h2 {
  margin: 0 0 18px;
  font:
    400 calc(20 * var(--px))/1.3 'Hyd Minar',
    sans-serif;
  color: #f5f3f6;
}
#desk-wishes .wishes-card label {
  display: block;
  color: #f5f3f6;
  font: calc(13 * var(--px))/1.5 var(--desktop-font);
}
#desk-wishes .wishes-card input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin: 5px 0 0;
  padding: 8px;
  border: 1px solid #89818f;
  border-radius: 2px;
  background: #28262c;
  color: #f5f3f6;
  font: calc(16 * var(--px))/1.5 var(--desktop-font);
}
#desk-wishes .wishes-card input[readonly] {
  color: #c8c4cd;
}
#desk-wishes .wishes-error {
  display: block;
  min-height: 20px;
  color: #f3b9b6;
  font-size: calc(12 * var(--px));
}
#desk-wishes .wishes-card p {
  margin: 12px 0;
  color: #c8c4cd;
}
#desk-wishes .wishes-card .wishes-actions {
  padding: 0;
}
#desk-wishes .wishes-rules {
  margin: 0;
  padding: 12px 16px 16px;
  border-top: 1px solid #89818f66;
  color: #c8c4cd;
  font: calc(12 * var(--px))/1.5 var(--desktop-font);
}

/* Keyboard focus ring for the window controls. */
#desk-wishes :is(button, input):focus-visible {
  outline: 2px solid #b8c9e6;
  outline-offset: 2px;
}

/* !important so no dock button sizing rule elsewhere can shrink this dock button below the 44 px
   touch target. */
html[data-theme] #world #home [data-task-window='wishes'] {
  min-width: 44px !important;
  min-height: 44px !important;
}

/* Phone sheet dialog: plain shell and dark backdrop; its layout is in the phone block below. */
#wishes-sheet {
  padding: 0;
  border: 0;
  background: #1c1a20;
  color: #f5f3f6;
}
#wishes-sheet::backdrop {
  background: #1c1a20cc;
}

/* Phone: the dialog is a fixed panel above the dock and the window fills it. */
@media (max-width: 620px) {
  html[data-theme] #world #home #wishes-sheet {
    position: fixed;
    inset: auto 8px var(--phone-sheet-bottom) 8px;
    margin: 0;
    width: auto;
    max-width: none;
    height: var(--phone-sheet-height);
    max-height: none;
    overflow: hidden;
    border-radius: 0;
  }

  /* The window manager offsets windows with transform: translate(--wx, --wy) (hyd-desktop.css).
     Inside the sheet the window must stay put, so transform and translate are !important none. */
  html[data-theme] #world #home #wishes-sheet #desk-wishes {
    position: static;
    inset: auto;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    transform: none !important;
    translate: none !important;
    rotate: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top,0px);
  }
  html[data-theme] #world #home #wishes-sheet #desk-wishes .desktop-window-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom,0px);
  }

  /* Inside the phone sheet the rock leaves room for the actions below it (title bar 44px + status and buttons ~120px). */
  #wishes-sheet #desk-wishes .wishes-sky {
    height: max(120px,calc(var(--phone-sheet-height-svh) - 164px));
    min-height: 0;
  }

  /* The rock has nothing to scroll here, so a swipe on it scrolls the sheet. */
  #wishes-sheet #desk-wishes .wishes-scroll {
    overscroll-behavior-y: auto;
  }
  #desk-wishes .wishes-card {
    padding: 18px 16px;
  }
}

/* Reduced motion, by OS setting or by the Animations toggle (body.motion-off): no animation or
   transition in the window. !important beats the per-element animation rules below. */
@media (prefers-reduced-motion: reduce) {
  #desk-wishes * {
    animation: none !important;
    transition: none !important;
  }
}
.motion-off #desk-wishes * {
  animation: none !important;
  transition: none !important;
}

/* One fixed image; bounded native scrolling moves through immutable six-column world rows. */
#desk-wishes .wishes-sky {
  min-width: 0;
  min-height: 310px;
}

/* Scroller: fills the sky and scrolls the star rows natively. */
#desk-wishes .wishes-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
#desk-wishes .wishes-stars {
  position: relative;
  min-height: 100%;
  width: 100%;
}

/* Stars: 44 px touch targets around a 16 px icon, centred on their position by the translate. */
#desk-wishes .wishes-star {
  position: absolute;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  margin: 0;
  transform: translate(-50%, -50%);
  background: transparent;
  color: #f9e9b8;
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
}
#desk-wishes .wishes-star svg {
  display: block;
  width: 16px;
  height: 16px;
  pointer-events: none;
  filter: drop-shadow(0 0 3px #f9e9b866);
}
#desk-wishes .wishes-star.is-new svg {
  animation: wish-twinkle 7s ease-in-out infinite;
}
#desk-wishes .wishes-star[aria-expanded='true'] {
  background: #f9e9b81a;
}

/* Label: the selected wish in a small lowercase card beside its star; it ignores pointer input. */
#desk-wishes .wishes-label {
  position: absolute;
  z-index: 2;
  box-sizing: border-box;
  width: max-content;
  max-width: 240px;
  margin: 0;
  padding: 9px 11px;
  border: 1px solid #bcb2c5;
  border-radius: 4px;
  background: #28232cf5;
  color: #f5f3f6;
  font: calc(13 * var(--px))/1.5 var(--desktop-font);
  overflow-wrap: anywhere;
  text-transform: lowercase;
  pointer-events: none;
  box-shadow: 0 3px 12px #0006;
}
#desk-wishes .wishes-label small {
  display: block;
  margin-top: 5px;
  color: #d7cedd;
  font: calc(12 * var(--px))/1.4 var(--desktop-font);
}
#desk-wishes .wishes-sky-status {
  min-height: 18px;
  padding: 8px 12px 0;
  font: calc(12 * var(--px))/1.5 var(--desktop-font);
}
#desk-wishes .wishes-actions button:disabled {
  opacity: 0.55;
  cursor: default;
}

/* New stars pulse between 65 and 100 percent opacity (7 s loop, set on .wishes-star.is-new svg). */
@keyframes wish-twinkle {
  0%,
  100% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
}

/* The twinkle is also switched off for reduced motion and for motion-off. */
@media (prefers-reduced-motion: reduce) {
  #desk-wishes .wishes-star svg {
    animation: none !important;
  }
}
.motion-off #desk-wishes .wishes-star svg {
  animation: none !important;
}

/* Keep the action row reachable above the dock on short landscape screens. */
@media (max-height: 500px) {
  #desk-wishes .wishes-sky {
    height: max(54px, calc(100dvh - 260px));
    min-height: 54px;
  }
}

/* Touch: action buttons reach the 44 px target. */
@media (pointer: coarse), (any-pointer: coarse) {
  #desk-wishes .wishes-actions button {
    min-height: 44px;
    padding: 7px 12px;
  }
}
