/* Harvest day: the planner dialog (harvest-planner.js), the live "harvest underway" panel and Your grain in the
   farm office (farm-office.js), and the visitor's harvest video call (harvest-call.js). Farm-office colours use
   the --fh-* tokens so light and dark themes both work. */

.hv-overlay {
  position: fixed;
  inset: 0;
  z-index: 1150;
  background: #0b1610c4;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
}
.hv-box {
  position: relative;
  width: min(860px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--fh-surface, #fff);
  color: var(--fh-ink, #14241a);
  border-radius: 16px;
  padding: 22px 24px 18px;
  box-shadow: 0 30px 80px #0008;
}
.hv-box h2 {
  margin: 4px 0 6px;
  font-size: 1.6rem;
}
.hv-box h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 8px;
  font-size: 1rem;
  letter-spacing: 0.02em;
}
.hv-box h3 span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--fh-accent-ink, #3a2a00);
  color: var(--fh-surface, #fff);
  font-size: 0.8rem;
}
.hv-lead,
.hv-sum {
  color: var(--fh-muted, #55645a);
  margin: 0;
}
.hv-sum {
  margin-top: 14px;
  font-weight: 600;
  color: var(--fh-ink, #14241a);
}
.hv-x {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: none;
  font-size: 1.2rem;
  color: var(--fh-muted, #55645a);
  cursor: pointer;
}
.hv-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}
.hv-cards.two {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.hv-card {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 12px;
  border: 2px solid var(--fh-line, #d9e0da);
  border-radius: 12px;
  background: var(--fh-surface-2, #f6f8f5);
  cursor: pointer;
  transition:
    border-color 0.15s,
    transform 0.15s;
}
.hv-card:hover {
  transform: translateY(-1px);
}
.hv-card:has(input:checked) {
  border-color: var(--fh-good, #2f7d3b);
  background: var(--fh-good-bg, #e7f4e8);
}
.hv-card:has(input:focus-visible) {
  outline: 3px solid var(--fh-info, #2a6fb0);
  outline-offset: 2px;
}
.hv-card.off {
  opacity: 0.55;
  cursor: not-allowed;
}
.hv-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.hv-pic {
  font-size: 1.8rem;
  line-height: 1;
}
.hv-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.hv-body small {
  color: var(--fh-muted, #55645a);
  line-height: 1.35;
}
.hv-body em {
  font-style: normal;
  font-size: 0.8rem;
  color: var(--fh-bad, #a23a2e);
}
.hv-facts {
  display: grid;
  gap: 2px;
  margin-top: 4px;
}
.hv-facts i {
  font-style: normal;
  font-size: 0.8rem;
  font-weight: 600;
}
.hv-buyers {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}
.hv-buyer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--fh-line, #d9e0da);
  border-radius: 10px;
  cursor: pointer;
}
.hv-buyer:has(input:checked) {
  border-color: var(--fh-good, #2f7d3b);
  background: var(--fh-good-bg, #e7f4e8);
}
.hv-buyer > span {
  flex: 1;
  display: grid;
}
.hv-buyer small {
  color: var(--fh-muted, #55645a);
}
.hv-buyer strong {
  font-size: 1.1rem;
  text-align: right;
}
.hv-buyer strong small {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
}
.hv-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* The live panel on the field page and overview. */
.hv-run {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--fh-line-strong, #b9c4bb);
  background: linear-gradient(120deg, var(--fh-warn-bg, #fff6dd), var(--fh-surface, #fff));
}
.hv-run.paused {
  background: var(--fh-surface-2, #f6f8f5);
}
.hv-run-head {
  display: flex;
  gap: 10px;
  align-items: center;
}
.hv-run-head > div {
  display: grid;
}
.hv-run-pic {
  font-size: 1.8rem;
}
.hv-run-bar {
  height: 12px;
  margin: 10px 0 6px;
  border-radius: 6px;
  background: var(--fh-line, #d9e0da);
  overflow: hidden;
}
.hv-run-bar i {
  display: block;
  height: 100%;
  background: repeating-linear-gradient(-45deg, #d8a73a 0 10px, #c48f22 10px 20px);
  transition: width 0.9s linear;
}
:root[data-motion='calm'] .hv-run-bar i {
  transition: none;
}
.hv-run-line {
  margin: 0;
  font-weight: 600;
}
.hv-money {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 4px;
}
.hv-grain {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--fh-line, #d9e0da);
  background: var(--fh-surface-2, #f6f8f5);
}
.hv-grain h3 {
  margin-top: 0;
}

/* Harvest-day video call. */
.hc-ring {
  position: fixed;
  top: 76px;
  right: 16px;
  z-index: 1230;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(380px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 22px;
  background: #1d1f22f2;
  color: #fff;
  box-shadow: 0 18px 50px #0009;
  backdrop-filter: blur(10px);
  animation: hc-in 0.35s ease-out;
}
.hc-ring-face {
  position: relative;
  flex: none;
}
.hc-ring-face img {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.hc-ring:not(.calm) .hc-ring-face::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #3ddc84;
  animation: hc-pulse 1.2s ease-out infinite;
}
.hc-ring-text {
  flex: 1;
  display: grid;
  min-width: 0;
}
.hc-ring-text small {
  color: #c8ccd0;
}
.hc-ring-why {
  font-size: 0.75rem;
}
.hc-btn {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  font-size: 1.15rem;
  color: #fff;
  cursor: pointer;
  background: #3a3d41;
}
.hc-btn.accept {
  background: #2fbf63;
}
.hc-btn.decline,
.hc-btn.end {
  background: #e0453a;
}
.hc-btn.end {
  transform: rotate(135deg);
}
.hc-missed {
  position: fixed;
  top: 76px;
  right: 16px;
  z-index: 1230;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 14px;
  background: #1d1f22f0;
  color: #fff;
}
.hc-missed .text-link {
  color: #7fe0a2;
}
.hc-call {
  position: fixed;
  inset: 0;
  z-index: 1240;
  display: grid;
  place-items: center;
  background: #000c;
  padding: 14px;
  animation: hc-fade 0.3s ease-out;
}
.hc-call.out {
  opacity: 0;
  transition: opacity 0.3s;
}
.hc-call.calm,
.hc-call.calm .hc-phone {
  animation: none;
}
.hc-phone {
  position: relative;
  width: min(820px, 100%, calc((100dvh - 60px) * 1.6));
  aspect-ratio: 16 / 10;
  border-radius: 34px;
  border: 10px solid #111;
  background: #000;
  overflow: hidden;
  box-shadow:
    0 0 0 2px #333,
    0 30px 90px #000;
  animation: hc-in 0.4s ease-out;
}
.hc-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  color: #fff;
  background: linear-gradient(#000a, transparent);
  font-size: 0.95rem;
}
.hc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3ddc84;
}
.hc-timer {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: #d8dbde;
}
.hc-screen,
.hc-face,
.hc-video {
  position: absolute;
  inset: 0;
}
.hc-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 25%;
  filter: saturate(1.05);
}
.hc-call:not(.calm) .hc-face img {
  animation: hc-handheld 6s ease-in-out infinite alternate;
}
.hc-say {
  position: absolute;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  width: min(88%, 560px);
  margin: 0;
  padding: 10px 14px;
  border-radius: 14px;
  background: #000b;
  color: #fff;
  text-align: center;
  font-size: 1.02rem;
  line-height: 1.35;
}
.hc-video iframe {
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
}
.hc-caption {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 80px;
  margin: 0;
  color: #fff;
  font-size: 0.9rem;
  text-shadow: 0 1px 3px #000;
}
.hc-caption small {
  display: block;
  color: #d0d4d8;
}
.hc-self {
  position: absolute;
  top: 52px;
  right: 14px;
  z-index: 3;
  width: 92px;
  height: 120px;
  border-radius: 14px;
  background: linear-gradient(160deg, #445d3a, #1f2d1a);
  border: 2px solid #ffffff55;
  display: grid;
  place-items: center;
  align-content: center;
  font-size: 2rem;
  color: #fff;
}
.hc-self small {
  font-size: 0.7rem;
}
.hc-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 14px;
  z-index: 3;
  display: flex;
  justify-content: center;
  gap: 22px;
}
.hc-unmute {
  position: absolute;
  top: 54px;
  left: 14px;
  z-index: 4;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  background: #fff;
  color: #111;
  font-weight: 700;
  cursor: pointer;
}
@keyframes hc-in {
  from {
    transform: translateY(-12px) scale(0.97);
    opacity: 0;
  }
}
@keyframes hc-fade {
  from {
    opacity: 0;
  }
}
@keyframes hc-pulse {
  from {
    transform: scale(0.9);
    opacity: 1;
  }
  to {
    transform: scale(1.35);
    opacity: 0;
  }
}
@keyframes hc-handheld {
  from {
    transform: scale(1.06) translate(-0.6%, 0.4%) rotate(-0.4deg);
  }
  to {
    transform: scale(1.08) translate(0.6%, -0.4%) rotate(0.4deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .hc-ring,
  .hc-phone,
  .hc-call,
  .hc-face img,
  .hc-ring-face::after {
    animation: none !important;
  }
}
@media (max-width: 700px) {
  .hv-box {
    padding: 18px 14px 14px;
  }
  .hc-phone {
    aspect-ratio: 9 / 16;
    width: min(100%, calc((100dvh - 40px) * 0.5625));
  }
  .hc-video iframe {
    /* Landscape episode in a portrait phone: letterboxed in the middle. */
    height: 56.25vw;
    max-height: 100%;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
  }
  .hc-self {
    width: 70px;
    height: 92px;
  }
}

/* "Grain ready to sell" strip under the farm office top bar. */
.fh-sellbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin: 8px 0 10px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--fh-good, #2f7a3b);
  background: var(--fh-good-bg, #e7f4e8);
  color: var(--fh-ink, #1d2a20);
}
.fh-sellbar-pic {
  font-size: 1.6rem;
}
.fh-sellbar > div:nth-child(2) {
  display: grid;
  flex: 1 1 220px;
}
.fh-sellbar small {
  color: var(--fh-muted, #56635a);
}
.fh-sellbar-do,
.hv-done-do,
.hv-money-do {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.hv-money-do {
  margin-top: 6px;
}
.hv-how {
  margin: 6px 0 10px;
  padding-left: 20px;
  display: grid;
  gap: 4px;
}

/* "The harvest is in" card, on the office or the 3D farm. */
.hv-done {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1240;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 16px 18px;
  border-radius: 16px;
  border: 2px solid var(--fh-good, #2f7a3b);
  background: var(--fh-surface, #fff);
  color: var(--fh-ink, #1d2a20);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.35);
  animation: hv-done-in 0.35s ease-out;
}
.hv-done h3 {
  margin: 4px 0;
}
.hv-done p {
  margin: 6px 0;
}
.hv-done-big {
  font-size: 1.35rem;
  font-weight: 700;
}
.hv-done-bid {
  flex: 1 0 100%;
}
.hv-done-x {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--fh-muted, #56635a);
}
@keyframes hv-done-in {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .hv-done {
    animation: none;
  }
}
:root[data-motion='calm'] .hv-done {
  animation: none;
}
