/* Watch rewards: top-bar button, rewards panel, chest reveal, level-up celebration (farm-rewards.js). */

.fh-rewards {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--fh-line-strong);
  background: var(--fh-accent-soft);
  color: var(--fh-ink);
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.fh-rewards:hover,
.fh-rewards:focus-visible {
  border-color: var(--fh-accent-ink);
}
.fh-rewards.has-chest {
  animation: rw-glow 2.4s ease-in-out infinite;
}
.fh-rewards .fh-badge {
  position: absolute;
  top: -6px;
  right: -6px;
}
@keyframes rw-glow {
  0%,
  100% {
    box-shadow: 0 0 0 0 #f2c14e00;
  }
  50% {
    box-shadow: 0 0 0 5px #f2c14e66;
  }
}

.rw-dialog {
  width: min(860px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--fh-line-strong);
  border-radius: 18px;
  background: var(--fh-bg);
  color: var(--fh-ink);
  box-shadow: 0 24px 80px #0008;
  overflow: hidden;
}
.rw-dialog::backdrop {
  background: #07120ccc;
}
.rw-wrap {
  position: relative;
  max-height: calc(100vh - 34px);
  overflow: auto;
  padding: 22px;
  display: grid;
  gap: 14px;
}
.rw-loading,
.rw-error {
  margin: 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--fh-surface);
}
.rw-error {
  background: var(--fh-bad-bg);
  color: var(--fh-bad);
  font-weight: 600;
}
.rw-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--fh-line-strong);
  background: var(--fh-surface);
  color: var(--fh-ink);
  cursor: pointer;
  font-size: 1rem;
}
.rw-head {
  display: flex;
  gap: 16px;
  align-items: center;
  padding-right: 40px;
}
.rw-head h2 {
  margin: 2px 0 4px;
  font-size: clamp(1.4rem, 3vw, 2rem);
}
.rw-head h2 b {
  color: var(--fh-accent-ink);
}
.rw-head p {
  margin: 0;
  color: var(--fh-muted);
}
.rw-dial {
  flex: none;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 2rem;
  background: conic-gradient(from 0deg, #f2c14e, #c7e35a, #2f7a4b, #5aa0d8, #f2c14e);
  box-shadow: inset 0 0 0 6px var(--fh-bg);
}
.rw-dial span {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--fh-surface);
}
html:not([data-motion='calm']) .rw-dial {
  animation: rw-spin 12s linear infinite;
}
html:not([data-motion='calm']) .rw-dial span {
  animation: rw-spin 12s linear infinite reverse;
}
@keyframes rw-spin {
  to {
    transform: rotate(360deg);
  }
}

.rw-card {
  position: relative;
  background: var(--fh-surface);
  border: 1px solid var(--fh-line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--fh-shadow);
}
.rw-card h3 {
  margin: 0;
  font-size: 1.05rem;
}
.rw-card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.rw-card-head small,
.rw-fine {
  color: var(--fh-faint);
  font-size: 0.82rem;
}
.rw-fine {
  margin: 10px 0 0;
}

.rw-season {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 0.78rem;
  color: var(--fh-faint);
  margin: 6px 0 26px;
}
.rw-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: var(--fh-fair-bg);
}
.rw-track i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #8bbf5a, #2f7a4b 60%, #c99a3b);
}
.rw-track em {
  position: absolute;
  top: 14px;
  transform: translateX(-50%);
  font-style: normal;
  font-weight: 700;
  color: var(--fh-ink);
  white-space: nowrap;
}
.rw-warp-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 8px;
}
.rw-warp-btn {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 12px 6px;
  border-radius: 12px;
  border: 1px solid var(--fh-line-strong);
  background: var(--fh-bg);
  color: var(--fh-ink);
  font: inherit;
  cursor: pointer;
  transition:
    transform 0.12s,
    border-color 0.12s;
}
.rw-warp-btn b {
  font-size: 1.25rem;
}
.rw-warp-btn small {
  color: var(--fh-muted);
  font-size: 0.75rem;
}
.rw-warp-btn:not(:disabled):hover,
.rw-warp-btn:not(:disabled):focus-visible {
  border-color: var(--fh-accent-ink);
  transform: translateY(-2px);
}
.rw-warp-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.rw-stage {
  grid-column: span 2;
  background: var(--fh-accent-soft);
}

.rw-timelapse {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  border-radius: inherit;
  background: color-mix(in srgb, var(--fh-surface) 88%, transparent);
  backdrop-filter: blur(2px);
  font-size: 1.1rem;
}
.rw-timelapse p {
  margin: 0;
}
.rw-timelapse b {
  font-size: 2rem;
  color: var(--fh-accent-ink);
}
.rw-sky {
  position: relative;
  width: 140px;
  height: 70px;
  overflow: hidden;
  border-radius: 70px 70px 0 0;
  background: linear-gradient(#5aa0d8, #c9e4f5);
}
.rw-sky.go {
  animation: rw-daynight 0.45s linear infinite;
}
.rw-sky i {
  position: absolute;
  left: 60px;
  top: 50px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  transform-origin: 10px 20px;
}
.rw-sky .sun {
  background: #f2c14e;
  box-shadow: 0 0 12px #f2c14e;
}
.rw-sky .moon {
  background: #eef0e6;
  transform: rotate(180deg) translateY(-48px);
}
.rw-sky.go .sun,
.rw-sky.go .moon {
  animation: rw-orbit 0.9s linear infinite;
}
.rw-sky.go .moon {
  animation-delay: -0.45s;
}
@keyframes rw-orbit {
  from {
    transform: rotate(-90deg) translateY(-48px);
  }
  to {
    transform: rotate(270deg) translateY(-48px);
  }
}
@keyframes rw-daynight {
  50% {
    filter: brightness(0.45);
  }
}

.rw-streak {
  display: flex;
  gap: 18px;
  align-items: center;
}
.rw-ring {
  flex: none;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(#e46b4c calc(var(--p) * 1%), var(--fh-fair-bg) 0);
}
.rw-ring span {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: var(--fh-surface);
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
}
.rw-ring small {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--fh-muted);
}
.rw-streak-copy p {
  margin: 6px 0;
  color: var(--fh-muted);
}
.rw-flame {
  color: var(--fh-ink) !important;
}
.rw-milestones {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
.rw-milestones li {
  display: grid;
  justify-items: center;
  min-width: 58px;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px dashed var(--fh-line-strong);
  font-size: 0.75rem;
}
.rw-milestones li b {
  font-size: 1rem;
}
.rw-milestones li em {
  font-style: normal;
  font-weight: 700;
  color: var(--fh-accent-ink);
}
.rw-milestones li.done {
  border-style: solid;
  background: var(--fh-warn-bg);
}

.rw-chests {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rw-chest {
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--fh-line);
  background: var(--fh-bg);
}
.rw-chest.ready {
  border-color: #f2c14e;
  background: linear-gradient(160deg, #f2c14e2e, var(--fh-bg) 60%);
}
html:not([data-motion='calm']) .rw-chest.ready .rw-badge {
  animation: rw-bob 1.6s ease-in-out infinite;
}
.rw-chest.locked {
  opacity: 0.72;
}
.rw-chest.claimed {
  background: var(--fh-good-bg);
}
.rw-chest-top {
  display: flex;
  gap: 10px;
  align-items: center;
}
.rw-chest-top small {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--fh-faint);
}
.rw-chest-top em {
  display: block;
  font-size: 0.75rem;
  color: var(--fh-muted);
}
.rw-chest ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.82rem;
}
.rw-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--fh-surface);
  border: 1px solid var(--fh-line);
  font-size: 1.5rem;
}
.rw-chest-state {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--fh-muted);
}
.rw-chest-state.done {
  color: var(--fh-good);
}
@keyframes rw-bob {
  50% {
    transform: translateY(-4px) rotate(-6deg);
  }
}

.rw-reveal {
  padding: 16px;
  border-radius: 14px;
  border: 2px solid #f2c14e;
  background: linear-gradient(140deg, #f2c14e33, var(--fh-surface));
}
.rw-reveal-warp {
  border-color: #5aa0d8;
  background: linear-gradient(140deg, #5aa0d833, var(--fh-surface));
}
.rw-reveal h3 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}
.rw-reveal > ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.rw-reveal > ol > li {
  display: flex;
  gap: 12px;
}
.rw-reveal small {
  display: block;
  color: var(--fh-muted);
}
.rw-reveal ul {
  margin: 4px 0 0;
  padding-left: 18px;
}
html:not([data-motion='calm']) .rw-badge.pop {
  animation: rw-pop 0.7s cubic-bezier(0.2, 1.6, 0.4, 1) both;
}
@keyframes rw-pop {
  from {
    transform: scale(0.2) rotate(-30deg);
    opacity: 0;
  }
}

.rw-history ul {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
}
.rw-history li {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.rw-history li small {
  margin-left: auto;
  color: var(--fh-faint);
}
.rw-history summary {
  cursor: pointer;
  font-weight: 700;
}
.rw-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.rw-foot p {
  margin: 0;
  flex: 1 1 280px;
  color: var(--fh-muted);
  font-size: 0.85rem;
}

.rw-confetti {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  overflow: hidden;
}
.rw-confetti i {
  position: absolute;
  top: -14px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: rw-fall linear forwards;
}
@keyframes rw-fall {
  to {
    top: 105%;
    transform: rotate(720deg) translateX(50px);
  }
}

.rw-levelup {
  width: min(460px, calc(100vw - 24px));
  text-align: center;
}
.rw-levelup .rw-wrap {
  justify-items: center;
}
.rw-levelup h2 {
  margin: 0;
}
.rw-levelup p {
  margin: 0;
  color: var(--fh-muted);
}
.rw-burst {
  width: 110px;
  height: 110px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle, #f2c14e66, transparent 70%);
}
.rw-burst .rw-badge {
  width: 72px;
  height: 72px;
  font-size: 2.4rem;
  border-radius: 20px;
}
.rw-lu-list {
  margin: 0;
  padding: 12px 16px;
  list-style: none;
  display: grid;
  gap: 4px;
  border-radius: 12px;
  background: var(--fh-surface);
  font-weight: 600;
}
.rw-lu-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

/* Show library: rewards strip under the level card, chest lines on the level ladder. */
.rw-strip {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #f2c14e22;
  border: 1px solid #f2c14e66;
  font-size: 0.9rem;
}
.rw-strip button {
  margin-left: auto;
}
.rw-strip-chest {
  font-weight: 700;
}
.edu-ladder .edu-chest {
  display: block;
  margin-top: 2px;
  opacity: 0.85;
}

@media (max-width: 560px) {
  .rw-wrap {
    padding: 16px;
  }
  .rw-streak {
    flex-direction: column;
    align-items: flex-start;
  }
  .rw-stage {
    grid-column: 1 / -1;
  }
  .fh-rewards span {
    display: none;
  }
}
