/* ==========================================================================
   Doorway Tree Overlay, 4-Period Calibration, Falling Leaves & Owner Shop
   ========================================================================== */
.hero-outside-decor {
  --outside-image-width: max(100cqw, 150cqh);
  --outside-image-height: max(100cqh, calc(100cqw / 1.5));
  position: absolute;
  z-index: 2;
  left: calc((100% - var(--outside-image-width)) * .69);
  top: var(--motion-outside-y, calc((100% - var(--outside-image-height)) * .643));
  width: var(--outside-image-width);
  height: var(--outside-image-height);
  pointer-events: none;
}

.door-tree-leaves {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hero-door-tree {
  --tree-image: url('/assets/tree-elm.webp');
  --tree-light: none;
  position: absolute;
  z-index: 2;
  left: 73.5677%;
  top: 40.5273%;
  width: 22.1354%;
  height: 31.25%;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: #fff6e2;
  appearance: none;
  pointer-events: none;
  cursor: zoom-in;
  transition: transform .36s cubic-bezier(.22, .75, .22, 1);
}

.hero[data-view="outside"] .hero-door-tree {
  pointer-events: auto;
}

.hero-door-tree:focus-visible {
  outline: 2px solid #f7dc9e;
  outline-offset: 4px;
  border-radius: 12px;
}

.door-tree-canopy {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
  background: center / 100% 100% no-repeat var(--tree-image);
  filter: var(--tree-light);
  transform-origin: 48% 72%;
  animation: tree-breeze 7.6s ease-in-out infinite;
  transition: filter .5s ease, opacity .5s ease;
}

.hero-door-tree[data-tree="ancient_tea"] .door-tree-canopy::after {
  content: '';
  position: absolute;
  inset: 4% 12% 30% 14%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 48% 42%, rgba(255, 224, 138, .28), rgba(242, 198, 96, .08) 54%, transparent 74%);
  mix-blend-mode: screen;
  animation: ancient-glow 4.6s ease-in-out infinite;
  pointer-events: none;
}

.hero-door-tree:hover .door-tree-canopy,
.hero-door-tree:focus-visible .door-tree-canopy {
  filter: var(--tree-light) brightness(1.08);
}

.hero-door-tree .decor-hint {
  bottom: auto;
  top: 2%;
  transform: translate(-50%, 6px);
}

.hero-door-tree:hover .decor-hint,
.hero-door-tree:focus-visible .decor-hint {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes tree-breeze {
  0%, 100% { transform: rotate(-.35deg) skewX(-.2deg); }
  45% { transform: rotate(.55deg) skewX(.45deg); }
  72% { transform: rotate(.1deg) skewX(.1deg); }
}

@keyframes ancient-glow {
  0%, 100% { opacity: .55; transform: scale(.97); }
  50% { opacity: 1; transform: scale(1.04); }
}

/* 4-period exterior lighting calibration for doorway tree */
.hero-scene-outside:has(> img:last-of-type[src$="-morning.webp"]) .hero-door-tree {
  --tree-light: brightness(.93) saturate(.90) sepia(.12);
}

.hero-scene-outside:has(> img:last-of-type[src$="-noon.webp"]) .hero-door-tree {
  --tree-light: brightness(1) saturate(1);
}

.hero-scene-outside:has(> img:last-of-type[src$="-afternoon.webp"]) .hero-door-tree {
  --tree-light: brightness(.90) contrast(1.08) saturate(1.08) sepia(.28) hue-rotate(-7deg);
}

.hero-scene-outside:has(> img:last-of-type[src$="-night.webp"]) .hero-door-tree {
  --tree-light: brightness(.36) contrast(1.08) saturate(.60) hue-rotate(8deg);
}

.hero-scene-outside:has(> img:last-of-type[src$="-night.webp"]) .hero-door-tree[data-tree="ancient_tea"] {
  --tree-light: brightness(.54) contrast(1.12) saturate(.88) drop-shadow(0 0 8px rgba(246, 206, 118, .28));
}

/* Tree showcase lightbox styling */
.decor-showcase[data-decor="tree"] .decor-showcase-stage {
  background: radial-gradient(ellipse at 50% 42%, #1d2d25 0%, #132019 66%, #0c1510 100%);
}

.decor-showcase[data-decor="tree"] .decor-showcase-art img {
  border-radius: 6px;
  border: 1px solid rgba(226, 193, 134, .48);
  box-shadow: 0 22px 46px rgba(0, 0, 0, .55);
}

.decor-showcase[data-decor="tree"] .decor-showcase-zoom {
  background: rgba(16, 29, 23, .84);
  border-color: rgba(226, 193, 134, .42);
  color: #f4e6c9;
}

/* Rarity badges (shared between lightbox & owner tree shop) */
.tree-rarity {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  white-space: nowrap;
}

.tree-rarity[data-rarity="common"] {
  background: #e7ede5;
  color: #35543e;
}

.tree-rarity[data-rarity="fine"] {
  background: #f5e8cc;
  color: #7d5317;
}

.tree-rarity[data-rarity="rare"] {
  background: #f2e3ee;
  color: #7c3568;
}

.tree-rarity[data-rarity="legendary"] {
  background: linear-gradient(135deg, #273b2f, #4c3b1d);
  color: #f6dc9b;
  box-shadow: 0 2px 10px rgba(172, 132, 48, .28);
}

/* ==========================================================================
   Owner Dashboard: Doorway Tree Redemption Shop (#owner-trees)
   ========================================================================== */
.tree-shop-intro {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: .94rem;
}

.tree-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(270px, 100%), 1fr));
  gap: 18px;
}

.tree-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .25s ease, box-shadow .25s ease;
}

.tree-card[data-active="true"] {
  border-color: #849f77;
  box-shadow: 0 8px 24px rgba(32, 62, 40, .10);
}

.tree-card[data-rarity="legendary"] {
  border-color: #d6ba80;
}

.tree-card-photo {
  position: relative;
  aspect-ratio: 340 / 245;
  overflow: hidden;
  background: #14221a;
}

.tree-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 36%;
  transition: transform .45s ease, filter .35s ease;
}

.tree-card[data-unlocked="false"] .tree-card-photo img {
  filter: saturate(.78) brightness(.88);
}

.tree-card:hover .tree-card-photo img {
  transform: scale(1.03);
}

.tree-card-tag {
  position: absolute;
  top: 10px;
  left: 10px;
}

.tree-card-active-pill {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(20, 44, 30, .88);
  border: 1px solid rgba(226, 193, 134, .55);
  color: #f6e1b2;
  font-size: .76rem;
  font-weight: 650;
}

.tree-card-copy {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 6px;
  padding: 16px 18px 18px;
}

.tree-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.tree-card-head h3 {
  font-size: 1.32rem;
}

.tree-card-cost {
  color: var(--earth);
  font-size: .84rem;
  font-weight: 650;
  white-space: nowrap;
}

.tree-card-leaf {
  color: #5b6e5a;
  font-size: .84rem;
  font-weight: 600;
}

.tree-card-desc {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.58;
}

.tree-progress {
  margin-top: 6px;
  display: grid;
  gap: 5px;
}

.tree-progress-meter {
  appearance: none;
  width: 100%;
  height: 7px;
  border: 0;
  border-radius: 999px;
  background: #e7e1d3;
  overflow: hidden;
}

.tree-progress-meter::-webkit-progress-bar {
  background: #e7e1d3;
  border-radius: 999px;
}

.tree-progress-meter::-webkit-progress-value {
  background: linear-gradient(90deg, #5e7e61, #c49b52);
  border-radius: 999px;
}

.tree-progress-meter::-moz-progress-bar {
  background: linear-gradient(90deg, #5e7e61, #c49b52);
  border-radius: 999px;
}

.tree-progress small {
  color: var(--muted);
  font-size: .8rem;
}

.tree-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
}

.tree-actions .button {
  min-height: 40px;
  padding: 7px 14px;
  font-size: .88rem;
}

@media (prefers-reduced-motion: reduce) {
  .door-tree-canopy,
  .hero-door-tree[data-tree="ancient_tea"] .door-tree-canopy::after {
    animation: none;
  }
}
