/* Default scenery: Woodland valley. views/layout.jsx renders the art
   attributes and the four URLs (on the CDN) on <body>, so these apply from the
   first paint — no script in the way. A player's own pick (scene-art-preview.js)
   sets the same properties inline, which wins; "Previous scenery" removes the
   attributes, so none of the rules below match. Dark keyed the three-state way
   the rest of the game is. */
body[data-scene="1"] {
  --scene-art-mountains-image: var(--scene-woodland-mountains-light, url("/assets/backgrounds/story-v1/woodland-mountains-light.webp"));
  --scene-art-ground-image: var(--scene-woodland-ground-light, url("/assets/backgrounds/story-v1/woodland-ground-light.webp"));
  --scene-art-ground-base: #7f782d;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body[data-scene="1"] {
    --scene-art-mountains-image: var(--scene-woodland-mountains-dark, url("/assets/backgrounds/story-v1/woodland-mountains-dark.webp"));
    --scene-art-ground-image: var(--scene-woodland-ground-dark, url("/assets/backgrounds/story-v1/woodland-ground-dark.webp"));
    --scene-art-ground-base: #172d40;
  }
}
:root[data-theme="dark"] body[data-scene="1"] {
  --scene-art-mountains-image: var(--scene-woodland-mountains-dark, url("/assets/backgrounds/story-v1/woodland-mountains-dark.webp"));
  --scene-art-ground-image: var(--scene-woodland-ground-dark, url("/assets/backgrounds/story-v1/woodland-ground-dark.webp"));
  --scene-art-ground-base: #172d40;
}

/* Every scenery override requires both the existing scene flag and an art
   attribute (the default, or a player's pick). Without them the previous
   production CSS wins. */
body[data-scene="1"][data-scene-mountains-art] #background::before {
  left: 50%;
  right: auto;
  width: max(100%, 900px);
  transform: translateX(-50%);
  bottom: calc(var(--scene-ground-height) - 32px);
  height: clamp(200px, 46vh, 580px);
  background-image: var(--scene-art-mountains-image);
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: 100% 100%;
}

/* The new mountain plates already include their own wooded/rocky foothills. */
body[data-scene="1"][data-scene-mountains-art] #background .scene-hills {
  display: none;
}

body[data-scene="1"][data-scene-ground-art] #background::after {
  height: calc(var(--scene-ground-height) * 0.94);
  background: var(--scene-art-ground-base);
}

body[data-scene="1"][data-scene-ground-art] #background .scene-grass {
  left: 50%;
  right: auto;
  width: max(100%, 900px);
  transform: translateX(-50%);
  /* The top ~18% of each ground plate is transparent. This aligns the painted
     grass edge with the game's shared, castle-tracked horizon. */
  height: calc(var(--scene-ground-height) * 1.22);
  background-image: var(--scene-art-ground-image);
  background-size: 100% 100%;
  background-position: center bottom;
  -webkit-mask-image: none;
  mask-image: none;
  filter: none; /* Night variants are painted assets, not the legacy dim filter. */
}

body[data-scene="1"][data-scene-ground-art] #background .scene-foreground {
  display: none;
}

#scene-art-preview[hidden],
#scene-art-preview [hidden] {
  display: none !important;
}

#scene-art-preview {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 2147483000;
  width: min(340px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 18px;
  border: 1px solid #8d815e;
  border-radius: 12px;
  background: #172333;
  box-shadow: 0 12px 40px #0008;
  color: #f4f1e8;
  font: 14px/1.5 system-ui, sans-serif;
  text-align: left;
}

#scene-art-preview .scene-art-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#scene-art-preview h2 {
  margin: 0;
  color: #f0d595;
  font: 600 18px/1.3 system-ui, sans-serif;
  text-shadow: none;
}

#scene-art-preview p {
  margin: 10px 0;
  font-size: 13px;
}

#scene-art-preview label {
  display: block;
  margin: 12px 0 4px;
  color: #ded7c3;
  font-weight: 600;
}

#scene-art-preview select,
#scene-art-preview button {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #637085;
  border-radius: 6px;
  background: #23354a;
  color: #f4f1e8;
  font: inherit;
  cursor: pointer;
  text-shadow: none;
  box-shadow: none;
}

#scene-art-preview select {
  width: 100%;
}

#scene-art-preview button:hover,
#scene-art-preview button[aria-pressed="true"] {
  border-color: #e2c477;
  background: #3e4a4c;
}

#scene-art-preview :focus-visible {
  outline: 2px solid #f0d595;
  outline-offset: 3px;
}

#scene-art-preview .scene-art-preview-presets,
#scene-art-preview .scene-art-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

#scene-art-preview .scene-art-preview-presets button,
#scene-art-preview .scene-art-preview-actions button {
  flex: 1;
}

#scene-art-preview .scene-art-preview-status {
  min-height: 3em;
  color: #f0d595;
}

#scene-art-preview .scene-art-preview-hint {
  margin-bottom: 0;
  color: #adb9c9;
  font-size: 12px;
}

#scene-art-preview a {
  color: #f0d595;
  text-decoration: underline;
}
