/* Enchanted Pixel Kingdom — Enhanced World Tokens
   A handcrafted pixel realm: lantern-lit inn rooms, curious companions, warm HD-2D light.
   Tokens live on html[data-world="enchanted-pixel-kingdom"] so they scope cleanly. */

@media screen {
  /* ── Dark mode (night in the kingdom) ── */
  html[data-world="enchanted-pixel-kingdom"][data-mode="dark"] {
    /* Core surfaces — deepening the HD-2D aesthetic */
    --world-background: #161f2e !important;           /* midnight kingdom sky */
    --world-deep: #1f2d45 !important;                 /* deep twilight */
    --world-surface: #2a3d56 !important;              /* stone walls */
    --world-elevated: #354b68 !important;             /* elevated surfaces */

    /* Text hierarchy */
    --world-text: #fff3d4 !important;                 /* warm parchment */
    --world-secondary: #d4c8a9 !important;            /* aged gold */
    --world-muted: #a89d84 !important;                /* weathered stone */
    --world-faint: #8b7f6a !important;                /* deep shadow text */

    /* Accents — the kingdom's glow */
    --world-accent: #f4c26d !important;               /* lantern gold */
    --world-accent-hover: #fad894 !important;         /* bright lantern */
    --world-accent-secondary: #a9d99b !important;     /* forest emerald */
    --world-accent-tertiary: #e8b86d !important;      /* warm amber */

    /* Borders & highlights */
    --world-border: #8d9a82 !important;               /* mossy stone */
    --world-border-soft: #74826e !important;          /* soft moss */
    --world-border-strong: #b8c4a8 !important;        /* highlighted moss */
    --world-highlight: #ffd991 !important;            /* lantern glow */
    --world-highlight-soft: #ffe8b8 !important;       /* soft glow */

    /* Semantic — pixel-perfect meanings */
    --world-danger: #ffb8ad !important;               /* rose danger */
    --world-success: #ace2a2 !important;              /* leaf success */
    --world-warning: #f4d26d !important;              /* amber warning */
    --world-info: #9bd8f0 !important;                 /* sky info */

    /* Inks (text on accent) */
    --world-accent-ink: #2d1f0a !important;           /* dark on gold */
    --world-accent-secondary-ink: #1a2d1a !important; /* dark on emerald */
    --world-on-accent: #161f2e !important;            /* universal */

    /* Status accents */
    --world-status-accent: #f4c26d !important;
    --world-status-accent-secondary: #a9d99b !important;

    /* Geometry — pixel-crisp */
    --world-radius: 10px 3px 10px 3px !important;
    --world-control: 5px 2px 5px 2px !important;
    --world-icon: 4px !important;
    --world-header: 8px 2px 0 0 !important;

    /* Glass/surface system — HD-2D clarity */
    --surface-card-opacity: 92% !important;
    --surface-panel-opacity: 96% !important;
    --surface-dense-opacity: 98% !important;
    --surface-elevated-opacity: 99% !important;
    --surface-modal-opacity: 99% !important;
    --surface-blur: 8px !important;
    --surface-border-opacity: 40% !important;
    --surface-shadow-opacity: 25% !important;

    /* Shadow colors — layered depth */
    --world-shadow: color-mix(in srgb, var(--world-deep) 92%, transparent) !important;
    --world-shadow-strong: color-mix(in srgb, var(--world-deep) 98%, transparent) !important;
    --world-shadow-colored: color-mix(in srgb, var(--world-accent-secondary) 10%, var(--world-deep) 90%) !important;
    --world-glow: color-mix(in srgb, var(--world-accent) 45%, transparent) !important;
    --world-glow-emerald: color-mix(in srgb, var(--world-accent-secondary) 40%, transparent) !important;

    /* Pixel-specific */
    --pixel-amber: #f4c26d !important;
    --pixel-warm-edge: #a8793c !important;
    --pixel-cool-edge: #627c91 !important;
    --pixel-lantern: #f4be61 !important;
    --pixel-shadow: #291f19a8 !important;
    --pixel-frame: color-mix(in srgb, var(--world-border) 74%, var(--pixel-amber)) !important;
  }

  /* ── Light mode (day in the kingdom) ── */
  html[data-world="enchanted-pixel-kingdom"][data-mode="light"] {
    --world-background: #e5d3a8;           /* sunlit kingdom */
    --world-deep: #94a17c;                 /* rolling hills */
    --world-surface: #fff5df;              /* parchment walls */
    --world-elevated: #eadbb9;             /* sun-warmed stone */

    --world-text: #332b22;                 /* ink on parchment */
    --world-secondary: #615442;            /* brown ink */
    --world-muted: #84765e !important;                /* faded ink */
    --world-faint: #6b5f4a !important;                /* marginalia */

    --world-accent: #78502a;               /* deep gold */
    --world-accent-hover: #9b6a3a !important;         /* brighter gold */
    --world-accent-secondary: #3b5c3e;     /* forest green */
    --world-accent-tertiary: #8a6832 !important;      /* amber */

    --world-border: #a18453;               /* aged wood */
    --world-border-soft: #b8a078 !important;          /* soft wood */
    --world-border-strong: #8a7042 !important;        /* dark wood */
    --world-highlight: #9b6730;            /* gold highlight */
    --world-highlight-soft: #c9a868 !important;       /* soft gold */

    --world-danger: #982f39;               /* crimson */
    --world-success: #2d6040;              /* forest */
    --world-warning: #b8860b !important;              /* amber */
    --world-info: #4a7c9e !important;                 /* sky blue */

    --world-accent-ink: #fff5df;
    --world-accent-secondary-ink: #f0f8ec !important;
    --world-on-accent: #fff5df;

    --world-status-accent: #78502a;
    --world-status-accent-secondary: #3b5c3e;

    --world-radius: 10px 3px 10px 3px !important;
    --world-control: 5px 2px 5px 2px !important;
    --world-icon: 4px !important;
    --world-header: 8px 2px 0 0 !important;

    --surface-card-opacity: 88% !important;
    --surface-panel-opacity: 92% !important;
    --surface-dense-opacity: 96% !important;
    --surface-elevated-opacity: 98% !important;
    --surface-modal-opacity: 99% !important;
    --surface-blur: 6px !important;
    --surface-border-opacity: 35% !important;
    --surface-shadow-opacity: 18% !important;

    --world-shadow: color-mix(in srgb, #161f2e 22%, transparent) !important;
    --world-shadow-strong: color-mix(in srgb, #161f2e 35%, transparent) !important;
    --world-shadow-colored: color-mix(in srgb, var(--world-accent-secondary) 8%, #161f2e 25%) !important;
    --world-glow: color-mix(in srgb, var(--world-accent) 30%, transparent) !important;
    --world-glow-emerald: color-mix(in srgb, var(--world-accent-secondary) 28%, transparent) !important;

    --pixel-amber: #78502a !important;
    --pixel-warm-edge: #8a6832 !important;
    --pixel-cool-edge: #3b5c3e !important;
    --pixel-lantern: #9b6730 !important;
    --pixel-shadow: #49351d78 !important;
    --pixel-frame: color-mix(in srgb, var(--world-border) 74%, var(--pixel-amber)) !important;
  }
}

/* ── World Preview (theme selector card) ── */
@media screen {
  .world-preview[data-world="enchanted-pixel-kingdom"] .world-portal-art {
    background:
      /* Pixel sky gradient */
      linear-gradient(180deg,
        var(--world-background) 0%,
        color-mix(in srgb, var(--world-deep) 60%, var(--world-accent) 15%) 50%,
        var(--world-surface) 100%),
      /* Pixel stars/sparkles */
      radial-gradient(2px 2px at 20% 15%, var(--world-highlight), transparent),
      radial-gradient(1px 1px at 60% 25%, var(--world-accent-secondary), transparent),
      radial-gradient(2px 2px at 80% 35%, var(--world-highlight), transparent),
      radial-gradient(1px 1px at 40% 60%, var(--world-accent), transparent),
      radial-gradient(2px 2px at 70% 80%, var(--world-highlight), transparent) !important;
    background-size:
      100% 100%,
      120px 80px,
      90px 60px,
      150px 100px,
      100px 70px !important;
    opacity: 1 !important;
    filter: none !important;
    image-rendering: pixelated;
  }

  .world-preview[data-world="enchanted-pixel-kingdom"] .world-sample-card {
    border-width: 2px !important;
    border-color: var(--pixel-frame) !important;
    border-radius: var(--world-radius) !important;
    box-shadow:
      0 12px 24px -16px var(--world-shadow),
      0 3px 0 color-mix(in srgb, var(--pixel-frame) 68%, transparent),
      inset 0 1px #fff8e24d,
      0 0 16px -4px var(--world-glow) !important;
    image-rendering: pixelated;
  }

  .world-preview[data-world="enchanted-pixel-kingdom"] .world-sample-heading {
    background:
      linear-gradient(var(--pixel-amber), var(--pixel-amber)) 0 0/100% 3px no-repeat,
      linear-gradient(var(--pixel-warm-edge), var(--pixel-warm-edge)) 0 3px/100% 2px no-repeat,
      linear-gradient(var(--pixel-lantern), var(--pixel-lantern)) 0 5px/100% 4px no-repeat !important;
    border-bottom-color: color-mix(in srgb, var(--pixel-frame) 66%, var(--pixel-amber)) !important;
    padding-bottom: 8px !important;
  }
}

/* ── Time-of-day token variants (applied via data-pixel-time) ── */
@media screen {
  html[data-world="enchanted-pixel-kingdom"][data-pixel-time="morning"] {
    --pixel-amber: #f4cd76 !important;
    --pixel-lantern: #ffd98c !important;
    --pixel-shadow: #49351d78 !important;
    --pixel-sky: #fff0c8 !important;
  }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-time="afternoon"] {
    --pixel-amber: #efb953 !important;
    --pixel-lantern: #ffcf69 !important;
    --pixel-shadow: #30251896 !important;
    --pixel-sky: #f7dda0 !important;
  }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-time="evening"] {
    --pixel-amber: #edaa5c !important;
    --pixel-lantern: #ffc265 !important;
    --pixel-shadow: #38231fa8 !important;
    --pixel-sky: #f2c28f !important;
  }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-time="night"] {
    --pixel-amber: #d5a959 !important;
    --pixel-lantern: #ffcc67 !important;
    --pixel-shadow: #090f20c4 !important;
    --pixel-sky: #25334c !important;
  }
}

/* ── Weather token variants (applied via data-pixel-weather) ── */
@media screen {
  html[data-world="enchanted-pixel-kingdom"][data-pixel-weather="rain"] {
    --pixel-sky: #9fb8c2 !important;
    --pixel-cool-edge: #63899c !important;
  }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-weather="snow"] {
    --pixel-sky: #d5e6e7 !important;
    --pixel-cool-edge: #9db9bf !important;
  }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-weather="fog"] {
    --pixel-sky: #c1c7bd !important;
    --pixel-cool-edge: #9aa69e !important;
  }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-weather="storm"] {
    --pixel-sky: #788da7 !important;
    --pixel-cool-edge: #7387a1 !important;
  }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-weather="off"] {
    --pixel-sky: transparent !important;
  }
}

/* ── Location accents (applied via data-pixel-location) ── */
@media screen {
  html[data-world="enchanted-pixel-kingdom"][data-pixel-location="village-square"] { --pixel-location-accent: #e4b451 !important; }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-location="adventurers-guild"] { --pixel-location-accent: #cf9850 !important; }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-location="cozy-inn"] { --pixel-location-accent: #e5a75a !important; }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-location="inventor-workshop"] { --pixel-location-accent: #bb8747 !important; }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-location="observatory"] { --pixel-location-accent: #8db8d5 !important; }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-location="royal-study"] { --pixel-location-accent: #c4a1d0 !important; }
}

/* ── Intensity modifiers (applied via data-pixel-intensity) ── */
@media screen {
  html[data-world="enchanted-pixel-kingdom"][data-pixel-intensity="cozy"] {
    --pixel-card-border-opacity: 42% !important;
    --pixel-shadow-opacity: 0.7 !important;
  }
  html[data-world="enchanted-pixel-kingdom"][data-pixel-intensity="minimal"] {
    --pixel-card-border-opacity: 20% !important;
    --pixel-shadow-opacity: 0.4 !important;
    --pixel-transition-duration: 0ms !important;
  }
}

/* ── Performance tier (applied via data-pixel-performance) ── */
@media screen {
  html[data-world="enchanted-pixel-kingdom"][data-pixel-performance="lite"] {
    --pixel-particle-count: 0 !important;
    --pixel-ambient-complexity: 0 !important;
  }
}