/* This term's three goals, shown only when they matter: the banners that drop across the table (a term begins,
   a goal kept) and hold play for a moment, and the sheet that opens when the player taps the reeve's name.
   Also the wax seal on quest cards. */
:root { --kept: #ffd35c; }

/* ── the sheet: a native modal dialog ── */
.goals-sheet {
  width: min(460px, calc(100vw - 24px));
  max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);
  margin: auto;
  padding: 0;
  border: 1px solid rgb(241 230 200 / .25);
  border-radius: 14px;
  background: var(--bar);
  color: #fbf3df;
  font-family: var(--serif);
  box-shadow: 0 20px 60px rgb(0 0 0 / .6);
  &::backdrop { background: rgb(5 7 18 / .6); }
  &[open] { animation: sheet-in .25s ease-out; }
}
@keyframes sheet-in { from { opacity: 0; translate: 0 16px; } }
.sheet-body { display: grid; gap: 18px; padding: 22px 22px 20px; }
.sheet-title { margin: 0; font-size: .95rem; font-weight: 400; letter-spacing: .16em; text-transform: uppercase; color: #d8d1e4; }
.goal-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 12px;
  li { display: flex; gap: 12px; align-items: center; font-size: 1.15rem; line-height: 1.25; }
  .tick { width: 26px; height: 26px; }
  .tick rect { fill: none; stroke: #fbf3df; }
  .is-quest span { color: #f6dc98; }
  .done span { color: var(--kept); }
  .done .tick rect { fill: var(--kept); stroke: var(--kept); }
  .done .tick path { stroke-dashoffset: 0; }
}
.sheet-lang {
  margin: 0; padding: 14px 0 0; border: 0; border-top: 1px solid rgb(241 230 200 / .2);
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  legend { float: left; margin-right: 6px; padding: 0; color: #d8d1e4; font-size: .95rem; }
}
.goals-sheet button {
  font: inherit; font-size: 1rem; cursor: pointer;
  min-height: 44px; padding: .4em 1em; border-radius: 999px;
  border: 1px solid rgb(241 230 200 / .4); background: none; color: #fbf3df;
  &:hover { border-color: var(--gold); }
  &:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
}
.goals-sheet .lang[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #1c1608; }
.sheet-actions { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.goals-sheet .sheet-close { border-color: var(--gold); color: var(--gold); }
.goals-sheet .new-game { border-color: transparent; text-decoration: underline; text-underline-offset: 3px; color: #d8d1e4; padding-inline: 0; }
.sheet-ask {
  margin: 0; padding: 14px; border-radius: 10px; background: rgb(194 78 34 / .18); line-height: 1.35;
  span { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
  .ask-yes { border-color: #ff9a74; color: #ffb796; }
}

/* ── banners: full width across the top of the table, just under the meters ── */
.goal-ribbon {
  position: fixed; z-index: 8;
  left: 0; right: 0; top: var(--ribbon-top, 0px);
  display: grid; justify-items: center; gap: 8px;
  padding: 22px 24px 24px;
  background: linear-gradient(#c24e22, #9a3416);
  border-block: 3px solid #f0bf5c;
  box-shadow: 0 14px 40px rgb(0 0 0 / .5);
  color: #fff6e2;
  text-align: center;
  pointer-events: none;
  transform-origin: top;
  translate: 0 -24px;
  opacity: 0;
  transition: translate .4s cubic-bezier(.3, 1.4, .5, 1), opacity .25s;
  &.show { translate: 0 0; opacity: 1; }
  small { font-size: 1rem; font-weight: 600; letter-spacing: .2em; text-transform: uppercase; color: #ffe1a6; }
  em { font-size: 1.05rem; color: #ffe1a6; }
  b { font-size: clamp(1.6rem, 4vh, 2.6rem); font-weight: 600; }
  span { font-size: clamp(1.1rem, 2.2vh, 1.35rem); }
  p, ol { margin: 0; }
}
.rb-goal {
  display: flex; align-items: center; gap: 16px;
  span { font-size: clamp(1.4rem, 3.4vh, 2.2rem) !important; font-weight: 600; line-height: 1.15; text-align: start; }
}
.tick {
  flex: none; width: 1.6em; height: 1.6em;
  .rb-goal & { width: clamp(36px, 5vh, 52px); height: clamp(36px, 5vh, 52px); }
  rect { fill: rgb(0 0 0 / .18); stroke: #fff6e2; stroke-width: 2.2; }
  path { fill: none; stroke: #2a1606; stroke-width: 3.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 20; stroke-dashoffset: 20; }
}
.goal-ribbon.show .tick.on {
  rect { animation: tick-fill .3s .45s ease-out forwards; }
  path { animation: tick-draw .35s .65s ease-out forwards; }
}
@keyframes tick-fill { to { fill: #ffd35c; stroke: #ffd35c; } }
@keyframes tick-draw { to { stroke-dashoffset: 0; } }

.goal-ribbon.term {
  background: linear-gradient(#18204a, #0d1230);
  border-block-color: var(--gold);
  ol { list-style: none; padding: 0; display: grid; gap: 10px; justify-items: start; }
  li { display: flex; align-items: center; gap: 14px; }
  li span { font-size: clamp(1.15rem, 2.6vh, 1.6rem); text-align: start; line-height: 1.2; }
  .is-quest span { color: #f6dc98; }
  .tick rect { fill: none; stroke: #fbf3df; }
}
body.goal-hold #card { cursor: wait; }

/* quest cards carry Leeghwater's wax seal */
.card[data-quest="1"]::after {
  content: "";
  position: absolute; right: 14px; bottom: 14px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%;
  background:
    linear-gradient(45deg, transparent 46%, #f2c36a 46% 54%, transparent 54%),
    linear-gradient(-45deg, transparent 46%, #f2c36a 46% 54%, transparent 54%),
    radial-gradient(circle, #8e1f1a 58%, #6a1410 60% 64%, #a8322a 66%);
  box-shadow: 0 3px 6px rgb(0 0 0 / .45);
  rotate: -12deg;
}

@media (max-width: 760px) {
  .goal-ribbon { padding: 14px 16px 16px; gap: 6px; }
  .rb-goal { gap: 12px; }
  .goal-ribbon.term li span { font-size: 1.1rem; }
  .card[data-quest="1"]::after { width: 32px; height: 32px; right: 10px; bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .goal-ribbon { transition: opacity .2s; translate: none; }
  .goal-ribbon.show .tick.on { rect, path { animation-duration: 0s; animation-delay: .2s; } }
  .goals-sheet[open] { animation: none; }
}
