/* ===== Galaxy colors — פאנל פלטות הצבע של השמש (js/sun-palette-panel.js) =====
 * נפתח מהשורה "Galaxy color" בפאנל המערכת (#sun-panel). כשיש מקום שני הפאנלים
 * זזים לקצוות (--spp-shift) והשמש באמצע נשארת גלויה — היא התצוגה המקדימה;
 * במסך צר הוא גיליון תחתון (.spp-sheet) שמכסה את פאנל המערכת.
 * כהה תמיד, כמו #sun-panel.
 */

#sun-palette-panel {
    --spp-shift: 0px;
    --spp-card: rgba(255, 255, 255, 0.07);
    --spp-card-border: rgba(255, 255, 255, 0.12);
    --spp-ink: #fff;
    --spp-ink-2: rgba(255, 255, 255, 0.74);
    --spp-ink-3: rgba(255, 255, 255, 0.5);
    --spp-focus: rgba(120, 205, 255, 0.9);
    --spp-spin: 7s;

    display: none;
    flex-direction: column;
    position: fixed;
    top: 84px;
    left: 50%;
    z-index: 10021; /* ברמת body — מעל ה-dock (10013) וה-feed (10012) */
    width: min(372px, calc(100vw - 32px));
    max-height: calc(100vh - 100px);
    box-sizing: border-box;
    color: var(--spp-ink);
    background: rgba(9, 13, 24, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 18px;
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transform: translateX(calc(-50% + var(--spp-shift)));
    transition: transform 0.25s ease;
    font-family: 'Google Sans', 'Inter', 'Segoe UI', sans-serif;
}

#sun-palette-panel.open {
    display: flex;
    animation: spp-enter 0.22s ease-out;
}

@keyframes spp-enter {
    from { opacity: 0; translate: 0 8px; }
    to { opacity: 1; translate: 0 0; }
}

#sun-palette-panel .edit-mode-header {
    margin: 0;
    padding: 20px 20px 14px;
}

#sun-palette-panel .edit-mode-header h3 {
    font-size: 21px;
}

.spp-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0 20px;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.spp-section {
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid var(--spp-card-border);
    border-radius: 14px;
    background: var(--spp-card);
}

.spp-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 10px;
    min-height: 28px;
}

.spp-label {
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
    font-weight: 700;
}

.spp-hint,
.spp-speed-val {
    color: var(--spp-ink-3);
    font-size: 11.5px;
    font-weight: 600;
}

.spp-speed-val {
    color: var(--spp-ink-2);
    font-variant-numeric: tabular-nums;
}

/* ---------- כדור צבעים מסתובב (גם בכפתור שבפאנל המערכת) ---------- */
.spp-orb {
    position: relative;
    display: block;
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    isolation: isolate;
    background: #0b0f1a;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16), 0 6px 16px rgba(0, 0, 0, 0.35);
}

.spp-orb-fill {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: var(--spp-g, #ffdd44);
    filter: blur(3px) saturate(1.15);
    animation: spp-spin var(--spp-spin) linear infinite;
}

.spp-orb.is-solid .spp-orb-fill {
    filter: none;
    animation: none;
}

/* ברק עליון ושוליים כהים — שייראה ככדור ולא כעוגה */
.spp-orb::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    background:
        radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 40%),
        radial-gradient(circle at 50% 50%, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.3) 100%);
}

@keyframes spp-spin {
    to { transform: rotate(360deg); }
}

/* ---------- פלטות מוכנות ---------- */
.spp-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
}

.spp-preset {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 7px 2px 6px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: var(--spp-ink-2);
    font: inherit;
    font-size: 10.5px;
    font-weight: 600;
    line-height: 1.15;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.spp-preset:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--spp-ink);
}

.spp-preset:hover .spp-orb {
    transform: scale(1.06);
}

.spp-preset .spp-orb {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.spp-preset-name {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.spp-preset.selected {
    border-color: rgba(255, 255, 255, 0.38);
    background: rgba(255, 255, 255, 0.1);
    color: var(--spp-ink);
}

.spp-preset.selected .spp-orb {
    box-shadow: 0 0 0 2px #fff, 0 0 18px rgba(255, 255, 255, 0.3);
}

/* ---------- בנה בעצמך ---------- */
.spp-surprise {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    background: linear-gradient(100deg, rgba(255, 31, 90, 0.38), rgba(179, 31, 255, 0.34) 50%, rgba(31, 107, 255, 0.38));
    color: #fff;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, filter 0.15s ease;
}

.spp-surprise:hover {
    filter: brightness(1.2);
}

.spp-surprise:active {
    transform: scale(0.96);
}

.spp-surprise.rolled svg {
    animation: spp-roll 0.45s ease;
}

@keyframes spp-roll {
    to { transform: rotate(360deg); }
}

.spp-custom {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 9px;
}

.spp-chip {
    position: relative;
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 50%;
    background: var(--c);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22), 0 4px 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.spp-chip input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 50%;
    opacity: 0;
    cursor: pointer;
}

.spp-chip-x {
    position: absolute;
    top: -6px;
    right: -6px;
    z-index: 1;
    width: 18px;
    height: 18px;
    padding: 0;
    display: none;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 50%;
    background: rgba(10, 13, 22, 0.92);
    color: #fff;
    font: 700 12px/1 'Inter', sans-serif;
    cursor: pointer;
}

.spp-chip:hover .spp-chip-x,
.spp-chip:focus-within .spp-chip-x {
    display: inline-flex;
}

@media (hover: none) {
    .spp-chip-x {
        display: inline-flex;
    }
}

.spp-chip-add {
    width: 34px;
    height: 34px;
    flex: none;
    padding: 0;
    border: 1.5px dashed rgba(255, 255, 255, 0.38);
    border-radius: 50%;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    font: 400 20px/1 'Inter', sans-serif;
    cursor: pointer;
}

.spp-chip-add:hover {
    border-color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.08);
}

.spp-chip-add[hidden] {
    display: none;
}

.spp-custom-name {
    margin: 10px 0 0;
    color: var(--spp-ink-3);
    font-size: 11.5px;
    font-weight: 600;
}

.spp-custom-name strong {
    color: var(--spp-ink);
    font-weight: 700;
}

/* ---------- תנועה ---------- */
.spp-range {
    width: 100%;
    margin: 2px 0 0;
    accent-color: #8fd0ff;
    cursor: pointer;
}

.spp-range:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.spp-range-ends {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    color: var(--spp-ink-3);
    font-size: 11px;
    font-weight: 600;
}

/* ---------- צבע אחיד ---------- */
.spp-solids {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.spp-solid {
    position: relative;
    width: 30px;
    height: 30px;
    flex: none;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--c);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.spp-solid:hover {
    transform: scale(1.1);
}

.spp-solid.selected {
    box-shadow: 0 0 0 2px #0b0f1a, 0 0 0 4px #fff;
}

/* צבע חופשי: גלגל צבעים עם נקודה של הצבע שנבחר */
.spp-solid-custom {
    background: conic-gradient(#ff3b3b, #ffe600, #2bff5e, #00d4ff, #3d5aff, #ff2bd6, #ff3b3b);
}

.spp-solid-custom::after {
    content: '';
    position: absolute;
    inset: 9px;
    border-radius: 50%;
    background: var(--c, #fff);
    box-shadow: 0 0 0 1.5px rgba(10, 13, 22, 0.85);
}

.spp-solid-custom input[type="color"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    opacity: 0;
    cursor: pointer;
}

/* ---------- שמירה ---------- */
.spp-footer {
    display: flex;
    padding: 4px 20px 18px;
}

.spp-footer .glass-button {
    flex: 1 1 0;
    min-height: 48px;
    justify-content: center;
    margin: 0;
    border-radius: 14px;
    background: rgba(18, 210, 126, 0.24);
    border-color: rgba(84, 255, 176, 0.45);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
}

.spp-footer .glass-button:hover {
    background: rgba(18, 210, 126, 0.34);
    border-color: rgba(84, 255, 176, 0.64);
}

.spp-footer .glass-button:disabled {
    opacity: 0.6;
    cursor: progress;
}

/* יש שינוי שעוד לא נשמר */
#sun-palette-panel.is-dirty .spp-footer .glass-button,
#sun-panel.is-dirty #sun-panel-save {
    box-shadow: 0 0 0 2px rgba(84, 255, 176, 0.55), 0 0 22px rgba(18, 210, 126, 0.35);
}

#sun-palette-panel :focus-visible,
#sun-panel .sun-color-trigger:focus-visible {
    outline: 2px solid var(--spp-focus);
    outline-offset: 2px;
}

/* ---------- הכפתור שבפאנל המערכת ---------- */
#sun-panel .sun-color-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px 8px 8px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

#sun-panel .sun-color-trigger:hover,
#sun-panel .sun-color-trigger[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(100, 200, 255, 0.45);
}

#sun-panel .sun-color-trigger .spp-orb {
    width: 36px;
    height: 36px;
}

.sun-color-trigger-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sun-color-trigger-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 700;
}

.sun-color-trigger-sub {
    color: rgba(255, 255, 255, 0.55);
    font-size: 11.5px;
    font-weight: 600;
}

.sun-color-trigger-cta {
    flex: none;
    color: rgba(140, 205, 255, 0.95);
    font-size: 12px;
    font-weight: 700;
}

/* הבורר הרגיל נשאר רק כשהפלטות כבויות (?nopalette=true) */
#sun-panel.has-palette-ui #sun-panel-color,
#sun-panel:not(.has-palette-ui) .sun-color-trigger {
    display: none;
}

/* מסך צר: הפאנל מכסה את פאנל המערכת במקום לשבת לידו */
#sun-panel.spp-covered {
    visibility: hidden;
}

/* #sun-panel יושב בתוך #ui-overlay (z 10), אז שום z-index לא מעלה אותו מעל
   ה-dock (10013) — והבועות כיסו את Save/Share. כמו ב-Settings/My Stars
   (galaxy-dock.css): בזמן שהפאנל פתוח ה-dock מוסתר. גם הצאצאים במפורש,
   כי .gd-adopted קובע לעצמו visibility: visible !important. */
html.dock-ui body:has(#sun-panel[style*="display: block"]) #galaxy-dock {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: opacity 0.2s ease, visibility 0.2s;
}

html.dock-ui body:has(#sun-panel[style*="display: block"]) #galaxy-dock * {
    visibility: hidden !important;
    pointer-events: none !important;
}

/* כשפאנל הצבעים פתוח הפאנלים יושבים בקצוות — בדיוק איפה שחיצי הניווט */
html.dock-ui body:has(#sun-palette-panel.open) .gd-edge-nav {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* טלפון: פחות ריפוד, כדי שגם "Psychedelic" ייכנס בעמודה */
@media (max-width: 420px) {
    #sun-palette-panel .edit-mode-header {
        padding: 16px 14px 12px;
    }

    .spp-scroll {
        padding: 0 12px;
    }

    .spp-section {
        padding: 10px;
    }

    .spp-footer {
        padding: 4px 12px 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .spp-orb-fill {
        animation: none;
    }

    #sun-palette-panel.open {
        animation: none;
    }
}
