/* =========================================================
   The Well - Core Geometry & CSS Architecture (style.well.css)
   ========================================================= */

/* --- 1. ROOT CONTAINERS --- */
.well-section {
    position: fixed; 
    inset: 0; 
    width: 100vw; 
    height: 100vh; 
    overflow: hidden; 
    z-index: 15; /* Sits just above the standard UniverseTrack (10) */
    background: transparent; 
    visibility: hidden; 
    opacity: 0;
}

#wellCanvas { 
    position: absolute; 
    inset: 0; 
    z-index: 1; 
    pointer-events: none; 
}

#wellDomLayer { 
    position: absolute; 
    inset: 0; 
    z-index: 5; 
    pointer-events: auto; 
}

/* --- 2. GLOBAL UI ELEMENTS --- */
.well-global-tooltip {
    position: absolute; 
    bottom: 30px; 
    left: 50%; 
    transform: translateX(-50%);
    font-family: 'Noto Sans JP', sans-serif; 
    font-size: 11px; 
    font-weight: 600;
    letter-spacing: 3px; 
    text-transform: uppercase; 
    color: rgba(255,255,255,0.4);
    pointer-events: none; 
    z-index: 995; 
    text-shadow: 0 0 15px rgba(0,0,0,1);
    transition: opacity 0.5s ease;
}

.is-dragging .well-global-tooltip, 
.is-scrubbing .well-global-tooltip { 
    opacity: 0.05; 
}

.well-selection-box {
    position: absolute; 
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.05); 
    pointer-events: none; 
    z-index: 990; 
    backdrop-filter: contrast(120%);
}

/* --- 3. ARTIFACT NODES (The Stars - Crystallized & Settled) --- */
.well-star-node {
    position: absolute; 
    top: 0; 
    left: 0;
    display: flex; 
    align-items: center; 
    justify-content: center;
    cursor: grab; 
    will-change: transform;
    width: calc(24px * var(--scale, 1)); 
    height: calc(24px * var(--scale, 1)); 
    border-radius: 50%;
    
    /* ✨ Soft pastel cores infused with the art color */
    background: color-mix(in srgb, var(--vibe) 30%, #ffffff);
    box-shadow: 0 0 4px color-mix(in srgb, var(--vibe) 50%, #ffffff), 0 0 10px 2px var(--vibe), 0 0 18px 4px color-mix(in srgb, var(--vibe) 30%, transparent);
    
    animation: starSettleBreathe 12s infinite alternate ease-in-out;
    animation-delay: calc(var(--seed, 0.5) * -30s);
    transition: background 0.4s ease;
}

/* ✨ The Organic Watercolor-Ink Bloom */
.well-star-node::after {
    content: '';
    position: absolute;
    inset: -250%; 
    background: radial-gradient(ellipse at center, 
        var(--vibe) 0%, 
        color-mix(in srgb, var(--vibe) 70%, transparent) 40%, 
        color-mix(in srgb, var(--vibe) 20%, transparent) 75%, 
        transparent 95%
    );
    mix-blend-mode: screen;
    opacity: 0.15; 
    filter: blur(10px);
    animation: resOrganicEdge 22s infinite alternate ease-in-out; 
    animation-delay: calc(var(--seed, 0.5) * -25s);
    z-index: -3;
    pointer-events: none;
}

/* Safe morphing without touching transforms */
@keyframes resOrganicEdge {
    0% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; opacity: 0.10; }
    34% { border-radius: 70% 30% 50% 50% / 30% 30% 70% 70%; opacity: 0.20; }
    67% { border-radius: 100% 60% 60% 100% / 100% 100% 60% 60%; opacity: 0.15; }
    100% { border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%; opacity: 0.25; }
}

/* ✨ Deep, richly colored glow peaks */
@keyframes starSettleBreathe {
    0% { box-shadow: 0 0 2px 1px color-mix(in srgb, var(--vibe) 40%, #ffffff), 0 0 8px 1px var(--vibe), 0 0 15px 2px color-mix(in srgb, var(--vibe) 20%, transparent); }
    100% { box-shadow: 0 0 8px 2px color-mix(in srgb, var(--vibe) 60%, #ffffff), 0 0 20px 4px var(--vibe), 0 0 35px 8px color-mix(in srgb, var(--vibe) 50%, transparent); }
}

.well-star-node:active, 
.well-star-node.is-dragging { 
    cursor: grabbing; 
}

.well-star-node:hover { 
    z-index: 100; 
}

.well-star-node.is-linking { 
    box-shadow: 0 0 25px 10px var(--vibe); 
}

.well-star-node.is-locked { 
    box-shadow: 0 0 5px 2px color-mix(in srgb, var(--vibe) 50%, transparent); 
    background: color-mix(in srgb, var(--vibe) 15%, #ffffff); 
    cursor: not-allowed; 
    animation: none;
}

/* Selection Orbital Ring */
.well-star-node::before {
    content: ''; 
    position: absolute; 
    inset: -12px; 
    border-radius: 50%;
    border: 1px dashed rgba(255,255,255,0);
    transition: border-color 0.3s ease, transform 10s linear; 
    pointer-events: none;
}

.well-star-node.is-selected::before { 
    border-color: color-mix(in srgb, var(--vibe) 80%, transparent); 
    animation: orbitalSpin 10s linear infinite; 
}

@keyframes orbitalSpin { 
    to { transform: rotate(360deg); } 
}

/* --- 4. GEOMETRIC PROJECTIONS (Ghosts & Reveals) --- */
.star-ghost-echo, 
.star-shape-reveal {
    position: absolute; 
    background: var(--vibe);
    top: 50%; 
    left: 50%;
    pointer-events: none; 
    mix-blend-mode: screen; 
}

/* The permanent, faint ghost shape behind the node */
.star-ghost-echo {
    opacity: 0.35;
    z-index: -2;
    transform: translate(-50%, -50%) scale(calc(0.25 * var(--scale, 1)));
    filter: blur(2px);
    transition: opacity 0.4s ease;
}

.well-star-node:hover .star-ghost-echo { 
    opacity: 0; 
}

/* The crisp hover shape */
.star-shape-reveal {
    opacity: 0; 
    z-index: -1;
    transform: translate(-50%, -50%) scale(calc(0.1 * var(--scale, 1))); 
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0 0 20px var(--vibe));
}

/* Radiates its specific media color cleanly on hover instead of blinding white */
.well-star-node:hover .star-shape-reveal { 
    opacity: 0.95; 
    background: color-mix(in srgb, var(--vibe) 40%, #ffffff); 
    filter: brightness(1.1) drop-shadow(0 0 15px var(--vibe));
    transform: translate(-50%, -50%) scale(calc(0.45 * var(--scale, 1))); 
}

/* Shape Math */
.shape-film { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); border-radius: 4px; }
.shape-tv { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); border-radius: 12px; } 
.shape-game { clip-path: polygon(10% 0, 90% 0, 100% 20%, 100% 100%, 0 100%, 0 20%); }
.shape-audio { clip-path: circle(50% at 50% 50%); }
.shape-sculpture { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.shape-poetry { clip-path: polygon(0 0, 100% 0, 100% 90%, 50% 100%, 0 90%); }
.shape-playbook { clip-path: polygon(10% 0, 90% 0, 100% 100%, 0 100%); }
.shape-book { clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%); border-radius: 2px; }
.shape-ambiance { clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%); }
.shape-creator { clip-path: polygon(20% 0%, 80% 0%, 100% 15%, 100% 100%, 0% 100%, 0% 15%); }
.shape-event { clip-path: polygon(0% 0%, 100% 0%, 100% 35%, 95% 50%, 100% 65%, 100% 100%, 0% 100%, 0% 65%, 5% 50%, 0% 35%); }
.shape-sport { clip-path: polygon(0% 0%, 100% 0%, 100% 75%, 50% 100%, 0% 75%); }

/* --- 5. TOPOLOGY LABELS --- */
.star-label {
    position: absolute; 
    top: 0; 
    left: 0;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 2px;
    pointer-events: none;
    background: transparent; 
    padding: 4px; 
    border: none; 
    backdrop-filter: none;
    text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 10px rgba(0,0,0,0.6);
    transform: translate(calc(-50% + var(--lx, 0px)), calc(-50% + var(--ly, 40px)));
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: transform, opacity;
}

.star-label.is-hovered {
    transform: translate(calc(-50% + var(--lx, 0px)), calc(-50% + var(--ly, 40px))) scale(1.15);
    z-index: 200;
}

.sl-title { 
    font-family: 'Noto Sans JP', sans-serif; 
    font-size: 11px; 
    font-weight: 800; 
    letter-spacing: 2px; 
    color: rgba(255,255,255,0.75); 
    white-space: nowrap; 
    transition: all 0.3s ease;
}

.star-label.is-hovered .sl-title {
    color: #ffffff;
    text-shadow: 0 0 12px var(--vibe), 0 0 4px var(--vibe);
    letter-spacing: 3px;
}

.sl-meta { 
    font-family: 'Neuton', serif; 
    font-size: 10px; 
    font-style: italic; 
    color: rgba(255,255,255,0.4); 
    white-space: nowrap; 
    transition: all 0.3s ease;
}

.star-label.is-hovered .sl-meta {
    color: rgba(255,255,255,0.85);
}

.well-nexus-label {
    position: absolute; 
    top: 0; 
    left: 0;
    transform: translate(-50%, -50%);
    font-family: 'Caveat', cursive; 
    font-size: 18px; 
    color: rgba(255,255,255,0.8);
    text-shadow: 0 0 10px rgba(255,255,255,0.4);
    cursor: pointer; 
    opacity: 0; 
    pointer-events: auto;
    transition: opacity 0.5s ease, transform 0.3s ease, text-shadow 0.3s ease;
    will-change: transform, opacity;
}

.well-nexus-label:hover { 
    color: #fff; 
    transform: translate(-50%, -50%) scale(1.1); 
    text-shadow: 0 0 20px rgba(255,255,255,0.8); 
}

/* --- 6. SANCTUARY MODALS --- */
.well-inspector-modal {
    position: fixed; 
    box-sizing: border-box; 
    background: rgba(10, 15, 25, 0.85); 
    backdrop-filter: blur(40px);
    border: 1px solid rgba(255,255,255,0.1); 
    border-radius: 16px;
    padding: 25px; 
    width: 380px; 
    box-shadow: 0 20px 50px rgba(0,0,0,0.9);
    display: flex; 
    flex-direction: column; 
    gap: 16px;
    font-family: 'Noto Sans JP', sans-serif; 
    z-index: 940; 
}

.well-inspector-header { display: flex; justify-content: space-between; align-items: center; }
.ins-group { display: flex; flex-direction: column; gap: 6px; }
.ins-label { font-size: 9px; color: rgba(255,255,255,0.5); text-transform: uppercase; letter-spacing: 2px; }

.well-inspector-modal input[type="text"],
.well-inspector-modal input[type="month"],
.well-inspector-modal textarea,
.well-inspector-modal select {
    box-sizing: border-box; 
    background: rgba(255,255,255,0.03); 
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff; 
    padding: 10px 12px; 
    border-radius: 8px; 
    font-family: inherit; 
    font-size: 13px;
    outline: none; 
    transition: border-color 0.3s ease; 
    resize: none; 
    width: 100%;
}

.well-inspector-modal select {
    appearance: none; 
    -webkit-appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="white" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat; 
    background-position: right 8px top 50%; 
    padding-right: 30px; 
    cursor: pointer;
}

.well-inspector-modal select option { background: #0a0f19; color: #fff; }
.well-inspector-modal input[type="text"]:focus,
.well-inspector-modal textarea:focus,
.well-inspector-modal select:focus { border-color: var(--vibe); box-shadow: 0 0 10px rgba(255,255,255,0.05); }

.importance-slider {
    -webkit-appearance: none; width: 100%; height: 4px; border-radius: 2px;
    background: rgba(255,255,255,0.1); outline: none; margin-top: 5px;
}
.importance-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none; width: 16px; height: 16px;
    border-radius: 50%; background: var(--vibe); cursor: pointer; box-shadow: 0 0 10px var(--vibe);
}

.inspector-toggle-btn {
    background: transparent; border: 1px solid rgba(255,255,255,0.2); color: #fff;
    padding: 6px 12px; border-radius: 20px; cursor: pointer; font-size: 10px;
    text-transform: uppercase; letter-spacing: 1px; transition: all 0.3s;
}
.inspector-toggle-btn.is-locked { background: rgba(255, 85, 85, 0.1); border-color: #ff5555; color: #ff5555; }

.inspector-fracture-btn {
    padding: 8px 16px; border-radius: 8px; background: transparent; border: 1px solid rgba(255,85,85,0.3); 
    color: #ff5555; font-size: 12px; cursor: pointer; transition: all 0.3s; margin-right: auto; 
}
.inspector-fracture-btn:hover { background: rgba(255,85,85,0.2); border-color: #ff5555; text-shadow: 0 0 5px #ff5555; }

.ins-etchings-list { display: flex; flex-direction: column; gap: 10px; max-height: 120px; overflow-y: auto; padding-right: 5px; }
.ins-etchings-list::-webkit-scrollbar { width: 4px; }
.ins-etching-list::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 2px; }
.ins-etchings-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.ins-etching-item { background: rgba(255,255,255,0.02); padding: 10px; border-radius: 8px; border-left: 2px solid var(--vibe); }
.ins-etching-date { font-family: 'Neuton', serif; font-size: 10px; color: rgba(255,255,255,0.4); margin-bottom: 4px; }
.ins-etching-text { font-size: 12px; color: #fff; line-height: 1.4; }

/* --- 7. DYNAMIC PATTERNS (Shared with Intake) --- */
.pattern-layer {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 1;
}

/* ✨ The Sharp 4-Point Glint Overlay for Raw Nodes */
.pattern-layer::after {
    content: '';
    position: absolute;
    inset: -150%;
    background: color-mix(in srgb, var(--vibe) 20%, #ffffff);
    clip-path: polygon(50% 0%, 53% 47%, 100% 50%, 53% 53%, 50% 100%, 47% 53%, 0% 50%, 47% 47%);
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

/* --- 8. UNINSCRIBED (RAW) STATE --- */
/* ✨ Slower, softer tinted glints */
.well-star-node.is-raw {
    background: color-mix(in srgb, var(--vibe) 15%, #ffffff);
    box-shadow: 0 0 5px 2px color-mix(in srgb, var(--vibe) 30%, #ffffff), 0 0 10px 4px var(--vibe);
    animation: rawStarGlint 4s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
    animation-delay: calc(var(--seed, 0.5) * -20s);
    mix-blend-mode: screen;
}

/* Keep the watercolor wash completely disabled for raw to focus on the sharp glint */
.well-star-node.is-raw::after {
    display: none;
}

@keyframes rawStarGlint {
    0% { box-shadow: 0 0 3px 1px color-mix(in srgb, var(--vibe) 40%, #ffffff), 0 0 8px 2px var(--vibe); filter: brightness(1); }
    100% { box-shadow: 0 0 10px 3px color-mix(in srgb, var(--vibe) 60%, #ffffff), 0 0 20px 8px var(--vibe), 0 0 35px 12px color-mix(in srgb, var(--vibe) 50%, transparent); filter: brightness(1.25); }
}

/* Slow down the inner shape pulse */
.well-star-node.is-raw .star-ghost-echo {
    animation: rawShapePulse 4s infinite alternate ease-in-out;
    animation-delay: calc(var(--seed, 0.5) * -12s);
    opacity: 0.5;
}

@keyframes rawShapePulse {
    0% { transform: translate(-50%, -50%) scale(calc(0.2 * var(--scale, 1))); filter: blur(3px); }
    100% { transform: translate(-50%, -50%) scale(calc(0.35 * var(--scale, 1))); filter: blur(1px); }
}

/* Activate the sharp glint safely within the pattern layer */
.well-star-node.is-raw .pattern-layer::after {
    animation: rawSharpTwinkle 3.5s infinite alternate ease-in-out;
    animation-delay: calc(var(--seed, 0.5) * -8s);
}

@keyframes rawSharpTwinkle {
    0% { opacity: 0.1; transform: scale(0.6) rotate(0deg); }
    100% { opacity: 0.85; transform: scale(1.4) rotate(45deg); }
}






/* =========================================================
   9. INTAKE MODALS & CASTING (Extracted from JS)
   ========================================================= */
.cast-modal-container {
    background: #0a0f19; 
    border: 1px solid var(--vibe); 
    border-radius: 16px; 
    padding: 30px; 
    width: 340px; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.8), 0 0 30px rgba(255,255,255,0.05); 
    font-family: 'Noto Sans JP', sans-serif; 
    position: relative; 
    overflow: hidden;
    --vibe-ink: var(--vibe); /* Full mode default */
}

.hm-subtitle { color: var(--vibe-ink); text-align: center; letter-spacing: 3px; font-size: 12px; font-weight: bold; text-transform: uppercase; margin-bottom: 10px; transition: color 0.3s ease; }
.hm-subtitle.alert-text { color: #ff5555; }

.cast-shape-stage { height: 140px; display: flex; align-items: center; justify-content: center; margin-bottom: 20px; perspective: 500px; }
.cast-shape-visual { width: 80px; height: 80px; background: var(--vibe); position: relative; overflow: hidden; transition: all 0.6s cubic-bezier(0.25, 1, 0.5, 1); box-shadow: 0 0 40px var(--vibe); }

.hm-type-scroller { display: flex; align-items: center; justify-content: space-between; margin-bottom: 25px; }
.hm-nav-btn { background: none; border: none; color: rgba(255,255,255,0.5); font-size: 20px; cursor: pointer; padding: 10px; transition: color 0.3s; }
.hm-nav-btn:hover { color: #fff; }
.hm-type-display { display: flex; flex-direction: column; align-items: center; }
.hm-type-label { font-size: 14px; letter-spacing: 4px; color: #fff; font-weight: bold; transition: color 0.3s ease; }

#castTitle { 
    width: 100%; box-sizing: border-box; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); 
    color: #fff; padding: 12px; border-radius: 8px; margin-bottom: 25px; text-align: center; 
    font-family: 'Caveat', cursive; font-size: 24px; outline: none; transition: border-color 0.3s, box-shadow 0.3s, color 0.3s, background 0.3s; 
}
#castTitle:focus { border-color: var(--vibe-ink); box-shadow: 0 0 15px color-mix(in srgb, var(--vibe-ink) 40%, transparent); }

.hm-actions { display: flex; justify-content: space-between; gap: 10px; }
.hm-actions.justify-center { justify-content: center; }

#castCancel { flex: 1; padding: 12px; border-radius: 8px; background: transparent; border: 1px solid rgba(255,255,255,0.2); color: #fff; cursor: pointer; transition: all 0.3s; }
#castCancel:hover { background: rgba(255,255,255,0.1); }

#castConfirm { flex: 1; padding: 12px; border-radius: 8px; background: var(--vibe-ink); border: 1.5px solid var(--vibe-ink); color: #000; font-weight: bold; cursor: pointer; box-shadow: 0 0 15px var(--vibe); transition: all 0.3s; }
#castConfirm:hover { transform: scale(1.05); box-shadow: 0 0 25px var(--vibe); }

.intake-ignite-modal { background: #0a0f19; border: 1px solid #ff5555; border-radius: 16px; padding: 30px; width: 340px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,0.8); transition: background 0.3s, border-color 0.3s; }
.ignite-desc { color: #fff; font-size: 18px; font-family: 'Neuton', serif; margin-bottom: 30px; transition: color 0.3s; }

.alert-btn { color: #ff5555 !important; border-color: rgba(255,85,85,0.4) !important; }
.alert-btn:hover { background: rgba(255,85,85,0.1) !important; border-color: #ff5555 !important; }


/* =========================================================
   10. LITE MODE PARITY (WELL & INTAKE MODALS)
   ========================================================= */

body.lite-mode .cast-modal-container,
body.lite-mode .intake-ignite-modal,
body.lite-mode .well-inspector-modal {
    /* ✨ DYNAMIC INK: Mixes neon vibe with the current text color */
    --vibe-ink: color-mix(in srgb, var(--vibe) 45%, var(--lite-text));
    
    background: var(--lite-shell-bg) !important;
    border-color: var(--lite-line) !important;
    box-shadow: none !important;
}

body.lite-mode .cast-shape-visual {
    box-shadow: none !important;
    border: 1.5px solid var(--lite-line);
}

body.lite-mode .hm-type-label,
body.lite-mode .ignite-desc {
    color: var(--lite-text) !important;
}

body.lite-mode .hm-nav-btn { color: var(--lite-muted-text); }
body.lite-mode .hm-nav-btn:hover { color: var(--lite-text); }

body.lite-mode #castTitle {
    background: var(--lite-input-bg) !important;
    border: 1px solid var(--lite-line) !important;
    color: var(--lite-text) !important;
}
body.lite-mode #castTitle:focus {
    border-color: var(--vibe-ink) !important;
    box-shadow: none !important;
}

body.lite-mode #castCancel {
    color: var(--lite-text) !important;
    border-color: var(--lite-line) !important;
}
body.lite-mode #castCancel:hover {
    background: var(--lite-text) !important;
    color: var(--lite-shell-bg) !important;
}

body.lite-mode #castConfirm {
    background: var(--lite-shell-bg) !important;
    color: var(--vibe-ink) !important;
    border: 1.5px solid var(--vibe-ink) !important;
    box-shadow: none !important;
}
body.lite-mode #castConfirm:hover {
    background: var(--vibe-ink) !important;
    color: var(--lite-shell-bg) !important;
}

/* Hard Alert Contrast */
body.lite-mode .alert-btn {
    color: #e63946 !important;
    border-color: #e63946 !important;
}
body.lite-mode .alert-btn:hover {
    background: #e63946 !important;
    color: var(--lite-shell-bg) !important;
}
body.lite-mode .hm-subtitle.alert-text {
    color: #e63946 !important;
}