/* Theme contract
 * 1. Theme blocks contain raw palette declarations only: --atlas-color-*.
 * 2. The semantic contract maps raw palette values to --app-* via var().
 * 3. Components consume only --app-* semantic tokens.
 * 4. Framework adapters map into the semantic contract and never define a second palette.
 */

/* Universal colors shared by every active theme.
 * Intentionally empty while no color value is shared by every supported theme.
 */
[data-app-theme] {
}

/* The editor's sRGB picker must show the entire color gamut, independently
 * of the restricted Atlas interface palette. Keep its colors in this theme
 * source while scoping the tokens to the color-picker form. */
.skyrp-geometry-style {
    --app-editor-picker-spectrum-base: #00e0df;
    --app-editor-picker-white: #fff;
    --app-editor-picker-black: #000;
    --app-editor-picker-shadow: rgb(0 0 0 / 45%);
    --app-editor-picker-hue-gradient: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}

/* Map-specific visual effects keep their fixed decorative colors in the theme source. */
.skyrp-map-page {
    --app-map-displacement-ink: #000;
    --app-map-displacement-stripe: #ffd45c;
    --app-map-proposal-create: #2e8b57;
    --app-map-proposal-update: #2475d0;
    --app-map-proposal-delete: #b84242;
    --app-map-category-rainbow: conic-gradient(#f04482, #ff9d36, #f9dd52, #60ce7a, #47a5ee, #ab75e8, #f04482);
    --app-map-actions-shadow: #0004;
}

/* Marker outlines inherit the configured map stroke without custom property registration. */

/* Atlas / night: raw palette declarations. */
:root[data-app-theme="atlas"][data-app-color-scheme="night"] {
    --atlas-color-page: #1c1c1a;
    --atlas-color-page-glow: rgba(200, 191, 174, 0.035);
    --atlas-color-surface: #1c1c1a;
    --atlas-color-surface-raised: #282825;
    --atlas-color-surface-active: #34332f;
    --atlas-color-text: #c5bba8;
    --atlas-color-interactive-text: #c5bba8;
    --atlas-color-text-muted: #b7ae9d;
    --atlas-color-accent: #c8bfae;
    --atlas-color-accent-strong: #ded6c8;
    --atlas-color-accent-ink: #1b1c19;
    --atlas-color-border: #5f5b53;
    --atlas-color-border-soft: rgba(211, 205, 192, 0.22);
    --atlas-color-icon: #e8e1d5;
    --atlas-color-focus: #c8bfae;
    --atlas-color-map-edit-boundary: #c8bfae;
    --atlas-color-map-edit-shadow: rgb(200 191 174 / 20%);
    --atlas-color-support-heart: #f28ab8;
    --atlas-color-support-heart-hover: #ff4f9f;
    --atlas-color-editor-popup-shadow: #1c1c1a;
    --atlas-color-rail-tooltip-shadow: rgb(0 0 0 / 24%);
    --atlas-color-cta-bg: #ddd9cf;
    --atlas-color-cta-text: #1b1c19;
    --atlas-color-danger: #f97066;
    --atlas-color-danger-ink: #1a0505;
    --atlas-color-danger-subtle: #2b1312;
    --atlas-color-danger-border: #7a2e28;
    --atlas-color-success: #4cc38a;
    --atlas-color-success-ink: #04150c;
    --atlas-color-success-subtle: #0e2a1d;
    --atlas-color-success-border: #2c6b4b;
    --atlas-color-warning-subtle: #3a2b12;
    --atlas-color-warning-text: #f2cd8f;
    --atlas-color-validation-valid: #4cc38a;
    --atlas-color-validation-invalid: #f97066;
    --atlas-color-control-disabled-bg: #282825;
    --atlas-color-control-disabled-text: rgba(197, 187, 168, 0.52);
    --atlas-color-control-disabled-border: rgba(197, 187, 168, 0.24);
    --atlas-color-sidebar-bg: rgba(28, 28, 26, 0.92);
    --atlas-color-page-overlay: rgba(28, 28, 26, 0.36);
    --atlas-color-shadow-sm: rgba(28, 28, 26, 0.28);
    --atlas-color-shadow: rgba(28, 28, 26, 0.4);
    --atlas-focus-shadow-rgb: 200, 191, 174;
}

/* Atlas / day: raw palette declarations. */
:root[data-app-theme="atlas"][data-app-color-scheme="day"] {
    --atlas-color-page: #dbd5c7;
    --atlas-color-page-glow: rgba(200, 191, 174, 0.035);
    --atlas-color-surface: #dbd5c7;
    --atlas-color-surface-raised: #d0cabb;
    --atlas-color-surface-active: #c5beb0;
    --atlas-color-text: #252525;
    --atlas-color-interactive-text: #555555;
    --atlas-color-text-muted: #676767;
    --atlas-color-accent: #2b2b2b;
    --atlas-color-accent-strong: #101010;
    --atlas-color-accent-ink: #f5f1e8;
    --atlas-color-border: #9b958a;
    --atlas-color-border-soft: rgba(37, 37, 37, 0.22);
    --atlas-color-icon: #34312d;
    --atlas-color-focus: #2b2b2b;
    --atlas-color-map-edit-boundary: #2b2b2b;
    --atlas-color-map-edit-shadow: rgb(43 43 43 / 20%);
    --atlas-color-support-heart: #f28ab8;
    --atlas-color-support-heart-hover: #ff4f9f;
    --atlas-color-editor-popup-shadow: #1c1c1a;
    --atlas-color-rail-tooltip-shadow: rgb(0 0 0 / 24%);
    --atlas-color-cta-bg: #3a342d;
    --atlas-color-cta-text: #f5f1e8;
    --atlas-color-danger: #b42318;
    --atlas-color-danger-ink: #f5f1e8;
    --atlas-color-danger-subtle: #fdecea;
    --atlas-color-danger-border: #f1b9b5;
    --atlas-color-success: #0f7b4a;
    --atlas-color-success-ink: #f5f1e8;
    --atlas-color-success-subtle: #e8f6ef;
    --atlas-color-success-border: #b7e3cb;
    --atlas-color-warning-subtle: #fdf1dc;
    --atlas-color-warning-text: #7a4d0e;
    --atlas-color-validation-valid: #26b050;
    --atlas-color-validation-invalid: #e50000;
    --atlas-color-control-disabled-bg: rgba(219, 213, 199, 0.72);
    --atlas-color-control-disabled-text: rgba(37, 37, 37, 0.48);
    --atlas-color-control-disabled-border: rgba(37, 37, 37, 0.22);
    --atlas-color-sidebar-bg: rgba(219, 213, 199, 0.92);
    --atlas-color-page-overlay: rgba(219, 213, 199, 0.44);
    --atlas-color-shadow-sm: rgba(37, 37, 37, 0.12);
    --atlas-color-shadow: rgba(37, 37, 37, 0.18);
    --atlas-focus-shadow-rgb: 43, 43, 43;
}

/* Semantic application contract. Components use this layer, not raw theme values. */
[data-app-theme="atlas"] {
    --app-page: var(--atlas-color-page);
    --app-surface: var(--atlas-color-surface);
    --app-surface-2: var(--atlas-color-surface-raised);
    --app-elevated: var(--atlas-color-surface-raised);
    --app-accent: var(--atlas-color-accent);
    --app-accent-strong: var(--atlas-color-accent-strong);
    --app-accent-ink: var(--atlas-color-accent-ink);
    --app-ink: var(--atlas-color-text);
    --app-text: var(--atlas-color-text);
    --app-interactive-text: var(--atlas-color-interactive-text);
    --app-muted: var(--atlas-color-text-muted);
    --app-faint: var(--atlas-color-text-muted);
    --app-line: var(--atlas-color-border);
    --app-line-soft: var(--atlas-color-border-soft);
    --app-focus-ring: var(--atlas-color-focus);
    --app-focus-ring-soft: var(--atlas-color-border-soft);
    --app-map-edit-boundary: var(--atlas-color-map-edit-boundary);
    --app-map-edit-shadow: var(--atlas-color-map-edit-shadow);
    --app-support-heart: var(--atlas-color-support-heart);
    --app-support-heart-hover: var(--atlas-color-support-heart-hover);
    --app-editor-popup-shadow: var(--atlas-color-editor-popup-shadow);
    --app-rail-tooltip-shadow: var(--atlas-color-rail-tooltip-shadow);
    --app-danger: var(--atlas-color-danger);
    --app-danger-ink: var(--atlas-color-danger-ink);
    --app-danger-subtle: var(--atlas-color-danger-subtle);
    --app-danger-line: var(--atlas-color-danger-border);
    --app-success: var(--atlas-color-success);
    --app-success-ink: var(--atlas-color-success-ink);
    --app-success-subtle: var(--atlas-color-success-subtle);
    --app-success-line: var(--atlas-color-success-border);
    --app-warning-subtle: var(--atlas-color-warning-subtle);
    --app-warning-ink: var(--atlas-color-warning-text);
    --app-validation-valid: var(--atlas-color-validation-valid);
    --app-validation-invalid: var(--atlas-color-validation-invalid);
    --app-control-bg: var(--atlas-color-surface);
    --app-control-fg: var(--atlas-color-text);
    --app-control-border: var(--atlas-color-border);
    --app-control-disabled-bg: var(--atlas-color-control-disabled-bg);
    --app-control-disabled-fg: var(--atlas-color-control-disabled-text);
    --app-control-disabled-border: var(--atlas-color-control-disabled-border);
    --app-sidebar-bg: var(--atlas-color-sidebar-bg);
    --app-topbar-bg: var(--atlas-color-surface);
    --app-topbar-border: var(--atlas-color-border);
    --app-topbar-text: var(--atlas-color-text);
    --app-page-overlay: var(--atlas-color-page-overlay);
    --app-page-glow: var(--atlas-color-page-glow);
    --app-shadow-sm: 0 1px 2px var(--atlas-color-shadow-sm);
    --app-shadow: 0 8px 24px var(--atlas-color-shadow);
    --app-focus-shadow-rgb: var(--atlas-focus-shadow-rgb);
}

/* Compatibility aliases for existing Atlas components. These map the legacy component vocabulary to the semantic contract; no additional palette is introduced. */
[data-app-theme="atlas"] {
    --atlas-page-bg: var(--app-page);
    --atlas-page-glow: var(--app-page-glow);
    --atlas-surface: var(--app-surface);
    --atlas-surface-raised: var(--app-surface-2);
    --atlas-surface-active: var(--atlas-color-surface-active);
    --atlas-text: var(--app-text);
    --atlas-text-muted: var(--app-muted);
    --atlas-accent: var(--app-accent);
    --atlas-accent-strong: var(--app-accent-strong);
    --atlas-border: var(--app-line);
    --atlas-topbar-line: var(--app-topbar-border);
    --atlas-icon: var(--atlas-color-icon);
    --atlas-icon-color: var(--atlas-color-icon);
    --atlas-focus: var(--app-focus-ring);
    --atlas-focus-ring: var(--app-focus-ring);
    --atlas-cta-bg: var(--atlas-color-cta-bg);
    --atlas-cta-text: var(--atlas-color-cta-text);
    --atlas-font-display: var(--app-font-display);
    --atlas-font-ui: var(--app-font-ui);
    --atlas-fg: var(--app-text);
    --atlas-line: var(--app-line);
    --atlas-panel: var(--app-surface);
    --atlas-hover-text: var(--app-accent-strong);
    --atlas-hover-icon: var(--app-accent);
}

/* Framework adapters consume the semantic application contract. */
[data-app-theme] {
    /* MudBlazor theme owns this token. */
    /* MudBlazor theme owns this token. */
    /* MudBlazor theme owns this token. */
    /* MudBlazor theme owns this token. */
}

/* Atlas interaction rule: stay inside the active semantic palette. */
[data-app-theme="atlas"] button,
[data-app-theme="atlas"] .skyrp-action,
[data-app-theme="atlas"] [role="button"] {
    transition:
        color 0.18s ease,
        background-color 0.18s ease;
}

[data-app-theme="atlas"] button:not(:disabled):hover:not(.skyrp-map-tool-button),
[data-app-theme="atlas"] [role="button"]:not([aria-disabled="true"]):hover {
    color: var(--app-accent-strong);
}

[data-app-theme="atlas"] #app-language {
    color: var(--app-control-fg);
    background-color: var(--app-control-bg);
    border-color: var(--app-control-border);
}

[data-app-theme="atlas"] #app-language option {
    color: var(--app-control-fg);
    background-color: var(--app-control-bg);
}
