﻿/* Guest book «دفتر التهاني» (§8) */
#wishes { padding-block-end: 96px; }

/* ---------- Spotlight ---------- */
.gb-spot { margin-block-end: 32px; }
.gb-spot-card {
  position: relative;
  padding: 44px 24px 26px;
  background: linear-gradient(180deg, var(--parchment), var(--ivory));
  border: 1px solid rgba(201, 164, 106, .6);
  border-radius: 0 0 6px 6px;
  touch-action: pan-y;
  user-select: none; -webkit-user-select: none;
  --arch: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 350 80' preserveAspectRatio='none'%3E%3Cpath d='M0,80 V64 C0,38 92,20 152,9 L175,0 L198,9 C258,20 350,38 350,64 V80 Z'/%3E%3C/svg%3E");
  -webkit-mask: var(--arch) top / 100% 80px no-repeat, linear-gradient(#000, #000) bottom / 100% calc(100% - 79px) no-repeat;
          mask: var(--arch) top / 100% 80px no-repeat, linear-gradient(#000, #000) bottom / 100% calc(100% - 79px) no-repeat;
}
.gb-spot-arch { position: absolute; inset: 0 0 auto; width: 100%; height: 80px; fill: none; stroke: var(--gold); stroke-width: 2; opacity: .8; pointer-events: none; }
.gb-spot-q { position: absolute; top: 58px; inset-inline-start: 18px; width: 30px; height: 24px; color: var(--gold); opacity: .5; transform: rotate(15deg); }
.gb-slide { display: grid; gap: 14px; margin: 0; transition: opacity .45s ease, transform .45s var(--e-expo); }
.gb-slide.is-out { opacity: 0; transform: translateY(-8px); }
.gb-slide.no-t { transition: none; }
.gb-spot-msg {
  margin: 0; padding-inline: 14px;
  font: 500 clamp(21px, 6vw, 26px)/1.6 var(--f-letter); color: var(--ink);
  min-height: 3.2em; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden;
  white-space: pre-line; overflow-wrap: anywhere;
}
.gb-slide figcaption { display: grid; gap: 2px; }
.gb-spot-sig { font: 700 16px/1.6 var(--f-head); color: var(--gold-ink); }
.gb-spot-time { font: 400 12px/1.6 var(--f-body); color: var(--ink-mute); }
.gb-spot-nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; margin-block-start: 12px; }
/* dots get their own centred row above prev / pause / next (up to 10 dots × 24px) */
.gb-dots { display: flex; align-items: center; justify-content: center; flex-basis: 100%; order: -1; }
.gb-dot { width: 24px; height: 44px; display: grid; place-items: center; }
.gb-dot::before { content: ''; width: 5px; height: 5px; border-radius: 3px; background: var(--sand); transition: transform .35s var(--e-expo), background-color .35s; }
.gb-dot[aria-current="true"]::before { background: var(--gold); transform: scaleX(2.8); }
.gb-pn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--rule-gold); color: var(--gold-ink); font: 600 22px/1 var(--f-body); }
.gb-pause svg { width: 16px; height: 16px; fill: currentColor; }
.gb-pause .ic-play, .gb-pause[aria-pressed="true"] .ic-pause { display: none; }
.gb-pause[aria-pressed="true"] .ic-play { display: block; }
html.is-reduced .gb-pause { display: none; }   /* nothing rotates under reduced motion */

/* ---------- Form (letter paper) ---------- */
.gb-form {
  position: relative; isolation: isolate;
  padding: 28px 22px; border-radius: 18px; background: var(--paper); text-align: start;
  box-shadow: inset 0 0 0 8px var(--paper), inset 0 0 0 9px var(--rule-gold), inset 0 0 0 12px var(--paper), inset 0 0 0 12.5px var(--rule-gold), var(--shadow-card);
}
.gb-form::before {
  content: ''; position: absolute; inset: 14px 14px auto; height: 34%; z-index: -1; pointer-events: none;
  background-image: var(--lattice); background-size: 48px 48px; opacity: .05; border-radius: 8px 8px 0 0;
  -webkit-mask-image: linear-gradient(#000, transparent); mask-image: linear-gradient(#000, transparent);
}
.gb-form .corner { top: 16px; bottom: auto; }
.gb-form .corner.br, .gb-form .corner.bl { top: auto; bottom: 16px; }
.gb-form .corner.tr, .gb-form .corner.br { inset-inline-start: 16px; }
.gb-form .corner.tl, .gb-form .corner.bl { inset-inline-end: 16px; }
.gb-form.is-dip { animation: gb-dip .18s ease-out; }
@keyframes gb-dip { 50% { transform: translateY(2px); } }

.gb-fwrap { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .4s var(--e-expo), opacity .4s ease; }
.gb-fields { min-height: 0; display: grid; gap: 22px; padding: 14px 4px 6px; }
.is-done .gb-fwrap { grid-template-rows: 0fr; opacity: 0; }
.is-done .gb-fields { overflow: hidden; padding-block: 0; }

.gb-field { position: relative; }
.gb-input {
  display: block; width: 100%; padding: 22px 0 8px; border: 0; border-bottom: 1px solid var(--sand); border-radius: 0;
  background: transparent; font: 400 17px/1.5 var(--f-body); color: var(--ink);
}
.gb-input:focus-visible { outline: none; }
.gb-flabel {
  position: absolute; top: 24px; inset-inline-start: 0; pointer-events: none;
  font: 500 16px/1.5 var(--f-body); color: var(--ink-mute);
  transform-origin: right top; transition: transform .25s var(--e-expo), color .25s;
}
.gb-input:focus + .gb-flabel, .gb-input:not(:placeholder-shown) + .gb-flabel { transform: translateY(-22px) scale(.8125); color: var(--gold-ink); }
.gb-line { position: absolute; inset-inline: 0; top: calc(22px + 1.5em + 7px); height: 2px; background: var(--gold); transform: scaleX(0); transition: transform .3s var(--e-expo); }
.gb-input:focus + .gb-flabel + .gb-line { transform: scaleX(1); }
.gb-input[aria-invalid="true"] { border-bottom-color: var(--error); }
.gb-err { font: 500 13px/1.6 var(--f-body); color: var(--error); margin-block-start: 6px; }
.gb-err:empty { display: none; }

.gb-att { border: 0; margin: 0; padding: 0; min-width: 0; }
.gb-att legend { padding: 0; margin-block-end: 12px; font: 700 18px/1.5 var(--f-head); color: var(--ink); }
.gb-pills { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 339px) { .gb-pills { grid-template-columns: minmax(0, 1fr); } }
.gb-pill { position: relative; display: block; min-width: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.gb-pill input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.gb-pface {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 56px; padding: 6px 8px;
  border: 1px solid var(--sand); border-radius: 14px; background: var(--paper);
  font: 500 14px/1.4 var(--f-body); color: var(--ink-soft); text-align: center; text-wrap: balance;
  transition: background-color .25s, color .25s, border-color .25s, transform .15s;
}
.gb-pface svg { width: 20px; height: 20px; flex: none; color: var(--gold-ink); }
.gb-pill:active .gb-pface { transform: scale(.98); }
.gb-pill input:focus-visible + .gb-pface { outline: 2px solid var(--focus-ivory); outline-offset: 3px; }
.gb-yes input:checked + .gb-pface { background: var(--btn-gold); border-color: transparent; color: var(--night-900); font-weight: 600; }
.gb-yes input:checked + .gb-pface svg { color: var(--night-900); }
.gb-no input:checked + .gb-pface { background: var(--blush); border-color: transparent; color: var(--rose-ink); font-weight: 600; }
.gb-no input:checked + .gb-pface svg { color: var(--rose-ink); }
.gb-att[aria-invalid="true"] .gb-pface { border-color: var(--error); }
.gb-spk { position: absolute; top: 50%; left: 50%; width: 10px; height: 10px; margin: -5px; color: var(--gold); pointer-events: none; animation: gb-spk .7s var(--e-expo) forwards; }
@keyframes gb-spk {
  0% { transform: rotate(var(--a)) translateY(0) scale(0); opacity: 1; }
  50% { transform: rotate(var(--a)) translateY(-36px) scale(1) rotate(45deg); opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(-44px) scale(0) rotate(90deg); opacity: 0; }
}

.gb-reveal { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .3s var(--e-expo), opacity .3s ease; }
.gb-reveal > div { min-height: 0; overflow: hidden; }
.gb-reveal.is-on { grid-template-rows: 1fr; opacity: 1; }
.gb-step { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 4px 4px; }
.gb-step-l { font: 500 15px/1.5 var(--f-body); color: var(--ink-soft); }
.gb-step-c { display: flex; align-items: center; gap: 10px; }
.gb-sbtn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--gold); color: var(--gold-ink); font: 500 22px/1 var(--f-body); display: grid; place-items: center; }
.gb-sbtn:disabled { opacity: .35; cursor: default; }
.gb-sval { min-width: 2ch; text-align: center; font-size: 28px; line-height: 1; color: var(--ink); }
.gb-miss { margin-block-start: 12px; font: 400 14px/1.7 var(--f-body); color: var(--rose-ink); }

.gb-label { display: block; margin-block-end: 6px; font: 500 13px/1.6 var(--f-body); color: var(--gold-ink); }
.gb-ta {
  display: block; width: 100%; height: 144px; resize: none; border: 0; border-radius: 0; padding: 0 2px;
  font: 500 19px/36px var(--f-letter); color: var(--ink);
  background: repeating-linear-gradient(transparent 0 35px, var(--rule-gold) 35px 36px);
  background-attachment: local;
}
.gb-ta::placeholder { color: var(--ink-mute); opacity: 1; }
.gb-ta:focus-visible { outline: 2px solid var(--focus-ivory); outline-offset: 6px; border-radius: 4px; }
.gb-ta[aria-invalid="true"] { box-shadow: inset 0 -2px 0 var(--error); }
.gb-count { margin-block-start: 6px; text-align: end; font: 400 12px/1.6 var(--f-body); color: var(--ink-mute); }
.gb-count.is-near { color: var(--rose-ink); }

.gb-hp { position: absolute; left: -200vw; top: 0; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.gb-submit { min-height: 54px; position: relative; }
.gb-submit:disabled { cursor: progress; }
.gb-submit .gb-bseal { width: 36px; height: 36px; margin-block: -8px; }
.gb-bseal .gb-ha, .gb-bseal .gb-hb { transition: transform .4s var(--e-fall); transform-box: view-box; transform-origin: 50% 50%; }
.gb-crack { opacity: 0; transition: opacity .2s; }
.is-crack .gb-ha { transform: translate(-6px, -8px) rotate(-8deg); }
.is-crack .gb-hb { transform: translate(6px, 8px) rotate(6deg); }
.is-crack .gb-crack { opacity: .5; }
.gb-submit .gb-spin { display: none; width: 22px; height: 22px; }
.gb-submit.is-loading .gb-bseal { display: none; }
.gb-submit.is-loading .gb-spin { display: block; animation: gb-rot 1.2s linear infinite; }
@keyframes gb-rot { to { transform: rotate(360deg); } }
.gb-nudge { animation: gb-nudge .3s ease; }
@keyframes gb-nudge { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.gb-ferr { font: 500 14px/1.6 var(--f-body); color: var(--error); text-align: center; margin-block-start: -8px; }
.gb-ferr:empty { display: none; }

/* success stamp */
.gb-stamp { position: absolute; top: -18px; left: -12px; width: 84px; height: 84px; z-index: 3; pointer-events: none; opacity: 0; transform: scale(1.8) rotate(-20deg); }
.is-sent .gb-stamp { animation: gb-stamp .42s var(--e-spring) forwards; }
@keyframes gb-stamp { to { opacity: 1; transform: scale(1) rotate(-12deg); } }
html.is-reduced .is-sent .gb-stamp { animation: none; opacity: 1; transform: rotate(-12deg); }
.gb-fleck { position: absolute; top: 24px; left: 30px; width: 5px; height: 5px; margin: -2.5px; border-radius: 50%; background: var(--gold); pointer-events: none; z-index: 4; animation: gb-fleck .75s var(--e-expo) forwards; }
@keyframes gb-fleck {
  from { transform: rotate(var(--a)) translateX(20px) scale(1); opacity: 1; }
  to { transform: rotate(var(--a)) translateX(var(--r)) scale(.3); opacity: 0; }
}
.gb-done { text-align: center; padding: 22px 6px 2px; animation: gb-up .5s var(--e-expo) both; }
.gb-done-t { font: 700 22px/1.6 var(--f-head); color: var(--ink); }
.gb-done-t:focus-visible { outline-offset: 6px; }
.gb-done-a { margin-block-start: 6px; font: 400 16px/1.7 var(--f-body); color: var(--olive); }
.gb-again { margin-block-start: 10px; }
@keyframes gb-up { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Wall ---------- */
.gb-wall { position: relative; margin-block-start: 56px; text-align: start; scroll-margin-top: 16px; }
.gb-whead { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-block-end: 18px; }
.gb-wtitle { font: 700 24px/1.5 var(--f-head); color: var(--ink); }
.gb-count-chip { padding: 2px 12px; border-radius: 999px; border: 1px solid var(--rule-gold); background: var(--parchment); font: 500 13px/1.7 var(--f-body); color: var(--gold-ink); }
.gb-live { display: inline-flex; align-items: center; gap: 8px; margin-inline-start: auto; font: 500 12.5px/1.6 var(--f-body); color: var(--ink-mute); }
.gb-live i { position: relative; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.gb-live i::after { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--gold); animation: gb-ping 1.8s ease-out infinite; }
@keyframes gb-ping { from { transform: scale(1); opacity: .8; } to { transform: scale(3.2); opacity: 0; } }
html.is-reduced .gb-live i::after { animation: none; opacity: 0; }

.gb-newpill {
  position: sticky; top: calc(12px + env(safe-area-inset-top)); z-index: 6;
  display: flex; align-items: center; min-height: 44px; margin: 0 auto -44px; width: max-content; padding: 0 18px;
  border-radius: 999px; background: var(--night-900); color: var(--gold-light); font: 500 13px/1 var(--f-body);
  box-shadow: 0 10px 24px -10px rgba(11, 16, 32, .6);
}
.gb-newpill.is-in { animation: gb-drop .45s var(--e-spring) both; }
@keyframes gb-drop { from { transform: translateY(-120%); opacity: 0; } }
.gb-newpill:focus-visible { outline-color: var(--focus-ivory); }

.gb-feed { display: grid; gap: 14px; }
.gb-card {
  position: relative; padding: 18px 20px; border-radius: 16px;
  background: var(--paper); border: 1px solid var(--rule-gold); box-shadow: var(--shadow-card);
}
.gb-card .corner { width: 14px; height: 14px; top: 5px; opacity: .8; }
.gb-card .corner.tr { inset-inline-start: 5px; }
.gb-card .corner.bl { top: auto; bottom: 5px; inset-inline-end: 5px; }
.gb-card:focus-visible { outline-offset: 3px; border-radius: 16px; }
.gb-chead { display: flex; align-items: center; gap: 12px; margin-block-end: 10px; }
.gb-av {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--blush), var(--paper)); box-shadow: inset 0 0 0 1px var(--gold);
  font: 700 18px/1 var(--f-head); color: var(--gold-ink);
}
.gb-who { display: grid; min-width: 0; }
.gb-name { font: 700 16px/1.5 var(--f-head); color: var(--gold-ink); overflow-wrap: anywhere; }
.gb-time { font: 400 12px/1.5 var(--f-body); color: var(--ink-mute); }
.gb-tag { flex: none; margin-inline-start: auto; padding: 1px 10px; border-radius: 999px; border: 1px solid var(--rule-gold); background: var(--parchment); font: 500 12px/1.7 var(--f-body); color: var(--gold-ink); }
.gb-tag--new { background: var(--night-900); border-color: var(--night-900); color: var(--gold-light); }
.gb-tag + .gb-tag { margin-inline-start: 0; }
.gb-msg {
  font: 500 clamp(18px, 4.9vw, 20px)/1.85 var(--f-letter); color: var(--ink);
  white-space: pre-line; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 6; overflow: hidden;
}
.gb-card.is-open .gb-msg { display: block; -webkit-line-clamp: unset; overflow: visible; }
.gb-rm { min-height: 44px; padding: 0; margin-block-start: 2px; font-size: 14px; }

.gb-card--q {
  text-align: center; padding: 30px 22px 24px;
  background:
    linear-gradient(var(--rule-gold), var(--rule-gold)) center top 12px / 56% 1px no-repeat,
    linear-gradient(var(--rule-gold), var(--rule-gold)) center top 16px / 36% 1px no-repeat,
    linear-gradient(var(--rule-gold), var(--rule-gold)) center bottom 12px / 56% 1px no-repeat,
    linear-gradient(var(--rule-gold), var(--rule-gold)) center bottom 16px / 36% 1px no-repeat,
    var(--paper);
}
.gb-q { width: 34px; height: 26px; margin: 0 auto 6px; color: var(--gold); opacity: .5; transform: rotate(15deg); }
.gb-card--q .gb-msg { font-size: clamp(21px, 6vw, 26px); line-height: 1.6; -webkit-line-clamp: unset; display: block; }
.gb-sig { margin-block-start: 10px; font: 700 16px/1.5 var(--f-head); color: var(--gold-ink); }
.gb-card--q .gb-tag { display: inline-block; margin: 6px auto 0; }

/* entrances */
.gb-enter { opacity: 0; transform: translateY(12px) scale(.98); }
.gb-enter.is-in { opacity: 1; transform: none; transition: opacity .5s var(--e-expo), transform .5s var(--e-expo); transition-delay: calc(var(--i, 0) * 60ms); }
.gb-grow { display: grid; overflow: hidden; animation: gb-grow .36s var(--e-expo) both; }
.gb-grow > .gb-card { min-height: 0; }
@keyframes gb-grow { from { grid-template-rows: 0fr; } to { grid-template-rows: 1fr; } }
.gb-rise { animation: gb-up .5s var(--e-expo) .1s both; }
.gb-unseal { animation: gb-unseal .75s var(--e-cine) both; }
@keyframes gb-unseal { from { clip-path: circle(22px at 50% 28px); } to { clip-path: circle(150% at 50% 28px); } }
.gb-sweep::after {
  content: ''; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1.5px var(--gold); animation: gb-fade 1.6s ease-out both;
}
@keyframes gb-fade { from { opacity: 1; } to { opacity: 0; } }

/* skeleton */
.gb-skel { position: relative; overflow: hidden; display: grid; gap: 10px; padding: 20px; border-radius: 16px; background: var(--paper); border: 1px solid var(--rule-gold); }
.gb-skel i { display: block; height: 12px; border-radius: 6px; background: var(--parchment); }
.gb-skel i:first-child { width: 40%; height: 14px; }
.gb-skel i:last-child { width: 70%; }
.gb-skel::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 30%, rgba(255, 253, 248, .75) 50%, transparent 70%);
  transform: translateX(100%); animation: gb-sheen 1.4s ease-in-out infinite;
}
@keyframes gb-sheen { to { transform: translateX(-100%); } }
html.is-reduced .gb-skel::after { display: none; }

.gb-empty { display: grid; justify-items: center; gap: 10px; padding: 28px 12px; text-align: center; font: 400 16px/1.8 var(--f-body); color: var(--ink-soft); }
.gb-quill { width: 44px; height: 44px; color: var(--gold-ink); --draw-dur: 1400ms; }
.gb-loaderr { text-align: center; margin-block-start: 12px; }
.gb-more { display: flex; margin: 24px auto 0; }
.gb-more:disabled { opacity: .6; }

/* reduced motion */
html.is-reduced .gb-slide, html.is-reduced .gb-fwrap, html.is-reduced .gb-reveal { transition: opacity .2s ease; }
html.is-reduced .gb-done, html.is-reduced .gb-newpill.is-in { animation: none; }

/* ===== desktop ===== */
/* Spotlight spans the top; the letter form is a sticky column on the start (right) side and
   the wall fills the end side with a 2-column masonry (CSS columns keep DOM/feed order). */
@media (min-width: 1024px) {
  #wishes {
    display: grid;
    grid-template-columns: clamp(340px, 30vw, 420px) minmax(0, 1fr);
    column-gap: clamp(40px, 4.5vw, 72px);
    align-items: start;
    padding-block-end: 140px;
  }
  #wishes > .sec-head, #wishes > .gb-spot { grid-column: 1 / -1; }
  .gb-spot { width: 100%; max-width: 760px; justify-self: center; margin-block-end: 64px; }
  .gb-spot-card { padding: 56px 48px 32px; }
  .gb-spot-msg { font-size: 28px; padding-inline: 24px; }
  .gb-spot-q { top: 64px; inset-inline-start: 28px; width: 38px; height: 30px; }

  .gb-form { grid-column: 1; position: sticky; top: 24px; padding: 32px 28px; }
  .gb-dots { flex-basis: auto; order: 0; }
  .gb-wall { grid-column: 2; margin-block-start: 0; }
  .gb-whead { margin-block-end: 22px; }
  .gb-wtitle { font-size: 28px; }

  .gb-feed { display: block; columns: 230px 2; column-gap: 18px; }   /* never narrower than 230px */
  .gb-feed > * { break-inside: avoid; margin-block-end: 18px; }
  .gb-msg { font-size: 19px; }
  .gb-card--q .gb-msg { font-size: 22px; }
  .gb-more { margin-block-start: 8px; }
}
/* The form (~620-720px with errors) must fit the viewport to be sticky, or its submit button
   and error line stay pinned below the fold on 1280x720 / 1366x768 laptops. */
@media (min-width: 1024px) and (max-height: 779px) {
  .gb-form { position: relative; top: auto; }
}
@media (min-width: 1440px) {
  #wishes { grid-template-columns: 420px minmax(0, 1fr); }
  .gb-feed { columns: 230px 3; }
}
