/*
 * Guestbook: the last page(s) of the photo album on Play (behavior in assets/js/guestbook.js).
 * The album renders `.pa-gb-pg` pages with an empty `.pa-gb-mount`, plus the `.pa-gb-tab` bookmark;
 * these styles fill them in on the album's own paper and type (its --ink, --muted, --hand, --paper
 * variables, which theme.css already re-colors for dark mode). The "Make a stamp" pop-up is a <dialog>.
 */

/* ---------- Bookmark tab: sticks out of the album's right edge (top edge on narrower screens) ---------- */
.pa-gb-tab {
  position: absolute;
  z-index: 7;
  top: 54px;
  right: calc(-1 * clamp(10px, 2.4vw, 22px) - 36px);
  width: 36px;
  padding: 16px 0 14px;
  border: 0;
  border-radius: 0 10px 10px 0;
  background: #fbe38a;
  color: #4a3a10;
  font: 500 17px/1 var(--hand, "Edu QLD Hand"), cursive;
  writing-mode: vertical-rl;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 2px 3px 8px rgba(40, 36, 24, .18), inset 1px 0 0 rgba(0, 0, 0, .06);
  transition: transform .2s ease, background .2s ease;
}
.pa-gb-tab:hover { transform: translateX(3px); }
.pa-gb-tab.on { background: #f6c3bd; color: #5a2420; }
.pa-gb-tab:focus-visible { outline: 3px solid var(--accent, #c58a00); outline-offset: 2px; }
@media (max-width: 1140px) {
  .pa-root:has(.pa-gb-tab) .pa-cover { margin-top: 52px; }
  .pa-gb-tab {
    top: calc(-1 * clamp(10px, 2.4vw, 22px) - 30px);
    right: 18px;
    width: auto;
    height: 30px;
    padding: 0 14px;
    border-radius: 10px 10px 0 0;
    writing-mode: horizontal-tb;
    box-shadow: 0 -2px 6px rgba(40, 36, 24, .12);
  }
  .pa-gb-tab:hover { transform: translateY(-2px); }
}
[data-theme="dark"] .pa-gb-tab { background: #e9cf6e; color: #2b2208; }
[data-theme="dark"] .pa-gb-tab.on { background: #e6aaa3; color: #3a1714; }

/* ---------- A guestbook page: title + postmark on the left, a dotted-edged sheet of stamps ---------- */
.pa-gb-mount {
  display: grid;
  grid-template-columns: minmax(160px, 1.15fr) minmax(0, 4.2fr);
  grid-template-rows: auto 1fr;
  gap: 8px clamp(16px, 2.4vw, 28px);
  padding-bottom: 46px; /* room for the album's page-turn buttons */
}
.pa-gb-mount .gb-title {
  grid-column: 1;
  grid-row: 1;
  aspect-ratio: auto;
  justify-content: flex-start;
  padding-top: clamp(8px, 2vw, 26px);
}
.pa-gb-mount .gb-title h2 { font-size: clamp(30px, 2.6vw, 37px); }
.gb-title-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 10px; }
.gb-in { font: 500 18px/1.2 var(--hand, "Edu QLD Hand"), cursive; color: var(--ink); }
.pa-gb-mount .gb-postmark { grid-column: 1; grid-row: 2; align-self: end; width: 120px; margin: 0 0 4px 2px; color: var(--muted); opacity: .45; transform: rotate(-8deg); }

.gb-grid {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(12px, 1.8vw, 20px);
  margin: 0;
  padding: clamp(12px, 1.6vw, 18px);
  list-style: none;
  border: 2px dotted color-mix(in srgb, var(--muted, #6d6d74) 45%, transparent);
  border-radius: 10px;
}

/* ---------- Buttons ---------- */
.gb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--ink, #23232b);
  color: var(--paper, #fff);
  font: 500 14px/1 "Poppins", system-ui, sans-serif;
  cursor: pointer;
  transition: transform .15s ease;
}
.gb-btn:hover:not(:disabled) { transform: translateY(-1px); }
.gb-btn:disabled { opacity: .6; cursor: default; }
.gb-link {
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--muted, #6d6d74);
  font: 400 13px/1.4 "Poppins", system-ui, sans-serif;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.gb-link:hover { color: var(--ink, #23232b); }
.gb-btn:focus-visible, .gb-link:focus-visible { outline: 2px solid var(--ink, #23232b); outline-offset: 3px; }
/* The album sets `.pa-root button { font: inherit; color: inherit }`; win over it inside the album. */
.pa-root .gb-btn { color: var(--paper, #fff); font: 500 14px/1 "Poppins", system-ui, sans-serif; }
.pa-root .gb-link { color: var(--muted, #6d6d74); font: 400 13px/1.4 "Poppins", system-ui, sans-serif; }
.pa-root .gb-link:hover { color: var(--ink, #23232b); }

/* ---------- One stamp: a perforated edge around a colored art panel, the name and place under it ---------- */
.gb-stamp {
  position: relative;
  min-width: 0;
  outline: none;
  filter: drop-shadow(0 1px 1px rgba(40, 36, 24, .2)) drop-shadow(0 5px 8px rgba(40, 36, 24, .12));
  transition: transform .2s ease;
}
.gb-grid .gb-stamp:hover, .gb-grid .gb-stamp:focus-visible { transform: rotate(var(--tilt, 0deg)) translateY(-2px); }
.gb-stamp:focus-visible .gb-paper { outline: 2px solid var(--ink, #23232b); outline-offset: 3px; }
.gb-paper, .gb-slot {
  --hole: 4px;
  --sx: var(--gb-step-x, 11px);
  --sy: var(--gb-step-y, 11px);
  -webkit-mask:
    linear-gradient(#000 0 0) center / calc(100% - 2 * var(--hole)) calc(100% - 2 * var(--hole)) no-repeat,
    radial-gradient(circle var(--hole) at calc(var(--sx) / 2) calc(var(--sy) / 2), #0000 96%, #000) calc(var(--sx) / -2) calc(var(--sy) / -2) / var(--sx) var(--sy);
  mask:
    linear-gradient(#000 0 0) center / calc(100% - 2 * var(--hole)) calc(100% - 2 * var(--hole)) no-repeat,
    radial-gradient(circle var(--hole) at calc(var(--sx) / 2) calc(var(--sy) / 2), #0000 96%, #000) calc(var(--sx) / -2) calc(var(--sy) / -2) / var(--sx) var(--sy);
}
.gb-paper {
  display: flex;
  flex-direction: column;
  aspect-ratio: 3 / 4;
  padding: 9% 9% 8%;
  background: #fffdf8;
}
.gb-art {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  border-radius: 2px;
  background: var(--paper);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06);
}
.gb-stamp .gb-art svg { width: 58%; height: auto; max-height: 82%; filter: drop-shadow(0 1.5px 1.5px rgba(0, 0, 0, .16)); }
.gb-name, .gb-from { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gb-name { margin-top: 7%; font: 500 clamp(14px, 1.25vw, 17px)/1.2 "Edu QLD Hand", "Poppins", cursive; color: #23232b; }
.gb-from { font: 400 11px/1.4 "Poppins", system-ui, sans-serif; color: #55555c; }

/* Number + date on hover or keyboard focus. */
.gb-when {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  z-index: 3;
  padding: 3px 9px;
  border-radius: 999px;
  background: #23232b;
  color: #fff;
  font: 500 11px/1.4 "Poppins", system-ui, sans-serif;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 4px);
  pointer-events: none;
  transition: opacity .15s ease, transform .15s ease;
}
.gb-stamp:hover .gb-when, .gb-stamp:focus-visible .gb-when { opacity: 1; transform: translate(-50%, 0); }
.gb-yours {
  position: absolute;
  top: -8px;
  left: -6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ink, #23232b);
  color: var(--paper, #fff);
  font: 500 10px/1.4 "Poppins", system-ui, sans-serif;
  transform: rotate(-6deg);
}

/* Empty spots: faint perforated outlines; the first one invites a stamp. */
.gb-slot { aspect-ratio: 3 / 4; background: color-mix(in srgb, var(--ink, #23232b) 5%, transparent); }
.gb-slot--invite { background: color-mix(in srgb, #fbe38a 55%, transparent); }
[data-theme="dark"] .gb-slot--invite { background: color-mix(in srgb, #e9cf6e 22%, transparent); }
.gb-slot-invite {
  display: grid;
  place-items: center;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  margin: 8px;
  padding: 0;
  border: 1.5px dashed color-mix(in srgb, var(--muted, #6d6d74) 60%, transparent);
  border-radius: 2px;
  background: none;
  color: var(--muted, #6d6d74);
  font: 500 clamp(15px, 1.4vw, 18px)/1.15 "Edu QLD Hand", "Poppins", cursive;
  text-align: center;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease;
}
.pa-root .gb-slot-invite { color: var(--muted, #6d6d74); font: 500 clamp(15px, 1.4vw, 18px)/1.15 "Edu QLD Hand", "Poppins", cursive; }
.gb-slot-invite:hover, .pa-root .gb-slot-invite:hover { color: var(--ink, #23232b); border-color: var(--ink, #23232b); }
.gb-slot-invite:focus-visible { outline: 2px solid var(--ink, #23232b); outline-offset: -6px; }

/* A new stamp lands with a little "thunk" once the page has turned. */
.gb-stamp--new { animation: gb-thunk .55s cubic-bezier(.2, .9, .3, 1.2) .45s both; }
@keyframes gb-thunk {
  0% { opacity: 0; transform: translateY(-14px) scale(1.3) rotate(-8deg); }
  60% { opacity: 1; transform: translateY(0) scale(.96) rotate(1deg); }
  100% { transform: none; }
}

/* ---------- Phones: a compact title row, then a 2 × 2 sheet, short enough to match the photo pages ---------- */
.pa-root.m .pa-gb-mount { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; gap: 6px; padding-bottom: 0; }
.pa-root.m .pa-gb-mount .gb-title { grid-column: 1; grid-row: 1; padding: 0 4px; }
.pa-root.m .pa-gb-mount .gb-title h2 { font-size: 30px; }
.pa-root.m .gb-title-actions { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; margin-top: 2px; }
.pa-root.m .gb-in { font-size: 15px; }
.pa-root.m .pa-gb-mount .gb-postmark { display: none; }
.pa-root.m .gb-grid { grid-column: 1; grid-row: 2; grid-template-columns: repeat(2, minmax(0, 94px)); justify-content: center; gap: 10px 18px; padding: 8px 10px; }
.pa-root.m .gb-paper { padding: 8% 8% 7%; }
.pa-root.m .gb-name { font-size: 14px; }
.pa-root.m .gb-from { font-size: 10px; }
.pa-root.m .gb-slot-invite { font-size: 14px; }
@media (max-width: 409px) { .pa-root.m .gb-grid { grid-template-columns: repeat(2, minmax(0, 84px)); } }
@media (max-width: 374px) { .pa-root.m .gb-grid { grid-template-columns: repeat(2, minmax(0, 80px)); } }

/* ---------- The "Make a stamp" pop-up ---------- */
.gb-dialog {
  --gb-ink: rgb(35, 35, 43);
  --gb-muted: #6d6d74;
  --gb-line: #e3e1da;
  --gb-panel: #fbfaf5;
  --gb-field: #fff;
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: var(--gb-panel);
  color: var(--gb-ink);
  box-shadow: 0 24px 60px -12px rgba(20, 18, 12, .45);
  font-family: "Poppins", system-ui, sans-serif;
  font-weight: 300;
  overflow: auto;
}
.gb-dialog[open] { animation: gb-pop .22s ease; }
@keyframes gb-pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.gb-dialog::backdrop { background: rgba(20, 20, 24, .45); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.gb-dialog *, .gb-dialog *::before, .gb-dialog *::after { box-sizing: border-box; }
.gb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.gb-maker { position: relative; display: grid; grid-template-columns: 190px 1fr; gap: 28px; padding: 28px; }
.gb-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--gb-muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.gb-close:hover { background: rgba(0, 0, 0, .05); color: var(--gb-ink); }
.gb-close:focus-visible { outline: 2px solid var(--gb-ink); outline-offset: 2px; }
.gb-maker h2 { margin: 0 0 16px; font: 700 24px/1.2 "Playfair Display", Georgia, serif; }
.gb-preview { display: grid; place-items: start center; padding-top: 52px; }
.gb-preview .gb-stamp { width: 150px; transform: rotate(-3deg); --gb-step-x: 12.5px; --gb-step-y: 12.5px; }
.gb-set { margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }
.gb-set legend, .gb-field > span { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 500; color: var(--gb-ink); }
.gb-field em { font-style: normal; font-weight: 300; color: var(--gb-muted); }
.gb-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; }
.gb-icon, .gb-paper-opt { position: relative; }
.gb-icon input, .gb-paper-opt input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.gb-icon > span {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1.5px solid var(--gb-line);
  border-radius: 12px;
  background: var(--gb-field);
  transition: border-color .15s ease, transform .15s ease;
}
.gb-icon svg { width: 30px; height: 30px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .18)); }
.gb-icon input:hover + span { transform: translateY(-1px); }
.gb-icon input:checked + span { border-color: var(--gb-ink); box-shadow: 0 0 0 1px var(--gb-ink); }
.gb-icon input:focus-visible + span, .gb-paper-opt input:focus-visible + span { outline: 2px solid var(--gb-ink); outline-offset: 2px; }
.gb-papers { display: flex; flex-wrap: wrap; gap: 10px; }
.gb-paper-opt > span { display: block; width: 34px; height: 34px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.gb-paper-opt input:checked + span { box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12), 0 0 0 2px var(--gb-panel), 0 0 0 4px var(--gb-ink); }
.gb-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.gb-field input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1.5px solid var(--gb-line);
  border-radius: 12px;
  background: var(--gb-field);
  color: var(--gb-ink);
  font: 400 15px/1.2 "Poppins", system-ui, sans-serif;
}
.gb-field input::placeholder { color: #8d8d93; }
.gb-field input:focus { border-color: var(--gb-ink); outline: none; }
.gb-error { margin: 12px 0 0; font-size: 14px; color: #b3261e; }
.gb-actions { display: flex; align-items: center; gap: 18px; margin-top: 18px; }
.gb-dialog .gb-btn { min-height: 44px; padding: 0 22px; font-size: 15px; background: var(--gb-ink); color: var(--gb-panel); }
.gb-dialog .gb-link { color: var(--gb-muted); font-size: 14px; }
@media (max-width: 640px) {
  .gb-maker { grid-template-columns: 1fr; gap: 12px; padding: 22px 18px; }
  .gb-preview { padding-top: 8px; }
  .gb-preview .gb-stamp { width: 120px; }
  .gb-maker h2 { margin-bottom: 12px; font-size: 22px; text-align: center; }
  .gb-row { grid-template-columns: 1fr; }
}

/* ---------- Dark mode: stamps stay paper; the pop-up follows the site theme ---------- */
[data-theme="dark"] .gb-dialog {
  --gb-ink: var(--c-text, #ecebe7);
  --gb-muted: var(--c-text-3, #a5a49e);
  --gb-line: rgba(255, 255, 255, .14);
  --gb-panel: var(--c-surface, #1f1f1d);
  --gb-field: var(--c-surface-2, #2a2926);
}
[data-theme="dark"] .gb-close:hover { background: rgba(255, 255, 255, .08); }
[data-theme="dark"] .gb-field input::placeholder { color: #8f8e88; }
[data-theme="dark"] .gb-error { color: #f2b8b5; }
[data-theme="dark"] .gb-paper { background: #efece4; }
[data-theme="dark"] .gb-stamp { filter: drop-shadow(0 5px 10px rgba(0, 0, 0, .45)); }
[data-theme="dark"] .gb-when { background: #ecebe7; color: #161614; }

@media (prefers-reduced-motion: reduce) {
  .gb-stamp--new, .gb-dialog[open] { animation: none; }
  .gb-stamp, .gb-btn, .pa-gb-tab { transition: none; }
}
@media (forced-colors: active) {
  .gb-paper, .gb-slot { -webkit-mask: none; mask: none; border: 1px solid CanvasText; }
}
