/*
 * hyd-guestbook.css - the Guestbook window (#desk-guestbook) and its phone sheet (#guestbook-sheet).
 *
 * hyd-guestbook.js builds the window, its dock button and the phone dialog sheet. Reviewed entries appear as paper
 * cards under a marquee ribbon and a sticky row with the entry count and the sign button; the sign-the-book form
 * replaces the cards while it is open. At 620 px and under the window moves into #guestbook-sheet, a dialog sized
 * by --phone-sheet-* (defined in hyd-world.css), and the sign button moves into a bar under the scroller.
 *
 * Loaded near the end of the cascade, after the shared desktop-window rules. Each !important group is
 * explained where it is used.
 */

/* Site chrome and pixel paper. */
html[data-theme] #world #home #desk-guestbook {
  top: 78px;
  left: auto;
  right: 12px;
  width: 414px;
  height: calc(100dvh - 158px);
  rotate: 0deg;
  background: #dbe1e5;
  color: #292733;
}

/* 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-guestbook .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 #guestbook-sheet #desk-guestbook .desktop-titlebar {
    height: 44px !important;
    min-height: 44px !important;
  }
  html[data-theme] #world #home #guestbook-sheet #desk-guestbook .window-grab {
    height: 100%;
    min-height: 0;
    padding-inline: 90px 8px;
  }
  html[data-theme] #world #home #guestbook-sheet #desk-guestbook .desktop-titlebar > div {
    height: 44px;
    left: 2px;
    gap: 0;
  }
  html[data-theme] #world #home #guestbook-sheet #desk-guestbook .desktop-titlebar > div > button {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
}

/* Window body: the scroll container for the ribbon, paper and form. */
html[data-theme] #world #home #desk-guestbook .desktop-window-body {
  padding: 0;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}
#desk-guestbook .guestbook-body {
  position: relative;
  min-height: 100%;
  font: calc(13 * var(--px))/1.45 var(--desktop-font);
  color: #292733;
  background: #dbe1e5;
}

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

/* Ribbon: a marquee strip above the paper. Its text repeats three times, so sliding by one third
   (the guestbook-ribbon keyframes) loops without a jump. */
#desk-guestbook .guestbook-ribbon {
  overflow: hidden;
  padding: 5px 0;
  border-block: 1px solid #8c899d;
  background: #b8c9e6;
  color: #292733;
  font:
    400 calc(12 * var(--px))/1.5 'Hyd Minar',
    sans-serif;
}
#desk-guestbook .guestbook-ribbon > span {
  display: block;
  width: max-content;
  white-space: nowrap;
  animation: guestbook-ribbon 28s linear infinite;
}

/* Paper: dotted paper background holding the head row, heading and entry cards. */
#desk-guestbook .guestbook-paper {
  position: relative;
  padding: 16px 26px 22px;
  background-color: #e8e5db;
  background-image: radial-gradient(#a6a5a04d 0.6px, transparent 0.7px);
  background-size: 3px 3px;
}

/* The count and sign the book share one row that stays at the top of the window while entries scroll. */
#desk-guestbook .guestbook-headrow {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: -16px -26px 0;
  padding: 9px 26px;
  background-color: #e8e5db;
  background-image: radial-gradient(#a6a5a04d 0.6px, transparent 0.7px);
  background-size: 3px 3px;
  border-bottom: 1px solid #8c899d;
  box-shadow: 0 1px #f5f3e8;
}
#desk-guestbook .guestbook-headrow .guestbook-count {
  min-width: 0;
}

/* Sign button: a chunky bevelled pixel button. Pressing it flips the bevel and moves the label 1 px
   down and right. */
#desk-guestbook .guestbook-sign {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  min-height: 38px;
  margin: 0;
  padding: 3px 12px 3px 7px;
  border: 2px solid;
  border-color: #f5f3f6 #466382 #466382 #f5f3f6;
  border-radius: 0;
  background: #b8c9e6;
  color: #292733;
  font:
    400 calc(15 * var(--px))/1.2 'Hyd Minar',
    sans-serif;
  box-shadow: 0 0 0 1px #292733;
  cursor: pointer;
  white-space: nowrap;
}
#desk-guestbook .guestbook-sign:active {
  border-color: #466382 #f5f3f6 #f5f3f6 #466382;
  padding: 4px 11px 2px 8px;
}
#desk-guestbook .guestbook-sign svg {
  width: 24px;
  height: 24px;
  flex: none;
}
#desk-guestbook .guestbook-heading {
  position: relative;
  z-index: 1;
  margin-bottom: 14px;
}

/* A landscape phone's window is short: keep the sticky row as low as its 44 px button allows. */
@media (min-width: 621px) and (max-height: 500px) {
  #desk-guestbook .guestbook-headrow {
    padding-block: 4px;
  }
}
#desk-guestbook .guestbook-heading h2 {
  margin: 14px 0;
  font:
    400 calc(17 * var(--px))/1.45 'Hyd Minar',
    sans-serif;
  color: #292733;
}
#desk-guestbook .guestbook-count {
  font: calc(11 * var(--px))/1.4 var(--desktop-font);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

/* Odometer: the entry count drawn as a dark mechanical counter. */
#desk-guestbook .guestbook-odometer {
  display: inline-block;
  padding: 3px 6px;
  border: 2px inset #a9afb5;
  background:
    repeating-linear-gradient(90deg, transparent 0 13px, #c8c4cd66 13px 14px),
    linear-gradient(#353239 48%, #1c1a20 49% 53%, #353239 54%);
  color: #f5f3f6;
  font:
    400 calc(18 * var(--px))/1.3 'Hyd Minar',
    monospace;
  letter-spacing: 3px;
}

/* One Finder-style button look for the heading, action, paging and load-more buttons (32 px, 44 px
   on touch below). */
#desk-guestbook
  :is(.guestbook-heading, .guestbook-actions, .guestbook-paging, .guestbook-load-actions)
  button {
  min-width: 32px;
  min-height: 32px;
  padding: 4px 9px;
  border: 1px solid var(--finder-border);
  border-radius: 4px;
  background: var(--finder-button);
  color: var(--finder-ink);
  font: calc(13 * var(--px))/1.3 var(--desktop-font);
  box-shadow: inset 0 1px #fff8;
}

/* Entry cards: paper slips with a torn bottom edge (the zigzag clip-path polygon), a purple owner
   reply line and a slightly rotated date stamp. */
#desk-guestbook .guestbook-cards {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 17px;
}
#desk-guestbook .guestbook-card {
  position: relative;
  margin: 0;
  padding: 15px 14px 19px;
  background: #f5f3e8;
  color: #292733;
  clip-path: polygon(
    0 0,
    100% 0,
    100% 97%,
    96% 100%,
    92% 97%,
    88% 100%,
    84% 97%,
    80% 100%,
    76% 97%,
    72% 100%,
    68% 97%,
    64% 100%,
    60% 97%,
    56% 100%,
    52% 97%,
    48% 100%,
    44% 97%,
    40% 100%,
    36% 97%,
    32% 100%,
    28% 97%,
    24% 100%,
    20% 97%,
    16% 100%,
    12% 97%,
    8% 100%,
    4% 97%,
    0 100%
  );
  box-shadow:
    inset 0 1px #fff,
    inset 1px 0 #8c899d88,
    inset -1px 0 #8c899d88;
  overflow-wrap: anywhere;
}

/* Card header: the visitor name and the new badge. */
#desk-guestbook .guestbook-card header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
#desk-guestbook .guestbook-card h3 {
  margin: 0;
  flex: 1;
  font:
    400 calc(15 * var(--px))/1.4 'Hyd Minar',
    sans-serif;
  color: #292733;
}
#desk-guestbook .guestbook-card p {
  margin: 10px 0;
  white-space: pre-wrap;
}

/* Badge on a new entry: a dashed label that blinks (guestbook-new keyframes). */
#desk-guestbook .guestbook-new {
  font:
    400 calc(10 * var(--px))/1.3 'Hyd Minar',
    sans-serif;
  color: #73548b;
  border: 1px dashed currentColor;
  padding: 3px;
  animation: guestbook-new 4s steps(2, end) infinite;
}
#desk-guestbook .guestbook-favourite {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: calc(11 * var(--px));
}
#desk-guestbook .guestbook-favourite svg {
  width: 28px;
  height: 28px;
  flex: none;
}
#desk-guestbook .guestbook-reply {
  padding-left: 9px;
  border-left: 2px solid #73548b;
  color: #73548b;
}
#desk-guestbook .guestbook-stamp {
  display: block;
  width: max-content;
  max-width: 100%;
  margin: 16px 0 0 auto;
  padding: 3px 6px;
  border: 2px solid #466382;
  color: #466382;
  font:
    400 calc(12 * var(--px))/1.4 'Hyd Minar',
    sans-serif;
  rotate: -3deg;
}

/* Paging row under the cards. !important keeps the Minar face on its buttons against the generic
   button font rules of the desktop theme. */
#desk-guestbook .guestbook-paging {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  font-size: calc(11 * var(--px));
}
#desk-guestbook .guestbook-paging button {
  font-family: 'Hyd Minar', sans-serif !important;
}
#desk-guestbook .guestbook-load-actions {
  margin-top: 9px;
}
#desk-guestbook .guestbook-read-status {
  color: #633b36;
  font-size: calc(12 * var(--px));
}

/* Sign-the-book form: a paper card with 16 px input text and a 44 px minimum input height. */
#desk-guestbook .guestbook-form {
  position: relative;
  z-index: 1;
  padding: 13px;
  background: #f5f3e8;
  border: 1px solid #8c899d;
  color: #292733;
}
#desk-guestbook .guestbook-form h3 {
  font:
    400 calc(19 * var(--px))/1.3 'Hyd Minar',
    sans-serif;
  margin: 0 0 14px;
  color: #292733;
}
#desk-guestbook .guestbook-form label {
  display: block;
  font: calc(13 * var(--px))/1.5 var(--desktop-font);
}
#desk-guestbook .guestbook-form :is(input, textarea, select) {
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 7px;
  margin-top: 4px;
  background: #fffef7;
  color: #292733;
  border: 1px solid #89818f;
  border-radius: 2px;
  font: calc(16 * var(--px))/1.5 var(--desktop-font);
  resize: vertical;
}
#desk-guestbook .guestbook-error {
  display: block;
  min-height: 17px;
  color: #633b36;
  font-size: calc(12 * var(--px));
}
#desk-guestbook .guestbook-other {
  margin-top: 4px;
}
#desk-guestbook .guestbook-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

/* Rules footer, empty-book message and the sparkle layer (a decorative overlay that ignores pointer input). */
#desk-guestbook .guestbook-rules {
  margin: 0;
  padding: 12px 16px;
  border-top: 1px solid #8c899d;
  font: calc(11 * var(--px))/1.5 var(--desktop-font);
  color: #494455;
  background: var(--finder-toolbar);
}
#desk-guestbook .guestbook-empty {
  text-align: center;
  margin: 20px 0;
}
#desk-guestbook .guestbook-empty svg {
  width: 64px;
  height: 64px;
}
#desk-guestbook .guestbook-sparkles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
#desk-guestbook .guestbook-sparkles span {
  position: absolute;
  color: #73548b;
  font-size: 15px;
  animation: guestbook-sparkle 0.8s ease-out forwards;
}

/* Keyboard focus ring for the controls and for entry cards (cards take script focus, tabindex -1). */
#desk-guestbook :is(button, input, textarea, select, .guestbook-card):focus-visible {
  outline: 2px solid #466382;
  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='guestbook'] {
  min-width: 44px !important;
  min-height: 44px !important;
}

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

/* Keyframes: ribbon scroll (one third of the text is one repeat), new-badge blink and sparkle fade. */
@keyframes guestbook-ribbon {
  to {
    transform: translateX(-33.333%);
  }
}
@keyframes guestbook-new {
  50% {
    opacity: 0.45;
  }
}
@keyframes guestbook-sparkle {
  to {
    opacity: 0;
    transform: translateY(-12px);
  }
}

/* Phone: the dialog is a fixed panel above the dock and the window fills it. */
@media (max-width: 620px) {
  html[data-theme] #world #home #guestbook-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 #guestbook-sheet #desk-guestbook {
    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 #guestbook-sheet #desk-guestbook .desktop-window-body {
    padding-bottom: env(safe-area-inset-bottom,0px);
  }
  #desk-guestbook .guestbook-paper {
    padding-inline: 22px;
  }
  #desk-guestbook .guestbook-sparkles {
    display: none;
  }
  html[data-theme] #world #home #guestbook-sheet #desk-guestbook:not([hidden]) {
    display: flex;
    flex-direction: column;
  }
  #desk-guestbook .guestbook-headrow {
    position: static;
    margin: -16px -22px 0;
    padding: 9px 22px;
  }

  /* On a phone the button sits in a bar under the scroller: always in reach, never over the last entry. */
  #desk-guestbook .guestbook-signbar {
    flex: none;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom,0px));
    border-top: 1px solid #8c899d;
    background: var(--finder-toolbar);
  }
  #desk-guestbook .guestbook-signbar .guestbook-sign {
    width: 100%;
    justify-content: center;
  }
  html[data-theme]
    #world
    #home
    #guestbook-sheet
    #desk-guestbook:has(> .guestbook-signbar:not([hidden]))
    .desktop-window-body {
    padding-bottom: 0;
  }
}

/* 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 above. */
@media (prefers-reduced-motion: reduce) {
  #desk-guestbook * {
    animation: none !important;
    transition: none !important;
  }
}
.motion-off #desk-guestbook * {
  animation: none !important;
  transition: none !important;
}

/* Phone or touch: 44 px sign button and heading, action, paging and load-more buttons. */
@media (max-width: 620px), (any-pointer: coarse) {
  #desk-guestbook .guestbook-sign {
    min-height: 44px;
  }
  #desk-guestbook
    :is(.guestbook-heading, .guestbook-actions, .guestbook-paging, .guestbook-load-actions)
    button {
    min-width: 44px;
    min-height: 44px;
  }

  /* WebKit keeps a native-looking select at its own height; drawn by the page it honours the 44px minimum and still opens the native picker. */
  #desk-guestbook .guestbook-form select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 28px;
    background-image:
      linear-gradient(45deg, transparent 50%, #292733 50%),
      linear-gradient(135deg, #292733 50%, transparent 50%);
    background-position:
      calc(100% - 14px) center,
      calc(100% - 10px) center;
    background-size:
      4px 4px,
      4px 4px;
    background-repeat: no-repeat;
  }
  html[data-theme] #world #home #desk-notes .about-actions button {
    min-height: 44px;
  }
}
