/* Eden and Dane — loading, error, empty and consent states.
   Loaded site-wide after site-polish.css. */

/* ============================================================
   1. IMAGE LOADING — skeleton that settles, not a spinner
   ============================================================ */

/* Wrapper-free: the skeleton lives on the img's own background, so no page
   layout changes and nothing to wrap. The image paints over it. */
img[data-ead-load] {
  opacity: 0;
  transform: scale(1.012);
  background-color: var(--cream, #ebe3d3);
  background-image: linear-gradient(
    100deg,
    rgba(138, 154, 123, 0.00) 20%,
    rgba(138, 154, 123, 0.18) 48%,
    rgba(138, 154, 123, 0.00) 76%
  );
  background-size: 220% 100%;
  background-repeat: no-repeat;
  animation: ead-settle 1.5s ease-in-out infinite;
  transition: opacity 0.5s ease, transform 0.7s cubic-bezier(0.22, 0.61, 0.36, 1);
}

img[data-ead-load].is-loaded {
  opacity: 1;
  transform: none;
  background-image: none;
  animation: none;
}

img[data-ead-load].is-failed {
  opacity: 1;
  transform: none;
  animation: none;
  background-image: none;
  background-color: var(--cream, #ebe3d3);
}

@keyframes ead-settle {
  from { background-position: 180% 0; }
  to   { background-position: -60% 0; }
}

/* If JS never runs, images must still be visible */
.no-js img[data-ead-load],
html:not(.js) img[data-ead-load] { opacity: 1; transform: none; animation: none; background-image: none; }

/* ============================================================
   2. BUTTON WORK STATE — a mark that turns, not a text swap
   ============================================================ */

.is-working {
  position: relative;
  pointer-events: none;
}

.ead-spin {
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-right: 0.5em;
  vertical-align: -0.08em;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ead-turn 0.75s linear infinite;
}

@keyframes ead-turn { to { transform: rotate(360deg); } }

/* ============================================================
   3. FORM FIELD ERRORS
   ============================================================ */

.field-error {
  display: none;
  margin-top: 6px;
  font-family: var(--sans, sans-serif);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--clay, #b8755a);
}

.field-error.show { display: block; }

input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--clay, #b8755a) !important;
}

input[aria-invalid="true"]:focus,
textarea[aria-invalid="true"]:focus,
select[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(184, 117, 90, 0.18);
}

/* ============================================================
   4. EMPTY STATES
   ============================================================ */

.state-empty {
  padding: 40px 28px;
  text-align: center;
}

.state-empty__mark {
  display: block;
  margin: 0 auto 14px;
  color: var(--sage, #8a9a7b);
  opacity: 0.7;
}

.state-empty__title {
  font-family: var(--display, Georgia, serif);
  font-size: 21px;
  line-height: 1.25;
  color: var(--moss, #2b3a2a);
  margin: 0 0 6px;
}

.state-empty__body {
  font-family: var(--sans, sans-serif);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--sage, #8a9a7b);
  margin: 0 0 18px;
  max-width: 30ch;
  margin-left: auto;
  margin-right: auto;
}

.state-empty__action {
  display: inline-block;
  font-family: var(--sans, sans-serif);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  color: var(--moss, #2b3a2a);
  border-bottom: 1px solid var(--clay, #b8755a);
  padding-bottom: 2px;
  text-decoration: none;
}

/* ============================================================
   5. COOKIE CONSENT
   ============================================================ */

.consent {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 10000;
  width: min(370px, calc(100vw - 40px));
  padding: 20px 22px 18px;
  background: var(--paper, #faf7f1);
  border: 1px solid var(--nav-border, rgba(43, 58, 42, 0.14));
  border-radius: var(--radius-md, 18px);
  box-shadow: 0 18px 44px -20px rgba(26, 31, 24, 0.42);
  transform: translateY(14px);
  opacity: 0;
  transition: transform 0.42s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.42s ease;
}

.consent.is-in { transform: none; opacity: 1; }

.consent.is-out {
  transform: translateY(10px);
  opacity: 0;
  pointer-events: none;
}

.consent__text {
  font-family: var(--sans, sans-serif);
  font-size: 13px;
  line-height: 1.62;
  color: var(--ink, #1a1f18);
  margin: 0 0 15px;
}

.consent__text a {
  color: inherit;
  border-bottom: 1px solid var(--clay, #b8755a);
  text-decoration: none;
}

.consent__row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.consent__btn {
  font-family: var(--sans, sans-serif);
  font-size: 12.5px;
  letter-spacing: 0.01em;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--moss, #2b3a2a);
  color: var(--paper, #faf7f1);
  transition: opacity 0.2s ease;
}

.consent__btn:hover { opacity: 0.86; }

.consent__btn--quiet {
  background: transparent;
  color: var(--sage, #8a9a7b);
  border-color: var(--nav-border, rgba(43, 58, 42, 0.16));
}

@media (max-width: 640px) {
  .consent {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    padding: 18px 18px 16px;
  }
}

/* ============================================================
   6. LEAF PAGE TRANSITION
   ============================================================ */

.leaf-veil {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.leaf-veil__sheet {
  position: absolute;
  inset: 0;
  background: var(--leaf-veil, #161e15);
  transform: translateY(101%);
  will-change: transform;
}

.leaf-veil__edge {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 56px;
  color: var(--leaf-veil, #161e15);
}

.leaf-veil__edge svg { display: block; width: 100%; height: 100%; }

.leaf-veil__leaf {
  position: absolute;
  top: -18vh;
  color: var(--sage, #8a9a7b);
  opacity: 0;
  will-change: transform, opacity;
}

/* Covering: sheet climbs, leaves drift down past it */
.leaf-veil.is-covering {
  opacity: 1;
  visibility: visible;
}

.leaf-veil.is-covering .leaf-veil__sheet {
  animation: leaf-cover 0.62s cubic-bezier(0.5, 0, 0.34, 1) forwards;
}

.leaf-veil.is-covering .leaf-veil__leaf {
  animation: leaf-fall 1.5s cubic-bezier(0.32, 0.14, 0.44, 1) forwards;
}

/* Uncovering: sheet retires downward, held first so paint can finish */
.leaf-veil.is-uncovering {
  opacity: 1;
  visibility: visible;
}

.leaf-veil.is-uncovering .leaf-veil__sheet {
  transform: translateY(0);
  animation: leaf-uncover 0.78s cubic-bezier(0.4, 0.02, 0.2, 1) 0.26s forwards;
}

@keyframes leaf-cover {
  from { transform: translateY(101%); }
  to   { transform: translateY(0); }
}

@keyframes leaf-uncover {
  from { transform: translateY(0); }
  to   { transform: translateY(-101%); }
}

@keyframes leaf-fall {
  0%   { opacity: 0; transform: translate3d(0, 0, 0) rotate(0deg); }
  14%  { opacity: 0.95; }
  72%  { opacity: 0.95; }
  100% { opacity: 0; transform: translate3d(var(--drift, 24px), 118vh, 0) rotate(var(--spin, 220deg)); }
}

@media (prefers-reduced-motion: reduce) {
  .leaf-veil { display: none !important; }
  .ead-spin { animation-duration: 2.4s; }
  img[data-ead-load] { transition: opacity 0.2s ease; transform: none; animation: none; }
  .consent { transition: none; }
}

/* Holds the cover between navigations, before leaf-transition.js takes over.
   Set by an inline snippet in <head> so there is never an uncovered flash. */
html.leaf-arriving::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: var(--leaf-veil, #161e15);
  pointer-events: none;
}
@media (prefers-reduced-motion: reduce) {
  html.leaf-arriving::before { display: none; }
}

/* ============================================================
   7. STICKY MOBILE CTA
   ============================================================ */

.sticky-cta {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 94;              /* under the cart bubble (95), not over it */
  display: none;
  align-items: center;
  gap: 8px;
  transform: translateY(140%);
  transition: transform 0.34s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.sticky-cta.is-in { transform: none; }

.sticky-cta__btn {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 18px;
  border: none;
  border-radius: 999px;
  background: var(--moss, #2b3a2a);
  color: var(--paper, #faf7f1);
  font-family: var(--sans, sans-serif);
  font-size: 13.5px;
  letter-spacing: 0.01em;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 6px 18px -8px rgba(26, 31, 24, 0.45);
}

.sticky-cta__btn:active { transform: translateY(1px); }

.sticky-cta__close {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--nav-border, rgba(43, 58, 42, 0.16));
  border-radius: 50%;
  background: var(--paper, #faf7f1);
  color: var(--sage, #8a9a7b);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

@media (max-width: 768px) {
  .sticky-cta { display: flex; }

  /* The cart bubble steps up so the bar has the bottom edge to itself. */
  body.has-sticky-cta .cart-icon-btn { bottom: 74px; }
  body.has-consent .cart-icon-btn { bottom: 150px; }

  /* Give the footer room so the bar never covers the last line. */
  body.has-sticky-cta footer { padding-bottom: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  .sticky-cta { transition: none; }
}

@media (min-width: 769px) {
  .sticky-cta { display: none !important; }
}
